cardus 0.0.94 → 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 -24
- package/index.ts +32 -25
- 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,14 +329,16 @@ class IntegrationManager {
|
|
|
331
329
|
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
332
330
|
if (!idEnvioTemporal)
|
|
333
331
|
return;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
}
|
|
337
|
-
if (grouped) {
|
|
332
|
+
const shouldGroup = (group === null || group === void 0 ? void 0 : group.grouped) === 1 && lineas.length > 1;
|
|
333
|
+
if (shouldGroup) {
|
|
338
334
|
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
339
335
|
}
|
|
340
336
|
lineas.forEach((line) => {
|
|
341
|
-
const bultoPromise = createBultoFromLine({
|
|
337
|
+
const bultoPromise = createBultoFromLine({
|
|
338
|
+
line,
|
|
339
|
+
idEnvioTemporal,
|
|
340
|
+
shouldGroup
|
|
341
|
+
});
|
|
342
342
|
obtenerBultosYCantidades.push(bultoPromise);
|
|
343
343
|
});
|
|
344
344
|
});
|
|
@@ -371,20 +371,20 @@ class IntegrationManager {
|
|
|
371
371
|
bultosYCantidades.forEach((each) => {
|
|
372
372
|
if (!each)
|
|
373
373
|
return;
|
|
374
|
-
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } = each;
|
|
374
|
+
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea, shouldGroup } = each;
|
|
375
375
|
try {
|
|
376
376
|
this.dataToInsert.details.push({
|
|
377
377
|
id_envio: idEnvioTemporal,
|
|
378
378
|
bulto,
|
|
379
379
|
cantidad
|
|
380
380
|
});
|
|
381
|
-
if (!
|
|
381
|
+
if (!shouldGroup && forzarAgrupamientoDeLinea) {
|
|
382
382
|
this.dataToInsert.lines.push({
|
|
383
383
|
id_envio: idEnvioTemporal,
|
|
384
384
|
bulto
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
|
-
if (!
|
|
387
|
+
if (!shouldGroup && !forzarAgrupamientoDeLinea) {
|
|
388
388
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
389
389
|
arrayFake.forEach(() => {
|
|
390
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,16 +557,18 @@ export class IntegrationManager {
|
|
|
557
557
|
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
558
558
|
if (!idEnvioTemporal) return;
|
|
559
559
|
|
|
560
|
-
|
|
561
|
-
grouped = 0;
|
|
562
|
-
}
|
|
560
|
+
const shouldGroup = group?.grouped === 1 && lineas.length > 1;
|
|
563
561
|
|
|
564
|
-
if (
|
|
562
|
+
if (shouldGroup) {
|
|
565
563
|
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
566
564
|
}
|
|
567
565
|
|
|
568
566
|
lineas.forEach((line) => {
|
|
569
|
-
const bultoPromise = createBultoFromLine({
|
|
567
|
+
const bultoPromise = createBultoFromLine({
|
|
568
|
+
line,
|
|
569
|
+
idEnvioTemporal,
|
|
570
|
+
shouldGroup
|
|
571
|
+
});
|
|
570
572
|
obtenerBultosYCantidades.push(bultoPromise);
|
|
571
573
|
});
|
|
572
574
|
});
|
|
@@ -610,22 +612,27 @@ export class IntegrationManager {
|
|
|
610
612
|
|
|
611
613
|
bultosYCantidades.forEach((each) => {
|
|
612
614
|
if (!each) return;
|
|
613
|
-
const {
|
|
614
|
-
|
|
615
|
+
const {
|
|
616
|
+
bulto,
|
|
617
|
+
cantidad,
|
|
618
|
+
idEnvioTemporal,
|
|
619
|
+
forzarAgrupamientoDeLinea,
|
|
620
|
+
shouldGroup
|
|
621
|
+
} = each;
|
|
615
622
|
try {
|
|
616
623
|
this.dataToInsert.details.push({
|
|
617
624
|
id_envio: idEnvioTemporal,
|
|
618
625
|
bulto,
|
|
619
626
|
cantidad
|
|
620
627
|
});
|
|
621
|
-
if (!
|
|
628
|
+
if (!shouldGroup && forzarAgrupamientoDeLinea) {
|
|
622
629
|
this.dataToInsert.lines.push({
|
|
623
630
|
id_envio: idEnvioTemporal,
|
|
624
631
|
bulto
|
|
625
632
|
});
|
|
626
633
|
}
|
|
627
634
|
|
|
628
|
-
if (!
|
|
635
|
+
if (!shouldGroup && !forzarAgrupamientoDeLinea) {
|
|
629
636
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
630
637
|
|
|
631
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 = {
|