Problem/Motivation
commerceguys/intl v2.1.0 separates the two meanings of a currency's fraction digits:
Currency::getFractionDigits(): the ISO 4217 minor units, used for converting amounts to minor units (e.g. for payment gateways). Since v2.0.10 (see #3625166).Currency::getDisplayFractionDigits(): the CLDR display digits, i.e. how many decimals are used in practice. For example, HUF has 2 minor units but is displayed and priced in whole forints.
CurrencyImporter currently uses getFractionDigits(), so newly imported currencies get the ISO minor units. For COP, HUF, IDR, PKR and a few others, that means prices are displayed and rounded with 2 decimals nobody uses (e.g. 9 505,00 Ft).
Proposed resolution
CurrencyImporterusesgetDisplayFractionDigits()for the imported currency's fraction digits.- Require
commerceguys/intl: ^2.1.0and updateludwig.json.
The currency entity's fraction digits are used for display, rounding (Rounder, PriceSplitter) and the price input, so newly imported HUF prices will be rounded to whole forints, matching how HUF is priced in practice. Minor units are not affected: getDefaultFractionDigits() keeps returning the ISO 4217 value, so gateways still receive the right amount.
Existing currencies are not changed (no update hook), since merchants may have configured their fraction digits on purpose. They can still be edited in the UI.
Remaining tasks
- MR with the importer change, the version bump, and test coverage (importing HUF gives 0 fraction digits).
Issue fork commerce-3625249
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
jsacksick commented