Item line code for aggregating the items based on tax rate and adding the rate, gross amount, tax amount and quantity
<table class="itemtable" style="width: 100%; margin-top: 20px;border-bottom: 1.5px solid Silver;"><!-- start items -->
<thead>
<tr>
<th colspan="10">Description</th>
<th colspan="5">Customer <br />Reference</th>
<th colspan="5">Shipment<br />Reference</th>
<th align="right" colspan="4">Amount</th>
<th align="right" colspan="4"><p style="text-align: center;">Tax Rate</p></th>
<th align="right" colspan="4">Tax Amount</th>
<th align="right" colspan="4"><p style="text-align: center;">Total<br /> Amount</p></th>
</tr>
</thead>
<#assign seenstyle = []>
<#list record.item as item>
<#assign Quantity=0/>
<#assign Rate=0/>
<#assign Taxamount=0/>
<#assign Grossamount=0/>
<#assign groupid = item.taxrate1>
<#if seenstyle?seq_contains(groupid)> <!-- no if body is intentional; skips seen style -->
<#else>
<#assign seenstyle = seenstyle + [groupid]/>
<#list record.item as item2>
<#if item.taxrate1==item2.taxrate1>
<#assign Rate=(Rate+item2.amount)/>
<#assign Quantity=(Quantity+item2.quantity)/>
<#assign Taxamount=(Taxamount+item2.tax1amt)/>
<#assign Grossamount=(Grossamount+item2.grossamt)/>
</#if>
</#list>
<#if groupid?has_content>
<tr>
<td colspan="10"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="5">${item.custcol_mf_med_customref}</td>
<td colspan="5">${item.custcol_mf_med_shipmentref}</td>
<td align="right" colspan="4">${currency[record.currencysymbol]}${Rate?string["#,###.00"]}</td>
<td align="right" colspan="4"><#if item.taxrate1?has_content>${item.taxrate1}<#else>0%</#if></td>
<td align="right" colspan="4"><#if Taxamount?has_content>${currency[record.currencysymbol]}${Taxamount?string["#,###.00"]}<#else>${(item.taxrate1*Rate)?string["#,###.00"]}</#if></td>
<td align="right" colspan="4"><#if Grossamount?has_content>${currency[record.currencysymbol]}${Grossamount?string["#,###.00"]}<#else>${((item.taxrate1*Rate)+Rate)?string["#,###.00"]}</#if></td>
</tr>
<#else>
<tr>
<td colspan="10" line-height="12px"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="5" line-height="12px">${item.custcol_mf_med_customref}</td>
<td colspan="5" line-height="12px">${item.custcol_mf_med_shipmentref}</td>
<td align="right" colspan="4" line-height="12px">${item.amount}</td>
<td align="right" colspan="4" line-height="12px"><#if item.taxrate1?has_content>${item.taxrate1}<#else>0%</#if></td>
<td align="right" colspan="4" line-height="12px"><#if item.tax1amt?has_content>${item.tax1amt}<#else>${(item.taxrate1*item.amount?string["#,###.00"])}</#if></td>
<td align="right" colspan="4" line-height="12px"><#if item.grossamt?has_content>${item.grossamt}<#else>${((item.taxrate1*item.amount)+item.amount?string["#,###.00"])}</#if></td>
</tr>
</#if>
</#if>
</#list>
<!-- end items --></table>
<!-- <hr style="background-color:#d3d3d3;width:100%;border:1px;color: #d3d3d3;height:1px;"/>-->
</#if>