mrob
11/21/2024, 8:04 PMmrob
11/21/2024, 8:06 PMmrob
11/21/2024, 8:07 PM.locale
being referenced in the existing code but I imagine that's more of the user's locale vs determined by the currency of the transaction (which isn't necessarily equivalent to a locale anyway)mrob
11/21/2024, 8:10 PM${item.rate?string["#,##0.##"]}
before, which I think should be ensuring 2 decimal places? Except item.rate?string by itself is returning the 0s lopped offrustyshackles
11/22/2024, 12:27 AMmrob
11/22/2024, 7:56 AMrustyshackles
11/22/2024, 10:00 AMscottvonduhn
11/22/2024, 4:48 PMnsformat_currency()
is usually the preferred solution, as it respects the format options NetSuite uses for the transaction currency, and you don't need to worry about which currency it is. ?string.currency
will use whatever locale setting NetSuite's Java environment has.
?string["#,##0.##"]
simply limits the decimals to no more than two places, but does not ensure they will be displayed. It also means the thousands separator will always be a comma, and the decimal point character will always be a period. # will only display if the digit is not zero, 0 will always be displayed, even if the digit is zero. The problem is that values like 1.50 will display as 1.5, and a whole dollar amount won't have any decimals, regardless of the currency, so it should work fine for JPY, but it's not ideal for other currencies. ?string[#,##0.00]
will always display two decimal places, as you have seen.
I would use nsformat_currency()
unless you find it's not working as expected. Usually it's the best option, if the currency formats are setup correctly in NetSuite. The examples all show a second parameter, but if you don't set that, it uses the transaction's currency by default. It's better to not use the second parameter.