i have an object that's have to be split in two parts cause the information that I grab from an excel is a jumbles mess, so I made this :
const data4 = xmlOrdenEntrega(salida4);
let dataPlanilla = [];
let order = {
cabecera: {},
detalle: [],
};
let esDetalle = false;
let detalle = {
item: null,
itemStatus: null,
qtyOrd: null,
qtyShp: null,
description: null,
series: null,
color: null,
uom: null,
qtyPerBox: null,
amount: null,
currency: null,
cubes: null,
estLoadDate: null,
}
let esCabecera = false;
let cabecera = {
store: null,
order: null,
po: null,
mode: null,
ordDte: null,
reqDte: null,
status: null,
whse: null,
};
let esPrimerciclo = true
data4.forEach(datito => {
if (datito.__EMPTY == 'Store #:') {
if (!esPrimerciclo) {
dataPlanilla.push(order);
esPrimerciclo = false;
}
esDetalle = false;
esCabecera = true;
cabecera = {
store: datito.__EMPTY_1,
order: datito.__EMPTY_3,
po: datito.__EMPTY_5,
mode: datito.__EMPTY_7,
};
order.cabecera = cabecera;
}
if (esCabecera == true && datito.__EMPTY != 'Store #:') {
cabecera = {
ordDte: datito.__EMPTY_1,
reqDte: datito.__EMPTY_3,
status: datito.__EMPTY_5,
whse: datito.__EMPTY_7,
}
order.cabecera = cabecera;
esCabecera = false;
}
in theory the object should be completed at the moment that it is saved to Order, but right now I'm not getting the completed object. i only receive half of it. if someone knows how to resolve this problem I would be thankful.