@@ -, +, @@ --- C4/Overdues.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/C4/Overdues.pm +++ a/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; } } --