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

(-)a/C4/Circulation.pm (-3 / +4 lines)
Lines 2329-2335 sub _FixOverduesOnReturn { Link Here
2329
        {
2329
        {
2330
            borrowernumber => $borrowernumber,
2330
            borrowernumber => $borrowernumber,
2331
            itemnumber     => $item,
2331
            itemnumber     => $item,
2332
            accounttype    => 'FU'
2332
            accounttype    => 'OVERDUE',
2333
            status         => 'UNRETURNED'
2333
        }
2334
        }
2334
    )->next();
2335
    )->next();
2335
    return 0 unless $accountline;    # no warning, there's just nothing to fix
2336
    return 0 unless $accountline;    # no warning, there's just nothing to fix
Lines 2337-2343 sub _FixOverduesOnReturn { Link Here
2337
    if ($exemptfine) {
2338
    if ($exemptfine) {
2338
        my $amountoutstanding = $accountline->amountoutstanding;
2339
        my $amountoutstanding = $accountline->amountoutstanding;
2339
2340
2340
        $accountline->accounttype('FFOR');
2341
        $accountline->status('FORGIVEN');
2341
        $accountline->amountoutstanding(0);
2342
        $accountline->amountoutstanding(0);
2342
2343
2343
        Koha::Account::Offset->new(
2344
        Koha::Account::Offset->new(
Lines 2352-2358 sub _FixOverduesOnReturn { Link Here
2352
            &logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item");
2353
            &logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item");
2353
        }
2354
        }
2354
    } else {
2355
    } else {
2355
        $accountline->accounttype('F');
2356
        $accountline->status('RETURNED');
2356
    }
2357
    }
2357
2358
2358
    return $accountline->store();
2359
    return $accountline->store();
(-)a/C4/Overdues.pm (-31 / +18 lines)
Lines 520-565 sub UpdateFine { Link Here
520
    }
520
    }
521
521
522
    my $dbh = C4::Context->dbh;
522
    my $dbh = C4::Context->dbh;
523
    # FIXME - What exactly is this query supposed to do? It looks up an
523
    my $overdues = Koha::Account::Lines->search(
524
    # entry in accountlines that matches the given item and borrower
524
        {
525
    # numbers, where the description contains $due, and where the
525
            borrowernumber    => $borrowernumber,
526
    # account type has one of several values, but what does this _mean_?
526
            accounttype       => [ 'OVERDUE', 'M' ],
527
    # Does it look up existing fines for this item?
527
            amountoutstanding => { '<>' => 0 }
528
    # FIXME - What are these various account types? ("FU", "O", "F", "M")
528
        }
529
    #   "L"   is LOST item
530
    #   "A"   is Account Management Fee
531
    #   "N"   is New Card
532
    #   "M"   is Sundry
533
    #   "F"   is Fine ??
534
    #   "FU"  is Fine UPDATE??
535
    #   "Pay" is Payment
536
    #   "REF" is Cash Refund
537
    my $sth = $dbh->prepare(
538
        "SELECT * FROM accountlines
539
        WHERE borrowernumber=? AND
540
        (( accounttype IN ('F','M') AND amountoutstanding<>0 ) OR
541
           accounttype = 'FU' )"
542
    );
529
    );
543
    $sth->execute( $borrowernumber );
530
544
    my $data;
531
    my $accountline;
545
    my $total_amount_other = 0.00;
532
    my $total_amount_other = 0.00;
546
    my $due_qr = qr/$due/;
533
    my $due_qr = qr/$due/;
547
    # Cycle through the fines and
534
    # Cycle through the fines and
548
    # - find line that relates to the requested $itemnum
535
    # - find line that relates to the requested $itemnum
549
    # - accumulate fines for other items
536
    # - accumulate fines for other items
550
    # so we can update $itemnum fine taking in account fine caps
537
    # so we can update $itemnum fine taking in account fine caps
551
    while (my $rec = $sth->fetchrow_hashref) {
538
    while (my $overdue = $overdues->next) {
552
        if ( $rec->{issue_id} == $issue_id && $rec->{accounttype} eq 'FU' ) {
539
        if ( $overdue->issue_id == $issue_id && $overdue->status eq 'UNRETURNED' ) {
553
            if ($data) {
540
            if ($accountline) {
554
                warn "Not a unique accountlines record for issue_id $issue_id";
541
                warn "Not a unique accountlines record for issue_id $issue_id";
555
                #FIXME Should we still count this one in total_amount ??
542
                #FIXME Should we still count this one in total_amount ??
556
            }
543
            }
557
            else {
544
            else {
558
                $data = $rec;
545
                $accountline = $overdue;
559
                next;
546
                next;
560
            }
547
            }
561
        }
548
        }
562
        $total_amount_other += $rec->{'amountoutstanding'};
549
        $total_amount_other += $overdue->amountoutstanding;
563
    }
550
    }
564
551
565
    if (my $maxfine = C4::Context->preference('MaxFine')) {
552
    if (my $maxfine = C4::Context->preference('MaxFine')) {
Lines 571-579 sub UpdateFine { Link Here
571
        }
558
        }
572
    }
559
    }
573
560
574
    if ( $data ) {
561
    if ( $accountline ) {
575
        if ( $data->{'amount'} != $amount ) {
562
        if ( $accountline->amount != $amount ) {
576
            my $accountline = Koha::Account::Lines->find( $data->{accountlines_id} );
577
            $accountline->adjust({ amount => $amount, type => 'fine_update' });
563
            $accountline->adjust({ amount => $amount, type => 'fine_update' });
578
        }
564
        }
579
    } else {
565
    } else {
Lines 586-592 sub UpdateFine { Link Here
586
            my $desc = "$title $due";
572
            my $desc = "$title $due";
587
573
588
            my $account = Koha::Account->new({ patron_id => $borrowernumber });
574
            my $account = Koha::Account->new({ patron_id => $borrowernumber });
589
            my $accountline = $account->add_debit(
575
            $accountline = $account->add_debit(
590
                {
576
                {
591
                    amount      => $amount,
577
                    amount      => $amount,
592
                    description => $desc,
578
                    description => $desc,
Lines 730-736 sub GetOverduesForBranch { Link Here
730
    LEFT JOIN itemtypes   ON itemtypes.itemtype       = $itype_link
716
    LEFT JOIN itemtypes   ON itemtypes.itemtype       = $itype_link
731
    LEFT JOIN branches    ON  branches.branchcode     = issues.branchcode
717
    LEFT JOIN branches    ON  branches.branchcode     = issues.branchcode
732
    WHERE (accountlines.amountoutstanding  != '0.000000')
718
    WHERE (accountlines.amountoutstanding  != '0.000000')
733
      AND (accountlines.accounttype         = 'FU'      )
719
      AND (accountlines.accounttype         = 'OVERDUE' )
720
      AND (accountlines.status              = 'UNRETURNED' )
734
      AND (issues.branchcode =  ?   )
721
      AND (issues.branchcode =  ?   )
735
      AND (issues.date_due  < NOW())
722
      AND (issues.date_due  < NOW())
736
    ";
723
    ";
(-)a/Koha/Account.pm (-4 / +5 lines)
Lines 409-415 my $debit_line = Koha::Account->new({ patron_id => $patron_id })->add_debit( Link Here
409
);
409
);
410
410
411
$debit_type can be any of:
411
$debit_type can be any of:
412
  - fine
412
  - overdue
413
  - lost_item
413
  - lost_item
414
  - new_card
414
  - new_card
415
  - account
415
  - account
Lines 471-477 sub add_debit { Link Here
471
                    itemnumber        => $item_id,
471
                    itemnumber        => $item_id,
472
                    issue_id          => $issue_id,
472
                    issue_id          => $issue_id,
473
                    branchcode        => $library_id,
473
                    branchcode        => $library_id,
474
                    ( $type eq 'fine' ? ( lastincrement => $amount ) : ()),
474
                    ( $type eq 'overdue' ? ( lastincrement => $amount ) : ()),
475
                    ( $type eq 'overdue' ? ( status => 'UNRETURNED' ) : ()),
475
                }
476
                }
476
            )->store();
477
            )->store();
477
478
Lines 672-678 our $offset_type = { Link Here
672
    'processing'       => 'Processing Fee',
673
    'processing'       => 'Processing Fee',
673
    'lost_item'        => 'Lost Item',
674
    'lost_item'        => 'Lost Item',
674
    'rent'             => 'Rental Fee',
675
    'rent'             => 'Rental Fee',
675
    'fine'             => 'Fine',
676
    'overdue'          => 'OVERDUE',
676
    'manual_debit'     => 'Manual Debit',
677
    'manual_debit'     => 'Manual Debit',
677
    'hold_expired'     => 'Hold Expired'
678
    'hold_expired'     => 'Hold Expired'
678
};
679
};
Lines 695-701 our $account_type_credit = { Link Here
695
696
696
our $account_type_debit = {
697
our $account_type_debit = {
697
    'account'       => 'A',
698
    'account'       => 'A',
698
    'fine'          => 'FU',
699
    'overdue'       => 'OVERDUE',
699
    'lost_item'     => 'L',
700
    'lost_item'     => 'L',
700
    'new_card'      => 'N',
701
    'new_card'      => 'N',
701
    'sundry'        => 'M',
702
    'sundry'        => 'M',
(-)a/Koha/Account/Line.pm (-9 / +19 lines)
Lines 235-241 This method allows updating a debit or credit on a patron's account Link Here
235
    );
235
    );
236
236
237
$update_type can be any of:
237
$update_type can be any of:
238
  - fine_update
238
  - overdue_update
239
239
240
Authors Note: The intention here is that this method is only used
240
Authors Note: The intention here is that this method is only used
241
to adjust accountlines where the final amount is not yet known/fixed.
241
to adjust accountlines where the final amount is not yet known/fixed.
Lines 257-267 sub adjust { Link Here
257
        );
257
        );
258
    }
258
    }
259
259
260
    my $account_type = $self->accounttype;
260
    my $account_type   = $self->accounttype;
261
    unless ( $Koha::Account::Line::allowed_update->{$update_type} eq $account_type ) {
261
    my $account_status = $self->status;
262
    unless (
263
        (
264
            exists(
265
                $Koha::Account::Line::allowed_update->{$update_type}
266
                  ->{$account_type}
267
            )
268
            && ( $Koha::Account::Line::allowed_update->{$update_type}
269
                ->{$account_type} eq $account_status )
270
        )
271
      )
272
    {
262
        Koha::Exceptions::Account::UnrecognisedType->throw(
273
        Koha::Exceptions::Account::UnrecognisedType->throw(
263
            error => 'Update type not allowed on this accounttype'
274
            error => 'Update type not allowed on this accounttype' );
264
        );
265
    }
275
    }
266
276
267
    my $schema = Koha::Database->new->schema;
277
    my $schema = Koha::Database->new->schema;
Lines 286-292 sub adjust { Link Here
286
                        amount      => $new_outstanding * -1,
296
                        amount      => $new_outstanding * -1,
287
                        description => 'Overpayment refund',
297
                        description => 'Overpayment refund',
288
                        type        => 'credit',
298
                        type        => 'credit',
289
                        ( $update_type eq 'fine_update' ? ( item_id => $self->itemnumber ) : ()),
299
                        ( $update_type eq 'overdue_update' ? ( item_id => $self->itemnumber ) : ()),
290
                    }
300
                    }
291
                );
301
                );
292
                $new_outstanding = 0;
302
                $new_outstanding = 0;
Lines 298-304 sub adjust { Link Here
298
                    date              => \'NOW()',
308
                    date              => \'NOW()',
299
                    amount            => $amount,
309
                    amount            => $amount,
300
                    amountoutstanding => $new_outstanding,
310
                    amountoutstanding => $new_outstanding,
301
                    ( $update_type eq 'fine_update' ? ( lastincrement => $difference ) : ()),
311
                    ( $update_type eq 'overdue_update' ? ( lastincrement => $difference ) : ()),
302
                }
312
                }
303
            )->store();
313
            )->store();
304
314
Lines 327-333 sub adjust { Link Here
327
                            manager_id        => undef,
337
                            manager_id        => undef,
328
                        }
338
                        }
329
                    )
339
                    )
330
                ) if ( $update_type eq 'fine_update' );
340
                ) if ( $update_type eq 'overdue_update' );
331
            }
341
            }
332
        }
342
        }
333
    );
343
    );
Lines 379-385 sub _type { Link Here
379
389
380
=cut
390
=cut
381
391
382
our $allowed_update = { 'fine_update' => 'FU', };
392
our $allowed_update = { 'overdue_update' => { 'OVERDUE' => 'UNRETURNED' } };
383
393
384
=head1 AUTHORS
394
=head1 AUTHORS
385
395
(-)a/circ/branchoverdues.pl (-2 / +4 lines)
Lines 31-38 use Data::Dumper; Link Here
31
31
32
=head1 branchoverdues.pl
32
=head1 branchoverdues.pl
33
33
34
 this module is a new interface, allow to the librarian to check all items on overdues (based on the acountlines type 'FU' )
34
This view is used to display all overdue items to the librarian.
35
 this interface is filtered by branches (automatically), and by location (optional) ....
35
36
It is automatically filtered by branch and can optionally be filtered
37
by item location.
36
38
37
=cut
39
=cut
38
40
(-)a/misc/cronjobs/staticfines.pl (-2 / +2 lines)
Lines 228-235 for ( my $i = 0 ; $i < scalar(@$data) ; $i++ ) { Link Here
228
228
229
            my $desc        = "staticfine";
229
            my $desc        = "staticfine";
230
            my $query       = "INSERT INTO accountlines
230
            my $query       = "INSERT INTO accountlines
231
                        (borrowernumber,itemnumber,date,amount,description,accounttype,amountoutstanding,lastincrement)
231
                        (borrowernumber,itemnumber,date,amount,description,accounttype,status,amountoutstanding,lastincrement)
232
                                VALUES (?,?,now(),?,?,'F',?,?)";
232
                                VALUES (?,?,now(),?,?,'OVERDUE','RETURNED',?,?)";
233
            my $sth2 = $dbh->prepare($query);
233
            my $sth2 = $dbh->prepare($query);
234
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount\n";
234
            $bigdebug and warn "query: $query\nw/ args: $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount\n";
235
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount );
235
            $sth2->execute( $borrowernumber, $itemnumber, $amount, $desc, $amount, $amount );
(-)a/opac/opac-user.pl (-1 / +1 lines)
Lines 196-202 if ( $pending_checkouts->count ) { # Useless test Link Here
196
            {
196
            {
197
                borrowernumber    => $patron->borrowernumber,
197
                borrowernumber    => $patron->borrowernumber,
198
                amountoutstanding => { '>' => 0 },
198
                amountoutstanding => { '>' => 0 },
199
                accounttype       => [ 'F', 'FU', 'L' ],
199
                accounttype       => [ 'F', 'L' ],
200
                itemnumber        => $issue->{itemnumber}
200
                itemnumber        => $issue->{itemnumber}
201
            },
201
            },
202
        );
202
        );
(-)a/t/db_dependent/Circulation.t (-13 / +17 lines)
Lines 502-509 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
502
502
503
    my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
503
    my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
504
    is( $fines->count, 2 );
504
    is( $fines->count, 2 );
505
    is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' );
505
    isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
506
    is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' );
506
    isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
507
    $fines->delete();
507
    $fines->delete();
508
508
509
509
Lines 688-694 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
688
                item_id     => $item_to_auto_renew->{itemnumber},
688
                item_id     => $item_to_auto_renew->{itemnumber},
689
                description => "Some fines"
689
                description => "Some fines"
690
            }
690
            }
691
        )->accounttype('F')->store;
691
        )->status('RETURNED')->store;
692
        ( $renewokay, $error ) =
692
        ( $renewokay, $error ) =
693
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
693
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
694
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
694
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
Lines 701-707 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
701
                item_id     => $item_to_auto_renew->{itemnumber},
701
                item_id     => $item_to_auto_renew->{itemnumber},
702
                description => "Some fines"
702
                description => "Some fines"
703
            }
703
            }
704
        )->accounttype('F')->store;
704
        )->status('RETURNED')->store;
705
        ( $renewokay, $error ) =
705
        ( $renewokay, $error ) =
706
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
706
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
707
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
707
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
Lines 714-720 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
714
                item_id     => $item_to_auto_renew->{itemnumber},
714
                item_id     => $item_to_auto_renew->{itemnumber},
715
                description => "Some fines"
715
                description => "Some fines"
716
            }
716
            }
717
        )->accounttype('F')->store;
717
        )->status('RETURNED')->store;
718
        ( $renewokay, $error ) =
718
        ( $renewokay, $error ) =
719
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
719
          CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
720
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
720
        is( $renewokay, 0, 'Do not renew, renewal is automatic' );
Lines 848-854 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
848
    );
848
    );
849
849
850
    my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next();
850
    my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next();
851
    is( $line->accounttype, 'FU', 'Account line type is FU' );
851
    is( $line->accounttype, 'OVERDUE', 'Account line type is OVERDUE' );
852
    is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' );
852
    is( $line->lastincrement, '15.000000', 'Account line last increment is 15.00' );
853
    is( $line->lastincrement, '15.000000', 'Account line last increment is 15.00' );
853
    is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' );
854
    is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' );
854
    is( $line->amount, '15.000000', 'Account line amount is 15.00' );
855
    is( $line->amount, '15.000000', 'Account line amount is 15.00' );
Lines 864-870 my ( $reused_itemnumber_1, $reused_itemnumber_2 ); Link Here
864
    LostItem( $item_1->itemnumber, 'test', 1 );
865
    LostItem( $item_1->itemnumber, 'test', 1 );
865
866
866
    $line = Koha::Account::Lines->find($line->id);
867
    $line = Koha::Account::Lines->find($line->id);
867
    is( $line->accounttype, 'F', 'Account type correctly changed from FU to F' );
868
    is( $line->accounttype, 'OVERDUE', 'Account type remains as OVERDUE' );
869
    isnt( $line->status, 'UNRETURNED', 'Account status correctly changed from UNRETURNED to RETURNED' );
868
870
869
    my $item = Koha::Items->find($item_1->itemnumber);
871
    my $item = Koha::Items->find($item_1->itemnumber);
870
    ok( !$item->onloan(), "Lost item marked as returned has false onloan value" );
872
    ok( !$item->onloan(), "Lost item marked as returned has false onloan value" );
Lines 1971-1977 subtest 'AddReturn | is_overdue' => sub { Link Here
1971
    # specify dropbox date 5 days later => overdue, or... not
1973
    # specify dropbox date 5 days later => overdue, or... not
1972
    AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
1974
    AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
1973
    AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago );
1975
    AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago );
1974
    is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature
1976
    is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the OVERDUE fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature
1975
    Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
1977
    Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
1976
};
1978
};
1977
1979
Lines 2346-2352 subtest '_FixAccountForLostAndReturned' => sub { Link Here
2346
2348
2347
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' );
2349
        is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' );
2348
2350
2349
        my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'FU' })->next;
2351
        my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next;
2350
        is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' );
2352
        is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' );
2351
    };
2353
    };
2352
};
2354
};
Lines 2373-2379 subtest '_FixOverduesOnReturn' => sub { Link Here
2373
    my $accountline = Koha::Account::Line->new(
2375
    my $accountline = Koha::Account::Line->new(
2374
        {
2376
        {
2375
            borrowernumber => $patron->{borrowernumber},
2377
            borrowernumber => $patron->{borrowernumber},
2376
            accounttype    => 'FU',
2378
            accounttype    => 'OVERDUE',
2379
            status         => 'UNRETURNED',
2377
            itemnumber     => $item->itemnumber,
2380
            itemnumber     => $item->itemnumber,
2378
            amount => 99.00,
2381
            amount => 99.00,
2379
            amountoutstanding => 99.00,
2382
            amountoutstanding => 99.00,
Lines 2386-2398 subtest '_FixOverduesOnReturn' => sub { Link Here
2386
    $accountline->_result()->discard_changes();
2389
    $accountline->_result()->discard_changes();
2387
2390
2388
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2391
    is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
2389
    is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )');
2392
    is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )');
2390
2393
2391
2394
2392
    ## Run again, with exemptfine enabled
2395
    ## Run again, with exemptfine enabled
2393
    $accountline->set(
2396
    $accountline->set(
2394
        {
2397
        {
2395
            accounttype    => 'FU',
2398
            accounttype    => 'OVERDUE',
2399
            status         => 'UNRETURNED',
2396
            amountoutstanding => 99.00,
2400
            amountoutstanding => 99.00,
2397
        }
2401
        }
2398
    )->store();
2402
    )->store();
Lines 2403-2409 subtest '_FixOverduesOnReturn' => sub { Link Here
2403
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2407
    my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
2404
2408
2405
    is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' );
2409
    is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' );
2406
    is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )');
2410
    is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
2407
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2411
    is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
2408
    is( $offset->amount, '-99.000000', "Amount of offset is correct" );
2412
    is( $offset->amount, '-99.000000', "Amount of offset is correct" );
2409
};
2413
};
(-)a/t/db_dependent/Overdues.t (-2 / +1 lines)
Lines 251-257 subtest 'UpdateFine tests' => sub { Link Here
251
    is( $fine2->amount, '30.000000', "Second fine increased after partial payment of first" );
251
    is( $fine2->amount, '30.000000', "Second fine increased after partial payment of first" );
252
252
253
    # Fix fine 1, create third fine
253
    # Fix fine 1, create third fine
254
    $fine->accounttype('F')->store;
254
    $fine->status('RETURNED')->store;
255
    UpdateFine(
255
    UpdateFine(
256
        {
256
        {
257
            issue_id       => $checkout1->issue_id,
257
            issue_id       => $checkout1->issue_id,
258
- 

Return to bug 22521