Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Intl] Document getCashFractionDigits() and getCashRoundingIncrement() #15215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions 44 components/intl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,45 @@ as some of their information (symbol, fraction digits, etc.)::
$symbol = Currencies::getSymbol('INR');
// => '₹'

$fractionDigits = Currencies::getFractionDigits('INR');
// => 2
The fraction digits methods return the number of decimal digits to display when
formatting numbers with this currency. Depending on the currency, this value
can change if the number is used in cash transactions or in other scenarios
(e.g. accounting)::

$roundingIncrement = Currencies::getRoundingIncrement('INR');
// => 0
// Indian rupee defines the same value for both
$fractionDigits = Currencies::getFractionDigits('INR'); // returns: 2
$cashFractionDigits = Currencies::getCashFractionDigits('INR'); // returns: 2

All methods (except for ``getFractionDigits()`` and ``getRoundingIncrement()``)
accept the translation locale as the last, optional parameter, which defaults to
the current default locale::
// Swedish krona defines different values
$fractionDigits = Currencies::getFractionDigits('SEK'); // returns: 2
$cashFractionDigits = Currencies::getCashFractionDigits('SEK'); // returns: 0

.. versionadded:: 5.3

The ``getCashFractionDigits()`` method was introduced in Symfony 5.3.

Some currencies require to round numbers to the nearest increment of some value
(e.g. 5 cents). This increment might be different if numbers are formatted for
cash transactions or other scenarios (e.g. accounting)::

// Indian rupee defines the same value for both
$roundingIncrement = Currencies::getRoundingIncrement('INR'); // returns: 0
$cashRoundingIncrement = Currencies::getCashRoundingIncrement('INR'); // returns: 0

// Canadian dollar defines different values because they have eliminated
// the smaller coins (1-cent and 2-cent) and prices in cash must be rounded to
// 5 cents (e.g. if price is 7.42 you pay 7.40; if price is 7.48 you pay 7.50)
$roundingIncrement = Currencies::getRoundingIncrement('CAD'); // returns: 0
$cashRoundingIncrement = Currencies::getCashRoundingIncrement('CAD'); // returns: 5

.. versionadded:: 5.3

The ``getCashRoundingIncrement()`` method was introduced in Symfony 5.3.

All methods (except for ``getFractionDigits()``, ``getCashFractionDigits()``,
``getRoundingIncrement()`` and ``getCashRoundingIncrement()``) accept the
translation locale as the last, optional parameter, which defaults to the
current default locale::

$currencies = Currencies::getNames('de');
// => ['AFN' => 'Afghanischer Afghani', 'EGP' => 'Ägyptisches Pfund', ...]
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.