fix: parseOrderList collects ALL source orders, edge fn returns orderItems
This commit is contained in:
parent
d0f2a72dda
commit
136e5c826a
|
|
@ -61,12 +61,25 @@ const parseOrderList = (order) => {
|
|||
}
|
||||
|
||||
// Fallback: sourceOrders (1C exchange data)
|
||||
// Collect orderList from ALL source orders, not just the first one
|
||||
if (order.sourceOrders) {
|
||||
let parsed = order.sourceOrders;
|
||||
if (typeof parsed === 'string') {
|
||||
try { parsed = JSON.parse(parsed); } catch { /* ignore */ }
|
||||
}
|
||||
if (Array.isArray(parsed) && parsed.length > 0) {
|
||||
const allItems = [];
|
||||
for (const src of parsed) {
|
||||
if (src && Array.isArray(src.orderList)) {
|
||||
for (const ol of src.orderList) {
|
||||
if (ol && (ol.items || ol.nom || ol.name)) {
|
||||
allItems.push(ol);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (allItems.length > 0) return allItems;
|
||||
// Legacy: return whole array if no orderList structure
|
||||
if (parsed[0].orderList && Array.isArray(parsed[0].orderList)) {
|
||||
return parsed[0].orderList;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue