money icon indicating copy to clipboard operation
money copied to clipboard

Is it possibly to specify a currency to more decimals?

Open devsi opened this issue 3 years ago • 1 comments

For example I want to see CAD to 8 decimal places, and calculate at that precision too. Is this possible with moneyphp?

devsi avatar May 20 '22 00:05 devsi

At the moment, no, it is not possible in an easily configurable way. I am currently adding more decimal places to the USD currency by modifying the currency.php file in the composer post-install and post-update scripts.

<?php

$currenciesFilePath = __DIR__ . '/../vendor/moneyphp/money/resources/currency.php';
$currencies = include $currenciesFilePath;
$currencies['USD']['minorUnit'] = 5;

file_put_contents($currenciesFilePath, sprintf('<?php return %s;', var_export($currencies, true)));

Would a PR making the minor unit of currencies configurable be accepted by this project?

magikid avatar Jul 14 '22 16:07 magikid

@devsi You can use a custom implementation of a Currencies interface instead of ISOCurrencies

arokettu avatar Sep 20 '22 20:09 arokettu

Question is answered.

frederikbosch avatar Sep 21 '22 07:09 frederikbosch