Hello People, I am working on customer statement p...
# advancedpdf
a
Hello People, I am working on customer statement pdf template and here is what I want to do. I am trying to calculate the total of charge column and total of payment column from the statement.
<#list statements as statement>
<#assign totalCharges = 0>
<#assign totalPayments = 0>
<#list statement.lines as line>
<#assign totalCharges += (line.charge?number!0)>
<#assign totalPayments += (line.payment?number!0)>
</#list>
<#assign amountDue = totalCharges - totalPayments>
It doesn't give me an error when I save the template but customer statement is not being generated. I am thinking that is because, not each line of statement has both charge and payment and some lines must be returning null for each of them. Any idea how can I tackle this? Thanks
c
are you just getting 0? typically I do <#assign totalCharges = totalCharges + (line.charge?number!0)> I am not sure the += will work in advancedpdf
a
I am getting error when I try to generate statement & the error is not very helpful. It just says: "An unexpected error has occurred. Please click here to notify support and provide your contact information."
c
I would try updating to what I mentioned without the += and see if its working. NetSuite isn't on the latest and greatest freemarker version so some things do not work.
a
Yeah, I did that. Still no luck. I just can't figure out the issue.
Initializing the total variables to 0 works fine but as soon as I try to add line.charge or line.payment to any of the variable, it starts showing error.
I noticed one more thing, If I wrap the addition lines in a condition like this:
<#if line.charge?has_content>
<#assign totalCharges = totalCharges + (line.charge?number!0)
</#if>
It gives 0 for totalCharges. I don't get why is it ignoring all lines. Even though it shouldn't
c
i'd limit to 1 addition like the charge. If you take out the ?number!0 does it work?
I've never dealt w/ the statements in advancedpdf so not sure what is going on with it but it seems like it could possibly be syntax.
f
Access the your math via a controller which calls a module with your logic and then use the view to present the data.
s
have you resolved it?