Advanced PDF Statement – How to show Amount Remaining on each invoice Invoice line ?

I’m working on a pdf statement and came across some code on stack overflow that fits exactly what I’m trying to accomplish. When I try to print a statement with this code inserted, it errors out. Any ideas on what can be done to get rid of the error?

==== From Stack

  • Each line will display a charge, if it is an invoice
  • Will show the amount paid, if it is an invoice with payments applied
  • If it is a payment/deposit/credit, the payment column will show the total paid on that payment.
  • The balance column will display an amount if, it as unpaid or partially paid invoice and the running column, will display the running total of the statement

===== Code

    <#list statement.lines as line>
<#if line_index==0>

 <th>References #</th>
 <th>Balance Due</th>

 <#function toNumber val><#if val?has_content && val?length gt 0 ><#return val?html?replace('[^0-9.]','','r')?number ><#else><#return 0 ></#if></#function>
 <#assign amountpaid=(line.charge?int-line.amountremaining?int)>
  <td><#if amountpaid gt 0>${amountpaid?string.currency}<#else>${line.payment}</#if></td>


Rookie Asked on March 2, 2020 in How To's.

What is the errror?

Do you have Charge Based Billing enabled?

Does your PDF have the rest of the necessary code to render? This is just an in-body snippet, you still have the rest of the needed tags right?

on March 3, 2020.
  1. Advanced PDF Statement - How to show Amount Remaining on each invoice Invoice line ?Error Message

  2. Do not have charge based billing enabled
  3. Yes, the pdf does have the rest of the code, I just swapped out the table I had previously setup, with this table
on March 3, 2020.

Sidenote: one change I did make to the code snippet above, before trying to print a statement, was change:

<#list statement.lines as line> to <#list record.lines as line>

on March 3, 2020.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor