I'm using the format.spellOut method to convert a ...
# suitescript
n
I'm using the format.spellOut method to convert a number to text. Is this the best way to to convert a currency field to text? The reason I ask is I am getting "one hundred sixty point two two" for "160.22" which I understand why.....I just expected there to be a method in an financial solution to handle dollars, cents, etc. (e.g. Check, Voucher, etc.) Otherwise, I'm going to have to think through all the scenarios myself.
m
My first thought is to manipulate the currency value by splitting it at the decimal point and then using
format.spellOut
for both the dollar and cent amounts separately.
n
@MTNathan thats what I ended up doing! Glad we're on the same page 🙂
just used Math.floor and math.round to get my dollars and cents and then format.spellout for both and contatenated them at the end with some simple logic to handle "zero cents" vs "dollars and cents"
👍 1