Verbuchte Zahlungen auch in neuen Fällen von Bankbewegegungen berücksichtigen
authorJan Büren <jan@kivitendo-premium.de>
Thu, 23 Mar 2017 13:54:19 +0000 (14:54 +0100)
committerJan Büren <jan@kivitendo-premium.de>
Thu, 23 Mar 2017 13:54:19 +0000 (14:54 +0100)
Ergänzend zu af131a46:
Banktransaction: Kontoauszug verbuchen: Sonderfall für "credit_notes"

SL/Controller/BankTransaction.pm

index d154667..dbb2786 100644 (file)
@@ -667,6 +667,14 @@ sub save_single_bank_transaction {
       } elsif (( $invoice->is_sales && $invoice->invoice_type eq 'credit_note' ) ||
                (!$invoice->is_sales && $invoice->invoice_type eq 'ap_transaction' )) {
         # no check for overpayment/multiple payments
+
+        # 1. $invoice->open_amount is arap.amount - ararp.paid (always positive!)
+        # 2. $bank_transaction->amount is negative for outgoing transactions and positive for
+        #    incoming transactions.
+        # 1. and 2. => we have to turn the sign for invoice_amount in bank_transactions
+        # for verifying expected data, check t/bank/bank_transactions.t
+        $bank_transaction->invoice_amount($invoice->open_amount * -1);
+
         $invoice->pay_invoice(chart_id     => $bank_transaction->local_bank_account->chart_id,
                               trans_id     => $invoice->id,
                               amount       => $invoice->open_amount,