From cc31daf13926c2caba23c4b23d082ac51cfc7093 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 2 Nov 2018 15:10:44 +0000 Subject: [PATCH] Bug 19066: (QA follow-up) Add handling in add_credit --- C4/Circulation.pm | 4 +++- Koha/Account.pm | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 599b100c55..3ccabd5d20 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2424,12 +2424,14 @@ sub _FixAccountForLostAndReturned { : 0; if ( $total_to_refund > 0 ) { + my $branchcode = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef; my $account = Koha::Patrons->find( $accountline->borrowernumber )->account; $credit = $account->add_credit( { amount => $total_to_refund, description => 'Item Returned ' . $item_id, - type => 'lost_item_return' + type => 'lost_item_return', + library_id => $branchcode, } ); } diff --git a/Koha/Account.pm b/Koha/Account.pm index df1677788f..3aec6a26e4 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -352,6 +352,7 @@ sub add_credit { # Insert the account line $line = Koha::Account::Line->new( { borrowernumber => $self->{patron_id}, + accountno => $accountno, date => \'NOW()', amount => $amount, description => $description, @@ -360,7 +361,9 @@ sub add_credit { payment_type => $payment_type, note => $note, manager_id => $user_id, - itemnumber => $item_id + branchcode => $library_id, + itemnumber => $item_id, + lastincrement => undef, } )->store(); @@ -396,6 +399,7 @@ sub add_credit { note => $note, itemnumber => $item_id, manager_id => $user_id, + branchcode => $library_id, } ) ); -- 2.19.1