Gil G
Gil G

Reputation: 11

How can I multiply a string.currency field in Freemarker?

I have the following line of code on a Netsuite PDF/HTML: ${item.rate?string.currency}

I would like to multiply the output of this line by 1.1 to display as GST Inclusive however the only time it works is when i remove the "?string.currency" section. When this is removed, I lose the currency formatting.

Any help is greatly appreciated.

Upvotes: 1

Views: 2757

Answers (1)

Jasper de Vries
Jasper de Vries

Reputation: 20188

Once you format a number as a currency (by using ?string.currency), you end up with a string which cannot be manipulated as a number anymore. So, do the manipulation first:

${item.rating * 1.1}

This will leave you with a number. To format the result as a currency, use brackets around the numeric part of the expression:

${(item.rating * 1.1)?string.currency}

See also:

Upvotes: 1

Related Questions