cardus 0.0.95 → 0.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +24 -27
- package/index.ts +32 -27
- package/package.json +1 -1
- package/types/index.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -48,19 +48,16 @@ class IntegrationManager {
|
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
50
|
this.insertTempShipmentGroupLine = ({ idEnvioTemporal, group }) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
51
|
+
this.dataToInsert.lines.push({
|
|
52
|
+
id_envio: idEnvioTemporal,
|
|
53
|
+
bulto: {
|
|
54
|
+
peso: group.weight,
|
|
55
|
+
alto: group.height,
|
|
56
|
+
ancho: group.width,
|
|
57
|
+
largo: group.length,
|
|
58
|
+
sku_producto: ''
|
|
59
|
+
}
|
|
60
|
+
});
|
|
64
61
|
};
|
|
65
62
|
this.services = {
|
|
66
63
|
integrationsService: params.integrationsService,
|
|
@@ -310,8 +307,8 @@ class IntegrationManager {
|
|
|
310
307
|
2 - si "forzarAgrupamientoDeLinea" es true, se crea una linea por cada linea
|
|
311
308
|
3- si NO esta agrupado y "forzarAgrupamientoDeLinea" NO es true, se crea una linea por cada unidad de cada linea
|
|
312
309
|
*/
|
|
313
|
-
let grouped = Number(
|
|
314
|
-
const createBultoFromLine = (_b) => __awaiter(this, [_b], void 0, function* ({ line, idEnvioTemporal }) {
|
|
310
|
+
//let grouped = Number(group?.grouped === 1);
|
|
311
|
+
const createBultoFromLine = (_b) => __awaiter(this, [_b], void 0, function* ({ line, idEnvioTemporal, shouldGroup }) {
|
|
315
312
|
const result = yield crearBulto({
|
|
316
313
|
lineItems: { idEnvioTemporal, line },
|
|
317
314
|
idUsuario
|
|
@@ -322,7 +319,8 @@ class IntegrationManager {
|
|
|
322
319
|
bulto,
|
|
323
320
|
cantidad,
|
|
324
321
|
idEnvioTemporal,
|
|
325
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
322
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea,
|
|
323
|
+
shouldGroup
|
|
326
324
|
};
|
|
327
325
|
}
|
|
328
326
|
return null;
|
|
@@ -331,17 +329,16 @@ class IntegrationManager {
|
|
|
331
329
|
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
332
330
|
if (!idEnvioTemporal)
|
|
333
331
|
return;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
grouped = 1;
|
|
339
|
-
}
|
|
340
|
-
if (grouped) {
|
|
332
|
+
const shouldGroup = (group === null || group === void 0 ? void 0 : group.grouped) === 1 && lineas.length > 1;
|
|
333
|
+
if (shouldGroup) {
|
|
341
334
|
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
342
335
|
}
|
|
343
336
|
lineas.forEach((line) => {
|
|
344
|
-
const bultoPromise = createBultoFromLine({
|
|
337
|
+
const bultoPromise = createBultoFromLine({
|
|
338
|
+
line,
|
|
339
|
+
idEnvioTemporal,
|
|
340
|
+
shouldGroup
|
|
341
|
+
});
|
|
345
342
|
obtenerBultosYCantidades.push(bultoPromise);
|
|
346
343
|
});
|
|
347
344
|
});
|
|
@@ -374,20 +371,20 @@ class IntegrationManager {
|
|
|
374
371
|
bultosYCantidades.forEach((each) => {
|
|
375
372
|
if (!each)
|
|
376
373
|
return;
|
|
377
|
-
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } = each;
|
|
374
|
+
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea, shouldGroup } = each;
|
|
378
375
|
try {
|
|
379
376
|
this.dataToInsert.details.push({
|
|
380
377
|
id_envio: idEnvioTemporal,
|
|
381
378
|
bulto,
|
|
382
379
|
cantidad
|
|
383
380
|
});
|
|
384
|
-
if (!
|
|
381
|
+
if (!shouldGroup && forzarAgrupamientoDeLinea) {
|
|
385
382
|
this.dataToInsert.lines.push({
|
|
386
383
|
id_envio: idEnvioTemporal,
|
|
387
384
|
bulto
|
|
388
385
|
});
|
|
389
386
|
}
|
|
390
|
-
if (!
|
|
387
|
+
if (!shouldGroup && !forzarAgrupamientoDeLinea) {
|
|
391
388
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
392
389
|
arrayFake.forEach(() => {
|
|
393
390
|
this.dataToInsert.lines.push({
|
package/index.ts
CHANGED
|
@@ -439,19 +439,16 @@ export class IntegrationManager {
|
|
|
439
439
|
idEnvioTemporal: number;
|
|
440
440
|
group: Group;
|
|
441
441
|
}) => {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
}
|
|
442
|
+
this.dataToInsert.lines.push({
|
|
443
|
+
id_envio: idEnvioTemporal,
|
|
444
|
+
bulto: {
|
|
445
|
+
peso: group.weight,
|
|
446
|
+
alto: group.height,
|
|
447
|
+
ancho: group.width,
|
|
448
|
+
largo: group.length,
|
|
449
|
+
sku_producto: ''
|
|
450
|
+
}
|
|
451
|
+
});
|
|
455
452
|
};
|
|
456
453
|
|
|
457
454
|
async createJsonQuantityReferencesFromLines({
|
|
@@ -526,14 +523,16 @@ export class IntegrationManager {
|
|
|
526
523
|
3- si NO esta agrupado y "forzarAgrupamientoDeLinea" NO es true, se crea una linea por cada unidad de cada linea
|
|
527
524
|
*/
|
|
528
525
|
|
|
529
|
-
let grouped = Number(group?.grouped === 1);
|
|
526
|
+
//let grouped = Number(group?.grouped === 1);
|
|
530
527
|
|
|
531
528
|
const createBultoFromLine = async ({
|
|
532
529
|
line,
|
|
533
|
-
idEnvioTemporal
|
|
530
|
+
idEnvioTemporal,
|
|
531
|
+
shouldGroup
|
|
534
532
|
}: {
|
|
535
533
|
line: InsertContentShipmentLine;
|
|
536
534
|
idEnvioTemporal: number;
|
|
535
|
+
shouldGroup: boolean;
|
|
537
536
|
}): Promise<BultoYCantidad | null> => {
|
|
538
537
|
const result = await crearBulto({
|
|
539
538
|
lineItems: { idEnvioTemporal, line },
|
|
@@ -546,7 +545,8 @@ export class IntegrationManager {
|
|
|
546
545
|
bulto,
|
|
547
546
|
cantidad,
|
|
548
547
|
idEnvioTemporal,
|
|
549
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
548
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea,
|
|
549
|
+
shouldGroup
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
552
|
return null;
|
|
@@ -557,18 +557,18 @@ export class IntegrationManager {
|
|
|
557
557
|
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
558
558
|
if (!idEnvioTemporal) return;
|
|
559
559
|
|
|
560
|
-
|
|
561
|
-
grouped = 0;
|
|
562
|
-
} else {
|
|
563
|
-
grouped = 1;
|
|
564
|
-
}
|
|
560
|
+
const shouldGroup = group?.grouped === 1 && lineas.length > 1;
|
|
565
561
|
|
|
566
|
-
if (
|
|
562
|
+
if (shouldGroup) {
|
|
567
563
|
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
568
564
|
}
|
|
569
565
|
|
|
570
566
|
lineas.forEach((line) => {
|
|
571
|
-
const bultoPromise = createBultoFromLine({
|
|
567
|
+
const bultoPromise = createBultoFromLine({
|
|
568
|
+
line,
|
|
569
|
+
idEnvioTemporal,
|
|
570
|
+
shouldGroup
|
|
571
|
+
});
|
|
572
572
|
obtenerBultosYCantidades.push(bultoPromise);
|
|
573
573
|
});
|
|
574
574
|
});
|
|
@@ -612,22 +612,27 @@ export class IntegrationManager {
|
|
|
612
612
|
|
|
613
613
|
bultosYCantidades.forEach((each) => {
|
|
614
614
|
if (!each) return;
|
|
615
|
-
const {
|
|
616
|
-
|
|
615
|
+
const {
|
|
616
|
+
bulto,
|
|
617
|
+
cantidad,
|
|
618
|
+
idEnvioTemporal,
|
|
619
|
+
forzarAgrupamientoDeLinea,
|
|
620
|
+
shouldGroup
|
|
621
|
+
} = each;
|
|
617
622
|
try {
|
|
618
623
|
this.dataToInsert.details.push({
|
|
619
624
|
id_envio: idEnvioTemporal,
|
|
620
625
|
bulto,
|
|
621
626
|
cantidad
|
|
622
627
|
});
|
|
623
|
-
if (!
|
|
628
|
+
if (!shouldGroup && forzarAgrupamientoDeLinea) {
|
|
624
629
|
this.dataToInsert.lines.push({
|
|
625
630
|
id_envio: idEnvioTemporal,
|
|
626
631
|
bulto
|
|
627
632
|
});
|
|
628
633
|
}
|
|
629
634
|
|
|
630
|
-
if (!
|
|
635
|
+
if (!shouldGroup && !forzarAgrupamientoDeLinea) {
|
|
631
636
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
632
637
|
|
|
633
638
|
arrayFake.forEach(() => {
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -109,6 +109,7 @@ export type BultoYCantidad = {
|
|
|
109
109
|
cantidad: Bulto['cantidad'];
|
|
110
110
|
idEnvioTemporal: number;
|
|
111
111
|
forzarAgrupamientoDeLinea: boolean;
|
|
112
|
+
shouldGroup: boolean;
|
|
112
113
|
} | null;
|
|
113
114
|
|
|
114
115
|
export type ModifiedOrder = {
|
|
@@ -158,6 +159,10 @@ type ModificarOrdenOriginal = (param: {
|
|
|
158
159
|
|
|
159
160
|
type GroupNotGrouped = {
|
|
160
161
|
grouped?: 0 | '0';
|
|
162
|
+
weight: number;
|
|
163
|
+
height: number;
|
|
164
|
+
width: number;
|
|
165
|
+
length: number;
|
|
161
166
|
};
|
|
162
167
|
|
|
163
168
|
type GroupGrouped = {
|