Bug 8338: Remove zero amount overdues on backdated returns where appropriate

This patch removes any overdues which would be reversed on a backdated
return if CalcFineOnBackdate is enabled and the user has not already
attempted to pay off the accruing fine.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 3f3534a8ee)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Martin Renvoize 2020-05-13 14:11:38 +01:00 committed by Lucas Gass
parent 54a4aa7d93
commit 754e900fbe
1 changed files with 6 additions and 3 deletions

View File

@ -2433,9 +2433,12 @@ sub _FixOverduesOnReturn {
return 0 unless $accountlines->count; # no warning, there's just nothing to fix
my $accountline = $accountlines->next;
my $payments = $accountline->credits;
my $amountoutstanding = $accountline->amountoutstanding;
if ($exemptfine && ($amountoutstanding != 0)) {
if ( $accountline->amount == 0 && $payments->count == 0 ) {
$accountline->delete;
} elsif ($exemptfine && ($amountoutstanding != 0)) {
my $account = Koha::Account->new({patron_id => $borrowernumber});
my $credit = $account->add_credit(
{
@ -2451,15 +2454,15 @@ sub _FixOverduesOnReturn {
$credit->apply({ debits => [ $accountline ], offset_type => 'Forgiven' });
$accountline->status('FORGIVEN');
$accountline->store();
if (C4::Context->preference("FinesLog")) {
&logaction("FINES", 'MODIFY',$borrowernumber,"Overdue forgiven: item $item");
}
} else {
$accountline->status($status);
$accountline->store();
}
return $accountline->store();
}
);