Revision 503fabbf
Von Martin Helmling martin.helmling@octosoft.eu vor fast 7 Jahren hinzugefügt
t/bank/bank_transactions.t | ||
---|---|---|
1 |
use Test::More tests => 105;
|
|
1 |
use Test::More tests => 130;
|
|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
... | ... | |
41 | 41 |
SL::DB::Manager::Part->delete_all(all => 1); |
42 | 42 |
SL::DB::Manager::Customer->delete_all(all => 1); |
43 | 43 |
SL::DB::Manager::Vendor->delete_all(all => 1); |
44 |
SL::DB::Manager::SepaExportItem->delete_all(all => 1); |
|
45 |
SL::DB::Manager::SepaExport->delete_all(all => 1); |
|
44 | 46 |
SL::DB::Manager::BankAccount->delete_all(all => 1); |
45 | 47 |
SL::DB::Manager::PaymentTerm->delete_all(all => 1); |
46 | 48 |
SL::DB::Manager::Currency->delete_all(where => [ name => 'CUR' ]); |
... | ... | |
79 | 81 |
test_ap_payment_part_transaction(); |
80 | 82 |
test_neg_sales_invoice(); |
81 | 83 |
|
84 |
test_bt_rule1(); |
|
85 |
test_sepa_export(); |
|
86 |
|
|
82 | 87 |
# remove all created data at end of test |
83 | 88 |
clear_up(); |
84 | 89 |
|
... | ... | |
656 | 661 |
is($bt->invoice_amount , '-345.10000', "$testname: bt invoice_amount ok"); |
657 | 662 |
} |
658 | 663 |
|
664 |
sub test_bt_rule1 { |
|
665 |
|
|
666 |
my $testname = 'test_bt_rule1'; |
|
667 |
|
|
668 |
$ar_transaction = test_ar_transaction(invnumber => 'bt_rule1'); |
|
669 |
|
|
670 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
671 |
|
|
672 |
$ar_transaction->load; |
|
673 |
$bt->load; |
|
674 |
is($ar_transaction->paid , '0.00000' , "$testname: not paid"); |
|
675 |
is($bt->invoice_amount , '0.00000' , "$testname: bt invoice amount was not assigned"); |
|
676 |
|
|
677 |
my $bt_controller = SL::Controller::BankTransaction->new; |
|
678 |
$::form->{dont_render_for_test} = 1; |
|
679 |
$::form->{filter}{bank_account} = $bank_account->id; |
|
680 |
my $bt_transactions = $bt_controller->action_list; |
|
681 |
|
|
682 |
is(scalar(@$bt_transactions) , 1 , "$testname: one bank_transaction"); |
|
683 |
is($bt_transactions->[0]->{agreement}, 20 , "$testname: agreement == 20"); |
|
684 |
my $match = join ( ' ',@{$bt_transactions->[0]->{rule_matches}}); |
|
685 |
#print "rule_matches='".$match."'\n"; |
|
686 |
is($match, |
|
687 |
"remote_account_number(3) exact_amount(4) own_invnumber_in_purpose(5) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus0(3) ", |
|
688 |
"$testname: rule_matches ok"); |
|
689 |
$bt->invoice_amount($bt->amount); |
|
690 |
$bt->save; |
|
691 |
is($bt->invoice_amount , '119.00000' , "$testname: bt invoice amount now set"); |
|
692 |
}; |
|
693 |
|
|
694 |
sub test_sepa_export { |
|
695 |
|
|
696 |
my $testname = 'test_sepa_export'; |
|
697 |
|
|
698 |
$ar_transaction = test_ar_transaction(invnumber => 'sepa1'); |
|
699 |
|
|
700 |
my $bt = SL::Dev::Payment::create_bank_transaction(record => $ar_transaction) or die "Couldn't create bank_transaction"; |
|
701 |
my $se = SL::Dev::Payment::create_sepa_export(); |
|
702 |
my $sei = SL::Dev::Payment::create_sepa_export_item( |
|
703 |
chart_id => $bank->id, |
|
704 |
ar_id => $ar_transaction->id, |
|
705 |
sepa_export_id => $se->id, |
|
706 |
vc_iban => $customer->iban, |
|
707 |
vc_bic => $customer->bic, |
|
708 |
vc_mandator_id => $customer->mandator_id, |
|
709 |
vc_depositor => $customer->depositor, |
|
710 |
amount => $ar_transaction->amount, |
|
711 |
); |
|
712 |
|
|
713 |
$ar_transaction->load; |
|
714 |
$bt->load; |
|
715 |
$sei->load; |
|
716 |
is($ar_transaction->paid , '0.00000' , "$testname: sepa1 not paid"); |
|
717 |
is($bt->invoice_amount , '0.00000' , "$testname: bt invoice amount was not assigned"); |
|
718 |
is($bt->amount , '119.00000' , "$testname: bt amount ok"); |
|
719 |
is($sei->amount , '119.00000' , "$testname: sepa export amount ok"); |
|
720 |
|
|
721 |
my $bt_controller = SL::Controller::BankTransaction->new; |
|
722 |
$::form->{dont_render_for_test} = 1; |
|
723 |
$::form->{filter}{bank_account} = $bank_account->id; |
|
724 |
my $bt_transactions = $bt_controller->action_list; |
|
725 |
|
|
726 |
is(scalar(@$bt_transactions) , 1 , "$testname: one bank_transaction"); |
|
727 |
is($bt_transactions->[0]->{agreement}, 25 , "$testname: agreement == 25"); |
|
728 |
my $match = join ( ' ',@{$bt_transactions->[0]->{rule_matches}}); |
|
729 |
is($match, |
|
730 |
"remote_account_number(3) exact_amount(4) own_invnumber_in_purpose(5) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus0(3) sepa_export_item(5) ", |
|
731 |
"$testname: rule_matches ok"); |
|
732 |
}; |
|
733 |
|
|
734 |
|
|
659 | 735 |
1; |
Auch abrufbar als: Unified diff
BankTransaction: Überarbeitung von "Kontoauszug verbuchen" , SEPA-Export wieder integriert
Die Punktebewertung findet wieder ausschließlich in "get_agreement_with_bank_transactions" statt,
auch die SEPA-Sammelüberweisung. Diese bekommt dor extra Punkte, da ggf. für bestimmte Rechnungen negative Punkte entstehen.
Auch gibt es dort keine Remote Banknummer etc.
Die Testdatei t/bank/bank_transactions.t wurde um zwei Tests erweitert,
1. ein Test der das Verbuchen ohne SEPA-Export macht,
2. ein Test mit SEPA-Export
fixt #277