cardus 0.0.98 → 0.0.100
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 +81 -67
- package/index.ts +124 -106
- package/package.json +1 -1
- package/types/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -161,7 +161,6 @@ class IntegrationManager {
|
|
|
161
161
|
});
|
|
162
162
|
yield this.insertUserDefaultConfigurationContent({
|
|
163
163
|
user,
|
|
164
|
-
tempShimpmentIds: successfullShipments.map((successfullShipment) => successfullShipment.idEnvioTemporal),
|
|
165
164
|
countryName: country.nombre_pais_en
|
|
166
165
|
});
|
|
167
166
|
// modificamos la agencia, cuando se tenga que hacer
|
|
@@ -200,7 +199,7 @@ class IntegrationManager {
|
|
|
200
199
|
});
|
|
201
200
|
}
|
|
202
201
|
insertUserDefaultConfigurationContent(_a) {
|
|
203
|
-
return __awaiter(this, arguments, void 0, function* ({ user,
|
|
202
|
+
return __awaiter(this, arguments, void 0, function* ({ user, countryName }) {
|
|
204
203
|
const idUsuario = user.id_usuario;
|
|
205
204
|
const { configurationService, llmAPIService } = this.services;
|
|
206
205
|
const insert = (data) => {
|
|
@@ -302,13 +301,22 @@ class IntegrationManager {
|
|
|
302
301
|
insertQuantityRelatedLines(_a) {
|
|
303
302
|
return __awaiter(this, arguments, void 0, function* ({ orders, idUsuario, crearBulto, group, warehouseId, shouldFindWarehouseSkus }) {
|
|
304
303
|
/*
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
304
|
+
En esta funcion se calculan los records a incluir en la tabla de detalles y en las de lineas
|
|
305
|
+
Los detalles, es facil, una por cada bulto (aqui no hay ni "agrupar" ni nada de eso, una por cada bulto y ya esta)
|
|
306
|
+
Las lineas, es mas complicado:
|
|
307
|
+
Creamos una linea por cada linea en el pedido.
|
|
308
|
+
Pero hay TRUCO, puede que haya que agrupar, puede que no, puede que haya que coger el peso y medidas del bulto, puede que del "bulto agrupado", hay que tener en cuenta las cantidades...
|
|
309
|
+
Asi que para ver todo esto, la logica esta dentro de la variable "shouldGroup".
|
|
309
310
|
*/
|
|
310
|
-
|
|
311
|
-
const
|
|
311
|
+
var _b;
|
|
312
|
+
const { integrationsService } = this.services;
|
|
313
|
+
const shouldGetMeasuresFromGroupBeingOneLine = !!((_b = (yield integrationsService.getDefaultIntegrationsData({
|
|
314
|
+
id_usuario: idUsuario,
|
|
315
|
+
id_integracion: this.integrationType
|
|
316
|
+
}))) === null || _b === void 0 ? void 0 : _b.dimensiones_medidas_configuradas);
|
|
317
|
+
// function to create package from line
|
|
318
|
+
const createBultoFromLine = (_c) => __awaiter(this, [_c], void 0, function* ({ line, idEnvioTemporal }) {
|
|
319
|
+
// funcion para crear bulto
|
|
312
320
|
const result = yield crearBulto({
|
|
313
321
|
lineItems: { idEnvioTemporal, line },
|
|
314
322
|
idUsuario
|
|
@@ -319,76 +327,60 @@ class IntegrationManager {
|
|
|
319
327
|
bulto,
|
|
320
328
|
cantidad,
|
|
321
329
|
idEnvioTemporal,
|
|
322
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
323
|
-
shouldGroup
|
|
330
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
324
331
|
};
|
|
325
332
|
}
|
|
326
333
|
return null;
|
|
327
334
|
});
|
|
328
|
-
|
|
329
|
-
|
|
335
|
+
yield Promise.allSettled(
|
|
336
|
+
// por cada pedido/envio
|
|
337
|
+
orders.map((_d) => __awaiter(this, [_d], void 0, function* ({ idEnvioTemporal, lineas }) {
|
|
330
338
|
if (!idEnvioTemporal)
|
|
331
339
|
return;
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
lineas.forEach((line) => {
|
|
337
|
-
const bultoPromise = createBultoFromLine({
|
|
340
|
+
// hacemos esto primero, todavia no sabemos si vamos a agrupar (porque necesitamos crear el bulto para eso, ya que la "cantidad" podria influir)
|
|
341
|
+
const bultosYCantidades = (yield Promise.all(lineas.map((line) => __awaiter(this, void 0, void 0, function* () {
|
|
342
|
+
const bultoYCantidad = yield createBultoFromLine({
|
|
338
343
|
line,
|
|
339
|
-
idEnvioTemporal
|
|
340
|
-
shouldGroup
|
|
341
|
-
});
|
|
342
|
-
obtenerBultosYCantidades.push(bultoPromise);
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
let bultosYCantidades = yield Promise.all(obtenerBultosYCantidades);
|
|
346
|
-
bultosYCantidades = bultosYCantidades.filter(Boolean);
|
|
347
|
-
if (shouldFindWarehouseSkus) {
|
|
348
|
-
const bultosYCantidadesGroupedByShipment = bultosYCantidades.reduce((acc, curr) => {
|
|
349
|
-
var _a;
|
|
350
|
-
const tempShipmentId = curr === null || curr === void 0 ? void 0 : curr.idEnvioTemporal;
|
|
351
|
-
if (!tempShipmentId)
|
|
352
|
-
return acc;
|
|
353
|
-
(_a = acc[tempShipmentId]) !== null && _a !== void 0 ? _a : (acc[tempShipmentId] = []);
|
|
354
|
-
acc[tempShipmentId].push(curr);
|
|
355
|
-
return acc;
|
|
356
|
-
}, {});
|
|
357
|
-
yield Promise.all(Object.entries(bultosYCantidadesGroupedByShipment).map((_c) => __awaiter(this, [_c], void 0, function* ([tempShipmentId, bultosYCantidades]) {
|
|
358
|
-
const json_referencias_cantidades = yield this.createJsonQuantityReferencesFromLines({
|
|
359
|
-
idUsuario,
|
|
360
|
-
warehouseId,
|
|
361
|
-
bultosYCantidades
|
|
344
|
+
idEnvioTemporal
|
|
362
345
|
});
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
bultosYCantidades.forEach((each) => {
|
|
372
|
-
if (!each)
|
|
373
|
-
return;
|
|
374
|
-
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea, shouldGroup } = each;
|
|
375
|
-
try {
|
|
346
|
+
return bultoYCantidad;
|
|
347
|
+
})))).filter(Boolean);
|
|
348
|
+
// sacamos todos los bultos (y cantidad)
|
|
349
|
+
yield Promise.allSettled(bultosYCantidades.map((bultoYCantidad) => __awaiter(this, void 0, void 0, function* () {
|
|
350
|
+
if (!bultoYCantidad)
|
|
351
|
+
return;
|
|
352
|
+
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } = bultoYCantidad;
|
|
353
|
+
// metemos los detalles siempre
|
|
376
354
|
this.dataToInsert.details.push({
|
|
377
355
|
id_envio: idEnvioTemporal,
|
|
378
356
|
bulto,
|
|
379
357
|
cantidad
|
|
380
358
|
});
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
359
|
+
// Debe agrupar si:
|
|
360
|
+
// 1. grouped es 1 + hay más de una línea
|
|
361
|
+
// 2. grouped es 1 + hay una línea + configuración integraciones tiene el campo dimensiones_medidas_configuradas a 1 (osea, que queremos que coja las dimensiones del bulto, aunque sea una sola linea)
|
|
362
|
+
// 3. grouped es 1 + hay una lines + cantidad es mayor que 1
|
|
363
|
+
const shouldGroup = (group === null || group === void 0 ? void 0 : group.grouped) === 1 &&
|
|
364
|
+
(lineas.length > 1 ||
|
|
365
|
+
(lineas.length === 1 &&
|
|
366
|
+
shouldGetMeasuresFromGroupBeingOneLine) ||
|
|
367
|
+
(lineas.length === 1 && Number(cantidad) > 1));
|
|
368
|
+
// si agrupamos, metemos solo una linea en "lineas" y cogemos las dimensiones y peso de "group" (lo que el usuario tenga por defecto)
|
|
369
|
+
if (shouldGroup) {
|
|
370
|
+
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
371
|
+
// si no agrupamos, cogemos el peso y dimensiones del peso mismo
|
|
386
372
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
373
|
+
else {
|
|
374
|
+
// 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)
|
|
375
|
+
if (forzarAgrupamientoDeLinea) {
|
|
376
|
+
this.dataToInsert.lines.push({
|
|
377
|
+
id_envio: idEnvioTemporal,
|
|
378
|
+
bulto
|
|
379
|
+
});
|
|
380
|
+
// y esto para todo el resto de usuarios
|
|
390
381
|
}
|
|
391
382
|
else {
|
|
383
|
+
// 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-)
|
|
392
384
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
393
385
|
arrayFake.forEach(() => {
|
|
394
386
|
this.dataToInsert.lines.push({
|
|
@@ -398,11 +390,33 @@ class IntegrationManager {
|
|
|
398
390
|
});
|
|
399
391
|
}
|
|
400
392
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
393
|
+
// para cuando el usuario quiere mapear su sku con la referencia que tenga en almacen
|
|
394
|
+
if (shouldFindWarehouseSkus) {
|
|
395
|
+
const bultosYCantidadesGroupedByShipment = bultosYCantidades.reduce((acc, curr) => {
|
|
396
|
+
var _a;
|
|
397
|
+
const tempShipmentId = curr === null || curr === void 0 ? void 0 : curr.idEnvioTemporal;
|
|
398
|
+
if (!tempShipmentId)
|
|
399
|
+
return acc;
|
|
400
|
+
(_a = acc[tempShipmentId]) !== null && _a !== void 0 ? _a : (acc[tempShipmentId] = []);
|
|
401
|
+
acc[tempShipmentId].push(curr);
|
|
402
|
+
return acc;
|
|
403
|
+
}, {});
|
|
404
|
+
yield Promise.all(Object.entries(bultosYCantidadesGroupedByShipment).map((_e) => __awaiter(this, [_e], void 0, function* ([tempShipmentId, bultosYCantidades]) {
|
|
405
|
+
const json_referencias_cantidades = yield this.createJsonQuantityReferencesFromLines({
|
|
406
|
+
idUsuario,
|
|
407
|
+
warehouseId,
|
|
408
|
+
bultosYCantidades
|
|
409
|
+
});
|
|
410
|
+
if (json_referencias_cantidades.length > 0) {
|
|
411
|
+
this.dataToInsert.jsonQuantityReferences.push({
|
|
412
|
+
id_envio: Number(tempShipmentId),
|
|
413
|
+
json_referencias_cantidades
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
})));
|
|
417
|
+
}
|
|
418
|
+
})));
|
|
419
|
+
})));
|
|
406
420
|
});
|
|
407
421
|
}
|
|
408
422
|
}
|
package/index.ts
CHANGED
|
@@ -218,9 +218,6 @@ export class IntegrationManager {
|
|
|
218
218
|
|
|
219
219
|
await this.insertUserDefaultConfigurationContent({
|
|
220
220
|
user,
|
|
221
|
-
tempShimpmentIds: successfullShipments.map(
|
|
222
|
-
(successfullShipment) => successfullShipment.idEnvioTemporal
|
|
223
|
-
),
|
|
224
221
|
countryName: country.nombre_pais_en
|
|
225
222
|
});
|
|
226
223
|
|
|
@@ -279,11 +276,9 @@ export class IntegrationManager {
|
|
|
279
276
|
|
|
280
277
|
async insertUserDefaultConfigurationContent({
|
|
281
278
|
user,
|
|
282
|
-
tempShimpmentIds,
|
|
283
279
|
countryName
|
|
284
280
|
}: {
|
|
285
281
|
user: Record<string, string | number>;
|
|
286
|
-
tempShimpmentIds: number[];
|
|
287
282
|
countryName: string;
|
|
288
283
|
}) {
|
|
289
284
|
const idUsuario = user.id_usuario as number;
|
|
@@ -517,23 +512,32 @@ export class IntegrationManager {
|
|
|
517
512
|
shouldFindWarehouseSkus: boolean;
|
|
518
513
|
}) {
|
|
519
514
|
/*
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
515
|
+
En esta funcion se calculan los records a incluir en la tabla de detalles y en las de lineas
|
|
516
|
+
Los detalles, es facil, una por cada bulto (aqui no hay ni "agrupar" ni nada de eso, una por cada bulto y ya esta)
|
|
517
|
+
Las lineas, es mas complicado:
|
|
518
|
+
Creamos una linea por cada linea en el pedido.
|
|
519
|
+
Pero hay TRUCO, puede que haya que agrupar, puede que no, puede que haya que coger el peso y medidas del bulto, puede que del "bulto agrupado", hay que tener en cuenta las cantidades...
|
|
520
|
+
Asi que para ver todo esto, la logica esta dentro de la variable "shouldGroup".
|
|
524
521
|
*/
|
|
525
522
|
|
|
526
|
-
|
|
523
|
+
const { integrationsService } = this.services;
|
|
524
|
+
|
|
525
|
+
const shouldGetMeasuresFromGroupBeingOneLine = !!(
|
|
526
|
+
await integrationsService.getDefaultIntegrationsData({
|
|
527
|
+
id_usuario: idUsuario,
|
|
528
|
+
id_integracion: this.integrationType
|
|
529
|
+
})
|
|
530
|
+
)?.dimensiones_medidas_configuradas;
|
|
527
531
|
|
|
532
|
+
// function to create package from line
|
|
528
533
|
const createBultoFromLine = async ({
|
|
529
534
|
line,
|
|
530
|
-
idEnvioTemporal
|
|
531
|
-
shouldGroup
|
|
535
|
+
idEnvioTemporal
|
|
532
536
|
}: {
|
|
533
537
|
line: InsertContentShipmentLine;
|
|
534
538
|
idEnvioTemporal: number;
|
|
535
|
-
shouldGroup: boolean;
|
|
536
539
|
}): Promise<BultoYCantidad | null> => {
|
|
540
|
+
// funcion para crear bulto
|
|
537
541
|
const result = await crearBulto({
|
|
538
542
|
lineItems: { idEnvioTemporal, line },
|
|
539
543
|
idUsuario
|
|
@@ -545,110 +549,124 @@ export class IntegrationManager {
|
|
|
545
549
|
bulto,
|
|
546
550
|
cantidad,
|
|
547
551
|
idEnvioTemporal,
|
|
548
|
-
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
549
|
-
shouldGroup
|
|
552
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
550
553
|
};
|
|
551
554
|
}
|
|
552
555
|
return null;
|
|
553
556
|
};
|
|
554
557
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
const shouldGroup = group?.grouped === 1 && lineas.length > 1;
|
|
561
|
-
|
|
562
|
-
if (shouldGroup) {
|
|
563
|
-
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
lineas.forEach((line) => {
|
|
567
|
-
const bultoPromise = createBultoFromLine({
|
|
568
|
-
line,
|
|
569
|
-
idEnvioTemporal,
|
|
570
|
-
shouldGroup
|
|
571
|
-
});
|
|
572
|
-
obtenerBultosYCantidades.push(bultoPromise);
|
|
573
|
-
});
|
|
574
|
-
});
|
|
558
|
+
await Promise.allSettled(
|
|
559
|
+
// por cada pedido/envio
|
|
560
|
+
orders.map(async ({ idEnvioTemporal, lineas }) => {
|
|
561
|
+
if (!idEnvioTemporal) return;
|
|
575
562
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const tempShipmentId = curr?.idEnvioTemporal;
|
|
584
|
-
if (!tempShipmentId) return acc;
|
|
585
|
-
|
|
586
|
-
acc[tempShipmentId] ??= [];
|
|
587
|
-
acc[tempShipmentId].push(curr);
|
|
588
|
-
|
|
589
|
-
return acc;
|
|
590
|
-
}, {});
|
|
591
|
-
|
|
592
|
-
await Promise.all(
|
|
593
|
-
Object.entries(bultosYCantidadesGroupedByShipment).map(
|
|
594
|
-
async ([tempShipmentId, bultosYCantidades]) => {
|
|
595
|
-
const json_referencias_cantidades =
|
|
596
|
-
await this.createJsonQuantityReferencesFromLines({
|
|
597
|
-
idUsuario,
|
|
598
|
-
warehouseId,
|
|
599
|
-
bultosYCantidades
|
|
563
|
+
// hacemos esto primero, todavia no sabemos si vamos a agrupar (porque necesitamos crear el bulto para eso, ya que la "cantidad" podria influir)
|
|
564
|
+
const bultosYCantidades = (
|
|
565
|
+
await Promise.all(
|
|
566
|
+
lineas.map(async (line) => {
|
|
567
|
+
const bultoYCantidad = await createBultoFromLine({
|
|
568
|
+
line,
|
|
569
|
+
idEnvioTemporal
|
|
600
570
|
});
|
|
571
|
+
return bultoYCantidad;
|
|
572
|
+
})
|
|
573
|
+
)
|
|
574
|
+
).filter(Boolean);
|
|
575
|
+
|
|
576
|
+
// sacamos todos los bultos (y cantidad)
|
|
577
|
+
await Promise.allSettled(
|
|
578
|
+
bultosYCantidades.map(async (bultoYCantidad) => {
|
|
579
|
+
if (!bultoYCantidad) return;
|
|
580
|
+
|
|
581
|
+
const {
|
|
582
|
+
bulto,
|
|
583
|
+
cantidad,
|
|
584
|
+
idEnvioTemporal,
|
|
585
|
+
forzarAgrupamientoDeLinea
|
|
586
|
+
} = bultoYCantidad;
|
|
587
|
+
|
|
588
|
+
// metemos los detalles siempre
|
|
589
|
+
this.dataToInsert.details.push({
|
|
590
|
+
id_envio: idEnvioTemporal,
|
|
591
|
+
bulto,
|
|
592
|
+
cantidad
|
|
593
|
+
});
|
|
601
594
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
595
|
+
// Debe agrupar si:
|
|
596
|
+
// 1. grouped es 1 + hay más de una línea
|
|
597
|
+
// 2. grouped es 1 + hay una línea + configuración integraciones tiene el campo dimensiones_medidas_configuradas a 1 (osea, que queremos que coja las dimensiones del bulto, aunque sea una sola linea)
|
|
598
|
+
// 3. grouped es 1 + hay una lines + cantidad es mayor que 1
|
|
599
|
+
const shouldGroup =
|
|
600
|
+
group?.grouped === 1 &&
|
|
601
|
+
(lineas.length > 1 ||
|
|
602
|
+
(lineas.length === 1 &&
|
|
603
|
+
shouldGetMeasuresFromGroupBeingOneLine) ||
|
|
604
|
+
(lineas.length === 1 && Number(cantidad) > 1));
|
|
605
|
+
|
|
606
|
+
// si agrupamos, metemos solo una linea en "lineas" y cogemos las dimensiones y peso de "group" (lo que el usuario tenga por defecto)
|
|
607
|
+
if (shouldGroup) {
|
|
608
|
+
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
609
|
+
// si no agrupamos, cogemos el peso y dimensiones del peso mismo
|
|
610
|
+
} else {
|
|
611
|
+
// 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)
|
|
612
|
+
if (forzarAgrupamientoDeLinea) {
|
|
613
|
+
this.dataToInsert.lines.push({
|
|
614
|
+
id_envio: idEnvioTemporal,
|
|
615
|
+
bulto
|
|
616
|
+
});
|
|
617
|
+
// y esto para todo el resto de usuarios
|
|
618
|
+
} else {
|
|
619
|
+
// 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-)
|
|
620
|
+
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
621
|
+
|
|
622
|
+
arrayFake.forEach(() => {
|
|
623
|
+
this.dataToInsert.lines.push({
|
|
624
|
+
id_envio: idEnvioTemporal,
|
|
625
|
+
bulto
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
}
|
|
607
629
|
}
|
|
608
|
-
}
|
|
609
|
-
)
|
|
610
|
-
);
|
|
611
|
-
}
|
|
612
630
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
shouldGroup
|
|
621
|
-
} = each;
|
|
622
|
-
try {
|
|
623
|
-
this.dataToInsert.details.push({
|
|
624
|
-
id_envio: idEnvioTemporal,
|
|
625
|
-
bulto,
|
|
626
|
-
cantidad
|
|
627
|
-
});
|
|
628
|
-
if (!shouldGroup && forzarAgrupamientoDeLinea) {
|
|
629
|
-
this.dataToInsert.lines.push({
|
|
630
|
-
id_envio: idEnvioTemporal,
|
|
631
|
-
bulto
|
|
632
|
-
});
|
|
633
|
-
}
|
|
631
|
+
// para cuando el usuario quiere mapear su sku con la referencia que tenga en almacen
|
|
632
|
+
if (shouldFindWarehouseSkus) {
|
|
633
|
+
const bultosYCantidadesGroupedByShipment =
|
|
634
|
+
bultosYCantidades.reduce<Record<number, BultoYCantidad[]>>(
|
|
635
|
+
(acc, curr) => {
|
|
636
|
+
const tempShipmentId = curr?.idEnvioTemporal;
|
|
637
|
+
if (!tempShipmentId) return acc;
|
|
634
638
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
this.insertTempShipmentGroupLine({ idEnvioTemporal, group });
|
|
638
|
-
} else {
|
|
639
|
-
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
639
|
+
acc[tempShipmentId] ??= [];
|
|
640
|
+
acc[tempShipmentId].push(curr);
|
|
640
641
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
642
|
+
return acc;
|
|
643
|
+
},
|
|
644
|
+
{}
|
|
645
|
+
);
|
|
646
|
+
|
|
647
|
+
await Promise.all(
|
|
648
|
+
Object.entries(bultosYCantidadesGroupedByShipment).map(
|
|
649
|
+
async ([tempShipmentId, bultosYCantidades]) => {
|
|
650
|
+
const json_referencias_cantidades =
|
|
651
|
+
await this.createJsonQuantityReferencesFromLines({
|
|
652
|
+
idUsuario,
|
|
653
|
+
warehouseId,
|
|
654
|
+
bultosYCantidades
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
if (json_referencias_cantidades.length > 0) {
|
|
658
|
+
this.dataToInsert.jsonQuantityReferences.push({
|
|
659
|
+
id_envio: Number(tempShipmentId),
|
|
660
|
+
json_referencias_cantidades
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
})
|
|
668
|
+
);
|
|
669
|
+
})
|
|
670
|
+
);
|
|
653
671
|
}
|
|
654
672
|
}
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -109,7 +109,6 @@ export type BultoYCantidad = {
|
|
|
109
109
|
cantidad: Bulto['cantidad'];
|
|
110
110
|
idEnvioTemporal: number;
|
|
111
111
|
forzarAgrupamientoDeLinea: boolean;
|
|
112
|
-
shouldGroup: boolean;
|
|
113
112
|
} | null;
|
|
114
113
|
|
|
115
114
|
export type ModifiedOrder = {
|
|
@@ -269,6 +268,7 @@ export type IntegrationsService = {
|
|
|
269
268
|
id_integracion: number;
|
|
270
269
|
}) => Promise<{
|
|
271
270
|
sku_almacen: 0 | 1;
|
|
271
|
+
dimensiones_medidas_configuradas: 0 | 1;
|
|
272
272
|
}>;
|
|
273
273
|
};
|
|
274
274
|
|