|
Lines 895-901
subtest "void() tests" => sub {
Link Here
|
| 895 |
|
895 |
|
| 896 |
subtest "payout() tests" => sub { |
896 |
subtest "payout() tests" => sub { |
| 897 |
|
897 |
|
| 898 |
plan tests => 17; |
898 |
plan tests => 18; |
| 899 |
|
899 |
|
| 900 |
$schema->storage->txn_begin; |
900 |
$schema->storage->txn_begin; |
| 901 |
|
901 |
|
|
Lines 948-956
subtest "payout() tests" => sub {
Link Here
|
| 948 |
)->store(); |
948 |
)->store(); |
| 949 |
|
949 |
|
| 950 |
is( $account->balance(), -10, "Account balance is -10" ); |
950 |
is( $account->balance(), -10, "Account balance is -10" ); |
| 951 |
is( $debit1->amountoutstanding, |
951 |
is( $debit1->amountoutstanding + 0, |
| 952 |
10, 'Overdue fee has an amount outstanding of 10' ); |
952 |
10, 'Overdue fee has an amount outstanding of 10' ); |
| 953 |
is( $credit1->amountoutstanding, |
953 |
is( $credit1->amountoutstanding + 0, |
| 954 |
-20, 'Credit has an amount outstanding of -20' ); |
954 |
-20, 'Credit has an amount outstanding of -20' ); |
| 955 |
|
955 |
|
| 956 |
my $pay_params = { |
956 |
my $pay_params = { |
|
Lines 1017-1028
subtest "payout() tests" => sub {
Link Here
|
| 1017 |
} |
1017 |
} |
| 1018 |
); |
1018 |
); |
| 1019 |
|
1019 |
|
| 1020 |
is( $payout->amount(), 10, "Payout amount is 10" ); |
1020 |
is( ref($payout), 'Koha::Account::Line', |
| 1021 |
is( $payout->amountoutstanding(), 0, "Payout amountoutstanding is 0" ); |
1021 |
'->payout() returns a Koha::Account::Line' ); |
| 1022 |
is( $account->balance(), 0, "Account balance is 0" ); |
1022 |
is( $payout->amount() + 0, 10, "Payout amount is 10" ); |
| 1023 |
is( $debit1->amountoutstanding, |
1023 |
is( $payout->amountoutstanding() + 0, 0, "Payout amountoutstanding is 0" ); |
|
|
1024 |
is( $account->balance() + 0, 0, "Account balance is 0" ); |
| 1025 |
is( $debit1->amountoutstanding + 0, |
| 1024 |
10, 'Overdue fee still has an amount outstanding of 10' ); |
1026 |
10, 'Overdue fee still has an amount outstanding of 10' ); |
| 1025 |
is( $credit1->amountoutstanding, |
1027 |
is( $credit1->amountoutstanding + 0, |
| 1026 |
-10, 'Credit has an new amount outstanding of -10' ); |
1028 |
-10, 'Credit has an new amount outstanding of -10' ); |
| 1027 |
is( $credit1->status(), 'PAID', "Credit has a new status of PAID" ); |
1029 |
is( $credit1->status(), 'PAID', "Credit has a new status of PAID" ); |
| 1028 |
|
1030 |
|
|
Lines 1031-1037
subtest "payout() tests" => sub {
Link Here
|
| 1031 |
|
1033 |
|
| 1032 |
subtest "reduce() tests" => sub { |
1034 |
subtest "reduce() tests" => sub { |
| 1033 |
|
1035 |
|
| 1034 |
plan tests => 25; |
1036 |
plan tests => 27; |
| 1035 |
|
1037 |
|
| 1036 |
$schema->storage->txn_begin; |
1038 |
$schema->storage->txn_begin; |
| 1037 |
|
1039 |
|
|
Lines 1142-1153
subtest "reduce() tests" => sub {
Link Here
|
| 1142 |
# (Refund 5 on debt of 20) |
1144 |
# (Refund 5 on debt of 20) |
| 1143 |
my $reduction = $debit1->reduce($reduce_params); |
1145 |
my $reduction = $debit1->reduce($reduce_params); |
| 1144 |
|
1146 |
|
|
|
1147 |
is( ref($reduction), 'Koha::Account::Line', |
| 1148 |
'->reduce() returns a Koha::Account::Line' ); |
| 1145 |
is( $reduction->amount() * 1, -5, "Reduce amount is -5" ); |
1149 |
is( $reduction->amount() * 1, -5, "Reduce amount is -5" ); |
| 1146 |
is( $reduction->amountoutstanding() * 1, |
1150 |
is( $reduction->amountoutstanding() * 1, |
| 1147 |
0, "Reduce amountoutstanding is 0" ); |
1151 |
0, "Reduce amountoutstanding is 0" ); |
| 1148 |
is( $debit1->amountoutstanding() * 1, |
1152 |
is( $debit1->amountoutstanding() * 1, |
| 1149 |
15, "Debit amountoutstanding reduced by 5 to 15" ); |
1153 |
15, "Debit amountoutstanding reduced by 5 to 15" ); |
| 1150 |
is( $account->balance() * 1, -5, "Account balance is -5" ); |
1154 |
is( $account->balance() * 1, -5, "Account balance is -5" ); |
| 1151 |
is( $reduction->status(), 'APPLIED', "Reduction status is 'APPLIED'" ); |
1155 |
is( $reduction->status(), 'APPLIED', "Reduction status is 'APPLIED'" ); |
| 1152 |
|
1156 |
|
| 1153 |
my $offsets = Koha::Account::Offsets->search( |
1157 |
my $offsets = Koha::Account::Offsets->search( |
|
Lines 1160-1167
subtest "reduce() tests" => sub {
Link Here
|
| 1160 |
|
1164 |
|
| 1161 |
# Zero offset created when zero outstanding |
1165 |
# Zero offset created when zero outstanding |
| 1162 |
# (Refund another 5 on paid debt of 20) |
1166 |
# (Refund another 5 on paid debt of 20) |
| 1163 |
$credit1->apply( { debits => [ $debit1 ] } ); |
1167 |
$credit1->apply( { debits => [$debit1] } ); |
| 1164 |
is($debit1->amountoutstanding + 0, 0, 'Debit1 amountoutstanding reduced to 0'); |
1168 |
is( $debit1->amountoutstanding + 0, |
|
|
1169 |
0, 'Debit1 amountoutstanding reduced to 0' ); |
| 1165 |
$reduction = $debit1->reduce($reduce_params); |
1170 |
$reduction = $debit1->reduce($reduce_params); |
| 1166 |
is( $reduction->amount() * 1, -5, "Reduce amount is -5" ); |
1171 |
is( $reduction->amount() * 1, -5, "Reduce amount is -5" ); |
| 1167 |
is( $reduction->amountoutstanding() * 1, |
1172 |
is( $reduction->amountoutstanding() * 1, |
|
Lines 1182-1188
subtest "reduce() tests" => sub {
Link Here
|
| 1182 |
$debit1->reduce($reduce_params); |
1187 |
$debit1->reduce($reduce_params); |
| 1183 |
} |
1188 |
} |
| 1184 |
'Koha::Exceptions::ParameterTooHigh', |
1189 |
'Koha::Exceptions::ParameterTooHigh', |
| 1185 |
'->reduce cannot reduce mor than the original amount (combined reductions test)'; |
1190 |
'->reduce cannot reduce more than the original amount (combined reductions test)'; |
|
|
1191 |
|
| 1192 |
# Throw exception if attempting to reduce a payout |
| 1193 |
my $payout = $reduction->payout( |
| 1194 |
{ |
| 1195 |
interface => 'intranet', |
| 1196 |
staff_id => $staff->borrowernumber, |
| 1197 |
branch => $branchcode, |
| 1198 |
payout_type => 'CASH', |
| 1199 |
amount => 5 |
| 1200 |
} |
| 1201 |
); |
| 1202 |
throws_ok { |
| 1203 |
$payout->reduce($reduce_params); |
| 1204 |
} |
| 1205 |
'Koha::Exceptions::Account::IsNotDebit', |
| 1206 |
'->reduce() cannot be used on a payout debit'; |
| 1186 |
|
1207 |
|
| 1187 |
$schema->storage->txn_rollback; |
1208 |
$schema->storage->txn_rollback; |
| 1188 |
}; |
1209 |
}; |
| 1189 |
- |
|
|