Revision 57e7e6c7
Von Jan Büren vor mehr als 1 Jahr hinzugefügt
t/bank/bank_transactions.t | ||
---|---|---|
1 |
use Test::More tests => 411;
|
|
1 |
use Test::More tests => 433;
|
|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
... | ... | |
116 | 116 |
test_bt_rule1(); |
117 | 117 |
reset_state(); |
118 | 118 |
test_two_banktransactions(); |
119 |
# remove all created data at end of test |
|
120 | 119 |
test_closedto(); |
120 |
test_fuzzy_skonto_pt(); |
|
121 |
test_fuzzy_skonto_pt_not_in_range(); |
|
122 |
# remove all created data at end of test |
|
121 | 123 |
clear_up(); |
122 | 124 |
|
123 | 125 |
done_testing(); |
... | ... | |
1075 | 1077 |
is($bt->amount , '-345.10000', "$testname: bt amount ok"); |
1076 | 1078 |
is($bt->invoice_amount , '-345.10000', "$testname: bt invoice_amount ok"); |
1077 | 1079 |
} |
1080 |
sub test_fuzzy_skonto_pt { |
|
1081 |
|
|
1082 |
my $testname = 'test_fuzzy_skonto_pt'; |
|
1083 |
|
|
1084 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv fuzzy skonto', |
|
1085 |
payment_id => $payment_terms->id, |
|
1086 |
); |
|
1087 |
my $fuzzy_amount_within_threshold = $ar_transaction->amount_less_skonto - 0.57; |
|
1088 |
my $bt = create_bank_transaction(record => $ar_transaction, |
|
1089 |
bank_chart_id => $bank->id, |
|
1090 |
transdate => $dt, |
|
1091 |
valutadate => $dt, |
|
1092 |
amount => $fuzzy_amount_within_threshold, |
|
1093 |
) or die "Couldn't create bank_transaction"; |
|
1094 |
|
|
1095 |
my ($agreement1, $rule_matches1) = $bt->get_agreement_with_invoice($ar_transaction); |
|
1096 |
is($agreement1, 14, "bt1 14 points for ar_transaction_1 in $testname ok"); |
|
1097 |
is($rule_matches1, |
|
1098 |
"remote_account_number(3) skonto_fuzzy_amount(3) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus0(3) ", |
|
1099 |
"$testname: rule_matches ok"); |
|
1100 |
my $skonto_type; |
|
1101 |
$skonto_type = 'with_fuzzy_skonto_pt' if $rule_matches1 =~ m/skonto_fuzzy_amount/; |
|
1102 |
$::form->{invoice_ids} = { |
|
1103 |
$bt->id => [ $ar_transaction->id ] |
|
1104 |
}; |
|
1105 |
$::form->{invoice_skontos} = { |
|
1106 |
$bt->id => [ $skonto_type ] |
|
1107 |
}; |
|
1108 |
|
|
1109 |
save_btcontroller_to_string(); |
|
1110 |
|
|
1111 |
$ar_transaction->load; |
|
1112 |
$bt->load; |
|
1113 |
is($ar_transaction->paid , '119.00000' , "$testname: salesinv skonto was paid"); |
|
1114 |
is($ar_transaction->closed , 1 , "$testname: salesinv skonto is closed"); |
|
1115 |
is($bt->invoice_amount , '112.48000' , "$testname: bt invoice amount was assigned"); |
|
1116 |
|
|
1117 |
} |
|
1118 |
|
|
1119 |
sub test_fuzzy_skonto_pt_not_in_range { |
|
1120 |
|
|
1121 |
my $testname = 'test_fuzzy_skonto_pt_not_in_range'; |
|
1122 |
|
|
1123 |
$ar_transaction = test_ar_transaction(invnumber => 'salesinv fuzzy skonto not in range', |
|
1124 |
payment_id => $payment_terms->id, |
|
1125 |
); |
|
1126 |
my $fuzzy_amount_within_threshold = $ar_transaction->amount_less_skonto - 0.7; |
|
1127 |
my $bt = create_bank_transaction(record => $ar_transaction, |
|
1128 |
bank_chart_id => $bank->id, |
|
1129 |
transdate => $dt, |
|
1130 |
valutadate => $dt, |
|
1131 |
amount => $fuzzy_amount_within_threshold, |
|
1132 |
) or die "Couldn't create bank_transaction"; |
|
1133 |
|
|
1134 |
my ($agreement1, $rule_matches1) = $bt->get_agreement_with_invoice($ar_transaction); |
|
1135 |
is($agreement1, 11, "bt1 14 points for ar_transaction_1 in $testname ok"); |
|
1136 |
is($rule_matches1, |
|
1137 |
"remote_account_number(3) depositor_matches(2) remote_name(2) payment_within_30_days(1) datebonus0(3) ", |
|
1138 |
"$testname: rule_matches ok"); |
|
1139 |
my $skonto_type; |
|
1140 |
$skonto_type = 'with_fuzzy_skonto_pt' if $rule_matches1 =~ m/skonto_fuzzy_amount/; |
|
1141 |
$::form->{invoice_ids} = { |
|
1142 |
$bt->id => [ $ar_transaction->id ] |
|
1143 |
}; |
|
1144 |
$::form->{invoice_skontos} = { |
|
1145 |
$bt->id => [ $skonto_type ] |
|
1146 |
}; |
|
1147 |
|
|
1148 |
save_btcontroller_to_string(); |
|
1149 |
|
|
1150 |
$ar_transaction->load; |
|
1151 |
$bt->load; |
|
1152 |
is($ar_transaction->paid , '112.35000' , "$testname: salesinv skonto was not paid"); |
|
1153 |
is($ar_transaction->closed , '' , "$testname: salesinv skonto is not closed"); |
|
1154 |
is($bt->invoice_amount , '112.35000' , "$testname: bt invoice amount was assigned"); |
|
1155 |
|
|
1156 |
} |
|
1157 |
|
|
1078 | 1158 |
|
1079 | 1159 |
sub test_bt_rule1 { |
1080 | 1160 |
|
... | ... | |
2066 | 2146 |
$invoice->save; |
2067 | 2147 |
return $invoice; |
2068 | 2148 |
} |
2149 |
|
|
2069 | 2150 |
1; |
Auch abrufbar als: Unified diff
testfall zu: fuzzy_skonto_within_pt