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

  • CurrencyImporter uses getDisplayFractionDigits() for the imported currency's fraction digits.
  • Require commerceguys/intl: ^2.1.0 and update ludwig.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

Command icon 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

jsacksick created an issue. See original summary.

  • jsacksick committed f2d13e41 on 3.x
    feat: #3625249 Import currencies with their display fraction digits
    
jsacksick’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.