From f2beb29b92764a7c7c0142d7093321850a076d5d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 24 Mar 2021 17:13:57 +0000 Subject: [PATCH] Bug 27927: Prevent renewal on lost forgive The `RenewAccruingItemWhenPaid` preference should only renew upon payment (and writeoff?) and not upon automatic forgival triggered by `WhenLostForgiveFine`. --- Koha/Account/Line.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 2cc81993ef..a7ab118df5 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -597,7 +597,8 @@ sub apply { # Attempt to renew the item associated with this debit if # appropriate if ($debit->renewable) { - $debit->renew_item($params->{interface}); + $debit->renew_item( + { interface => $params->{interface}, credit => $self } ); } # Same logic exists in Koha::Account::pay @@ -929,15 +930,18 @@ sub renew_item { # - There is an interface param passed and it's value is 'opac' if ( - !C4::Context->preference('RenewAccruingItemWhenPaid') || - !$self->item || - !$self->patron || ( - !C4::Context->preference('RenewAccruingItemInOpac') && - $params->{interface} && - $params->{interface} eq 'opac' + exists $params->{credit} + && $params->{credit}->credit_type_code eq 'FORGIVEN' ) - ) { + || !C4::Context->preference('RenewAccruingItemWhenPaid') + || !$self->item + || !$self->patron + || ( !C4::Context->preference('RenewAccruingItemInOpac') + && $params->{interface} + && $params->{interface} eq 'opac' ) + ) + { return; } -- 2.20.1