From cb5e03da1aa91c4013da135bf87768ea2e343317 Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm
index 185c753772..22aaa4e00f 100644
--- a/Koha/Account/Line.pm
+++ b/Koha/Account/Line.pm
@@ -596,8 +596,8 @@ sub apply {
 
             # Attempt to renew the item associated with this debit if
             # appropriate
-            if ($debit->renewable) {
-                $debit->renew_item($params->{interface});
+            if ( $self->credit_type_code ne 'FORGIVEN' && $debit->renewable ) {
+                $debit->renew_item( { interface => $params->{interface} } );
             }
 
             # Same logic exists in Koha::Account::pay
-- 
2.20.1