Hi All, How to combine duplicate items in sales or...
# suitescript
s
Hi All, How to combine duplicate items in sales order advanced pdf template. Need to combine same items and sum up its quantity and amount and display as single line. Thanks
e
I’ve done this using a hash in freemarker. Basically, list (loop through) your lines, and instead of printing / outputting the detail, add the detail to the hash, holding the values for the quantity/amount and summing through each iteration of the loop.
then, list through the hash and print/output!
s
Thankyou @ec
Do you have any snippet please could you share it
e
Copy code
<#assign qtyHash = {} />
...
<#assign unique_key = ... />
<#assign line_summary_data = {"qty" : line_qty, "amt" : line_amount, "item": line.item, "rate": line.rate} />
<#assign qtyHash = qtyHash + {unique_key: line_summary_data} />
...
<#list qtyHash as key, value>
<tr>
	<td colspan="10"><p style="text-align: left;"><strong><span class="itemname">${value.item}</span></strong></p></td>
	<td colspan="3" align="right"><p style="text-align: right;">${value.qty}</p></td>
	<td colspan="4" align="right"><p style="text-align: right;">${value.rate}</p></td>
	<td colspan="4" align="right"><p style="text-align: right;">$${value.amt?string["#,###.00"]}</p></td>
</tr>
</#list>
Note: line_summary_data had “item” and “subsc” and all the other values as properties
s
Sure thankyou @ec