[Bug 43958] New: Replace toFixed-based price formatting with a currency-aware minor-unit helper
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: oleonard@myacpl.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org 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.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43958 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |43959 Blocks| |43961 Blocks|23728 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23728 [Bug 23728] [OMNIBUS] Currency precision and rounding: central engine, per-currency digits, configurable policy https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43959 [Bug 43959] Cash-up reports false surplus or deficit when amounts contain fractions of a penny https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43961 [Bug 43961] POS accepts prices and quantities that produce fractions of a penny -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43958 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 210093 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=210093&action=edit Bug 43958: Add shared JavaScript currency helper -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43958 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|oleonard@myacpl.org |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43958 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43958 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |43962 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43962 [Bug 43962] Use the shared rounding engine in acquisitions with per-vendor rounding settings -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org