|
Lines 1988-1994
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 1988 |
t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); |
1988 |
t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); |
| 1989 |
t::lib::Mocks::mock_preference( 'WhenLostForgiveFine', 0 ); |
1989 |
t::lib::Mocks::mock_preference( 'WhenLostForgiveFine', 0 ); |
| 1990 |
|
1990 |
|
| 1991 |
my $processfee_amount = 20.00; |
1991 |
my $processfee_amount = 20; |
| 1992 |
my $replacement_amount = 99.00; |
1992 |
my $replacement_amount = 99.00; |
| 1993 |
my $item_type = $builder->build_object( |
1993 |
my $item_type = $builder->build_object( |
| 1994 |
{ class => 'Koha::ItemTypes', |
1994 |
{ class => 'Koha::ItemTypes', |
|
Lines 2033-2049
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2033 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
2033 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
| 2034 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
2034 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
| 2035 |
my $processing_fee_line = $processing_fee_lines->next; |
2035 |
my $processing_fee_line = $processing_fee_lines->next; |
| 2036 |
is( $processing_fee_line->amount + 0.00, |
2036 |
is( $processing_fee_line->amount + 0, |
| 2037 |
$processfee_amount, 'The right PF amount is generated' ); |
2037 |
$processfee_amount, 'The right PF amount is generated' ); |
| 2038 |
is( $processing_fee_line->amountoutstanding + 0.00, |
2038 |
is( $processing_fee_line->amountoutstanding + 0, |
| 2039 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
2039 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
| 2040 |
|
2040 |
|
| 2041 |
my $lost_fee_lines = Koha::Account::Lines->search( |
2041 |
my $lost_fee_lines = Koha::Account::Lines->search( |
| 2042 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
2042 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
| 2043 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
2043 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
| 2044 |
my $lost_fee_line = $lost_fee_lines->next; |
2044 |
my $lost_fee_line = $lost_fee_lines->next; |
| 2045 |
is( $lost_fee_line->amount + 0.00, $replacement_amount, 'The right L amount is generated' ); |
2045 |
is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); |
| 2046 |
is( $lost_fee_line->amountoutstanding + 0.00, |
2046 |
is( $lost_fee_line->amountoutstanding + 0, |
| 2047 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
2047 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
| 2048 |
|
2048 |
|
| 2049 |
my $account = $patron->account; |
2049 |
my $account = $patron->account; |
|
Lines 2061-2067
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2061 |
is( $credit_return_id, undef, 'No CR account line added' ); |
2061 |
is( $credit_return_id, undef, 'No CR account line added' ); |
| 2062 |
|
2062 |
|
| 2063 |
$lost_fee_line->discard_changes; # reload from DB |
2063 |
$lost_fee_line->discard_changes; # reload from DB |
| 2064 |
is( $lost_fee_line->amountoutstanding + 0.00, 0.00, 'Lost fee has no outstanding amount' ); |
2064 |
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); |
| 2065 |
is( $lost_fee_line->accounttype, |
2065 |
is( $lost_fee_line->accounttype, |
| 2066 |
'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
2066 |
'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
| 2067 |
|
2067 |
|
|
Lines 2095-2111
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2095 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
2095 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
| 2096 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
2096 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
| 2097 |
my $processing_fee_line = $processing_fee_lines->next; |
2097 |
my $processing_fee_line = $processing_fee_lines->next; |
| 2098 |
is( $processing_fee_line->amount + 0.00, |
2098 |
is( $processing_fee_line->amount + 0, |
| 2099 |
$processfee_amount, 'The right PF amount is generated' ); |
2099 |
$processfee_amount, 'The right PF amount is generated' ); |
| 2100 |
is( $processing_fee_line->amountoutstanding + 0.00, |
2100 |
is( $processing_fee_line->amountoutstanding + 0, |
| 2101 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
2101 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
| 2102 |
|
2102 |
|
| 2103 |
my $lost_fee_lines = Koha::Account::Lines->search( |
2103 |
my $lost_fee_lines = Koha::Account::Lines->search( |
| 2104 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
2104 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
| 2105 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
2105 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
| 2106 |
my $lost_fee_line = $lost_fee_lines->next; |
2106 |
my $lost_fee_line = $lost_fee_lines->next; |
| 2107 |
is( $lost_fee_line->amount + 0.00, $replacement_amount, 'The right L amount is generated' ); |
2107 |
is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); |
| 2108 |
is( $lost_fee_line->amountoutstanding + 0.00, |
2108 |
is( $lost_fee_line->amountoutstanding + 0, |
| 2109 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
2109 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
| 2110 |
|
2110 |
|
| 2111 |
my $account = $patron->account; |
2111 |
my $account = $patron->account; |
|
Lines 2123-2135
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2123 |
my $credit_return = Koha::Account::Lines->find($credit_return_id); |
2123 |
my $credit_return = Koha::Account::Lines->find($credit_return_id); |
| 2124 |
|
2124 |
|
| 2125 |
is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' ); |
2125 |
is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' ); |
| 2126 |
is( $credit_return->amount + 0.00, |
2126 |
is( $credit_return->amount + 0, |
| 2127 |
-99.00, 'The account line of type CR has an amount of -99' ); |
2127 |
-99.00, 'The account line of type CR has an amount of -99' ); |
| 2128 |
is( $credit_return->amountoutstanding + 0.00, |
2128 |
is( $credit_return->amountoutstanding + 0, |
| 2129 |
-99.00, 'The account line of type CR has an amountoutstanding of -99' ); |
2129 |
-99.00, 'The account line of type CR has an amountoutstanding of -99' ); |
| 2130 |
|
2130 |
|
| 2131 |
$lost_fee_line->discard_changes; |
2131 |
$lost_fee_line->discard_changes; |
| 2132 |
is( $lost_fee_line->amountoutstanding + 0.00, 0.00, 'Lost fee has no outstanding amount' ); |
2132 |
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); |
| 2133 |
is( $lost_fee_line->accounttype, |
2133 |
is( $lost_fee_line->accounttype, |
| 2134 |
'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
2134 |
'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
| 2135 |
|
2135 |
|
|
Lines 2164-2187
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2164 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
2164 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
| 2165 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
2165 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
| 2166 |
my $processing_fee_line = $processing_fee_lines->next; |
2166 |
my $processing_fee_line = $processing_fee_lines->next; |
| 2167 |
is( $processing_fee_line->amount + 0.00, |
2167 |
is( $processing_fee_line->amount + 0, |
| 2168 |
$processfee_amount, 'The right PF amount is generated' ); |
2168 |
$processfee_amount, 'The right PF amount is generated' ); |
| 2169 |
is( $processing_fee_line->amountoutstanding + 0.00, |
2169 |
is( $processing_fee_line->amountoutstanding + 0, |
| 2170 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
2170 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
| 2171 |
|
2171 |
|
| 2172 |
my $lost_fee_lines = Koha::Account::Lines->search( |
2172 |
my $lost_fee_lines = Koha::Account::Lines->search( |
| 2173 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
2173 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
| 2174 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
2174 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
| 2175 |
my $lost_fee_line = $lost_fee_lines->next; |
2175 |
my $lost_fee_line = $lost_fee_lines->next; |
| 2176 |
is( $lost_fee_line->amount + 0.00, $replacement_amount, 'The right L amount is generated' ); |
2176 |
is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); |
| 2177 |
is( $lost_fee_line->amountoutstanding + 0.00, |
2177 |
is( $lost_fee_line->amountoutstanding + 0, |
| 2178 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
2178 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
| 2179 |
|
2179 |
|
| 2180 |
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id ); |
2180 |
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id ); |
| 2181 |
is( $credit_return_id, undef, 'No CR account line added' ); |
2181 |
is( $credit_return_id, undef, 'No CR account line added' ); |
| 2182 |
|
2182 |
|
| 2183 |
$lost_fee_line->discard_changes; |
2183 |
$lost_fee_line->discard_changes; |
| 2184 |
is( $lost_fee_line->amountoutstanding + 0.00, 0.00, 'Lost fee has no outstanding amount' ); |
2184 |
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); |
| 2185 |
is( $lost_fee_line->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
2185 |
is( $lost_fee_line->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
| 2186 |
|
2186 |
|
| 2187 |
is( $patron->account->balance, 20, 'The patron balance is 20, still owes the processing fee' ); |
2187 |
is( $patron->account->balance, 20, 'The patron balance is 20, still owes the processing fee' ); |
|
Lines 2214-2230
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2214 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
2214 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'PF' } ); |
| 2215 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
2215 |
is( $processing_fee_lines->count, 1, 'Only one processing fee produced' ); |
| 2216 |
my $processing_fee_line = $processing_fee_lines->next; |
2216 |
my $processing_fee_line = $processing_fee_lines->next; |
| 2217 |
is( $processing_fee_line->amount + 0.00, |
2217 |
is( $processing_fee_line->amount + 0, |
| 2218 |
$processfee_amount, 'The right PF amount is generated' ); |
2218 |
$processfee_amount, 'The right PF amount is generated' ); |
| 2219 |
is( $processing_fee_line->amountoutstanding + 0.00, |
2219 |
is( $processing_fee_line->amountoutstanding + 0, |
| 2220 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
2220 |
$processfee_amount, 'The right PF amountoutstanding is generated' ); |
| 2221 |
|
2221 |
|
| 2222 |
my $lost_fee_lines = Koha::Account::Lines->search( |
2222 |
my $lost_fee_lines = Koha::Account::Lines->search( |
| 2223 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
2223 |
{ borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } ); |
| 2224 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
2224 |
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' ); |
| 2225 |
my $lost_fee_line = $lost_fee_lines->next; |
2225 |
my $lost_fee_line = $lost_fee_lines->next; |
| 2226 |
is( $lost_fee_line->amount + 0.00, $replacement_amount, 'The right L amount is generated' ); |
2226 |
is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' ); |
| 2227 |
is( $lost_fee_line->amountoutstanding + 0.00, |
2227 |
is( $lost_fee_line->amountoutstanding + 0, |
| 2228 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
2228 |
$replacement_amount, 'The right L amountountstanding is generated' ); |
| 2229 |
|
2229 |
|
| 2230 |
my $account = $patron->account; |
2230 |
my $account = $patron->account; |
|
Lines 2260-2276
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2260 |
is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2260 |
is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
| 2261 |
|
2261 |
|
| 2262 |
is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' ); |
2262 |
is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' ); |
| 2263 |
is( $credit_return->amount + 0.00, |
2263 |
is( $credit_return->amount + 0, |
| 2264 |
$payment_amount * -1, |
2264 |
$payment_amount * -1, |
| 2265 |
'The account line of type CR has an amount equal to the payment' |
2265 |
'The account line of type CR has an amount equal to the payment' |
| 2266 |
); |
2266 |
); |
| 2267 |
is( $credit_return->amountoutstanding + 0.00, |
2267 |
is( $credit_return->amountoutstanding + 0, |
| 2268 |
$payment_amount * -1, |
2268 |
$payment_amount * -1, |
| 2269 |
'The account line of type CR has an amountoutstanding equal to the payment' |
2269 |
'The account line of type CR has an amountoutstanding equal to the payment' |
| 2270 |
); |
2270 |
); |
| 2271 |
|
2271 |
|
| 2272 |
$lost_fee_line->discard_changes; |
2272 |
$lost_fee_line->discard_changes; |
| 2273 |
is( $lost_fee_line->amountoutstanding + 0.00, 0.00, 'Lost fee has no outstanding amount' ); |
2273 |
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' ); |
| 2274 |
is( $lost_fee_line->accounttype, |
2274 |
is( $lost_fee_line->accounttype, |
| 2275 |
'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
2275 |
'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
| 2276 |
|
2276 |
|
|
Lines 2336-2342
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
| 2336 |
|
2336 |
|
| 2337 |
$accountline->_result()->discard_changes(); |
2337 |
$accountline->_result()->discard_changes(); |
| 2338 |
|
2338 |
|
| 2339 |
is( $accountline->amountoutstanding, '0.000000', 'Fine has been reduced to 0' ); |
2339 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
| 2340 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
2340 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
| 2341 |
|
2341 |
|
| 2342 |
## Run again, with dropbox mode enabled |
2342 |
## Run again, with dropbox mode enabled |
|
Lines 2351-2357
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
| 2351 |
|
2351 |
|
| 2352 |
$accountline->_result()->discard_changes(); |
2352 |
$accountline->_result()->discard_changes(); |
| 2353 |
|
2353 |
|
| 2354 |
is( $accountline->amountoutstanding, '90.000000', 'Fine has been reduced to 90' ); |
2354 |
is( $accountline->amountoutstanding + 0, 90, 'Fine has been reduced to 90' ); |
| 2355 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
2355 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
| 2356 |
}; |
2356 |
}; |
| 2357 |
|
2357 |
|
| 2358 |
- |
|
|