From c4f81ea8f9d165a1cdfa1e5f4a80983f480befc7 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 23 May 2019 11:27:23 -0400 Subject: [PATCH] Bug 22982: Paying lost fee does not always remove lost item from checkouts Depending on how a lost fee is paid, it may or may not be removed from the patrons current checkouts. The current expected behavior is for the lost item to be removed from the patrons checkouts when the lost fee is paid in full. This is due to the subroutine for handling of lost fees being included in the 'pay specific lines' code but not in the 'pay by amount' code. Test Plan: 1) Apply this patch 2) prove t/db_dependent/Koha/Account.t Signed-off-by: Liz Rea Signed-off-by: Nadine Pierre Signed-off-by: Martin Renvoize (cherry picked from commit 20dde4cc4acf35ba9f5edc76c5271198217994e6) Signed-off-by: Fridolin Somers --- Koha/Account.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Koha/Account.pm b/Koha/Account.pm index 9d66e70f7c..5c8bcf30a7 100644 --- a/Koha/Account.pm +++ b/Koha/Account.pm @@ -108,7 +108,7 @@ sub pay { $fine->amountoutstanding($new_amountoutstanding)->store(); $balance_remaining = $balance_remaining - $amount_to_pay; - if ( $fine->itemnumber && $fine->accounttype && ( $fine->accounttype eq 'L' ) ) + if ( $new_amountoutstanding == 0 && $fine->itemnumber && $fine->accounttype && ( $fine->accounttype eq 'L' ) ) { C4::Circulation::ReturnLostItem( $self->{patron_id}, $fine->itemnumber ); } @@ -164,6 +164,11 @@ sub pay { $fine->amountoutstanding( $old_amountoutstanding - $amount_to_pay ); $fine->store(); + if ( $fine->amountoutstanding == 0 && $fine->itemnumber && $fine->accounttype && ( $fine->accounttype eq 'L' ) ) + { + C4::Circulation::ReturnLostItem( $self->{patron_id}, $fine->itemnumber ); + } + my $account_offset = Koha::Account::Offset->new( { debit_id => $fine->id, -- 2.39.5