cardus 0.0.95 → 0.0.97
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 +33 -27
- package/index.ts +46 -27
- package/package.json +1 -1
- package/types/index.ts +6 -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,13 @@ 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
|
-
|
|
314
|
-
const
|
|
310
|
+
const { integrationsService } = this.services;
|
|
311
|
+
const userIntegrationConfiguration = yield integrationsService.getDefaultIntegrationsData({
|
|
312
|
+
id_usuario: idUsuario,
|
|
313
|
+
id_integracion: this.integrationType
|
|
314
|
+
});
|
|
315
|
+
const measuresFromConfig = !!(userIntegrationConfiguration === null || userIntegrationConfiguration === void 0 ? void 0 : userIntegrationConfiguration.dimensiones_medidas_configuradas);
|
|
316
|
+
const createBultoFromLine = (_b) => __awaiter(this, [_b], void 0, function* ({ line, idEnvioTemporal, shouldGroup }) {
|
|
315
317
|
const result = yield crearBulto({
|
|
316
318
|
lineItems: { idEnvioTemporal, line },
|
|
317
319
|
idUsuario
|
|
@@ -322,7 +324,8 @@ class IntegrationManager {
|
|
|
322
324
|
bulto,
|
|
323
325
|
cantidad,
|
|
324
326
|
idEnvioTemporal,
|
|
325
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
327
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea,
|
|
328
|
+
shouldGroup
|
|
326
329
|
};
|
|
327
330
|
}
|
|
328
331
|
return null;
|
|
@@ -331,17 +334,20 @@ class IntegrationManager {
|
|
|
331
334
|
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
332
335
|
if (!idEnvioTemporal)
|
|
333
336
|
return;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
grouped
|
|
339
|
-
|
|
340
|
-
if (grouped) {
|
|
337
|
+
// Debe agrupar si:
|
|
338
|
+
// 1. grouped es 1 + hay más de una línea
|
|
339
|
+
// 2. grouped es 1 + hay una línea + configuración integraciones tiene el campo dimensiones_medidas_configuradas a 1
|
|
340
|
+
const shouldGroup = ((group === null || group === void 0 ? void 0 : group.grouped) === 1 && lineas.length > 1) ||
|
|
341
|
+
((group === null || group === void 0 ? void 0 : group.grouped) === 1 && lineas.length === 1 && measuresFromConfig);
|
|
342
|
+
if (shouldGroup) {
|
|
341
343
|
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
342
344
|
}
|
|
343
345
|
lineas.forEach((line) => {
|
|
344
|
-
const bultoPromise = createBultoFromLine({
|
|
346
|
+
const bultoPromise = createBultoFromLine({
|
|
347
|
+
line,
|
|
348
|
+
idEnvioTemporal,
|
|
349
|
+
shouldGroup
|
|
350
|
+
});
|
|
345
351
|
obtenerBultosYCantidades.push(bultoPromise);
|
|
346
352
|
});
|
|
347
353
|
});
|
|
@@ -374,20 +380,20 @@ class IntegrationManager {
|
|
|
374
380
|
bultosYCantidades.forEach((each) => {
|
|
375
381
|
if (!each)
|
|
376
382
|
return;
|
|
377
|
-
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } = each;
|
|
383
|
+
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea, shouldGroup } = each;
|
|
378
384
|
try {
|
|
379
385
|
this.dataToInsert.details.push({
|
|
380
386
|
id_envio: idEnvioTemporal,
|
|
381
387
|
bulto,
|
|
382
388
|
cantidad
|
|
383
389
|
});
|
|
384
|
-
if (!
|
|
390
|
+
if (!shouldGroup && forzarAgrupamientoDeLinea) {
|
|
385
391
|
this.dataToInsert.lines.push({
|
|
386
392
|
id_envio: idEnvioTemporal,
|
|
387
393
|
bulto
|
|
388
394
|
});
|
|
389
395
|
}
|
|
390
|
-
if (!
|
|
396
|
+
if (!shouldGroup && !forzarAgrupamientoDeLinea) {
|
|
391
397
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
392
398
|
arrayFake.forEach(() => {
|
|
393
399
|
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,25 @@ 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
|
-
|
|
526
|
+
const { integrationsService } = this.services;
|
|
527
|
+
|
|
528
|
+
const userIntegrationConfiguration =
|
|
529
|
+
await integrationsService.getDefaultIntegrationsData({
|
|
530
|
+
id_usuario: idUsuario,
|
|
531
|
+
id_integracion: this.integrationType
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
const measuresFromConfig =
|
|
535
|
+
!!userIntegrationConfiguration?.dimensiones_medidas_configuradas;
|
|
530
536
|
|
|
531
537
|
const createBultoFromLine = async ({
|
|
532
538
|
line,
|
|
533
|
-
idEnvioTemporal
|
|
539
|
+
idEnvioTemporal,
|
|
540
|
+
shouldGroup
|
|
534
541
|
}: {
|
|
535
542
|
line: InsertContentShipmentLine;
|
|
536
543
|
idEnvioTemporal: number;
|
|
544
|
+
shouldGroup: boolean;
|
|
537
545
|
}): Promise<BultoYCantidad | null> => {
|
|
538
546
|
const result = await crearBulto({
|
|
539
547
|
lineItems: { idEnvioTemporal, line },
|
|
@@ -546,7 +554,8 @@ export class IntegrationManager {
|
|
|
546
554
|
bulto,
|
|
547
555
|
cantidad,
|
|
548
556
|
idEnvioTemporal,
|
|
549
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
557
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea,
|
|
558
|
+
shouldGroup
|
|
550
559
|
};
|
|
551
560
|
}
|
|
552
561
|
return null;
|
|
@@ -557,18 +566,23 @@ export class IntegrationManager {
|
|
|
557
566
|
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
558
567
|
if (!idEnvioTemporal) return;
|
|
559
568
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
569
|
+
// Debe agrupar si:
|
|
570
|
+
// 1. grouped es 1 + hay más de una línea
|
|
571
|
+
// 2. grouped es 1 + hay una línea + configuración integraciones tiene el campo dimensiones_medidas_configuradas a 1
|
|
572
|
+
const shouldGroup =
|
|
573
|
+
(group?.grouped === 1 && lineas.length > 1) ||
|
|
574
|
+
(group?.grouped === 1 && lineas.length === 1 && measuresFromConfig);
|
|
565
575
|
|
|
566
|
-
if (
|
|
576
|
+
if (shouldGroup) {
|
|
567
577
|
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
568
578
|
}
|
|
569
579
|
|
|
570
580
|
lineas.forEach((line) => {
|
|
571
|
-
const bultoPromise = createBultoFromLine({
|
|
581
|
+
const bultoPromise = createBultoFromLine({
|
|
582
|
+
line,
|
|
583
|
+
idEnvioTemporal,
|
|
584
|
+
shouldGroup
|
|
585
|
+
});
|
|
572
586
|
obtenerBultosYCantidades.push(bultoPromise);
|
|
573
587
|
});
|
|
574
588
|
});
|
|
@@ -612,22 +626,27 @@ export class IntegrationManager {
|
|
|
612
626
|
|
|
613
627
|
bultosYCantidades.forEach((each) => {
|
|
614
628
|
if (!each) return;
|
|
615
|
-
const {
|
|
616
|
-
|
|
629
|
+
const {
|
|
630
|
+
bulto,
|
|
631
|
+
cantidad,
|
|
632
|
+
idEnvioTemporal,
|
|
633
|
+
forzarAgrupamientoDeLinea,
|
|
634
|
+
shouldGroup
|
|
635
|
+
} = each;
|
|
617
636
|
try {
|
|
618
637
|
this.dataToInsert.details.push({
|
|
619
638
|
id_envio: idEnvioTemporal,
|
|
620
639
|
bulto,
|
|
621
640
|
cantidad
|
|
622
641
|
});
|
|
623
|
-
if (!
|
|
642
|
+
if (!shouldGroup && forzarAgrupamientoDeLinea) {
|
|
624
643
|
this.dataToInsert.lines.push({
|
|
625
644
|
id_envio: idEnvioTemporal,
|
|
626
645
|
bulto
|
|
627
646
|
});
|
|
628
647
|
}
|
|
629
648
|
|
|
630
|
-
if (!
|
|
649
|
+
if (!shouldGroup && !forzarAgrupamientoDeLinea) {
|
|
631
650
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
632
651
|
|
|
633
652
|
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 = {
|
|
@@ -264,6 +269,7 @@ export type IntegrationsService = {
|
|
|
264
269
|
id_integracion: number;
|
|
265
270
|
}) => Promise<{
|
|
266
271
|
sku_almacen: 0 | 1;
|
|
272
|
+
dimensiones_medidas_configuradas: 0 | 1;
|
|
267
273
|
}>;
|
|
268
274
|
};
|
|
269
275
|
|