I have the items sublist with the next info, but o...
# advancedpdf
i
I have the items sublist with the next info, but on the pdf template dont want items duplicated and want the sum of each items quantity, like this, and all this logic needs to be on the PDF
Copy code
Description        Quantity
Description1          1
Description1          1
Description1          1
Description1          1
Description2          2
Description2          2
Description2          4
Description2          4
I want to create this
Copy code
Description        Quantity
Description1          4
Description2          12
This is what i have but doesnt work u.u
Copy code
<#assign itemsList = {} />
            <#if record.item?has_content>
                <#list record.item as item>
                       
                        <#if !itemsList[item.class]??>
                            <#assign itemsList = {item.class} />
                            <#assign itemsList[item.class][pieces] = item.quantity />
                            <#assign itemsList[item.class][weight] = item.weight />
                        <#else>
                            <#assign itemsList[item.class][pieces] = itemsList[item.class][pieces] + item.quantity />
                            <#assign itemsList[item.class][weight] = itemsList[item.class][weight] + item.weight />
                        </#if>
                </#list><!-- end items -->
            </#if>
Any idea how do i create a new object like this on freemarker?