Having trouble doing calculations with record.taxr...
# advancedpdf
s
Having trouble doing calculations with record.taxrate record.taxtotal and record.discountrate are fine but for some reason I get an error with record.taxrate
Expected a number, but this has evaluated to a sequence+hash+string
s
It’s possible that because it is a percentage, the value is a string with the percent symbol in it, which might be causing problems for the numeric conversion. However, if it actually is a percentage, you’d need to divide any calculated results by 100.0 in your formula. So it may just be as simple as defining a tax rate variable, and using that, something like this:
<#assign xyz = record.taxrate?replace('%', '')?number / 100.0>
I’d print out the value of record.taxrate and the converted variable, just to verify the values are correct.
An alternative approach, which I actually prefer, is to define custom transaction or transaction line fields and calculate the values there. Then the PDF can just show the custom field value, no math or conversions required in the template.