ajrey77
12/12/2024, 7:20 PMCeligo AI
12/12/2024, 7:20 PMAI generated answer (using internal Slack threads):To summarize lines by item on an invoice advanced PDF template, you can use a hash in Freemarker. You can loop through your lines, and instead of printing 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. Here is a code snippet that demonstrates this:
freemarker
<#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>
\t<td colspan="10"><p style="text-align: left;"><strong><span class="itemname">${value.item}</span></strong></p></td>
\t<td colspan="3" align="right"><p style="text-align: right;">${value.qty}</p></td>
\t<td colspan="4" align="right"><p style="text-align: right;">${value.rate}</p></td>
\t<td colspan="4" align="right"><p style="text-align: right;">$${value.amt?string["#,###.00"]}</p></td>
</tr>
</#list>
In this code, line_summary_data
is a hash that contains the item details like quantity, amount, item name, and rate. This hash is then added to qtyHash
using the unique key. Finally, we loop through qtyHash
and print the details.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
12/12/2024, 7:21 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840605855
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823982954
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821719646
Celigo AI
12/12/2024, 7:21 PM