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 <nick@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-12-06 15:10:17 +00:00
parent 7a1e1a1f88
commit f94b32f074
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 13 additions and 6 deletions

View File

@ -551,12 +551,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;
}
}