Fine generator can generate overdue fines beyond max-fine amount (rounding error)

Bug #1704819 reported by Bill Erickson
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Fix Released
Medium
Unassigned
3.1
Fix Released
Medium
Unassigned
3.2
Fix Released
Medium
Unassigned

Bug Description

Evergreen 2.12 / affects all versions.

Seen in the wild:

1. Item is marked lost and $2.30 of overdue fines are voided.
2. Item is returned and a $2.30 "OVERDUES REINSTATED" billing is applied.
3. Additional $0.10 overdue fines are applied, totaling $3.10, with a max fine amount of $3.00.

In short, the fine generator should avoid use of int() for rounding:

% perl -e 'print int(100 * 2.30) . "\n"'
229

See also 'perldoc -f int'.

Simply removing the int() wrapper resolves the issue in a standalone test script. Note that we are using sprintf %.2f for creating new billings, so there is no danger of creating billings with meandering decimal values.

Bill Erickson (berick)
summary: Fine generator can generate overdue fines beyond max-fine amount
- (rounding)
+ (rounding error)
Revision history for this message
Bill Erickson (berick) wrote :

Noting for reference the int() issue has come up before with credit card payments: bug #1282751.

Revision history for this message
Bill Erickson (berick) wrote :

Branch with fix pushed:

http://git.evergreen-ils.org/?p=working/Evergreen.git;a=shortlog;h=refs/heads/user/berick/lp1704819-fine-gen-int-rounding

Confirmed total fines accumulated match pre-patch amounts on a concerto test system. Perl test pending.

Revision history for this message
Jessica Woolford (jwoolford) wrote :

We observed this behavior in our 2.12 system as well. We're running your patch. Thanks!

Changed in evergreen:
status: New → Confirmed
status: Confirmed → New
Revision history for this message
Bill Erickson (berick) wrote :

Re-marking as confirmed based on Jessica's comments.

Changed in evergreen:
status: New → Confirmed
Dan Wells (dbw2)
tags: added: billing
Revision history for this message
Bill Erickson (berick) wrote :

We are also now running this patch in production.

Dan Wells (dbw2)
tags: added: pullrequest
Changed in evergreen:
assignee: nobody → Dan Wells (dbw2)
importance: Undecided → Medium
Michele Morgan (mmorgan)
Changed in evergreen:
milestone: none → 3.3-rc
Changed in evergreen:
milestone: 3.3-rc → 3.3.1
Changed in evergreen:
milestone: 3.3.1 → 3.3.2
Dan Wells (dbw2)
Changed in evergreen:
assignee: Dan Wells (dbw2) → nobody
Revision history for this message
Galen Charlton (gmc) wrote :

Pushed to master, rel_3_3, rel_3_2, and rel_3_1 on the strength of this having been run in production for a couple years and per discussion at http://irc.evergreen-ils.org/evergreen/2019-05-23#i_407072. Thanks, Bill!

Changed in evergreen:
assignee: nobody → Galen Charlton (gmc)
assignee: Galen Charlton (gmc) → nobody
status: Confirmed → Fix Committed
Changed in evergreen:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.