I've got a knotty problem that I can't seem to think out.
I've got a CSV file that comes out of system A (the coloured section of the image).
It's invoices that need paying against Purchase Orders.
An invoice starts with a H (header) and has a number of D (detail) rows.
On occasion a PO Item may have it's TAX split and the source system outputs the tax splits.
The target system can only cope with a single line per PO Item number so I create a list and group on the appropriate columns and return a list on the ones I need to aggregate...
Tax code - first code
Amount - sum of the values
Quantity - sum of the values
So far so good.
BUT the DOC_ITEM (blue) must be sequential based on the number of rows in the actual invoice.
It's late in the day so my brain may have stopped working but I can't think of a way to achieve the goal...
How can I relate a line item back to the number of line items in the invoice and set DOC_ITEM accordingly.
Any help gratefully received.
Thanks