Revision b92403ae
Von Jan Büren vor fast 6 Jahren hinzugefügt
SL/Controller/BankTransaction.pm | ||
---|---|---|
633 | 633 |
# TODO rewrite this: really booked amount should be a return value of Payment.pm |
634 | 634 |
# also this controller shouldnt care about how to calc skonto. we simply delegate the |
635 | 635 |
# payment_type to the helper and get the corresponding bank_transaction values back |
636 |
|
|
637 |
my $open_amount = ($payment_type eq 'with_skonto_pt' ? $invoice->amount_less_skonto : $invoice->open_amount); |
|
638 |
my $amount_for_booking = abs(($open_amount < $not_assigned_amount) ? $open_amount : $not_assigned_amount); |
|
636 |
# hotfix to get the signs right - compare absolute values and later set the signs |
|
637 |
# should be better done elsewhere - changing not_assigned_amount to abs feels seriously bogus |
|
638 |
|
|
639 |
my $open_amount = $payment_type eq 'with_skonto_pt' ? $invoice->amount_less_skonto : $invoice->open_amount; |
|
640 |
$open_amount = abs($open_amount); |
|
641 |
$not_assigned_amount = abs($not_assigned_amount); |
|
642 |
my $amount_for_booking = ($open_amount < $not_assigned_amount) ? $open_amount : $not_assigned_amount; |
|
643 |
my $amount_for_payment = $amount_for_booking; |
|
644 |
|
|
645 |
# get the right direction for the payment bookings (all amounts < 0 are stornos, credit notes or negative ap) |
|
646 |
$amount_for_payment *= -1 if $invoice->amount < 0; |
|
647 |
# get the right direction for the bank transaction |
|
639 | 648 |
$amount_for_booking *= $sign; |
649 |
|
|
640 | 650 |
$bank_transaction->invoice_amount($bank_transaction->invoice_amount + $amount_for_booking); |
641 | 651 |
|
642 | 652 |
# ... and then pay the invoice |
643 | 653 |
my @acc_ids = $invoice->pay_invoice(chart_id => $bank_transaction->local_bank_account->chart_id, |
644 | 654 |
trans_id => $invoice->id, |
645 |
amount => ($open_amount < $not_assigned_amount) ? $open_amount : $not_assigned_amount,
|
|
655 |
amount => $amount_for_payment,
|
|
646 | 656 |
payment_type => $payment_type, |
647 | 657 |
source => $source, |
648 | 658 |
memo => $memo, |
649 | 659 |
transdate => $bank_transaction->transdate->to_kivitendo); |
650 | 660 |
# ... and record the origin via BankTransactionAccTrans |
651 |
if (scalar(@acc_ids) != 2) {
|
|
661 |
if (scalar(@acc_ids) < 2) {
|
|
652 | 662 |
return { |
653 | 663 |
%data, |
654 | 664 |
result => 'error', |
Auch abrufbar als: Unified diff
BankTransaction Die richtigen (erwarteten) Parameter von amount an pay_invoice
Stellt den vorherigen Zustand im Controller wieder her, der über
Fallunterschiede vom Invoice-Typ Vorzeichen verschoben hat.
Tests laufen damit erstmal durch. Ferner kann und muss es mehr
als 2 acc_trans_ids als Rückgabe von pay_invoice geben