How Can I divide a array to different arrays objects if the total b > 700 in DWL

Job ID: 38620343

Budget: $8 – $15 USD

Hi , I have a little problem, I need to separate the paylod of a dinamic array of objecs but I don't know how to do it, the follow array of object:

[{ "number": "000001", "price": 14.99, "qty": 18, "line": "3" }, { "number": "000003", "price": 24.0, "qty": 18, "line": "3" }, { "number": "000004", "price": 18.0, "qty": 18, "line": "3" }]

I need to separate in a similar schema if the operation (qty * price) not sum more than 700, if sum more than I need to create a new array with thist element for example taked the before example:

[ { "object": 1, "total": "677.82", "items": [ { "number": "000001", "price": 14.99, "qty": 18, "line": "3" }, { "number": "000003", "price": 24, "qty": 17, "line": "3" } ] }, { "object": 2, "total": "348.00", "items": [ { "number": "000003", "price": 24, "qty": 1, "line": "3" }, { "number": "000004", "price": 18, "qty": 18, "line": "3" } ] }]

I try to explain the result : "Object": is an iterator, value of object generated., "total": is the total of (qty * price) in the "items" element and finally "items": are until the elements in the "items" object do not exceed 700 in total, to complement the summary, the item: 000003 in the first object was reduced by one and the residue begins in a new array with the same logic in this case, all the rest of elements was succesfully in 2 objects, but it can be separate 3,4...n objects depends of the payload.

Please if you have any idea how to solve it, I'll really apreciate.

Thank you.