simonmichael / hledger

Robust, fast, intuitive plain text accounting tool with CLI, TUI and web interfaces.
https://hledger.org
GNU General Public License v3.0
3.07k stars 320 forks source link

Symbols inside numbers in currencies #796

Open Ekleog opened 6 years ago

Ekleog commented 6 years ago

Hello,

So I am trying to add the Yen as a currency in hledger. I thus put this:

commodity 円
    format 1億0,000万0,000円

which is the common way of writing Yen in japanese.

However, hledger then replies:

unexpected '0'
expecting end of input, newline, or the rest of right-symbol amount

As hledger appears to support UTF-8 pretty well (as eg. a format 1,0000,0000円 works), I guess this is due to having a non-digit non-dot-or-comma symbol inside the number.

Is there a way to have symbols other than dot-and-comma be considered for inclusion as digit separators?

As usual, thank you for your work!

simonmichael commented 6 years ago

Wow. :) Yes your guess is correct. Where could we learn more about this usage, the allowed symbols and their meanings etc, eg on wikipedia ?

simonmichael commented 6 years ago

/me reads https://en.wikipedia.org/wiki/Japanese_numerals / http://www.guidetojapanese.org/learn/grammar/numbers .. mind blown.

I would be glad to have more support for this in hledger, if: a developer steps up to design and build it, verify all tests pass, and stick around to resolve the issues that will show up later.

Ekleog commented 6 years ago

Hmm, according to https://ja.wikipedia.org/wiki/%E5%86%86_(%E9%80%9A%E8%B2%A8)#%E5%86%86%E3%81%AE%E6%B5%81%E9%80%9A%E9%AB%98 the total amount of currency of Yen is 96兆0,377億円 ; so I guess for Yen it should be enough to add 兆, 億 and 万 as dot-and-comma-like symbols.

Do you think this would be an acceptable solution, or that it'd be better to have something more generic, in order to accommodate other currencies that may have “weird” (non-pejorative menaing) numbering schemes?

simonmichael commented 6 years ago

That sounds ok, though it seems unlikely to be the last word on the matter.

alerque commented 5 years ago

Having symbols other than comma, period, and space inside the currency is not unique to the Yen. Swiss Francs would be another example.

I just tried to import my books from a year when I had some extra travels (from Money Manager Ex) and ran into lots of issues with currencies. I even thought I could make it work by adopting only ISO-4217 symbols, but that's a not quite a go either. Basically it doesn't seem possible to get properly localized currency displays yet.

simonmichael commented 5 years ago

Nice additional examples, thanks. This remains a tricky problem that will require a champion [and careful cost-benefit analysis].

alerque commented 5 years ago

Another example @bradyt dredged up, the Cape Verdean escudo:

Amounts are generally written by using the $ as the decimal separator, such as 20$00 for 20 escudos, or 1.000$00 for 1000.

Genius. :warning:

alerque commented 5 years ago

Just for future reference, here are some things related to this issue: