Revision b6f37661
Von Martin Helmling martin.helmling@octosoft.eu vor mehr als 7 Jahren hinzugefügt
SL/Controller/BankTransaction.pm | ||
---|---|---|
666 | 666 |
source => $source, |
667 | 667 |
memo => $memo, |
668 | 668 |
transdate => $bank_transaction->transdate->to_kivitendo); |
669 |
} elsif (( $invoice->is_sales && $invoice->invoice_type eq 'credit_note' ) || |
|
670 |
(!$invoice->is_sales && $invoice->invoice_type eq 'ap_transaction' )) { |
|
671 |
# no check for overpayment/multiple payments |
|
672 |
|
|
673 |
# 1. $invoice->open_amount is arap.amount - ararp.paid (always positive!) |
|
674 |
# 2. $bank_transaction->amount is negative for outgoing transactions and positive for |
|
675 |
# incoming transactions. |
|
676 |
# 1. and 2. => we have to turn the sign for invoice_amount in bank_transactions |
|
677 |
# for verifying expected data, check t/bank/bank_transactions.t |
|
678 |
$bank_transaction->invoice_amount($invoice->open_amount * -1); |
|
669 |
} else { |
|
670 |
# use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary |
|
671 |
|
|
672 |
if ( $invoice->is_sales && $invoice->invoice_type eq 'credit_note' ) { |
|
673 |
# $invoice->open_amount is negative for credit_notes |
|
674 |
# $bank_transaction->amount is negative for outgoing transactions |
|
675 |
# so $amount_of_transaction is negative but needs positive |
|
676 |
$amount_of_transaction *= -1; |
|
677 |
|
|
678 |
} elsif (!$invoice->is_sales && $invoice->invoice_type eq 'ap_transaction' ) { |
|
679 |
# $invoice->open_amount may be negative for ap_transaction but may be positiv for negativ ap_transaction |
|
680 |
# if $invoice->open_amount is negative $bank_transaction->amount is positve |
|
681 |
# if $invoice->open_amount is positive $bank_transaction->amount is negative |
|
682 |
# but amount of transaction is for both positive |
|
683 |
$amount_of_transaction *= -1 if $invoice->open_amount == - $amount_of_transaction; |
|
684 |
} |
|
679 | 685 |
|
680 |
$invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id, |
|
681 |
trans_id => $invoice->id, |
|
682 |
amount => $invoice->open_amount, |
|
683 |
payment_type => $payment_type, |
|
684 |
source => $source, |
|
685 |
memo => $memo, |
|
686 |
transdate => $bank_transaction->transdate->to_kivitendo); |
|
687 |
} else { # use the whole amount of the bank transaction for the invoice, overpay the invoice if necessary |
|
688 | 686 |
my $overpaid_amount = $amount_of_transaction - $invoice->open_amount; |
689 | 687 |
$invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id, |
690 | 688 |
trans_id => $invoice->id, |
Auch abrufbar als: Unified diff
BankTransaction: "Kontoauszug verbuchen" überarbeitet für ap_transaction und credit_note
sowie Test erweitert