Money rounding error in TPAC credit card payment interface
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Evergreen |
Fix Released
|
Undecided
|
Unassigned | ||
2.10 |
Fix Released
|
Undecided
|
Unassigned | ||
2.11 |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
While paying a fine by credit card in the TPAC, I encountered a money rounding error. The single fine was for $1.15, but the total immediately below it is displayed as $1.14 (see attached screenshot). If I attempt to pay the fine via credit card (via Stripe payment service), the confirmation page again says I am about to pay $1.14, but after the payment completes the receipt page says "Paid 1.15 via credit card". It displays correctly everywhere else in the interface (e.g. the "dashboard" at the top-right of the page, the initial fine-selection page).
This may require a larger discussion about using floating-point math vs. money-safe math, and there may be multiple places in the Evergreen code affected by this issue, as mentioned in this bug:
Changed in evergreen: | |
milestone: | 2.11-rc → 2.11.1 |
Changed in evergreen: | |
status: | Fix Committed → Fix Released |
milestone: | 2.11.1 → 2.next |
status: | Fix Released → Fix Committed |
Changed in evergreen: | |
milestone: | 2.next → 2.12-beta |
Changed in evergreen: | |
status: | Fix Committed → Fix Released |
Just encountered this bug. Patron had 100+ small billings ($0.10, $0.20, etc.). The final amount to pay was "9.999999999...", which PayPal naturally rejected. I traced this to the Money.pm code that's adding the amounts to create the $total_paid amount. Using the $amount*100; $total_paid/100 trick resolves it. Will post a patch after more testing.