@@ -, +, @@ --- Koha/Account/Line.pm | 4 +++- t/db_dependent/Koha/Account.t | 2 +- t/db_dependent/Koha/Account/Lines.t | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) --- a/Koha/Account/Line.pm +++ a/Koha/Account/Line.pm @@ -248,7 +248,9 @@ sub apply { $debit->amountoutstanding, $debit ); - $overdue_unreturned->{$debit->itemnumber} = $debit if $renewable; + if ($renewable && $debit->itemnumber) { + $overdue_unreturned->{$debit->itemnumber} = $debit; + } # Same logic exists in Koha::Account::pay if ( $debit->amountoutstanding == 0 --- a/t/db_dependent/Koha/Account.t +++ a/t/db_dependent/Koha/Account.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 12; use Test::MockModule; use Test::Exception; --- a/t/db_dependent/Koha/Account/Lines.t +++ a/t/db_dependent/Koha/Account/Lines.t @@ -365,7 +365,7 @@ subtest 'apply() tests' => sub { my $module = new Test::MockModule('C4::Circulation'); $module->mock('AddRenewal', sub { $called = 1; }); my $credit_renew = $account->add_credit({ amount => 100, user_id => $patron->id, interface => 'commandline' }); - my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id }); + my $debits_renew = Koha::Account::Lines->search({ accountlines_id => $accountline->id })->as_list; $credit_renew->apply( { debits => $debits_renew, offset_type => 'Manual Credit' } ); is( $called, 1, 'RenewAccruingItemWhenPaid causes C4::Circulation::AddRenew to be called when appropriate' ); --