]> wagnertech.de Git - kivitendo-erp.git/blobdiff - SL/Controller/BankTransaction.pm
Kontoauszug verbuchen -> Dialogbuchungsentwürfe verbessert
[kivitendo-erp.git] / SL / Controller / BankTransaction.pm
index 6b51c246360555747590ebfedd4bd82036ef6d02..370ac954c9b2dfcbcf4f6fda735b65722e7e9692 100644 (file)
@@ -28,7 +28,6 @@ use SL::DBUtils qw(like);
 
 use List::UtilsBy qw(partition_by);
 use List::MoreUtils qw(any);
-use List::MoreUtils qw(any none);
 use List::Util qw(max);
 
 use Rose::Object::MakeMethods::Generic
@@ -129,7 +128,8 @@ sub action_list {
     $open_invoice->{skonto_type} = 'without_skonto';
     foreach (@{ $sepa_export_items_by_id{ $open_invoice->id } || [] }) {
       my $factor                   = ($_->ar_id == $open_invoice->id ? 1 : -1);
-      $open_invoice->{realamount}  = $::form->format_sellprice($open_invoice->amount*$factor);
+      $open_invoice->{realamount}  = $::form->format_amount(\%::myconfig,$open_invoice->amount*$factor,2);
+
       $open_invoice->{skonto_type} = $_->payment_type;
       $sepa_exports{$_->sepa_export_id} ||= { count => 0, is_ar => 0, amount => 0, proposed => 0, invoices => [], item => $_ };
       $sepa_exports{$_->sepa_export_id}->{count}++;
@@ -182,7 +182,9 @@ sub action_list {
     # score is stored in $bt->{agreement}
 
     foreach my $open_invoice (@all_open_invoices) {
-      ($open_invoice->{agreement}, $open_invoice->{rule_matches}) = $bt->get_agreement_with_invoice($open_invoice);
+      ($open_invoice->{agreement}, $open_invoice->{rule_matches}) = $bt->get_agreement_with_invoice($open_invoice,
+        sepa_export_items => $all_open_sepa_export_items,
+      );
       $open_invoice->{realamount} = $::form->format_amount(\%::myconfig,
                                       $open_invoice->amount * ($open_invoice->{is_ar} ? 1 : -1), 2);
     }
@@ -260,12 +262,6 @@ sub action_create_invoice {
 
   $self->transaction(SL::DB::Manager::BankTransaction->find_by(id => $::form->{bt_id}));
 
-  # This was dead code: We compared vendor.account_name with bank_transaction.iban.
-  # This did never match (Kontonummer != IBAN). It's kivis 09/02 (2013) day
-  # If refactored/improved, also consider that vendor.iban should be normalized
-  # user may like to input strings like: 'AT 3333 3333 2222 1111' -> can be checked strictly
-  # at Vendor code because we need the correct data for all sepa exports.
-
   my $vendor_of_transaction = SL::DB::Manager::Vendor->find_by(iban => $self->transaction->{remote_account_number});
   my $use_vendor_filter     = $self->transaction->{remote_account_number} && $vendor_of_transaction;
 
@@ -297,6 +293,7 @@ sub action_create_invoice {
     TEMPLATES_GL => $use_vendor_filter && @{ $templates_ap } ? undef : $templates_gl,
     TEMPLATES_AP => $templates_ap,
     vendor_name  => $use_vendor_filter && @{ $templates_ap } ? $vendor_of_transaction->name : undef,
+    BT_ID        => $::form->{bt_id},
   );
 }
 
@@ -738,6 +735,9 @@ sub save_single_bank_transaction {
 
     # Rollback Fehler nicht weiterreichen
     # die if $error;
+    # aber einen rollback von hand
+    $::lxdebug->message(LXDebug->DEBUG2(),"finish worker with ". ($error ? $error->{result} : '-'));
+    $data{bank_transaction}->db->dbh->rollback if $error && $error->{result} eq 'error';
   });
 
   return grep { $_ } ($error, @warnings);
@@ -895,7 +895,7 @@ sub load_ap_record_template_url {
 }
 
 sub load_gl_record_template_url {
-  my ($self, $template) = @_;
+  my ($self, $template, $bt_id) = @_;
 
   return $self->url_for(
     controller                           => 'gl.pl',
@@ -904,6 +904,7 @@ sub load_gl_record_template_url {
     'form_defaults.amount_1'             => abs($self->transaction->amount), # always positive
     'form_defaults.transdate'            => $self->transaction->transdate_as_date,
     'form_defaults.callback'             => $self->callback,
+    'form_defaults.bt_id'                => $self->transaction->id,
   );
 }