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 2597-2602 subtest '_FixOverduesOnReturn' => sub { Link Here
2597
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2597
    is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
2598
};
2598
};
2599
2599
2600
subtest '_FixAccountForLostAndReturned returns undef if patron is deleted' => sub {
2601
    plan tests => 1;
2602
2603
    my $manager = $builder->build_object({ class => "Koha::Patrons" });
2604
    t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
2605
2606
    my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' });
2607
2608
    my $branchcode  = $library2->{branchcode};
2609
2610
    my $item = $builder->build_sample_item(
2611
        {
2612
            biblionumber     => $biblio->biblionumber,
2613
            library          => $branchcode,
2614
            replacementprice => 99.00,
2615
            itype            => $itemtype,
2616
        }
2617
    );
2618
2619
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
2620
2621
    ## Start with basic call, should just close out the open fine
2622
    my $accountline = Koha::Account::Line->new(
2623
        {
2624
            borrowernumber => $patron->id,
2625
            accounttype    => 'L',
2626
            status         => undef,
2627
            itemnumber     => $item->itemnumber,
2628
            amount => 99.00,
2629
            amountoutstanding => 99.00,
2630
            interface => 'test',
2631
        }
2632
    )->store();
2633
2634
    $patron->delete();
2635
2636
    my $return_value = C4::Circulation::_FixAccountForLostAndReturned( $patron->id, $item->itemnumber );
2637
2638
    is( $return_value, undef, "_FixAccountForLostAndReturned returns undef if patron is deleted" );
2639
2640
};
2641
2600
subtest 'Set waiting flag' => sub {
2642
subtest 'Set waiting flag' => sub {
2601
    plan tests => 4;
2643
    plan tests => 4;
2602
2644
2603
- 

Return to bug 23103