From add79c20d936ac783f2c378dd5aa39e7b24148c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Wed, 9 Dec 2020 12:17:13 +0100 Subject: [PATCH] Kontoauszug verbuchen: Verkaufsgutschriften nicht negativ bewerten MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Punkte für wrong_sign höher gesetzt und beide Gutschriftentypen jetzt sauber abgegrenzt (credit_note und negative_ap_transaction) --- SL/DB/BankTransaction.pm | 7 ++++--- t/bank/bank_transactions.t | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/SL/DB/BankTransaction.pm b/SL/DB/BankTransaction.pm index 0d6895b23..c02ebb93e 100644 --- a/SL/DB/BankTransaction.pm +++ b/SL/DB/BankTransaction.pm @@ -79,7 +79,7 @@ sub get_agreement_with_invoice { payment_within_30_days => 1, remote_account_number => 3, skonto_exact_amount => 5, - wrong_sign => -1, + wrong_sign => -4, sepa_export_item => 5, batch_sepa_transaction => 20, ); @@ -162,12 +162,13 @@ sub get_agreement_with_invoice { } #check sign - if ( $invoice->is_sales && $self->amount < 0 ) { # TODO debit note + if (( $invoice->is_sales && $invoice->amount > 0 && $self->amount < 0 ) || + ( $invoice->is_sales && $invoice->amount < 0 && $self->amount > 0 ) ) { # sales credit note $agreement += $points{wrong_sign}; $rule_matches .= 'wrong_sign(' . $points{'wrong_sign'} . ') '; } if (( !$invoice->is_sales && $invoice->amount > 0 && $self->amount > 0) || - ( !$invoice->is_sales && $invoice->amount < 0 && $self->amount < 0) ) { # credit note + ( !$invoice->is_sales && $invoice->amount < 0 && $self->amount < 0) ) { # purchase credit note $agreement += $points{wrong_sign}; $rule_matches .= 'wrong_sign(' . $points{'wrong_sign'} . ') '; } diff --git a/t/bank/bank_transactions.t b/t/bank/bank_transactions.t index ff3a001ed..6ea6b687c 100644 --- a/t/bank/bank_transactions.t +++ b/t/bank/bank_transactions.t @@ -711,8 +711,8 @@ sub test_credit_note { transdate => $dt_10, ); my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($credit_note); - is($agreement, 13, "points for credit note ok"); - is($rule_matches, 'remote_account_number(3) exact_amount(4) wrong_sign(-1) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus14(2) ', "rules_matches for credit note ok"); + is($agreement, 14, "points for credit note ok"); + is($rule_matches, 'remote_account_number(3) exact_amount(4) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus14(2) ', "rules_matches for credit note ok"); $::form->{invoice_ids} = { $bt->id => [ $credit_note->id ] -- 2.20.1