Revision 6378f59b
Von Jan Büren vor mehr als 4 Jahren hinzugefügt
t/bank/bank_transactions.t | ||
---|---|---|
31 | 31 |
use Data::Dumper; |
32 | 32 |
|
33 | 33 |
my ($customer, $vendor, $currency_id, $unit, $tax, $tax0, $tax7, $tax_9, $payment_terms, $bank_account); |
34 |
my ($transdate1, $transdate2, $currency);
|
|
34 |
my ($currency); |
|
35 | 35 |
my ($ar_chart,$bank,$ar_amount_chart, $ap_chart, $ap_amount_chart); |
36 | 36 |
my ($ar_transaction, $ap_transaction); |
37 | 37 |
|
38 |
my $dt = DateTime->new(year => 2019, month => 1, day => 12); |
|
39 |
my $dt_5 = DateTime->new(year => 2019, month => 1, day => 17); |
|
40 |
my $dt_10 = DateTime->new(year => 2019, month => 1, day => 22); |
|
41 |
|
|
38 | 42 |
sub clear_up { |
39 | 43 |
|
40 | 44 |
SL::DB::Manager::BankTransactionAccTrans->delete_all(all => 1); |
... | ... | |
116 | 120 |
|
117 | 121 |
clear_up(); |
118 | 122 |
|
119 |
$transdate1 = DateTime->today; |
|
120 |
$transdate2 = DateTime->today->add(days => 5); |
|
121 | 123 |
|
122 | 124 |
$tax = SL::DB::Manager::Tax->find_by(taxkey => 3, rate => 0.19, %{ $params{tax} }) || croak "No tax"; |
123 | 125 |
$tax7 = SL::DB::Manager::Tax->find_by(taxkey => 2, rate => 0.07) || croak "No tax for 7\%"; |
... | ... | |
141 | 143 |
iban => 'DE12500105170648489890', |
142 | 144 |
bic => 'TESTBIC', |
143 | 145 |
account_number => '648489890', |
144 |
mandate_date_of_signature => $transdate1,
|
|
146 |
mandate_date_of_signature => $dt,
|
|
145 | 147 |
mandator_id => 'foobar', |
146 | 148 |
bank => 'Geizkasse', |
147 | 149 |
bank_code => 'G1235', |
... | ... | |
180 | 182 |
invnumber => $params{invnumber} || undef, # let it use its own invnumber |
181 | 183 |
amount => $amount, |
182 | 184 |
netamount => $netamount, |
183 |
transdate => $transdate1,
|
|
185 |
transdate => $dt,
|
|
184 | 186 |
taxincluded => $params{taxincluded } || 0, |
185 | 187 |
customer_id => $customer->id, |
186 | 188 |
taxzone_id => $customer->taxzone_id, |
... | ... | |
221 | 223 |
invnumber => $params{invnumber} || $testname, |
222 | 224 |
amount => $amount, |
223 | 225 |
netamount => $netamount, |
224 |
transdate => $transdate1,
|
|
226 |
transdate => $dt,
|
|
225 | 227 |
taxincluded => 0, |
226 | 228 |
vendor_id => $vendor->id, |
227 | 229 |
taxzone_id => $vendor->taxzone_id, |
... | ... | |
257 | 259 |
|
258 | 260 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv1'); |
259 | 261 |
|
260 |
my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
262 |
my $bt = create_bank_transaction(record => $ar_transaction, |
|
263 |
transdate => $dt, |
|
264 |
valutadate => $dt) or die "Couldn't create bank_transaction"; |
|
261 | 265 |
|
262 | 266 |
$::form->{invoice_ids} = { |
263 | 267 |
$bt->id => [ $ar_transaction->id ] |
... | ... | |
283 | 287 |
|
284 | 288 |
my $bt = create_bank_transaction(record => $ar_transaction, |
285 | 289 |
bank_chart_id => $bank->id, |
290 |
transdate => $dt, |
|
291 |
valutadate => $dt, |
|
286 | 292 |
amount => $ar_transaction->amount_less_skonto |
287 | 293 |
) or die "Couldn't create bank_transaction"; |
288 | 294 |
|
... | ... | |
317 | 323 |
|
318 | 324 |
my $bt = create_bank_transaction(record => $ar_transaction, |
319 | 325 |
bank_chart_id => $bank->id, |
326 |
transdate => $dt, |
|
327 |
valutadate => $dt, |
|
320 | 328 |
amount => 160.15, |
321 | 329 |
) or die "Couldn't create bank_transaction"; |
322 | 330 |
$::form->{invoice_ids} = { |
... | ... | |
357 | 365 |
my $bt = create_bank_transaction(record => $ar_transaction_1, |
358 | 366 |
amount => ($ar_transaction_1->amount + $ar_transaction_2->amount), |
359 | 367 |
purpose => "Rechnungen " . $ar_transaction_1->invnumber . " und " . $ar_transaction_2->invnumber, |
368 |
transdate => $dt, |
|
369 |
valutadate => $dt, |
|
360 | 370 |
bank_chart_id => $bank->id, |
361 | 371 |
) or die "Couldn't create bank_transaction"; |
362 | 372 |
|
... | ... | |
397 | 407 |
|
398 | 408 |
my $bt = create_bank_transaction(record => $ar_transaction_1, |
399 | 409 |
bank_chart_id => $bank->id, |
410 |
transdate => $dt, |
|
411 |
valutadate => $dt, |
|
400 | 412 |
amount => $ar_transaction_1->amount_less_skonto * 2 + $ar_transaction_3->amount |
401 | 413 |
) or die "Couldn't create bank_transaction"; |
402 | 414 |
|
... | ... | |
436 | 448 |
# amount 135 > 119 |
437 | 449 |
my $bt = create_bank_transaction(record => $ar_transaction, |
438 | 450 |
bank_chart_id => $bank->id, |
451 |
transdate => $dt, |
|
452 |
valutadate => $dt, |
|
439 | 453 |
amount => 135 |
440 | 454 |
) or die "Couldn't create bank_transaction"; |
441 | 455 |
|
... | ... | |
467 | 481 |
|
468 | 482 |
my $bt_1 = create_bank_transaction(record => $ar_transaction, |
469 | 483 |
bank_chart_id => $bank->id, |
484 |
transdate => $dt, |
|
485 |
valutadate => $dt, |
|
470 | 486 |
amount => 10 |
471 | 487 |
) or die "Couldn't create bank_transaction"; |
472 | 488 |
my $bt_2 = create_bank_transaction(record => $ar_transaction, |
473 | 489 |
amount => 119, |
474 |
transdate => DateTime->today->add(days => 5), |
|
490 |
transdate => $dt_5, |
|
491 |
valutadate => $dt_5, |
|
475 | 492 |
bank_chart_id => $bank->id, |
476 | 493 |
) or die "Couldn't create bank_transaction"; |
477 | 494 |
|
... | ... | |
505 | 522 |
# amount 100 < 119 |
506 | 523 |
my $bt = create_bank_transaction(record => $ar_transaction, |
507 | 524 |
bank_chart_id => $bank->id, |
525 |
transdate => $dt, |
|
526 |
valutadate => $dt, |
|
508 | 527 |
amount => 100 |
509 | 528 |
) or die "Couldn't create bank_transaction"; |
510 | 529 |
|
... | ... | |
678 | 697 |
my $credit_note = create_credit_note( |
679 | 698 |
invnumber => 'cn 1', |
680 | 699 |
customer => $customer, |
700 |
transdate => $dt, |
|
681 | 701 |
taxincluded => 0, |
682 | 702 |
invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70), |
683 | 703 |
create_invoice_item(part => $part2, qty => 10, sellprice => 50), |
... | ... | |
686 | 706 |
my $bt = create_bank_transaction(record => $credit_note, |
687 | 707 |
amount => $credit_note->amount, |
688 | 708 |
bank_chart_id => $bank->id, |
689 |
transdate => DateTime->today->add(days => 10),
|
|
709 |
transdate => $dt_10,
|
|
690 | 710 |
); |
691 | 711 |
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($credit_note); |
692 | 712 |
is($agreement, 13, "points for credit note ok"); |
... | ... | |
715 | 735 |
invnumber => $params{invnumber} || 'test_neg_ap_transaction', |
716 | 736 |
amount => $amount, |
717 | 737 |
netamount => $netamount, |
718 |
transdate => $transdate1,
|
|
738 |
transdate => $dt,
|
|
719 | 739 |
taxincluded => 0, |
720 | 740 |
vendor_id => $vendor->id, |
721 | 741 |
taxzone_id => $vendor->taxzone_id, |
... | ... | |
738 | 758 |
my $bt = create_bank_transaction(record => $invoice, |
739 | 759 |
amount => $invoice->amount, |
740 | 760 |
bank_chart_id => $bank->id, |
741 |
transdate => DateTime->today->add(days => 10),
|
|
761 |
transdate => $dt_10,
|
|
742 | 762 |
); |
743 | 763 |
|
744 | 764 |
my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice); |
... | ... | |
770 | 790 |
invnumber => 'test_neg_ap_transaction', |
771 | 791 |
amount => $amount, |
772 | 792 |
netamount => $netamount, |
773 |
transdate => $transdate1,
|
|
793 |
transdate => $dt,
|
|
774 | 794 |
taxincluded => 0, |
775 | 795 |
vendor_id => $vendor->id, |
776 | 796 |
taxzone_id => $vendor->taxzone_id, |
... | ... | |
797 | 817 |
invnumber => 'test_neg_ap_transaction_two', |
798 | 818 |
amount => $amount_two, |
799 | 819 |
netamount => $netamount_two, |
800 |
transdate => $transdate1,
|
|
820 |
transdate => $dt,
|
|
801 | 821 |
taxincluded => 0, |
802 | 822 |
vendor_id => $vendor->id, |
803 | 823 |
taxzone_id => $vendor->taxzone_id, |
... | ... | |
821 | 841 |
my $bt = create_bank_transaction(record => $invoice_two, |
822 | 842 |
amount => $invoice_two->amount + $invoice->amount, |
823 | 843 |
bank_chart_id => $bank->id, |
824 |
transdate => DateTime->today->add(days => 10),
|
|
844 |
transdate => $dt_10,
|
|
825 | 845 |
); |
826 | 846 |
# my ($agreement, $rule_matches) = $bt->get_agreement_with_invoice($invoice_two); |
827 | 847 |
# is($agreement, 15, "points for negative ap transaction ok"); |
... | ... | |
858 | 878 |
invnumber => $params{invnumber} || $testname, |
859 | 879 |
amount => $amount, |
860 | 880 |
netamount => $netamount, |
861 |
transdate => $transdate1,
|
|
881 |
transdate => $dt,
|
|
862 | 882 |
taxincluded => 0, |
863 | 883 |
vendor_id => $vendor->id, |
864 | 884 |
taxzone_id => $vendor->taxzone_id, |
... | ... | |
881 | 901 |
my $bt = create_bank_transaction(record => $invoice, |
882 | 902 |
amount => $invoice->amount, |
883 | 903 |
bank_chart_id => $bank->id, |
884 |
transdate => DateTime->today->add(days => 10),
|
|
904 |
transdate => $dt_10,
|
|
885 | 905 |
); |
886 | 906 |
$::form->{invoice_ids} = { |
887 | 907 |
$bt->id => [ $invoice->id ] |
... | ... | |
911 | 931 |
invnumber => $params{invnumber} || $testname, |
912 | 932 |
amount => $amount, |
913 | 933 |
netamount => $netamount, |
914 |
transdate => $transdate1,
|
|
934 |
transdate => $dt,
|
|
915 | 935 |
taxincluded => 0, |
916 | 936 |
vendor_id => $vendor->id, |
917 | 937 |
taxzone_id => $vendor->taxzone_id, |
... | ... | |
934 | 954 |
my $bt = create_bank_transaction(record => $invoice, |
935 | 955 |
amount => $invoice->amount-100, |
936 | 956 |
bank_chart_id => $bank->id, |
937 |
transdate => DateTime->today->add(days => 10),
|
|
957 |
transdate => $dt_10,
|
|
938 | 958 |
); |
939 | 959 |
$::form->{invoice_ids} = { |
940 | 960 |
$bt->id => [ $invoice->id ] |
... | ... | |
954 | 974 |
my $bt2 = create_bank_transaction(record => $invoice, |
955 | 975 |
amount => 100, |
956 | 976 |
bank_chart_id => $bank->id, |
957 |
transdate => DateTime->today->add(days => 10),
|
|
977 |
transdate => $dt_10,
|
|
958 | 978 |
); |
959 | 979 |
$::form->{invoice_ids} = { |
960 | 980 |
$bt2->id => [ $invoice->id ] |
... | ... | |
984 | 1004 |
invnumber => '20172201', |
985 | 1005 |
customer => $customer, |
986 | 1006 |
taxincluded => 0, |
1007 |
transdate => $dt, |
|
987 | 1008 |
invoiceitems => [ create_invoice_item(part => $part1, qty => 3, sellprice => 70), |
988 | 1009 |
create_invoice_item(part => $part2, qty => 10, sellprice => -50), |
989 | 1010 |
] |
... | ... | |
991 | 1012 |
my $bt = create_bank_transaction(record => $neg_sales_inv, |
992 | 1013 |
amount => $neg_sales_inv->amount, |
993 | 1014 |
bank_chart_id => $bank->id, |
994 |
transdate => DateTime->today, |
|
1015 |
transdate => $dt, |
|
1016 |
valutadate => $dt, |
|
995 | 1017 |
); |
996 | 1018 |
$::form->{invoice_ids} = { |
997 | 1019 |
$bt->id => [ $neg_sales_inv->id ] |
... | ... | |
1012 | 1034 |
|
1013 | 1035 |
my $testname = 'test_bt_rule1'; |
1014 | 1036 |
|
1015 |
$ar_transaction = test_ar_transaction(invnumber => 'bt_rule1'); |
|
1037 |
$ar_transaction = test_ar_transaction(invnumber => 'bt_rule1', transdate => $dt);
|
|
1016 | 1038 |
|
1017 |
my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
1039 |
my $bt = create_bank_transaction(record => $ar_transaction, transdate => $dt) or die "Couldn't create bank_transaction";
|
|
1018 | 1040 |
|
1019 | 1041 |
$ar_transaction->load; |
1020 | 1042 |
$bt->load; |
... | ... | |
1040 | 1062 |
|
1041 | 1063 |
my $testname = 'test_sepa_export'; |
1042 | 1064 |
|
1043 |
$ar_transaction = test_ar_transaction(invnumber => 'sepa1'); |
|
1065 |
$ar_transaction = test_ar_transaction(invnumber => 'sepa1', transdate => $dt);
|
|
1044 | 1066 |
|
1045 |
my $bt = create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
1067 |
my $bt = create_bank_transaction(record => $ar_transaction, transdate => $dt) or die "Couldn't create bank_transaction";
|
|
1046 | 1068 |
my $se = create_sepa_export(); |
1047 | 1069 |
my $sei = create_sepa_export_item( |
1048 | 1070 |
chart_id => $bank->id, |
... | ... | |
1091 | 1113 |
my $bt1 = create_bank_transaction(record => $ar_transaction_1, |
1092 | 1114 |
amount => $ar_transaction_1->amount, |
1093 | 1115 |
purpose => "Rechnung10000 beinahe", |
1116 |
transdate => $dt, |
|
1094 | 1117 |
bank_chart_id => $bank->id, |
1095 | 1118 |
) or die "Couldn't create bank_transaction"; |
1096 | 1119 |
|
1097 | 1120 |
my $bt2 = create_bank_transaction(record => $ar_transaction_1, |
1098 | 1121 |
amount => $ar_transaction_1->amount + 0.01, |
1099 | 1122 |
purpose => "sicher salesinv20000 vielleicht", |
1123 |
transdate => $dt, |
|
1100 | 1124 |
bank_chart_id => $bank->id, |
1101 | 1125 |
) or die "Couldn't create bank_transaction"; |
1102 | 1126 |
|
... | ... | |
1127 | 1151 |
my $bt3 = create_bank_transaction(record => $ar_transaction_3, |
1128 | 1152 |
amount => $ar_transaction_3->amount, |
1129 | 1153 |
purpose => "sicher Rechnung10000 vielleicht", |
1154 |
transdate => $dt, |
|
1130 | 1155 |
bank_chart_id => $bank->id, |
1131 | 1156 |
) or die "Couldn't create bank_transaction"; |
1132 | 1157 |
|
Auch abrufbar als: Unified diff
Testfälle: bank_transactions.t um Datum erweitert