Keine Rechnungen mit Bankauszug verbuchen überbezahlen
authorJan Büren <jan@kivitendo-premium.de>
Fri, 13 May 2016 08:18:31 +0000 (10:18 +0200)
committerJan Büren <jan@kivitendo-premium.de>
Mon, 13 Jun 2016 13:28:05 +0000 (15:28 +0200)
SL/Controller/BankTransaction.pm

index d018930..18e96ce 100644 (file)
@@ -397,18 +397,18 @@ sub action_save_invoices {
         last;
       }
       # pay invoice or go to the next bank transaction if the amount is not sufficiently high
-      if ($invoice->amount <= $amount_of_transaction) {
+      if ($invoice->amount_open <= $amount_of_transaction) {
         $invoice->pay_invoice(chart_id     => $bank_transaction->local_bank_account->chart_id,
                               trans_id     => $invoice->id,
-                              amount       => $invoice->amount,
+                              amount       => $invoice->amount_open,
                               payment_type => $payment_type,
                               transdate    => $bank_transaction->transdate->to_kivitendo);
         if ($invoice->is_sales) {
-          $amount_of_transaction -= $sign * $invoice->amount;
-          $bank_transaction->invoice_amount($bank_transaction->invoice_amount + $invoice->amount);
+          $amount_of_transaction -= $sign * $invoice->amount_open;
+          $bank_transaction->invoice_amount($bank_transaction->invoice_amount + $invoice->amount_open);
         } else {
-          $amount_of_transaction += $sign * $invoice->amount if (!$invoice->is_sales);
-          $bank_transaction->invoice_amount($bank_transaction->invoice_amount - $invoice->amount);
+          $amount_of_transaction += $sign * $invoice->amount_open if (!$invoice->is_sales);
+          $bank_transaction->invoice_amount($bank_transaction->invoice_amount - $invoice->amount_open);
         }
       } else {
         $invoice->pay_invoice(chart_id     => $bank_transaction->local_bank_account->chart_id,