Open hizmarck opened 1 month ago
Thanks for the report! Sorry for the late reply. I've been very busy the last month.
I was able to reproduce this. I looks like the number formatted gets properly configured with the MONEY_DECIMAL_DIGITS
var, but IntlLocalizedDecimalParser
does not respect that.
The problem is in IntlLocalizedDecimalParser
as you said where it does not allow for more decimals then the minor unit for that currency. The only solution I can think of to fix this would be to allow that you inject your own Decimal parser that implements Money\MoneyParser
and replaces IntlLocalizedDecimalParser
.
Is that something you would want?
Hi @pelmered, ty for your response. That sure will work for me.
I also was thinking of a way only to inject the currencies:
new CurrencyList([ 'MXN' => 4, // minor unit pairs 'USD' => 2 // minor unit pairs ])
instead of the ISOCurrencies.
new IntlLocalizedDecimalParser($numberFormatter, new ISOCurrencies);
But, reading your response, I can see better control if we can implement our own Money\MoneyParser.
Regards.
Describe the bug I have the next use case, which is to save 4 decimal digits:
Steps To Reproduce
.env
composer.json
If I insert this value = 19.5455, the saved one is 19.5500
Expected behavior and actual behavior Let the MoneyInput save the configured decimal digits.
Additional context I debugged the code a little and found that the MoneyFormatter use the $moneyParser = new IntlLocalizedDecimalParser($numberFormatter, new ISOCurrencies);
in which we have 2 minor units:
I can understand that for Money calculations this configuration is correct and that at the end we need to round the final changes, so maybe this is not a bug, but for my use case is almost impossible to find a solution, ty very much.