Hi, I am working on an invoice layout... and tryi...
# advancedpdf
m
Hi, I am working on an invoice layout... and trying to get all sum amounts for items based on their tax rate. To get something at the end like... the sum amount of all items with 15% tax rate is X the sum amount of all items with 10% tax rate is Y I am trying to utilize hashes but l have no idea how to update the hashes, I can't find it in the docs. And if that won't work, any idea about how it could be done?
a
Hi, this blog has some good code samples on doing something like this, it helped me out in the past: https://followingnetsuite.com/2018/12/14/advanced-templates-freemarker-lists-hashes/
that being said, working with hashes in NS's implementation of Freemarker is incredibly frustrating
your use case seems simple enough that you should be able to get it working though
i think you'd want something more along the lines of
<#assign taxRateAmounts = taxRateAmounts + {taxRate: itemAmount} />
f
You'll want to introduce an intermediate script that then presents the object to the renderer. Friends don't let friends do logic in the presentation layer.
😂 1
m
@al3xicon Thanks for the reference. I tried something like
<#assign taxRateAmounts = taxRateAmounts + {taxRate: itemAmount} />
but it doesn't accept they key to be this way. It wasn't a string directly, not a variable that has a string. That's what I understood from the (not so obvious error). Not sure how it worked with the author of that article... maybe I am missing something.
I think a script will be more neat. Will see.
Thanks again.
a
@Marwan if you have the capability to script the logic, I absolutely agree with Fred above that it is the better way to go about this
m
Yeah, it is very easy with a script. Not sure if the team leader will like it thou. Will see.
a
That's often a driving factor in unfortunately moving more of this kind of stuff to the advanced pdf templates