Sometimes you just need some fresh eyes at the issue, I have been struggling with this for days and now calling for help.
Use case:
- I receive a CSV with data about customs export declarations with items for a shipment and per carrier (multiple carriers possible in one file) (in other words one file can contain one or multiple items for one or multiple shipments per one or multiple carriers).
Simplified like this:
Carrier;ShipmentNr;ExportDeclarationNr;ItemNr
carrier1;Shipment1;ExportDeclarationNr1;item1
carrier1;Shipment1;ExportDeclarationNr1;item2
carrier1;Shipment1;ExportDeclarationNr2;item1
carrier1;Shipment1;ExportDeclarationNr2;item2
carrier1;Shipment1;ExportDeclarationNr2;item3
carrier1;Shipment2;ExportDeclarationNr3;item1
carrier2;Shipment3;ExportDeclarationNr4;item1
carrier2;Shipment3;ExportDeclarationNr4;item2 - I need to create a JSON API call per carrier grouped by the ExportDeclarationNr with all the items.
Problem statement:
When building the modules and aggregating the data I could build an array for the items to be inserted into the data structure of the JSON as an Array to ensure that if you have a Shipment that it then shows multiple items but within a Shipment is it is also possible to have multiple ExportDeclarationNrs which is an array at itself but in the data structure the delivery and items can not be mapped as arrays. I can only do one or the other and not both. So I either have an API call per carrier containing always one Shipment with multiple items or have an API call per carrier containing all the Shipments but always only has 1 item.
Like this for the items array.
I may have over thought this but maybe there is a solution to build separate arrays and combine these into the JSON call, taking into account the hierarchy.
Any help is very much appreciated.
blueprint (6).json (95.8 KB)