@@ -237,15 +237,45 @@ as some of their information (symbol, fraction digits, etc.)::
237
237
$symbol = Currencies::getSymbol('INR');
238
238
// => '₹'
239
239
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)::
242
244
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
245
248
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::
249
279
250
280
$currencies = Currencies::getNames('de');
251
281
// => ['AFN' => 'Afghanischer Afghani', 'EGP' => 'Ägyptisches Pfund', ...]
0 commit comments