From 92e2fb5927e65dd8c509c794ebe273554c6f6ef6 Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Tue, 19 Jul 2016 15:48:41 +0200 Subject: [PATCH] Kontoauszug verbuchen: Fehlermeldung und falscher Betrag MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Werden mehrere Rechnungen mit einer Banküberweisung bezahlt, bekommt letzte Rechnung immer den Rest des Betrages, auch wenn sie überbucht wird. fix Redmine #192 Eine Rückbuchung von ganz bezahlten Rechnungen kann über diesen Weg nicht gemacht werden --- SL/Controller/BankTransaction.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SL/Controller/BankTransaction.pm b/SL/Controller/BankTransaction.pm index c07b799e6..64198ee40 100644 --- a/SL/Controller/BankTransaction.pm +++ b/SL/Controller/BankTransaction.pm @@ -381,8 +381,12 @@ sub action_save_invoices { return -1 if (!$a->is_sales and $a->amount < 0); return 1; } @invoices if $bank_transaction->amount < 0; + my $max_invoices = scalar(@invoices); + my $n_invoices = 0; + foreach my $invoice (@invoices) { + $n_invoices++ ; # Check if bank_transaction already has a link to the invoice, may only be linked once per invoice # This might be caused by the user reloading a page and resending the form die t8("Bank transaction with id #1 has already been linked to #2.", $bank_transaction->id, $invoice->displayable_name) @@ -402,7 +406,7 @@ sub action_save_invoices { last; } # pay invoice or go to the next bank transaction if the amount is not sufficiently high - if ($invoice->open_amount <= $amount_of_transaction) { + if ($invoice->open_amount <= $amount_of_transaction && $n_invoices < $max_invoices) { # first calculate new bank transaction amount ... if ($invoice->is_sales) { $amount_of_transaction -= $sign * $invoice->open_amount; -- 2.20.1