View | Details | Raw Unified | Return to bug 27079
Collapse All | Expand All

(-)a/t/db_dependent/Overdues.t (-3 / +35 lines)
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 => 70;
135
    plan tests => 74;
136
136
137
    $schema->storage->txn_begin;
137
    $schema->storage->txn_begin;
138
138
Lines 430-436 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)
433
    # Ensure maxfine calculations work correctly for floats (bug #25127)
434
    # 7.2 (maxfine) - 7.2 (total_amount_other) != 8.88178419700125e-16 (😢)
434
    # 7.2 (maxfine) - 7.2 (total_amount_other) != 8.88178419700125e-16 (😢)
435
    t::lib::Mocks::mock_preference( 'MaxFine', '7.2' );
435
    t::lib::Mocks::mock_preference( 'MaxFine', '7.2' );
436
    my $patron_1   = $builder->build_object( { class => 'Koha::Patrons' } );
436
    my $patron_1   = $builder->build_object( { class => 'Koha::Patrons' } );
Lines 503-507 subtest 'UpdateFine tests' => sub { Link Here
503
    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" );
504
    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");
505
505
506
    t::lib::Mocks::mock_preference( 'MaxFine', 0 );
507
508
    # Ensure CalcFine calculations work correctly for floats (bug #27079)
509
    # 1.800000 (amount from database) != 1.8~ (CalcFine of 0.15cents * 12units) (😢)
510
    my $amount = 0.15 * 12;
511
    UpdateFine(
512
        {
513
            issue_id       => $checkout_2->issue_id,
514
            itemnumber     => $item_2->itemnumber,
515
            borrowernumber => $patron_1->borrowernumber,
516
            amount         => $amount,
517
            due            => $checkout_2->date_due
518
        }
519
    );
520
    $fine = Koha::Account::Lines->search({ issue_id => $checkout_2->issue_id })->single;
521
    ok( $fine, 'Fine added for checkout 2');
522
    is( $fine->amount, "1.800000", "Fine amount is 1.800000 as expected");
523
524
    $fine->amountoutstanding(0)->store;
525
    $fine->discard_changes;
526
    is( $fine->amountoutstanding + 0, 0, "Fine was paid off");
527
    UpdateFine(
528
        {
529
            issue_id       => $checkout_2->issue_id,
530
            itemnumber     => $item_2->itemnumber,
531
            borrowernumber => $patron_1->borrowernumber,
532
            amount         => $amount,
533
            due            => $checkout_2->date_due
534
        }
535
    );
536
    my $refunds = Koha::Account::Lines->search({ itemnumber => $item_2->itemnumber, credit_type_code => 'OVERPAYMENT' });
537
    is( $refunds->count, 0, "Overpayment refund not added when the amounts are equal" );
538
506
    $schema->storage->txn_rollback;
539
    $schema->storage->txn_rollback;
507
};
540
};
508
- 

Return to bug 27079