From efe03dca0d3b89de10bf79d64b9d48419b6fdedd Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 5 Feb 2020 09:18:48 +0000 Subject: [PATCH] Bug 24474: Add ReturnLostItem handling for paypal payments This patch adds a call to ReturnLostItem for Lost Item payments taken via OPAC online payments through PayPal. --- opac/opac-account-pay-paypal-return.pl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/opac/opac-account-pay-paypal-return.pl b/opac/opac-account-pay-paypal-return.pl index 07ed4bc5e7..7df395878b 100755 --- a/opac/opac-account-pay-paypal-return.pl +++ b/opac/opac-account-pay-paypal-return.pl @@ -107,6 +107,26 @@ if ( $response->is_success ) { interface => C4::Context->interface } ); + + if ( + C4::Context->preference('MarkLostItemsAsReturned') =~ m|OnPayment| ) + { + my $lines = Koha::Account::Lines->search( + { + accountlines_id => { -in => \@accountlines } + } + ); + while ( my $debit = $lines->next ) { + if ( $debit->amountoutstanding == 0 + && $debit->itemnumber + && $debit->debit_type_code + && ( $debit->debit_type_code eq 'LOST' ) ) + { + C4::Circulation::ReturnLostItem( $borrowernumber, + $debit->itemnumber ); + } + } + } } else { $error = "PAYPAL_ERROR_PROCESSING"; -- 2.20.1