|
Lines 144-156
subtest 'UpdateFine tests' => sub {
Link Here
|
| 144 |
my $checkout1 = $builder->build_object( |
144 |
my $checkout1 = $builder->build_object( |
| 145 |
{ |
145 |
{ |
| 146 |
class => 'Koha::Checkouts', |
146 |
class => 'Koha::Checkouts', |
| 147 |
value => { itemnumber => $item1->itemnumber } |
147 |
value => { itemnumber => $item1->itemnumber, borrowernumber => $patron->id } |
| 148 |
} |
148 |
} |
| 149 |
); |
149 |
); |
| 150 |
my $checkout2 = $builder->build_object( |
150 |
my $checkout2 = $builder->build_object( |
| 151 |
{ |
151 |
{ |
| 152 |
class => 'Koha::Checkouts', |
152 |
class => 'Koha::Checkouts', |
| 153 |
value => { itemnumber => $item2->itemnumber } |
153 |
value => { itemnumber => $item2->itemnumber, borrowernumber => $patron->id } |
| 154 |
} |
154 |
} |
| 155 |
); |
155 |
); |
| 156 |
|
156 |
|
|
Lines 430-456
subtest 'UpdateFine tests' => sub {
Link Here
|
| 430 |
is( $fine3->amount+0, 30, "Third fine reduced" ); |
430 |
is( $fine3->amount+0, 30, "Third fine reduced" ); |
| 431 |
is( $fine3->amountoutstanding+0, 10, "Third fine amount outstanding is reduced" ); |
431 |
is( $fine3->amountoutstanding+0, 10, "Third fine amount outstanding is reduced" ); |
| 432 |
|
432 |
|
|
|
433 |
# Ensure calculations work correctly for floats (bug #25127) |
| 434 |
# 7.2 (maxfine) - 7.2 (total_amount_other) != 8.88178419700125e-16 (😢) |
| 433 |
t::lib::Mocks::mock_preference( 'MaxFine', '7.2' ); |
435 |
t::lib::Mocks::mock_preference( 'MaxFine', '7.2' ); |
| 434 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
436 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 435 |
my $account = $patron_1->account; |
|
|
| 436 |
$account->add_debit({ type => 'OVERDUE', amount => '6.99', interface => 'TEST'}); |
| 437 |
$account->add_debit({ type => 'OVERDUE', amount => '.10', interface => 'TEST'}); |
| 438 |
$account->add_debit({ type => 'OVERDUE', amount => '.10', interface => 'TEST'}); |
| 439 |
$account->add_debit({ type => 'OVERDUE', amount => '.01', interface => 'TEST'}); |
| 440 |
my $item_1 = $builder->build_sample_item(); |
437 |
my $item_1 = $builder->build_sample_item(); |
|
|
438 |
my $item_2 = $builder->build_sample_item(); |
| 441 |
my $checkout_1 = $builder->build_object( |
439 |
my $checkout_1 = $builder->build_object( |
| 442 |
{ |
440 |
{ |
| 443 |
class => 'Koha::Checkouts', |
441 |
class => 'Koha::Checkouts', |
| 444 |
value => { itemnumber => $item_1->itemnumber, borrowernumber => $patron_1->id } |
442 |
value => { |
|
|
443 |
itemnumber => $item_1->itemnumber, |
| 444 |
borrowernumber => $patron_1->id |
| 445 |
} |
| 446 |
} |
| 447 |
); |
| 448 |
my $checkout_2 = $builder->build_object( |
| 449 |
{ |
| 450 |
class => 'Koha::Checkouts', |
| 451 |
value => { |
| 452 |
itemnumber => $item_2->itemnumber, |
| 453 |
borrowernumber => $patron->id |
| 454 |
} |
| 455 |
} |
| 456 |
); |
| 457 |
my $account = $patron_1->account; |
| 458 |
$account->add_debit( |
| 459 |
{ |
| 460 |
type => 'OVERDUE', |
| 461 |
amount => '6.99', |
| 462 |
issue_id => $checkout_1->issue_id, |
| 463 |
interface => 'TEST' |
| 464 |
} |
| 465 |
); |
| 466 |
$account->add_debit( |
| 467 |
{ |
| 468 |
type => 'OVERDUE', |
| 469 |
amount => '.10', |
| 470 |
issue_id => $checkout_1->issue_id, |
| 471 |
interface => 'TEST' |
| 472 |
} |
| 473 |
); |
| 474 |
$account->add_debit( |
| 475 |
{ |
| 476 |
type => 'OVERDUE', |
| 477 |
amount => '.10', |
| 478 |
issue_id => $checkout_1->issue_id, |
| 479 |
interface => 'TEST' |
| 480 |
} |
| 481 |
); |
| 482 |
$account->add_debit( |
| 483 |
{ |
| 484 |
type => 'OVERDUE', |
| 485 |
amount => '.01', |
| 486 |
issue_id => $checkout_1->issue_id, |
| 487 |
interface => 'TEST' |
| 445 |
} |
488 |
} |
| 446 |
); |
489 |
); |
| 447 |
UpdateFine( |
490 |
UpdateFine( |
| 448 |
{ |
491 |
{ |
| 449 |
issue_id => $checkout_1->issue_id, |
492 |
issue_id => $checkout_2->issue_id, |
| 450 |
itemnumber => $item_1->itemnumber, |
493 |
itemnumber => $item_2->itemnumber, |
| 451 |
borrowernumber => $patron_1->borrowernumber, |
494 |
borrowernumber => $patron_1->borrowernumber, |
| 452 |
amount => '.1', |
495 |
amount => '.1', |
| 453 |
due => $checkout_1->date_due |
496 |
due => $checkout_2->date_due |
| 454 |
} |
497 |
} |
| 455 |
); |
498 |
); |
| 456 |
$fines = Koha::Account::Lines->search( |
499 |
$fines = Koha::Account::Lines->search( |
|
Lines 460-465
subtest 'UpdateFine tests' => sub {
Link Here
|
| 460 |
is( $fines->count, 4, "New amount should be 0 so no fine added" ); |
503 |
is( $fines->count, 4, "New amount should be 0 so no fine added" ); |
| 461 |
ok( C4::Circulation::AddReturn( $item_1->barcode, $item_1->homebranch, 1), "Returning the item and forgiving fines succeeds"); |
504 |
ok( C4::Circulation::AddReturn( $item_1->barcode, $item_1->homebranch, 1), "Returning the item and forgiving fines succeeds"); |
| 462 |
|
505 |
|
| 463 |
|
|
|
| 464 |
$schema->storage->txn_rollback; |
506 |
$schema->storage->txn_rollback; |
| 465 |
}; |
507 |
}; |
| 466 |
- |
|
|