behebt #300 negative Einkaufsrechnungen per Kontenimport verbucht
authorJan Büren <jan@kivitendo-premium.de>
Tue, 5 Sep 2017 07:14:36 +0000 (09:14 +0200)
committerJan Büren <jan@kivitendo-premium.de>
Tue, 5 Sep 2017 07:14:36 +0000 (09:14 +0200)
SL/Controller/BankTransaction.pm

index e772406..5471687 100644 (file)
@@ -101,7 +101,7 @@ sub action_list {
       @where
     ],
   );
-
+ $::lxdebug->log_time('asdf');
   # credit notes have a negative amount, treat differently
   my $all_open_ar_invoices = SL::DB::Manager::Invoice        ->get_all(where => [ or => [ amount => { gt => \'paid' },
                                                                                           and => [ type    => 'credit_note',
@@ -115,6 +115,7 @@ sub action_list {
   my $all_open_sepa_export_items = SL::DB::Manager::SepaExportItem->get_all(where => [chart_id => $bank_account->chart_id ,
                                                                              'sepa_export.executed' => 0, 'sepa_export.closed' => 0 ], with_objects => ['sepa_export']);
 
+  $::lxdebug->log_time('asdf 2');
   my @all_open_invoices;
   # filter out invoices with less than 1 cent outstanding
   push @all_open_invoices, map { $_->{is_ar}=1 ; $_ } grep { abs($_->amount - $_->paid) >= 0.01 } @{ $all_open_ar_invoices };
@@ -140,6 +141,7 @@ sub action_list {
     }
   }
 
+ $::lxdebug->log_time('asdf 4');
   # try to match each bank_transaction with each of the possible open invoices
   # by awarding points
   my @proposals;
@@ -200,6 +202,7 @@ sub action_list {
         push(@{$bt->{rule_matches}}, $_->{rule_matches});
       };
     };
+  $::lxdebug->log_time('asdf 5');
   }  # finished one bt
   # finished all bt
 
@@ -658,7 +661,7 @@ sub save_single_bank_transaction {
           # so $amount_of_transaction is negative but needs positive
           $amount_of_transaction *= -1;
 
-        } elsif (!$invoice->is_sales && $invoice->invoice_type eq 'ap_transaction' ) {
+        } elsif (!$invoice->is_sales && $invoice->invoice_type =~ m/ap_transaction|purchase_invoice/) {
           # $invoice->open_amount may be negative for ap_transaction but may be positiv for negativ ap_transaction
           # if $invoice->open_amount is negative $bank_transaction->amount is positve
           # if $invoice->open_amount is positive $bank_transaction->amount is negative