From 8416cf33eef4c70bd27ea5fa03f79f2c9802a728 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 6 Dec 2019 15:10:17 +0000 Subject: [PATCH] Bug 24146: Corrections to UpdateFine logic concerning maxFine The `maxFine` system preference actually refers to the amount of outsanding debt (in fines) a patron may have at a given time. This patch corrects the functionality of UpdateFine such that it properly respects that counter given the payment of accruing fines scenario. Signed-off-by: Nick Clemens Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson --- C4/Overdues.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/C4/Overdues.pm b/C4/Overdues.pm index daffbd0397..64046aee9e 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -552,12 +552,19 @@ sub UpdateFine { $total_amount_other += $overdue->amountoutstanding; } - if (my $maxfine = C4::Context->preference('MaxFine')) { - if ($total_amount_other + $amount > $maxfine) { - my $new_amount = $maxfine - $total_amount_other; - return if $new_amount <= 0.00; - $debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; - $amount = $new_amount; + if ( my $maxfine = C4::Context->preference('MaxFine') ) { + my $maxIncrease = $maxfine - $total_amount_other; + return if $maxIncrease <= 0.00; + if ($accountline) { + if ( ( $amount - $accountline->amount ) > $maxIncrease ) { + my $new_amount = $accountline->amount + $maxIncrease; + $debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; + $amount = $new_amount; + } + } + elsif ( $amount > $maxIncrease ) { + $debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $maxIncrease - MaxFine reached"; + $amount = $maxIncrease; } } -- 2.39.5