From 94246f8dbc2a20d930e15c5cff809c02d4cdf5ad Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 12 Oct 2022 04:23:42 +0000 Subject: [PATCH] Bug 23012: [WIP] Mark processing fee as found when lost item found --- Koha/Item.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Koha/Item.pm b/Koha/Item.pm index e549be6d85b..7f89bff70d0 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1183,6 +1183,19 @@ sub _set_found_trigger { } )->single; + # refund processing charge made for lost book + my $processing_charge = Koha::Account::Lines->search( + { + itemnumber => $self->itemnumber, + debit_type_code => 'PROCESSING', + status => [ undef, { '<>' => 'FOUND' } ] + }, + { + order_by => { -desc => [ 'date', 'accountlines_id' ] }, + rows => 1 + } + )->single; + if ( $lost_charge ) { my $patron = $lost_charge->patron; @@ -1256,6 +1269,10 @@ sub _set_found_trigger { $lost_charge->status('FOUND'); $lost_charge->store(); + if ( $processing_charge && $processing_charge->borrowernumber == $lost_charge->borrowernumber ) { + $processing_charge->status('FOUND')->store; + } + # Reconcile balances if required if ( C4::Context->preference('AccountAutoReconcile') ) { $account->reconcile_balance; @@ -1286,6 +1303,10 @@ sub _set_found_trigger { # Update status of fine $lost_overdue->status('FOUND')->store(); + if ( $processing_charge && $processing_charge->borrowernumber == $lost_charge->borrowernumber ) { + $processing_charge->status('FOUND')->store; + } + # Find related forgive credit my $refund = $lost_overdue->credits( { -- 2.20.1