Lines 132-138
$schema->storage->txn_rollback;
Link Here
|
132 |
|
132 |
|
133 |
subtest 'UpdateFine tests' => sub { |
133 |
subtest 'UpdateFine tests' => sub { |
134 |
|
134 |
|
135 |
plan tests => 25; |
135 |
plan tests => 43; |
136 |
|
136 |
|
137 |
$schema->storage->txn_begin; |
137 |
$schema->storage->txn_begin; |
138 |
|
138 |
|
Lines 185-190
subtest 'UpdateFine tests' => sub {
Link Here
|
185 |
is( $fines->count, 1, "Fine added when amount is greater than 0" ); |
185 |
is( $fines->count, 1, "Fine added when amount is greater than 0" ); |
186 |
my $fine = $fines->next; |
186 |
my $fine = $fines->next; |
187 |
is( $fine->amount, '50.000000', "Fine amount correctly set to 50" ); |
187 |
is( $fine->amount, '50.000000', "Fine amount correctly set to 50" ); |
|
|
188 |
is( $fine->amountoutstanding, '50.000000', "Fine amountoutstanding correctly set to 50" ); |
188 |
is( $fine->issue_id, $checkout1->issue_id, "Fine is associated with the correct issue" ); |
189 |
is( $fine->issue_id, $checkout1->issue_id, "Fine is associated with the correct issue" ); |
189 |
is( $fine->itemnumber, $checkout1->itemnumber, "Fine is associated with the correct item" ); |
190 |
is( $fine->itemnumber, $checkout1->itemnumber, "Fine is associated with the correct item" ); |
190 |
|
191 |
|
Lines 204-209
subtest 'UpdateFine tests' => sub {
Link Here
|
204 |
is( $fines->count, 1, "Existing fine updated" ); |
205 |
is( $fines->count, 1, "Existing fine updated" ); |
205 |
$fine = $fines->next; |
206 |
$fine = $fines->next; |
206 |
is( $fine->amount, '80.000000', "Fine amount correctly updated to 80" ); |
207 |
is( $fine->amount, '80.000000', "Fine amount correctly updated to 80" ); |
|
|
208 |
is( $fine->amountoutstanding, '80.000000', "Fine amountoutstanding correctly updated to 80" ); |
207 |
|
209 |
|
208 |
# Add fine 2 |
210 |
# Add fine 2 |
209 |
UpdateFine( |
211 |
UpdateFine( |
Lines 223-235
subtest 'UpdateFine tests' => sub {
Link Here
|
223 |
is( $fines->count, 2, "New fine added for second checkout" ); |
225 |
is( $fines->count, 2, "New fine added for second checkout" ); |
224 |
$fine = $fines->next; |
226 |
$fine = $fines->next; |
225 |
is( $fine->amount, '80.000000', "First fine amount unchanged" ); |
227 |
is( $fine->amount, '80.000000', "First fine amount unchanged" ); |
|
|
228 |
is( $fine->amountoutstanding, '80.000000', "First fine amountoutstanding unchanged" ); |
226 |
my $fine2 = $fines->next; |
229 |
my $fine2 = $fines->next; |
227 |
is( $fine2->amount, '20.000000', "Second fine capped at '20' by MaxFine" ); |
230 |
is( $fine2->amount, '20.000000', "Second fine capped at '20' by MaxFine" ); |
|
|
231 |
is( $fine2->amountoutstanding, '20.000000', "Second fine amountoutstanding capped at '20' by MaxFine" ); |
228 |
is( $fine2->issue_id, $checkout2->issue_id, "Second fine is associated with the correct issue" ); |
232 |
is( $fine2->issue_id, $checkout2->issue_id, "Second fine is associated with the correct issue" ); |
229 |
is( $fine2->itemnumber, $checkout2->itemnumber, "Second fine is associated with the correct item" ); |
233 |
is( $fine2->itemnumber, $checkout2->itemnumber, "Second fine is associated with the correct item" ); |
230 |
|
234 |
|
231 |
# Partial pay fine 1 |
235 |
# Partial pay fine 1 |
232 |
$fine->amountoutstanding('50')->store; |
236 |
$fine->amountoutstanding('50.000000')->store; |
233 |
UpdateFine( |
237 |
UpdateFine( |
234 |
{ |
238 |
{ |
235 |
issue_id => $checkout2->issue_id, |
239 |
issue_id => $checkout2->issue_id, |
Lines 247-254
subtest 'UpdateFine tests' => sub {
Link Here
|
247 |
is( $fines->count, 2, "Still two fines after second checkout update" ); |
251 |
is( $fines->count, 2, "Still two fines after second checkout update" ); |
248 |
$fine = $fines->next; |
252 |
$fine = $fines->next; |
249 |
is( $fine->amount, '80.000000', "First fine amount unchanged" ); |
253 |
is( $fine->amount, '80.000000', "First fine amount unchanged" ); |
|
|
254 |
is( $fine->amountoutstanding, '50.000000', "First fine amountoutstanding unchanged" ); |
250 |
$fine2 = $fines->next; |
255 |
$fine2 = $fines->next; |
251 |
is( $fine2->amount, '30.000000', "Second fine increased after partial payment of first" ); |
256 |
is( $fine2->amount, '30.000000', "Second fine increased after partial payment of first" ); |
|
|
257 |
is( $fine2->amountoutstanding, '30.000000', "Second fine amountoutstanding increased after partial payment of first" ); |
252 |
|
258 |
|
253 |
# Fix fine 1, create third fine |
259 |
# Fix fine 1, create third fine |
254 |
$fine->status('RETURNED')->store; |
260 |
$fine->status('RETURNED')->store; |
Lines 269-278
subtest 'UpdateFine tests' => sub {
Link Here
|
269 |
is( $fines->count, 3, "Third fine added for overdue renewal" ); |
275 |
is( $fines->count, 3, "Third fine added for overdue renewal" ); |
270 |
$fine = $fines->next; |
276 |
$fine = $fines->next; |
271 |
is( $fine->amount, '80.000000', "First fine amount unchanged" ); |
277 |
is( $fine->amount, '80.000000', "First fine amount unchanged" ); |
|
|
278 |
is( $fine->amountoutstanding, '50.000000', "First fine amountoutstanding unchanged" ); |
272 |
$fine2 = $fines->next; |
279 |
$fine2 = $fines->next; |
273 |
is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); |
280 |
is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); |
|
|
281 |
is( $fine2->amountoutstanding, '30.000000', "Second fine amountoutstanding unchanged" ); |
274 |
my $fine3 = $fines->next; |
282 |
my $fine3 = $fines->next; |
275 |
is( $fine3->amount, '20.000000', "Third fine amount capped due to MaxFine" ); |
283 |
is( $fine3->amount, '20.000000', "Third fine amount capped due to MaxFine" ); |
|
|
284 |
is( $fine3->amountoutstanding, '20.000000', "Third fine amountoutstanding capped at '20' by MaxFine" ); |
285 |
is( $fine3->issue_id, $checkout1->issue_id, "Third fine is associated with the correct issue" ); |
286 |
is( $fine3->itemnumber, $checkout1->itemnumber, "Third fine is associated with the correct item" ); |
287 |
|
288 |
# Payoff accruing fine and ensure next increment doesn't create a new one (bug #24146) |
289 |
$fine3->amountoutstanding('0.000000')->store; |
290 |
UpdateFine( |
291 |
{ |
292 |
issue_id => $checkout1->issue_id, |
293 |
itemnumber => $item1->itemnumber, |
294 |
borrowernumber => $patron->borrowernumber, |
295 |
amount => '50', |
296 |
due => $checkout1->date_due |
297 |
} |
298 |
); |
299 |
|
300 |
$fines = Koha::Account::Lines->search( |
301 |
{ borrowernumber => $patron->borrowernumber }, |
302 |
{ order_by => { '-asc' => 'accountlines_id' } } |
303 |
); |
304 |
is( $fines->count, 3, "Still three fines after third checkout update" ); |
305 |
$fine = $fines->next; |
306 |
is( $fine->amount, '80.000000', "First fine amount unchanged" ); |
307 |
is( $fine->amountoutstanding, '50.000000', "First fine amountoutstanding unchanged" ); |
308 |
$fine2 = $fines->next; |
309 |
is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); |
310 |
is( $fine2->amountoutstanding, '30.000000', "Second fine amountoutstanding unchanged" ); |
311 |
$fine3 = $fines->next; |
312 |
is( $fine3->amount, '50.000000', "Third fine amount capped due to MaxFine" ); |
313 |
is( $fine3->amountoutstanding, '20.000000', "Third fine amountoutstanding increased ..." ); |
276 |
is( $fine3->issue_id, $checkout1->issue_id, "Third fine is associated with the correct issue" ); |
314 |
is( $fine3->issue_id, $checkout1->issue_id, "Third fine is associated with the correct issue" ); |
277 |
is( $fine3->itemnumber, $checkout1->itemnumber, "Third fine is associated with the correct item" ); |
315 |
is( $fine3->itemnumber, $checkout1->itemnumber, "Third fine is associated with the correct item" ); |
278 |
|
316 |
|
279 |
- |
|
|