https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43958
Bug ID: 43958
Summary: Replace toFixed-based price formatting with a
currency-aware minor-unit helper
Initiative type: ---
Sponsorship ---
status:
Product: Koha
Version: Main
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P5 - low
Component: Templates
Assignee: [email protected]
Reporter: [email protected]
QA Contact: [email protected]
Depends on: 43957
Blocks: 23728
Target Milestone: ---
Provide a shared, currency-aware JavaScript helper for minor-unit arithmetic
and formatting, replacing bare toFixed(). Part of the currency rounding work
collected on bug 23728.
format_price.inc hard-codes 2 digits and uses Number.prototype.toFixed, which
rounds the underlying binary float: (0.825).toFixed(2) is "0.82" but
(1.005).toFixed(2) is "1.00", and the result can disagree with the server. The
POS pay screen also truncates in moneyFormat() and sums floats in the grid
footer.
Proposed:
- A helper that converts to and from integer minor units using the currency
decimal_digits and the configured rounding mode, matching Koha::Number::Price.
- format_price uses it.
- POS pay.tt and the cash-up modals use it for totals and comparisons.
Tests: Cypress/unit tests for halves, negatives, 0- and 3-digit currencies.
Referenced Bugs:
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23728
[Bug 23728] Rounding code should be moved to a Koha module so code can be
centralised
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43957
[Bug 43957] Add per-currency decimal digits and configurable rounding policy
preferences
--
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/