Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
object split in two parts

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!