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

(-)a/t/db_dependent/Circulation.t (-8 / +9 lines)
Lines 2542-2548 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2542
};
2542
};
2543
2543
2544
subtest '_FixOverduesOnReturn' => sub {
2544
subtest '_FixOverduesOnReturn' => sub {
2545
    plan tests => 9;
2545
    plan tests => 11;
2546
2546
2547
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2547
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2548
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
2548
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
Lines 2575-2586 subtest '_FixOverduesOnReturn' => sub { Link Here
2575
        }
2575
        }
2576
    )->store();
2576
    )->store();
2577
2577
2578
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber );
2578
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, undef, 'RETURNED' );
2579
2579
2580
    $accountline->_result()->discard_changes();
2580
    $accountline->_result()->discard_changes();
2581
2581
2582
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2582
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2583
    is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )');
2583
    isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
2584
    is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )');
2584
2585
2585
    ## Run again, with exemptfine enabled
2586
    ## Run again, with exemptfine enabled
2586
    $accountline->set(
2587
    $accountline->set(
Lines 2591-2608 subtest '_FixOverduesOnReturn' => sub { Link Here
2591
        }
2592
        }
2592
    )->store();
2593
    )->store();
2593
2594
2594
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1 );
2595
    C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1, 'RETURNED' );
2595
2596
2596
    $accountline->_result()->discard_changes();
2597
    $accountline->_result()->discard_changes();
2597
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2598
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2598
2599
2599
    is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' );
2600
    is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' );
2601
    isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
2600
    is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
2602
    is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
2601
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2603
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2602
    is( $offset->amount, '-99.000000', "Amount of offset is correct" );
2604
    is( $offset->amount + 0, -99, "Amount of offset is correct" );
2603
    my $credit = $offset->credit;
2605
    my $credit = $offset->credit;
2604
    is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
2606
    is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
2605
    is( $credit->amount, '-99.000000', "Credit amount is set correctly" );
2607
    is( $credit->amount + 0, -99, "Credit amount is set correctly" );
2606
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2608
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2607
};
2609
};
2608
2610
2609
- 

Return to bug 22563