4 ms·
# Paisa.format / Paisa.format_with_sym This can be done with Rails's number_to_currency helper: https://apidock.com/rails/ActionView/Helpers/NumberHelper/numbe
by aboutruby 8y ago
# Paisa.format / Paisa.format_with_sym
This can be done with Rails's number_to_currency helper: https://apidock.com/rails/ActionView/Helpers/NumberHelper/number_to_currency https://apidock.com/rails/ActionView/Helpers/NumberHelper/nu...
# Paisa.words
There is number_to_human which is close: https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html#method-i-number_to_human https://api.rubyonrails.org/classes/ActionView/Helpers/Numbe..., otherwise number_to_words's gem https://github.com/kslazarev/numbers_and_words https://github.com/kslazarev/numbers_and_words
I would actually recommend using the money gem to handle money objects: https://github.com/RubyMoney/money https://github.com/RubyMoney/money
- sudhirj 8y agoAll of the methods and libraries assume regular grouping, but India's money is grouped irregularly. While regular money is counted in groups of 10^3 (thousands, millions, billions, trillions), in India there's a 3,2,2 cycle. One lakhs = 100,000 and 1 crore is 100 lakhs, but if you had 1000 of them it would still be a thousand. Everybody seems to get this wrong, even Google Sheets.
- marvindanig 8y agoTremendous, thanks for sharing this gem!
- aboutruby 8y agoOh I see, sorry, didn't look closely enough at the examples. Great project! Maybe this could be upstreamed in Rails?
- sudhirj 8y agoYeah, that would be ideal. Let me get the algos tightened up with feedback and testing, and I’ll try submitting them.