From: Jan Büren Date: Tue, 7 Jul 2020 09:56:04 +0000 (+0200) Subject: Testfälle: bank_transactions.t um Datum erweitert X-Git-Tag: release-3.5.6.1~159 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=6378f59b4a810a4ac8c0ed03a0cb1f822eecf06b;p=kivitendo-erp.git Testfälle: bank_transactions.t um Datum erweitert --- diff --git a/t/bank/bank_transactions.t b/t/bank/bank_transactions.t index ca1fb1726..378d3f2ef 100644 --- a/t/bank/bank_transactions.t +++ b/t/bank/bank_transactions.t @@ -31,10 +31,14 @@ use SL::Dev::ALL qw(:ALL); use Data::Dumper; my ($customer, $vendor, $currency_id, $unit, $tax, $tax0, $tax7, $tax_9, $payment_terms, $bank_account); -my ($transdate1, $transdate2, $currency); +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); + sub clear_up { SL::DB::Manager::BankTransactionAccTrans->delete_all(all => 1); @@ -116,8 +120,6 @@ sub reset_state { clear_up(); - $transdate1 = DateTime->today; - $transdate2 = DateTime->today->add(days => 5); $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\%"; @@ -141,7 +143,7 @@ sub reset_state { iban => 'DE12500105170648489890', bic => 'TESTBIC', account_number => '648489890', - mandate_date_of_signature => $transdate1, + mandate_date_of_signature => $dt, mandator_id => 'foobar', bank => 'Geizkasse', bank_code => 'G1235', @@ -180,7 +182,7 @@ sub test_ar_transaction { invnumber => $params{invnumber} || undef, # let it use its own invnumber amount => $amount, netamount => $netamount, - transdate => $transdate1, + transdate => $dt, taxincluded => $params{taxincluded } || 0, customer_id => $customer->id, taxzone_id => $customer->taxzone_id, @@ -221,7 +223,7 @@ sub test_ap_transaction { invnumber => $params{invnumber} || $testname, amount => $amount, netamount => $netamount, - transdate => $transdate1, + transdate => $dt, taxincluded => 0, vendor_id => $vendor->id, taxzone_id => $vendor->taxzone_id, @@ -257,7 +259,9 @@ sub test1 { $ar_transaction = test_ar_transaction(invnumber => 'salesinv1'); - my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; + my $bt = create_bank_transaction(record => $ar_transaction, + transdate => $dt, + valutadate => $dt) or die "Couldn't create bank_transaction"; $::form->{invoice_ids} = { $bt->id => [ $ar_transaction->id ] @@ -283,6 +287,8 @@ sub test_skonto_exact { my $bt = create_bank_transaction(record => $ar_transaction, bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, amount => $ar_transaction->amount_less_skonto ) or die "Couldn't create bank_transaction"; @@ -317,6 +323,8 @@ sub test_bt_error { my $bt = create_bank_transaction(record => $ar_transaction, bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, amount => 160.15, ) or die "Couldn't create bank_transaction"; $::form->{invoice_ids} = { @@ -357,6 +365,8 @@ sub test_two_invoices { my $bt = create_bank_transaction(record => $ar_transaction_1, amount => ($ar_transaction_1->amount + $ar_transaction_2->amount), purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber, + transdate => $dt, + valutadate => $dt, bank_chart_id => $bank->id, ) or die "Couldn't create bank_transaction"; @@ -397,6 +407,8 @@ sub test_one_inv_and_two_invoices_with_skonto_exact { my $bt = create_bank_transaction(record => $ar_transaction_1, bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, amount => $ar_transaction_1->amount_less_skonto * 2 + $ar_transaction_3->amount ) or die "Couldn't create bank_transaction"; @@ -436,6 +448,8 @@ sub test_overpayment { # amount 135 > 119 my $bt = create_bank_transaction(record => $ar_transaction, bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, amount => 135 ) or die "Couldn't create bank_transaction"; @@ -467,11 +481,14 @@ sub test_overpayment_with_partialpayment { my $bt_1 = create_bank_transaction(record => $ar_transaction, bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, amount => 10 ) or die "Couldn't create bank_transaction"; my $bt_2 = create_bank_transaction(record => $ar_transaction, amount => 119, - transdate => DateTime->today->add(days => 5), + transdate => $dt_5, + valutadate => $dt_5, bank_chart_id => $bank->id, ) or die "Couldn't create bank_transaction"; @@ -505,6 +522,8 @@ sub test_partial_payment { # amount 100 < 119 my $bt = create_bank_transaction(record => $ar_transaction, bank_chart_id => $bank->id, + transdate => $dt, + valutadate => $dt, amount => 100 ) or die "Couldn't create bank_transaction"; @@ -678,6 +697,7 @@ sub test_credit_note { my $credit_note = create_credit_note( invnumber => 'cn 1', customer => $customer, + transdate => $dt, taxincluded => 0, invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70), create_invoice_item(part => $part2, qty => 10, sellprice => 50), @@ -686,7 +706,7 @@ sub test_credit_note { my $bt = create_bank_transaction(record => $credit_note, amount => $credit_note->amount, bank_chart_id => $bank->id, - transdate => DateTime->today->add(days => 10), + transdate => $dt_10, ); my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($credit_note); is($agreement, 13, "points for credit note ok"); @@ -715,7 +735,7 @@ sub test_neg_ap_transaction { invnumber => $params{invnumber} || 'test_neg_ap_transaction', amount => $amount, netamount => $netamount, - transdate => $transdate1, + transdate => $dt, taxincluded => 0, vendor_id => $vendor->id, taxzone_id => $vendor->taxzone_id, @@ -738,7 +758,7 @@ sub test_neg_ap_transaction { my $bt = create_bank_transaction(record => $invoice, amount => $invoice->amount, bank_chart_id => $bank->id, - transdate => DateTime->today->add(days => 10), + transdate => $dt_10, ); my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice); @@ -770,7 +790,7 @@ sub test_two_neg_ap_transaction { invnumber => 'test_neg_ap_transaction', amount => $amount, netamount => $netamount, - transdate => $transdate1, + transdate => $dt, taxincluded => 0, vendor_id => $vendor->id, taxzone_id => $vendor->taxzone_id, @@ -797,7 +817,7 @@ sub test_two_neg_ap_transaction { invnumber => 'test_neg_ap_transaction_two', amount => $amount_two, netamount => $netamount_two, - transdate => $transdate1, + transdate => $dt, taxincluded => 0, vendor_id => $vendor->id, taxzone_id => $vendor->taxzone_id, @@ -821,7 +841,7 @@ sub test_two_neg_ap_transaction { my $bt = create_bank_transaction(record => $invoice_two, amount => $invoice_two->amount + $invoice->amount, bank_chart_id => $bank->id, - transdate => DateTime->today->add(days => 10), + transdate => $dt_10, ); # my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice_two); # is($agreement, 15, "points for negative ap transaction ok"); @@ -858,7 +878,7 @@ sub test_ap_payment_transaction { invnumber => $params{invnumber} || $testname, amount => $amount, netamount => $netamount, - transdate => $transdate1, + transdate => $dt, taxincluded => 0, vendor_id => $vendor->id, taxzone_id => $vendor->taxzone_id, @@ -881,7 +901,7 @@ sub test_ap_payment_transaction { my $bt = create_bank_transaction(record => $invoice, amount => $invoice->amount, bank_chart_id => $bank->id, - transdate => DateTime->today->add(days => 10), + transdate => $dt_10, ); $::form->{invoice_ids} = { $bt->id => [ $invoice->id ] @@ -911,7 +931,7 @@ sub test_ap_payment_part_transaction { invnumber => $params{invnumber} || $testname, amount => $amount, netamount => $netamount, - transdate => $transdate1, + transdate => $dt, taxincluded => 0, vendor_id => $vendor->id, taxzone_id => $vendor->taxzone_id, @@ -934,7 +954,7 @@ sub test_ap_payment_part_transaction { my $bt = create_bank_transaction(record => $invoice, amount => $invoice->amount-100, bank_chart_id => $bank->id, - transdate => DateTime->today->add(days => 10), + transdate => $dt_10, ); $::form->{invoice_ids} = { $bt->id => [ $invoice->id ] @@ -954,7 +974,7 @@ sub test_ap_payment_part_transaction { my $bt2 = create_bank_transaction(record => $invoice, amount => 100, bank_chart_id => $bank->id, - transdate => DateTime->today->add(days => 10), + transdate => $dt_10, ); $::form->{invoice_ids} = { $bt2->id => [ $invoice->id ] @@ -984,6 +1004,7 @@ sub test_neg_sales_invoice { invnumber => '20172201', customer => $customer, taxincluded => 0, + transdate => $dt, invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70), create_invoice_item(part => $part2, qty => 10, sellprice => -50), ] @@ -991,7 +1012,8 @@ sub test_neg_sales_invoice { my $bt = create_bank_transaction(record => $neg_sales_inv, amount => $neg_sales_inv->amount, bank_chart_id => $bank->id, - transdate => DateTime->today, + transdate => $dt, + valutadate => $dt, ); $::form->{invoice_ids} = { $bt->id => [ $neg_sales_inv->id ] @@ -1012,9 +1034,9 @@ sub test_bt_rule1 { my $testname = 'test_bt_rule1'; - $ar_transaction = test_ar_transaction(invnumber => 'bt_rule1'); + $ar_transaction = test_ar_transaction(invnumber => 'bt_rule1', transdate => $dt); - my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; + my $bt = create_bank_transaction(record => $ar_transaction, transdate => $dt) or die "Couldn't create bank_transaction"; $ar_transaction->load; $bt->load; @@ -1040,9 +1062,9 @@ sub test_sepa_export { my $testname = 'test_sepa_export'; - $ar_transaction = test_ar_transaction(invnumber => 'sepa1'); + $ar_transaction = test_ar_transaction(invnumber => 'sepa1', transdate => $dt); - my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; + my $bt = create_bank_transaction(record => $ar_transaction, transdate => $dt) or die "Couldn't create bank_transaction"; my $se = create_sepa_export(); my $sei = create_sepa_export_item( chart_id => $bank->id, @@ -1091,12 +1113,14 @@ sub test_two_banktransactions { my $bt1 = create_bank_transaction(record => $ar_transaction_1, amount => $ar_transaction_1->amount, purpose => "Rechnung10000 beinahe", + transdate => $dt, bank_chart_id => $bank->id, ) or die "Couldn't create bank_transaction"; my $bt2 = create_bank_transaction(record => $ar_transaction_1, amount => $ar_transaction_1->amount + 0.01, purpose => "sicher salesinv20000 vielleicht", + transdate => $dt, bank_chart_id => $bank->id, ) or die "Couldn't create bank_transaction"; @@ -1127,6 +1151,7 @@ sub test_two_banktransactions { my $bt3 = create_bank_transaction(record => $ar_transaction_3, amount => $ar_transaction_3->amount, purpose => "sicher Rechnung10000 vielleicht", + transdate => $dt, bank_chart_id => $bank->id, ) or die "Couldn't create bank_transaction";