Print consolidated value by Parent Item

This code is used to print the consolidated value of line items that all belong to the same parent item in the Invoice PDF. The components that belong to the same parent item are grouped together, and the sum, VAT and quantity are calculated. Also, print the parent’s name in PDF.

<#assign totalAmount=0 totalQty=0 vatAmt=0 itemIndex=0/>
<#assign seen_style = []>

<#function findConsolidatedItemData itemToFind itemArray index>
<#assign totalAmount=0 totalQty=0 vatAmt=0/>
<#if itemToFind.custcol_jj_sub_item?has_content>
<#assign seen_style = seen_style + [itemToFind.custcol_jj_sub_item]/>
<#list itemArray as item>
<#if item.custcol_jj_sub_item==itemToFind.custcol_jj_sub_item && item.quantity != 0>
<#assign totalAmount=totalAmount + item.amount />
<#assign totalQty=totalQty + item.quantity />
<#assign vatAmt=vatAmt + item.tax1amt />
<#assign itemIndex=itemIndex+1>
<#assign returnValue=’true’ />
<#return returnValue>
<#else>
<#if itemToFind.quantity == 0>
<#assign totalAmount=0 />
<#else>
<#assign totalAmount=itemToFind.rate />
<#assign totalQty=itemToFind.quantity />
<#assign vatAmt=itemToFind.tax1amt/>
<#assign returnValue=’true’ />
<#assign itemIndex=itemIndex+1>
<#return returnValue>

Leave a comment

Your email address will not be published. Required fields are marked *