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

Bug #1704819 reported by Bill Erickson on 2017-07-17
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Medium
Dan Wells
3.1
Medium
Unassigned
3.2
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) on 2017-07-17
summary: Fine generator can generate overdue fines beyond max-fine amount
- (rounding)
+ (rounding error)
Bill Erickson (berick) wrote :

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

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.

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
Bill Erickson (berick) wrote :

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

Changed in evergreen:
status: New → Confirmed
Dan Wells (dbw2) on 2018-04-26
tags: added: billing
Bill Erickson (berick) wrote :

We are also now running this patch in production.

Dan Wells (dbw2) on 2018-05-01
tags: added: pullrequest
Changed in evergreen:
assignee: nobody → Dan Wells (dbw2)
importance: Undecided → Medium
Michele Morgan (mmorgan) on 2019-03-07
Changed in evergreen:
milestone: none → 3.3-rc
Changed in evergreen:
milestone: 3.3-rc → 3.3.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers