Open chvp opened 1 month ago
This is a complex issue. Just a toggle might work for dinner folks with only currency and locale combinations that use all the same number formatting, but as soon add you have multiple currencies things get messy. You end up needing per-commodity formatting rules. I use hledger
which supports this pretty well, but keep ISO variants of my commodities setup for imports from NanoLedger, banks, etc. These later get localized but having them eases the import process. Since NanoLedger doesn't support localized commodities I have to use it with the ISO formatted variants.
Here is a small except of different commodity formats I use:
# hledger compatable
commodity $1,000.00
commodity ₺1.000,00
commodity 1 000,00 ₸
commodity 1,000.000 دت
commodity 1.000,00 лв
# ledger compatable
commodity 1,000.00 USD
commodity 1,000.00 TRY
commodity 1,000.00 KZT
commodity 1,000.00 TND
commodity 1,000.00 BGN
Another interesting one is:
commodity ALT 1.000,
This is an indivisible whole number unit for a gold commodity managed by a bank and hence shouldn't have a decimal separator at all.
My idea would be to just be accepting of all formats when the numbers are entered. It would be up to the user to write them according to their defined format.
I don't think accepting all formats is an option of you do math on the result unless you also limit to only one commodity and refuse any thousands separator. If you can guaranty that any and all separators are only ever decimal separators and only like commodities are handled then you can natively just accept (\d+)([\.,;])(\d*))?
and map to decimals for processing, then reuse whatever the separator was on the output.
There is no support for multiple commodities currently anyway. If #78 is handled first, then I can use the user preference of decimal separator and filter out all other separators. This will mean no thousands separators on the output, but the only math that NanoLedger does is to show a hint for the unreconciled amount anyway (where the thousands separators should not matter that much, IMO).
Related to #78, but also allowing a comma or period as thousands separator might be nice.