Wrong format for zero-decimal currencies

Created on 25 March 2025, about 1 month ago

Problem/Motivation

When using a currency that does not have decimal places, the Currency module still applies decimal formatting incorrectly. This leads to unexpected display issues.

Steps to reproduce

  1. Configure a currency that does not use decimal places (e.g., JPY, KRW), with 'Number of subunits' to zero.
  2. Use the currency in a field or rendered output.
  3. Notice that the amount is still formatted with decimals when it should not be.

Proposed resolution

Modify the condition in the formatting logic from:

if ($use_currency_precision && $this->getSubunits())

to:

if ($use_currency_precision)

This ensures that the formatting logic correctly follows the currency's precision setting.

Remaining tasks

  • Modify the condition in the relevant code section.
  • Test with different currencies, including both decimal and non-decimal ones.
  • Ensure that automated tests still pass.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇪🇸Spain psf_ Huelva

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024