ecma402 icon indicating copy to clipboard operation
ecma402 copied to clipboard

Normative: Allow users to specify rounding based on cash denominations in common use

Open ben-allen opened this issue 2 years ago • 5 comments

fix #134 fix #835

For some currencies, the number of fractional digits and rounding increment used when dealing with cash values differs from the fractional digits/rounding increments used in financial contexts, with the cash contexts being limited to what's allowed for by the smallest currency denominations in actual circulation. ISO 4217 data uses the values for financial rounding, which is often inappropriate for common usage, while CLDR's currency data has separate attributes for:

  1. cash fractional digits and financial fractional digits
  2. cash rounding and financial rounding

This PR allows users to specify a new "currencyPrecision" attribute, which can be set to either "cash" (using CLDR's cash data) or "financial" (using CLDR's financial data, which is almost identical to ISO 4217's values).

This PR makes CLDR normative.

Note 1: I'm not confident about the wording used in CurrencyDigits and the new CurrencyRounding AOs to describe the CLDR data pulled in -- this is to be taken as a best first guess rather than a definitive attempt. Note 2: Current version shows whether "cash" or "financial" rounding has been set in resolvedOptions, which may not be necessary, as the actual values used for fractional digits and rounding increment are already visible elsewhere in resolvedOptions.

ben-allen avatar Oct 18 '23 16:10 ben-allen

This PR allows users to specify a new "cashPrecision" attribute, which can be set to either "cash" (using CLDR's cash data) or "financial" (using CLDR's financial data, which is almost identical to ISO 4217's values).

Note that the spec has the attribute named currencyPrecision, not cashPrecision.

sffc avatar Oct 20 '23 04:10 sffc

I haven't formed a position yet on the normative reference to CLDR. Happy to have that discussion.

sffc avatar Oct 20 '23 04:10 sffc

Note that the spec has the attribute named currencyPrecision, not cashPrecision.

Ah, of course! I've edited the comment

ben-allen avatar Oct 23 '23 11:10 ben-allen

@ben-allen, @romulocintra and I discussed converting this to a proposal that can go through the stage process.

sffc avatar Jan 17 '24 16:01 sffc

TG2 notes: https://github.com/tc39/ecma402/blob/main/meetings/notes-2024-01-18.md#support-cash-rounding-835

Conclusion: Add Test262 and docs for the current spec behavior.

LGTM: SFC, BAN, FYT

sffc avatar Feb 23 '24 00:02 sffc

Closing this PR but there is still work tracked in the issues linked in the OP

sffc avatar Aug 27 '24 19:08 sffc