cardus 0.0.112 → 0.0.114
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/__tests__/insertTempShipments.test.ts +12 -24
- package/dist/__tests__/insertTempShipments.test.js +12 -24
- package/dist/index.js +12 -22
- package/index.ts +12 -22
- package/package.json +1 -1
- package/types/index.ts +0 -2
|
@@ -185,8 +185,7 @@ const arrangeDefaultStubs = ({ manager, shipmentId = 12345 }) => {
|
|
|
185
185
|
{
|
|
186
186
|
idEnvioTemporal: parsedOrder.idEnvioTemporal,
|
|
187
187
|
bulto: detail.bulto,
|
|
188
|
-
cantidad: 2
|
|
189
|
-
forzarAgrupamientoDeLinea: false
|
|
188
|
+
cantidad: 2
|
|
190
189
|
}
|
|
191
190
|
]
|
|
192
191
|
};
|
|
@@ -522,8 +521,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
522
521
|
sku_producto: lineItems.line.sku_producto,
|
|
523
522
|
nombre_producto: lineItems.line.nombre_producto
|
|
524
523
|
},
|
|
525
|
-
cantidad: 2
|
|
526
|
-
forzarAgrupamientoDeLinea: false
|
|
524
|
+
cantidad: 2
|
|
527
525
|
}));
|
|
528
526
|
|
|
529
527
|
await manager.insertTempShipments({
|
|
@@ -592,8 +590,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
592
590
|
sku_producto: lineItems.line.sku_producto,
|
|
593
591
|
nombre_producto: lineItems.line.nombre_producto
|
|
594
592
|
},
|
|
595
|
-
cantidad: 1
|
|
596
|
-
forzarAgrupamientoDeLinea: false
|
|
593
|
+
cantidad: 1
|
|
597
594
|
}));
|
|
598
595
|
|
|
599
596
|
await manager.insertTempShipments({
|
|
@@ -659,8 +656,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
659
656
|
sku_producto: lineItems.line.sku_producto,
|
|
660
657
|
nombre_producto: lineItems.line.nombre_producto
|
|
661
658
|
},
|
|
662
|
-
cantidad: 1
|
|
663
|
-
forzarAgrupamientoDeLinea: false
|
|
659
|
+
cantidad: 1
|
|
664
660
|
}));
|
|
665
661
|
|
|
666
662
|
await manager.insertTempShipments({
|
|
@@ -730,8 +726,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
730
726
|
sku_producto: lineItems.line.sku_producto,
|
|
731
727
|
nombre_producto: lineItems.line.nombre_producto
|
|
732
728
|
},
|
|
733
|
-
cantidad: 2
|
|
734
|
-
forzarAgrupamientoDeLinea: false
|
|
729
|
+
cantidad: 2
|
|
735
730
|
}));
|
|
736
731
|
|
|
737
732
|
await manager.insertTempShipments({
|
|
@@ -796,8 +791,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
796
791
|
sku_producto: lineItems.line.sku_producto,
|
|
797
792
|
nombre_producto: lineItems.line.nombre_producto
|
|
798
793
|
},
|
|
799
|
-
cantidad: 1
|
|
800
|
-
forzarAgrupamientoDeLinea: false
|
|
794
|
+
cantidad: 1
|
|
801
795
|
}));
|
|
802
796
|
|
|
803
797
|
await manager.insertTempShipments({
|
|
@@ -880,8 +874,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
880
874
|
sku_producto: lineItems.line.sku_producto,
|
|
881
875
|
nombre_producto: lineItems.line.nombre_producto
|
|
882
876
|
},
|
|
883
|
-
cantidad: 2
|
|
884
|
-
forzarAgrupamientoDeLinea: false
|
|
877
|
+
cantidad: 2
|
|
885
878
|
}));
|
|
886
879
|
|
|
887
880
|
await manager.insertTempShipments({
|
|
@@ -961,8 +954,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
961
954
|
sku_producto: lineItems.line.sku_producto,
|
|
962
955
|
nombre_producto: lineItems.line.nombre_producto
|
|
963
956
|
},
|
|
964
|
-
cantidad: 1
|
|
965
|
-
forzarAgrupamientoDeLinea: false
|
|
957
|
+
cantidad: 1
|
|
966
958
|
}));
|
|
967
959
|
|
|
968
960
|
await manager.insertTempShipments({
|
|
@@ -1036,8 +1028,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
1036
1028
|
sku_producto: lineItems.line.sku_producto,
|
|
1037
1029
|
nombre_producto: lineItems.line.nombre_producto
|
|
1038
1030
|
},
|
|
1039
|
-
cantidad: 1
|
|
1040
|
-
forzarAgrupamientoDeLinea: false
|
|
1031
|
+
cantidad: 1
|
|
1041
1032
|
}));
|
|
1042
1033
|
|
|
1043
1034
|
await manager.insertTempShipments({
|
|
@@ -1133,8 +1124,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
1133
1124
|
sku_producto: lineItems.line.sku_producto,
|
|
1134
1125
|
nombre_producto: lineItems.line.nombre_producto
|
|
1135
1126
|
},
|
|
1136
|
-
cantidad: 2
|
|
1137
|
-
forzarAgrupamientoDeLinea: false
|
|
1127
|
+
cantidad: 2
|
|
1138
1128
|
}));
|
|
1139
1129
|
|
|
1140
1130
|
await manager.insertTempShipments({
|
|
@@ -1234,8 +1224,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
1234
1224
|
sku_producto: lineItems.line.sku_producto,
|
|
1235
1225
|
nombre_producto: lineItems.line.nombre_producto
|
|
1236
1226
|
},
|
|
1237
|
-
cantidad: 1
|
|
1238
|
-
forzarAgrupamientoDeLinea: false
|
|
1227
|
+
cantidad: 1
|
|
1239
1228
|
};
|
|
1240
1229
|
});
|
|
1241
1230
|
|
|
@@ -1339,8 +1328,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
1339
1328
|
sku_producto: lineItems.line.sku_producto,
|
|
1340
1329
|
nombre_producto: lineItems.line.nombre_producto
|
|
1341
1330
|
},
|
|
1342
|
-
cantidad: 2
|
|
1343
|
-
forzarAgrupamientoDeLinea: false
|
|
1331
|
+
cantidad: 2
|
|
1344
1332
|
}));
|
|
1345
1333
|
|
|
1346
1334
|
await manager.insertTempShipments({
|
|
@@ -164,8 +164,7 @@ const arrangeDefaultStubs = ({ manager, shipmentId = 12345 }) => {
|
|
|
164
164
|
{
|
|
165
165
|
idEnvioTemporal: parsedOrder.idEnvioTemporal,
|
|
166
166
|
bulto: detail.bulto,
|
|
167
|
-
cantidad: 2
|
|
168
|
-
forzarAgrupamientoDeLinea: false
|
|
167
|
+
cantidad: 2
|
|
169
168
|
}
|
|
170
169
|
]
|
|
171
170
|
};
|
|
@@ -439,8 +438,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
439
438
|
sku_producto: lineItems.line.sku_producto,
|
|
440
439
|
nombre_producto: lineItems.line.nombre_producto
|
|
441
440
|
},
|
|
442
|
-
cantidad: 2
|
|
443
|
-
forzarAgrupamientoDeLinea: false
|
|
441
|
+
cantidad: 2
|
|
444
442
|
});
|
|
445
443
|
}));
|
|
446
444
|
yield manager.insertTempShipments({
|
|
@@ -499,8 +497,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
499
497
|
sku_producto: lineItems.line.sku_producto,
|
|
500
498
|
nombre_producto: lineItems.line.nombre_producto
|
|
501
499
|
},
|
|
502
|
-
cantidad: 1
|
|
503
|
-
forzarAgrupamientoDeLinea: false
|
|
500
|
+
cantidad: 1
|
|
504
501
|
});
|
|
505
502
|
}));
|
|
506
503
|
yield manager.insertTempShipments({
|
|
@@ -556,8 +553,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
556
553
|
sku_producto: lineItems.line.sku_producto,
|
|
557
554
|
nombre_producto: lineItems.line.nombre_producto
|
|
558
555
|
},
|
|
559
|
-
cantidad: 1
|
|
560
|
-
forzarAgrupamientoDeLinea: false
|
|
556
|
+
cantidad: 1
|
|
561
557
|
});
|
|
562
558
|
}));
|
|
563
559
|
yield manager.insertTempShipments({
|
|
@@ -616,8 +612,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
616
612
|
sku_producto: lineItems.line.sku_producto,
|
|
617
613
|
nombre_producto: lineItems.line.nombre_producto
|
|
618
614
|
},
|
|
619
|
-
cantidad: 2
|
|
620
|
-
forzarAgrupamientoDeLinea: false
|
|
615
|
+
cantidad: 2
|
|
621
616
|
});
|
|
622
617
|
}));
|
|
623
618
|
yield manager.insertTempShipments({
|
|
@@ -672,8 +667,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
672
667
|
sku_producto: lineItems.line.sku_producto,
|
|
673
668
|
nombre_producto: lineItems.line.nombre_producto
|
|
674
669
|
},
|
|
675
|
-
cantidad: 1
|
|
676
|
-
forzarAgrupamientoDeLinea: false
|
|
670
|
+
cantidad: 1
|
|
677
671
|
});
|
|
678
672
|
}));
|
|
679
673
|
yield manager.insertTempShipments({
|
|
@@ -746,8 +740,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
746
740
|
sku_producto: lineItems.line.sku_producto,
|
|
747
741
|
nombre_producto: lineItems.line.nombre_producto
|
|
748
742
|
},
|
|
749
|
-
cantidad: 2
|
|
750
|
-
forzarAgrupamientoDeLinea: false
|
|
743
|
+
cantidad: 2
|
|
751
744
|
});
|
|
752
745
|
}));
|
|
753
746
|
yield manager.insertTempShipments({
|
|
@@ -813,8 +806,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
813
806
|
sku_producto: lineItems.line.sku_producto,
|
|
814
807
|
nombre_producto: lineItems.line.nombre_producto
|
|
815
808
|
},
|
|
816
|
-
cantidad: 1
|
|
817
|
-
forzarAgrupamientoDeLinea: false
|
|
809
|
+
cantidad: 1
|
|
818
810
|
});
|
|
819
811
|
}));
|
|
820
812
|
yield manager.insertTempShipments({
|
|
@@ -878,8 +870,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
878
870
|
sku_producto: lineItems.line.sku_producto,
|
|
879
871
|
nombre_producto: lineItems.line.nombre_producto
|
|
880
872
|
},
|
|
881
|
-
cantidad: 1
|
|
882
|
-
forzarAgrupamientoDeLinea: false
|
|
873
|
+
cantidad: 1
|
|
883
874
|
});
|
|
884
875
|
}));
|
|
885
876
|
yield manager.insertTempShipments({
|
|
@@ -964,8 +955,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
964
955
|
sku_producto: lineItems.line.sku_producto,
|
|
965
956
|
nombre_producto: lineItems.line.nombre_producto
|
|
966
957
|
},
|
|
967
|
-
cantidad: 2
|
|
968
|
-
forzarAgrupamientoDeLinea: false
|
|
958
|
+
cantidad: 2
|
|
969
959
|
});
|
|
970
960
|
}));
|
|
971
961
|
yield manager.insertTempShipments({
|
|
@@ -1050,8 +1040,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
1050
1040
|
sku_producto: lineItems.line.sku_producto,
|
|
1051
1041
|
nombre_producto: lineItems.line.nombre_producto
|
|
1052
1042
|
},
|
|
1053
|
-
cantidad: 1
|
|
1054
|
-
forzarAgrupamientoDeLinea: false
|
|
1043
|
+
cantidad: 1
|
|
1055
1044
|
};
|
|
1056
1045
|
}));
|
|
1057
1046
|
yield manager.insertTempShipments({
|
|
@@ -1138,8 +1127,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
1138
1127
|
sku_producto: lineItems.line.sku_producto,
|
|
1139
1128
|
nombre_producto: lineItems.line.nombre_producto
|
|
1140
1129
|
},
|
|
1141
|
-
cantidad: 2
|
|
1142
|
-
forzarAgrupamientoDeLinea: false
|
|
1130
|
+
cantidad: 2
|
|
1143
1131
|
});
|
|
1144
1132
|
}));
|
|
1145
1133
|
yield manager.insertTempShipments({
|
package/dist/index.js
CHANGED
|
@@ -214,7 +214,8 @@ class IntegrationManager {
|
|
|
214
214
|
const successfullShipments = insertOrdersResult
|
|
215
215
|
.filter(Boolean)
|
|
216
216
|
.filter((each) => each.status === 'fulfilled')
|
|
217
|
-
.map((each) => each.value)
|
|
217
|
+
.map((each) => each.value)
|
|
218
|
+
.filter(Boolean);
|
|
218
219
|
return {
|
|
219
220
|
filteredOrders,
|
|
220
221
|
insertedTempShipments: successfullShipments,
|
|
@@ -347,13 +348,12 @@ class IntegrationManager {
|
|
|
347
348
|
lineItems: { idEnvioTemporal, line },
|
|
348
349
|
idUsuario
|
|
349
350
|
});
|
|
350
|
-
const { bulto, cantidad
|
|
351
|
+
const { bulto, cantidad } = result;
|
|
351
352
|
if (cantidad && bulto) {
|
|
352
353
|
return {
|
|
353
354
|
bulto,
|
|
354
355
|
cantidad,
|
|
355
|
-
idEnvioTemporal
|
|
356
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
356
|
+
idEnvioTemporal
|
|
357
357
|
};
|
|
358
358
|
}
|
|
359
359
|
return null;
|
|
@@ -373,7 +373,7 @@ class IntegrationManager {
|
|
|
373
373
|
var _d;
|
|
374
374
|
if (!bultoYCantidad)
|
|
375
375
|
return;
|
|
376
|
-
const { bulto, cantidad, idEnvioTemporal
|
|
376
|
+
const { bulto, cantidad, idEnvioTemporal } = bultoYCantidad;
|
|
377
377
|
// metemos los detalles siempre
|
|
378
378
|
shipmentDetails.push({
|
|
379
379
|
id_envio: idEnvioTemporal,
|
|
@@ -406,24 +406,14 @@ class IntegrationManager {
|
|
|
406
406
|
// si no agrupamos, cogemos el peso y dimensiones del peso mismo
|
|
407
407
|
}
|
|
408
408
|
else {
|
|
409
|
-
// lo de "forzarAgrupamientoDeLinea" se hizo solo para un usuario (Pegaso) que ya ni siquiera esta. Lo que hace es que siempre mete una linea, sin tener en cuenta la cantidad, pero con las dimensiones que les hemos preparado para ese bulto (que es una suma de todos los bultos reales... un chanchullo)
|
|
410
409
|
const tempShipmentLines = [];
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
else {
|
|
419
|
-
// creamos una linea por cada una de las unidades de "cantidad" (si cantidad es 5, pues 5 lineas -todas iguales, con el peso y medidas del bulto-)
|
|
420
|
-
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
421
|
-
const linesToAdd = arrayFake.map(() => ({
|
|
422
|
-
id_envio: idEnvioTemporal,
|
|
423
|
-
bulto
|
|
424
|
-
}));
|
|
425
|
-
tempShipmentLines.push(...linesToAdd);
|
|
426
|
-
}
|
|
410
|
+
// creamos una linea por cada una de las unidades de "cantidad" (si cantidad es 5, pues 5 lineas -todas iguales, con el peso y medidas del bulto-)
|
|
411
|
+
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
412
|
+
const linesToAdd = arrayFake.map(() => ({
|
|
413
|
+
id_envio: idEnvioTemporal,
|
|
414
|
+
bulto
|
|
415
|
+
}));
|
|
416
|
+
tempShipmentLines.push(...linesToAdd);
|
|
427
417
|
if (this.dataToInsert.lines.has(idEnvioTemporal)) {
|
|
428
418
|
this.dataToInsert.lines.set(idEnvioTemporal, [
|
|
429
419
|
...((_d = this.dataToInsert.lines.get(idEnvioTemporal)) !== null && _d !== void 0 ? _d : []),
|
package/index.ts
CHANGED
|
@@ -344,7 +344,8 @@ export class IntegrationManager {
|
|
|
344
344
|
const successfullShipments = insertOrdersResult
|
|
345
345
|
.filter(Boolean)
|
|
346
346
|
.filter((each) => each.status === 'fulfilled')
|
|
347
|
-
.map((each) => each.value)
|
|
347
|
+
.map((each) => each.value)
|
|
348
|
+
.filter(Boolean) as (ModifiedOrder & {
|
|
348
349
|
idEnvioTemporal: number;
|
|
349
350
|
agencyId: number;
|
|
350
351
|
})[];
|
|
@@ -579,14 +580,13 @@ export class IntegrationManager {
|
|
|
579
580
|
lineItems: { idEnvioTemporal, line },
|
|
580
581
|
idUsuario
|
|
581
582
|
});
|
|
582
|
-
const { bulto, cantidad
|
|
583
|
+
const { bulto, cantidad } = result;
|
|
583
584
|
|
|
584
585
|
if (cantidad && bulto) {
|
|
585
586
|
return {
|
|
586
587
|
bulto,
|
|
587
588
|
cantidad,
|
|
588
|
-
idEnvioTemporal
|
|
589
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
589
|
+
idEnvioTemporal
|
|
590
590
|
};
|
|
591
591
|
}
|
|
592
592
|
return null;
|
|
@@ -614,8 +614,7 @@ export class IntegrationManager {
|
|
|
614
614
|
bultosYCantidades.map(async (bultoYCantidad) => {
|
|
615
615
|
if (!bultoYCantidad) return;
|
|
616
616
|
|
|
617
|
-
const { bulto, cantidad, idEnvioTemporal
|
|
618
|
-
bultoYCantidad;
|
|
617
|
+
const { bulto, cantidad, idEnvioTemporal } = bultoYCantidad;
|
|
619
618
|
|
|
620
619
|
// metemos los detalles siempre
|
|
621
620
|
shipmentDetails.push({
|
|
@@ -651,26 +650,17 @@ export class IntegrationManager {
|
|
|
651
650
|
]);
|
|
652
651
|
// si no agrupamos, cogemos el peso y dimensiones del peso mismo
|
|
653
652
|
} else {
|
|
654
|
-
// lo de "forzarAgrupamientoDeLinea" se hizo solo para un usuario (Pegaso) que ya ni siquiera esta. Lo que hace es que siempre mete una linea, sin tener en cuenta la cantidad, pero con las dimensiones que les hemos preparado para ese bulto (que es una suma de todos los bultos reales... un chanchullo)
|
|
655
653
|
const tempShipmentLines = [];
|
|
656
654
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
} else {
|
|
664
|
-
// creamos una linea por cada una de las unidades de "cantidad" (si cantidad es 5, pues 5 lineas -todas iguales, con el peso y medidas del bulto-)
|
|
655
|
+
// creamos una linea por cada una de las unidades de "cantidad" (si cantidad es 5, pues 5 lineas -todas iguales, con el peso y medidas del bulto-)
|
|
656
|
+
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
657
|
+
const linesToAdd = arrayFake.map(() => ({
|
|
658
|
+
id_envio: idEnvioTemporal,
|
|
659
|
+
bulto
|
|
660
|
+
}));
|
|
665
661
|
|
|
666
|
-
|
|
667
|
-
const linesToAdd = arrayFake.map(() => ({
|
|
668
|
-
id_envio: idEnvioTemporal,
|
|
669
|
-
bulto
|
|
670
|
-
}));
|
|
662
|
+
tempShipmentLines.push(...linesToAdd);
|
|
671
663
|
|
|
672
|
-
tempShipmentLines.push(...linesToAdd);
|
|
673
|
-
}
|
|
674
664
|
if (this.dataToInsert.lines.has(idEnvioTemporal)) {
|
|
675
665
|
this.dataToInsert.lines.set(idEnvioTemporal, [
|
|
676
666
|
...(this.dataToInsert.lines.get(idEnvioTemporal) ?? []),
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -101,14 +101,12 @@ export type Bulto = {
|
|
|
101
101
|
hs_code: string | null;
|
|
102
102
|
};
|
|
103
103
|
cantidad: number;
|
|
104
|
-
forzarAgrupamientoDeLinea: boolean;
|
|
105
104
|
};
|
|
106
105
|
|
|
107
106
|
export type BultoYCantidad = {
|
|
108
107
|
bulto: Bulto['bulto'];
|
|
109
108
|
cantidad: Bulto['cantidad'];
|
|
110
109
|
idEnvioTemporal: number;
|
|
111
|
-
forzarAgrupamientoDeLinea: boolean;
|
|
112
110
|
} | null;
|
|
113
111
|
|
|
114
112
|
export type ModifiedOrder = {
|