From ce26f797d11027693531b5e592f5a618f0abe701 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 5 Feb 2020 13:10:49 +0000 Subject: [PATCH] Bug 24474: Filter out LOST_FOUND --- Koha/Account/Line.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 1fac85d10c..731ae0e0c9 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -484,14 +484,22 @@ sub apply { $debit->amountoutstanding( $owed - $amount_to_cancel )->store; # Same logic exists in Koha::Account::pay - if ( $debit->amountoutstanding == 0 - && $debit->itemnumber + if ( + C4::Context->preference('MarkLostItemsAsReturned') =~ + m|onpayment| && $debit->debit_type_code - && $debit->debit_type_code eq 'LOST' ) + && $debit->debit_type_code eq 'LOST' + && $debit->amountoutstanding == 0 + && $debit->itemnumber + && !( + $self->credit_type_code eq 'LOST_FOUND' + && $self->itemnumber == $debit->itemnumber + ) + ) { - C4::Circulation::ReturnLostItem( $self->borrowernumber, $debit->itemnumber ); + C4::Circulation::ReturnLostItem( $self->borrowernumber, + $debit->itemnumber ); } - } }); -- 2.20.1