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

(-)a/t/db_dependent/Circulation.t (-8 / +9 lines)
Lines 2447-2453 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2447
};
2447
};
2448
2448
2449
subtest '_FixOverduesOnReturn' => sub {
2449
subtest '_FixOverduesOnReturn' => sub {
2450
    plan tests => 9;
2450
    plan tests => 11;
2451
2451
2452
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2452
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2453
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
2453
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
Lines 2480-2491 subtest '_FixOverduesOnReturn' => sub { Link Here
2480
        }
2480
        }
2481
    )->store();
2481
    )->store();
2482
2482
2483
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber );
2483
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, undef, 'RETURNED' );
2484
2484
2485
    $accountline->_result()->discard_changes();
2485
    $accountline->_result()->discard_changes();
2486
2486
2487
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2487
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2488
    is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )');
2488
    isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
2489
    is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )');
2489
2490
2490
    ## Run again, with exemptfine enabled
2491
    ## Run again, with exemptfine enabled
2491
    $accountline->set(
2492
    $accountline->set(
Lines 2496-2513 subtest '_FixOverduesOnReturn' => sub { Link Here
2496
        }
2497
        }
2497
    )->store();
2498
    )->store();
2498
2499
2499
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1 );
2500
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1, 'RETURNED' );
2500
2501
2501
    $accountline->_result()->discard_changes();
2502
    $accountline->_result()->discard_changes();
2502
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2503
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2503
2504
2504
    is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' );
2505
    is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' );
2506
    isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
2505
    is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
2507
    is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
2506
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2508
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2507
    is( $offset->amount, '-99.000000', "Amount of offset is correct" );
2509
    is( $offset->amount + 0, -99, "Amount of offset is correct" );
2508
    my $credit = $offset->credit;
2510
    my $credit = $offset->credit;
2509
    is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
2511
    is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
2510
    is( $credit->amount, '-99.000000', "Credit amount is set correctly" );
2512
    is( $credit->amount + 0, -99, "Credit amount is set correctly" );
2511
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2513
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2512
};
2514
};
2513
2515
2514
- 

Return to bug 22563