Bug 17140: fix rounding errors when paying fines

Whenever a fine (accountlines in DB) has a precision longer than two floating points, it becomes very hard for a user to clear it.
Ex: 1.035 will be displayed as 1.04 or 1.03 depending on the screen.  But entering any of those value in Pay Fine will not clear it.
The user has no way to know the exact value to enter.

This fix makes sure that the intent of the user is met, by matching the EXACT needed sum when the difference is less than 0.01.

TEST
1) Create a 1.035 fine
  - Go to a Patron screen
  - Fines tab on the left
  - Create manual invoice
2) go to Pay fines, click Pay amount on bottom left.
3) It will show 1.03 as Total, and as Collect from patron.  Click confirm.
4) An error message will appear.
5) Apply patch, do again.

Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Blou 2018-12-21 10:33:29 -05:00 committed by Martin Renvoize
parent 85b5abcc4e
commit c2df905bfe
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 2 additions and 0 deletions

View File

@ -99,6 +99,7 @@ elsif ( $input->param('confirm_writeoff') ) {
my $accountline = Koha::Account::Lines->find( $accountlines_id );
$amount = $accountline->amountoutstanding if (abs($amount - $accountline->amountoutstanding) < 0.01);
if ( $amount > $accountline->amountoutstanding ) {
print $input->redirect( "/cgi-bin/koha/members/paycollect.pl?"
. "borrowernumber=$borrowernumber"

View File

@ -137,6 +137,7 @@ if ( $pay_individual || $writeoff_individual ) {
}
if ( $total_paid and $total_paid ne '0.00' ) {
$total_paid = $total_due if (abs($total_paid - $total_due) < 0.01);
if ( $total_paid < 0 or $total_paid > $total_due ) {
$template->param(
error_over => 1,