Bug 17140: fix rounding errors when paying fines
authorBlou <philippe.blouin@inlibro.com>
Fri, 21 Dec 2018 15:33:29 +0000 (10:33 -0500)
committerFridolin Somers <fridolin.somers@biblibre.com>
Fri, 8 Nov 2019 15:31:27 +0000 (16:31 +0100)
commit8166424b07602d5e32f4a30adf859d3a54e00525
tree4e24e37a80adb50c1ee9bed423774bb65efe3837
parent367f96aa0f418046fe3c5b409df9de7ad82efc1c
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>
(cherry picked from commit c2df905bfef771415d47aeba7db6ea445a33f1e1)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
members/pay.pl
members/paycollect.pl