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

(-)a/t/db_dependent/Circulation.t (-8 / +9 lines)
Lines 2493-2499 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2493
};
2493
};
2494
2494
2495
subtest '_FixOverduesOnReturn' => sub {
2495
subtest '_FixOverduesOnReturn' => sub {
2496
    plan tests => 9;
2496
    plan tests => 11;
2497
2497
2498
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2498
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2499
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
2499
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
Lines 2526-2537 subtest '_FixOverduesOnReturn' => sub { Link Here
2526
        }
2526
        }
2527
    )->store();
2527
    )->store();
2528
2528
2529
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber );
2529
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, undef, 'RETURNED' );
2530
2530
2531
    $accountline->_result()->discard_changes();
2531
    $accountline->_result()->discard_changes();
2532
2532
2533
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2533
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2534
    is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )');
2534
    isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
2535
    is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )');
2535
2536
2536
    ## Run again, with exemptfine enabled
2537
    ## Run again, with exemptfine enabled
2537
    $accountline->set(
2538
    $accountline->set(
Lines 2542-2559 subtest '_FixOverduesOnReturn' => sub { Link Here
2542
        }
2543
        }
2543
    )->store();
2544
    )->store();
2544
2545
2545
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1 );
2546
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1, 'RETURNED' );
2546
2547
2547
    $accountline->_result()->discard_changes();
2548
    $accountline->_result()->discard_changes();
2548
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2549
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2549
2550
2550
    is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' );
2551
    is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' );
2552
    isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
2551
    is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
2553
    is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
2552
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2554
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2553
    is( $offset->amount, '-99.000000', "Amount of offset is correct" );
2555
    is( $offset->amount + 0, -99, "Amount of offset is correct" );
2554
    my $credit = $offset->credit;
2556
    my $credit = $offset->credit;
2555
    is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
2557
    is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
2556
    is( $credit->amount, '-99.000000', "Credit amount is set correctly" );
2558
    is( $credit->amount + 0, -99, "Credit amount is set correctly" );
2557
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2559
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2558
};
2560
};
2559
2561
2560
- 

Return to bug 22563