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

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

Return to bug 22200