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

(-)a/C4/Circulation.pm (-12 / +17 lines)
Lines 2329-2357 sub _FixOverduesOnReturn { Link Here
2329
    }
2329
    }
2330
2330
2331
    # check for overdue fine
2331
    # check for overdue fine
2332
    my $accountline = Koha::Account::Lines->search(
2332
    my $accountlines = Koha::Account::Lines->search(
2333
        {
2333
        {
2334
            borrowernumber => $borrowernumber,
2334
            borrowernumber => $borrowernumber,
2335
            itemnumber     => $item,
2335
            itemnumber     => $item,
2336
            accounttype    => 'OVERDUE',
2336
            accounttype    => 'OVERDUE',
2337
            status         => 'UNRETURNED'
2337
            status         => 'UNRETURNED'
2338
        }
2338
        }
2339
    )->next();
2339
    );
2340
    return 0 unless $accountline;    # no warning, there's just nothing to fix
2340
    return 0 unless $accountlines->count; # no warning, there's just nothing to fix
2341
2341
2342
    my $accountline = $accountlines->next;
2342
    if ($exemptfine) {
2343
    if ($exemptfine) {
2343
        my $amountoutstanding = $accountline->amountoutstanding;
2344
        my $amountoutstanding = $accountline->amountoutstanding;
2344
2345
2345
        $accountline->status('FORGIVEN');
2346
        my $account = Koha::Account->new({patron_id => $borrowernumber});
2346
        $accountline->amountoutstanding(0);
2347
        my $credit = $account->add_credit(
2347
2348
        Koha::Account::Offset->new(
2349
            {
2348
            {
2350
                debit_id => $accountline->id,
2349
                amount     => $amountoutstanding,
2351
                type => 'Forgiven',
2350
                user_id    => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
2352
                amount => $amountoutstanding * -1,
2351
                library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
2352
                interface  => C4::Context->interface,
2353
                type       => 'forgiven',
2354
                item_id    => $item
2353
            }
2355
            }
2354
        )->store();
2356
        );
2357
2358
        $credit->apply({ debits => $accountlines->reset, offset_type => 'Forgiven' });
2359
2360
        $accountline->status('FORGIVEN');
2355
2361
2356
        if (C4::Context->preference("FinesLog")) {
2362
        if (C4::Context->preference("FinesLog")) {
2357
            &logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item");
2363
            &logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item");
2358
- 

Return to bug 22200