currency-formatter icon indicating copy to clipboard operation
currency-formatter copied to clipboard

Incorrect format for Indian Rupees (INR)

Open GearoidCollins opened this issue 6 years ago • 4 comments

Said I would raise this for awareness.

We had this formatting issue internally and was going to look into using an external module, but it seems to be commonly overlooked.

https://en.wikipedia.org/wiki/Indian_numbering_system

GearoidCollins avatar May 15 '18 14:05 GearoidCollins

What would be the correct format?

Leaving the current format here for convenience:

  "INR": {
    "code": "INR",
    "symbol": "₹",
    "thousandsSeparator": ",",
    "decimalSeparator": ".",
    "symbolOnLeft": true,
    "spaceBetweenAmountAndSymbol": false,
    "decimalDigits": 2
  },

edorivai avatar May 16 '18 07:05 edorivai

Hi @edorivai,

Thanks for that, great package by the way.

The first thousand is , then it is separated by every hundred there after. e.g (100000000).toLocaleString('en-IN') = 1,00,00,00,000

GearoidCollins avatar May 16 '18 08:05 GearoidCollins

Oh my, I don't think the accounting package supports formatting in that fashion.

edorivai avatar May 16 '18 09:05 edorivai

Oh! that's interesting...

@edorivai is right! The accounting library doesn't support this kind of formatting.

openexchangerates/accounting.js#113 openexchangerates/accounting.js#141

Personally I'd suggest the Intl API:

new Intl.NumberFormat('en-IN', { style: 'currency', currency: 'INR' }).format(100000000)

// => "₹ 10,00,00,000.00"

smirzaei avatar May 17 '18 11:05 smirzaei