From af131a4635b49e0615dec59c9b7423f0c828e027 Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Fri, 3 Feb 2017 19:23:01 +0100 Subject: [PATCH] =?utf8?q?Banktransaction:=20Kontoauszug=20verbuchen:=20So?= =?utf8?q?nderfall=20f=C3=BCr=20"credit=5Fnotes"?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit "credit_notes" haben negativen Betrag, diese werden nun gesondert behandelt. Ersetzt commit fbcd5580 --- SL/Controller/BankTransaction.pm | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index 5e25cbd22..8b0c9216a 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -100,7 +100,15 @@ sub action_list { ); $main::lxdebug->message(LXDebug->DEBUG2(),"count bt=".scalar(@{$bank_transactions}." bank_account=".$bank_account->id." chart=".$bank_account->chart_id)); - my $all_open_ar_invoices = SL::DB::Manager::Invoice ->get_all(where => [amount => { ne => \'paid' }], with_objects => ['customer','payment_terms']); + # 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', + amount => { lt => \'paid' } + ], + ], + ], + with_objects => ['customer','payment_terms']); + my $all_open_ap_invoices = SL::DB::Manager::PurchaseInvoice->get_all(where => [amount => { ne => \'paid' }], with_objects => ['vendor' ,'payment_terms']); 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']); @@ -658,10 +666,14 @@ sub save_single_bank_transaction { amount => $open_amount, payment_type => $payment_type, transdate => $bank_transaction->transdate->to_kivitendo); + } elsif ( $invoice->is_sales && $invoice->type eq 'credit_note' ) { + # no check for overpayment/multiple payments + $invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id, + trans_id => $invoice->id, + amount => $invoice->open_amount, + payment_type => $payment_type, + transdate => $bank_transaction->transdate->to_kivitendo); } else { # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary - if ( $invoice->is_sales && $invoice->invoice_type eq 'credit_note' ) { - $amount_of_transaction *= -1; - } my $overpaid_amount = $amount_of_transaction - $invoice->open_amount; $invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id, trans_id => $invoice->id, -- 2.20.1