name in currencyOptions not working
I tried below code, it works well but name config is not working. It always considers plural
{
"localeCode": "en-IN",
"converterOptions": {
"currency": true,
"currencyOptions": {
"name": "Rupee",
"plural": "Rupees",
"symbol": "",
"fractionalUnit": {
"name": "Paisa",
"plural": "Paise",
"symbol": ""
}
}
}
}
Test#1: 1.01 outputs One Rupees And One Paise Only but should be One Rupee And One Paisa Only
Test#2: 1.00 outputs One Rupees Only but should be One Rupee Only
Can you please check this or am I missing anything ?
Any chance to check this issue ? @mastermunj
@anil-suthar This seems like a breaking change. Will you be able to raise a PR for the same?
@mastermunj I checked the code here : https://github.com/mastermunj/to-words/blob/main/dist/ToWords.js and I think you should replace the following code blocks :
Replace : (line# 161)
if (currencyOptions.plural) {
words.push(currencyOptions.plural);
}
with
if (Number(split[0]) > 1 && currencyOptions.plural) {
words.push(currencyOptions.plural);
} else {
words.push(currencyOptions.name);
}
and Replace : (line# 180)
wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);
with
if (Number(split[1]) > 1 && currencyOptions.fractionalUnit.plural) {
wordsWithDecimal.push(currencyOptions.fractionalUnit.plural);
} else {
wordsWithDecimal.push(currencyOptions.fractionalUnit.name);
}
Hi @anil-suthar have a look at this https://github.com/mastermunj/to-words/pull/1470