X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=t%2Fbank%2Fbank_transactions.t;h=e79429b8ce6d3f6199922e74bf2e675393278faa;hb=c48f5c3b361d4c87c8a1b0c0eca0a7a3008d4539;hp=378d3f2efea19d9cd705d8e34a0fdecd23592707;hpb=6378f59b4a810a4ac8c0ed03a0cb1f822eecf06b;p=kivitendo-erp.git diff --git a/t/bank/bank_transactions.t b/t/bank/bank_transactions.t index 378d3f2ef..e79429b8c 100644 --- a/t/bank/bank_transactions.t +++ b/t/bank/bank_transactions.t @@ -1,4 +1,4 @@ -use Test::More tests => 289; +use Test::More tests => 291; use strict; @@ -34,10 +34,7 @@ my ($customer, $vendor, $currency_id, $unit, $tax, $tax0, $tax7, $tax_9, $paymen my ($currency); my ($ar_chart,$bank,$ar_amount_chart, $ap_chart, $ap_amount_chart); my ($ar_transaction, $ap_transaction); - -my $dt = DateTime->new(year => 2019, month => 1, day => 12); -my $dt_5 = DateTime->new(year => 2019, month => 1, day => 17); -my $dt_10 = DateTime->new(year => 2019, month => 1, day => 22); +my ($dt, $dt_5, $dt_10, $year); sub clear_up { @@ -120,6 +117,11 @@ sub reset_state { clear_up(); + $year = DateTime->today_local->year; + $year = 2019 if $year == 2020; # use year 2019 in 2020, because of tax rate change in Germany + $dt = DateTime->new(year => $year, month => 1, day => 12); + $dt_5 = $dt->clone->add(days => 5); + $dt_10 = $dt->clone->add(days => 10); $tax = SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, %{ $params{tax} }) || croak "No tax"; $tax7 = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07) || croak "No tax for 7\%"; @@ -539,6 +541,17 @@ sub test_partial_payment { is($ar_transaction->paid , '100.00000' , "$testname: 'salesinv partial payment' was partially paid"); is($bt->invoice_amount , '100.00000' , "$testname: bt invoice amount was assigned partially paid amount"); + # addon test partial payment full point match + my $bt2 = create_bank_transaction(record => $ar_transaction, + bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, + amount => 19 + ) or die "Couldn't create bank_transaction"; + + my ($agreement, $rule_matches) = $bt2->get_agreement_with_invoice($ar_transaction); + is($agreement, 15, "points for exact partial payment ok"); + is($rule_matches, 'remote_account_number(3) exact_open_amount(4) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus0(3) ', "rules_matches for exact partial payment ok"); }; sub test_full_workflow_ar_multiple_inv_skonto_reconciliate_and_undo { @@ -709,8 +722,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 ] @@ -762,7 +775,7 @@ sub test_neg_ap_transaction { ); my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice); - is($agreement, 15, "points for negative ap transaction ok"); + is($agreement, 16, "points for negative ap transaction ok"); $::form->{invoice_ids} = { $bt->id => [ $invoice->id ] @@ -1225,4 +1238,36 @@ sub test_closedto { } +sub test_skonto_exact_ap_transaction { + + my $testname = 'test_skonto_exact_ap_transaction'; + + $ap_transaction = test_ap_transaction(invnumber => 'ap transaction skonto', + payment_id => $payment_terms->id, + ); + + my $bt = create_bank_transaction(record => $ap_transaction, + bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, + amount => $ap_transaction->amount_less_skonto + ) or die "Couldn't create bank_transaction"; + + $::form->{invoice_ids} = { + $bt->id => [ $ap_transaction->id ] + }; + $::form->{invoice_skontos} = { + $bt->id => [ 'with_skonto_pt' ] + }; + + save_btcontroller_to_string(); + + $ap_transaction->load; + $bt->load; + is($ap_transaction->paid , '119.00000' , "$testname: ap transaction skonto was paid"); + is($ap_transaction->closed , 1 , "$testname: ap transaction skonto is closed"); + is($bt->invoice_amount , '113.05000' , "$testname: bt invoice amount was assigned"); + +}; + 1;