I have an invoice xml where I need to perform a grouping / sum on itemid's For instance for ItemId 444 I need a lineamount of 100 + 25 = 125 and ItemId 555 = 200 + 15. Lot's of examples out there how to do this you're about to say but I have another requirement. I also need to do the same grouping and sum for my TaxTrans\TaxAmounts and TaxTrans\TaxBaseAmounts based on the joining InventTransId field (AABB / BBCC) between CustInvoiceTrans and TaxTrans.
Before:
<CustInvoiceJour class="entity">
<CustInvoiceTrans class="entity">
<InventTransId>AABB</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>444</ItemId>
<LineAmount>100</LineAmount>
</CustInvoiceTrans>
<CustInvoiceTrans class="entity">
<InventTransId>BBCC</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>444</ItemId>
<LineAmount>25</LineAmount>
</CustInvoiceTrans>
<CustInvoiceTrans class="entity">
<InventTransId>CCDD</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>555</ItemId>
<LineAmount>200</LineAmount>
</CustInvoiceTrans>
<CustInvoiceTrans class="entity">
<InventTransId>DDEE</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>555</ItemId>
<LineAmount>15</LineAmount>
</CustInvoiceTrans>
<CustInvoiceTrans class="entity">
<InventTransId>EEFF</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>12345</ItemId>
<LineAmount>40</LineAmount>
</CustInvoiceTrans>
<TaxTrans class="entity">
<InventTransId>AABB</InventTransId>
<TaxAmount>-21</TaxAmount>
<TaxBaseAmount>-100</TaxBaseAmount>
<TaxValue>21.00</TaxValue>
</TaxTrans>
<TaxTrans class="entity">
<InventTransId>BBCC</InventTransId>
<TaxAmount>-5.25</TaxAmount>
<TaxBaseAmount>-25</TaxBaseAmount>
<TaxValue>21.00</TaxValue>
</TaxTrans>
<TaxTrans class="entity">
<InventTransId>CCDD</InventTransId>
<TaxAmount>-42</TaxAmount>
<TaxBaseAmount>-200</TaxBaseAmount>
<TaxValue>21.00</TaxValue>
</TaxTrans>
<TaxTrans class="entity">
<InventTransId>DDEE</InventTransId>
<TaxAmount>-3.15</TaxAmount>
<TaxBaseAmount>-15</TaxBaseAmount>
<TaxValue>15</TaxValue>
</TaxTrans>
<TaxTrans class="entity">
<InventTransId>EEFF</InventTransId>
<TaxAmount>-8.40</TaxAmount>
<TaxBaseAmount>-40</TaxBaseAmount>
<TaxValue>15</TaxValue>
</TaxTrans>
</CustInvoiceJour>
Required output:
<CustInvoiceJour class="entity">
<CustInvoiceTrans class="entity">
<InventTransId>AABB</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>444</ItemId>
<LineAmount>125</LineAmount>
</CustInvoiceTrans>
<CustInvoiceTrans class="entity">
<InventTransId>CCDD</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>555</ItemId>
<LineAmount>215</LineAmount>
</CustInvoiceTrans>
<CustInvoiceTrans class="entity">
<InventTransId>EEFF</InventTransId>
<InvoiceId>SI100</InvoiceId>
<ItemId>12345</ItemId>
<LineAmount>40</LineAmount>
</CustInvoiceTrans>
<TaxTrans class="entity">
<InventTransId>AABB</InventTransId>
<TaxAmount>-26.25</TaxAmount>
<TaxBaseAmount>-125</TaxBaseAmount>
<TaxValue>21.00</TaxValue>
</TaxTrans>
<TaxTrans class="entity">
<InventTransId>CCDD</InventTransId>
<TaxAmount>-45.15</TaxAmount>
<TaxBaseAmount>-215</TaxBaseAmount>
<TaxValue>21.00</TaxValue>
</TaxTrans>
<TaxTrans class="entity">
<InventTransId>EEFF</InventTransId>
<TaxAmount>-8.40</TaxAmount>
<TaxBaseAmount>-40</TaxBaseAmount>
<TaxValue>15</TaxValue>
</TaxTrans>
</CustInvoiceJour>
I don't know if this is even possible. Let alone where to start?
Mike