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

(-)a/C4/Circulation.pm (-1 / +6 lines)
Lines 2418-2424 sub _FixAccountForLostAndReturned { Link Here
2418
    return unless $accountlines->count > 0;
2418
    return unless $accountlines->count > 0;
2419
    my $accountline     = $accountlines->next;
2419
    my $accountline     = $accountlines->next;
2420
    my $total_to_refund = 0;
2420
    my $total_to_refund = 0;
2421
    my $account = Koha::Patrons->find( $accountline->borrowernumber )->account;
2421
2422
    return unless $accountline->borrowernumber;
2423
    my $patron = Koha::Patrons->find( $accountline->borrowernumber );
2424
    return undef unless $patron; # Patron has been deleted, nobody to credit the return to
2425
2426
    my $account = $patron->account;
2422
2427
2423
    # Use cases
2428
    # Use cases
2424
    if ( $accountline->amount > $accountline->amountoutstanding ) {
2429
    if ( $accountline->amount > $accountline->amountoutstanding ) {
(-)a/t/db_dependent/Circulation.t (-2 / +43 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use utf8;
19
use utf8;
20
20
21
use Test::More tests => 130;
21
use Test::More tests => 131;
22
use Test::MockModule;
22
use Test::MockModule;
23
23
24
use Data::Dumper;
24
use Data::Dumper;
Lines 2550-2555 subtest '_FixOverduesOnReturn' => sub { Link Here
2550
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2550
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2551
};
2551
};
2552
2552
2553
subtest '_FixAccountForLostAndReturned returns undef if patron is deleted' => sub {
2554
    plan tests => 1;
2555
2556
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2557
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
2558
2559
    my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' });
2560
2561
    my $branchcode  = $library2->{branchcode};
2562
2563
    my $item = $builder->build_sample_item(
2564
        {
2565
            biblionumber     => $biblio->biblionumber,
2566
            library          => $branchcode,
2567
            replacementprice => 99.00,
2568
            itype            => $itemtype,
2569
        }
2570
    );
2571
2572
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2573
2574
    ## Start with basic call, should just close out the open fine
2575
    my $accountline = Koha::Account::Line->new(
2576
        {
2577
            borrowernumber => $patron->id,
2578
            accounttype    => 'L',
2579
            status         => undef,
2580
            itemnumber     => $item->itemnumber,
2581
            amount => 99.00,
2582
            amountoutstanding => 99.00,
2583
            interface => 'test',
2584
        }
2585
    )->store();
2586
2587
    $patron->delete();
2588
2589
    my $return_value = C4::Circulation::_FixAccountForLostAndReturned( $patron->id, $item->itemnumber );
2590
2591
    is( $return_value, undef, "_FixAccountForLostAndReturned returns undef if patron is deleted" );
2592
2593
};
2594
2553
subtest 'Set waiting flag' => sub {
2595
subtest 'Set waiting flag' => sub {
2554
    plan tests => 4;
2596
    plan tests => 4;
2555
2597
2556
- 

Return to bug 23103