From e0862e8eb615adcc51c7fd3de4242e0f19a829ec Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 20 Apr 2020 10:30:05 +0100 Subject: [PATCH] Bug 25127: Crude float fix --- C4/Overdues.pm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/C4/Overdues.pm b/C4/Overdues.pm index b6773c2cf1..932d98c69f 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -519,7 +519,7 @@ sub UpdateFine { my $issue_id = $params->{issue_id}; my $itemnum = $params->{itemnumber}; my $borrowernumber = $params->{borrowernumber}; - my $amount = $params->{amount}; + my $amount = $params->{amount} * 100; my $due = $params->{due} // q{}; $debug and warn "UpdateFine({ itemnumber => $itemnum, borrowernumber => $borrowernumber, due => $due, issue_id => $issue_id})"; @@ -538,7 +538,7 @@ sub UpdateFine { ); my $accountline; - my $total_amount_other = 0.00; + my $total_amount_other = 0; my $due_qr = qr/$due/; # Cycle through the fines and # - find line that relates to the requested $itemnum @@ -554,15 +554,16 @@ sub UpdateFine { $accountline = $overdue; } } - $total_amount_other += $overdue->amountoutstanding; + $total_amount_other += ( $overdue->amountoutstanding * 100 ); } if ( my $maxfine = C4::Context->preference('MaxFine') ) { + $maxfine = $maxfine * 100; my $maxIncrease = $maxfine - $total_amount_other; - return if $maxIncrease <= 0.00; + return if $maxIncrease <= 0; if ($accountline) { - if ( ( $amount - $accountline->amount ) > $maxIncrease ) { - my $new_amount = $accountline->amount + $maxIncrease; + if ( ( $amount - ( $accountline->amount * 100 ) ) > $maxIncrease ) { + my $new_amount = ( $accountline->amount * 100 ) + $maxIncrease; $debug and warn "Reducing fine for item $itemnum borrower $borrowernumber from $amount to $new_amount - MaxFine reached"; $amount = $new_amount; } @@ -574,10 +575,10 @@ sub UpdateFine { } if ( $accountline ) { - if ( $accountline->amount != $amount ) { + if ( ( $accountline->amount * 100 ) != $amount ) { $accountline->adjust( { - amount => $amount, + amount => ( $amount / 100 ), type => 'overdue_update', interface => C4::Context->interface } @@ -595,7 +596,7 @@ sub UpdateFine { my $account = Koha::Account->new({ patron_id => $borrowernumber }); $accountline = $account->add_debit( { - amount => $amount, + amount => ( $amount / 100 ), description => $desc, note => undef, user_id => undef, -- 2.20.1