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

Commit 7cb1a0f

Browse filesBrowse files
committed
minor #15215 [Intl] Document getCashFractionDigits() and getCashRoundingIncrement() (javiereguiluz)
This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [Intl] Document getCashFractionDigits() and getCashRoundingIncrement() Fixes #15006. Commits ------- c0a3fdd [Intl] Document getCashFractionDigits() and getCashRoundingIncrement()
2 parents 9281f87 + c0a3fdd commit 7cb1a0f
Copy full SHA for 7cb1a0f

File tree

1 file changed

+37
-7
lines changed
Filter options

1 file changed

+37
-7
lines changed

‎components/intl.rst

Copy file name to clipboardExpand all lines: components/intl.rst
+37-7Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,45 @@ as some of their information (symbol, fraction digits, etc.)::
237237
$symbol = Currencies::getSymbol('INR');
238238
// => '₹'
239239

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

243-
$roundingIncrement = Currencies::getRoundingIncrement('INR');
244-
// => 0
245+
// Indian rupee defines the same value for both
246+
$fractionDigits = Currencies::getFractionDigits('INR'); // returns: 2
247+
$cashFractionDigits = Currencies::getCashFractionDigits('INR'); // returns: 2
245248

246-
All methods (except for ``getFractionDigits()`` and ``getRoundingIncrement()``)
247-
accept the translation locale as the last, optional parameter, which defaults to
248-
the current default locale::
249+
// Swedish krona defines different values
250+
$fractionDigits = Currencies::getFractionDigits('SEK'); // returns: 2
251+
$cashFractionDigits = Currencies::getCashFractionDigits('SEK'); // returns: 0
252+
253+
.. versionadded:: 5.3
254+
255+
The ``getCashFractionDigits()`` method was introduced in Symfony 5.3.
256+
257+
Some currencies require to round numbers to the nearest increment of some value
258+
(e.g. 5 cents). This increment might be different if numbers are formatted for
259+
cash transactions or other scenarios (e.g. accounting)::
260+
261+
// Indian rupee defines the same value for both
262+
$roundingIncrement = Currencies::getRoundingIncrement('INR'); // returns: 0
263+
$cashRoundingIncrement = Currencies::getCashRoundingIncrement('INR'); // returns: 0
264+
265+
// Canadian dollar defines different values because they have eliminated
266+
// the smaller coins (1-cent and 2-cent) and prices in cash must be rounded to
267+
// 5 cents (e.g. if price is 7.42 you pay 7.40; if price is 7.48 you pay 7.50)
268+
$roundingIncrement = Currencies::getRoundingIncrement('CAD'); // returns: 0
269+
$cashRoundingIncrement = Currencies::getCashRoundingIncrement('CAD'); // returns: 5
270+
271+
.. versionadded:: 5.3
272+
273+
The ``getCashRoundingIncrement()`` method was introduced in Symfony 5.3.
274+
275+
All methods (except for ``getFractionDigits()``, ``getCashFractionDigits()``,
276+
``getRoundingIncrement()`` and ``getCashRoundingIncrement()``) accept the
277+
translation locale as the last, optional parameter, which defaults to the
278+
current default locale::
249279

250280
$currencies = Currencies::getNames('de');
251281
// => ['AFN' => 'Afghanischer Afghani', 'EGP' => 'Ägyptisches Pfund', ...]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.