cardus 0.0.86 → 0.0.88
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 +28 -19
- package/index.ts +39 -28
- package/package.json +1 -1
- package/types/index.ts +4 -3
package/dist/index.js
CHANGED
|
@@ -265,27 +265,35 @@ class IntegrationManager {
|
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
createJsonQuantityReferencesFromLines(_a) {
|
|
268
|
-
return __awaiter(this, arguments, void 0, function* ({ warehouseId, bultosYCantidades }) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
[reference.id]: 1
|
|
268
|
+
return __awaiter(this, arguments, void 0, function* ({ idUsuario, warehouseId, bultosYCantidades }) {
|
|
269
|
+
try {
|
|
270
|
+
if (warehouseId) {
|
|
271
|
+
const json_referencias_cantidades = (yield Promise.all(bultosYCantidades.map((each) => __awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
const cantidad = each === null || each === void 0 ? void 0 : each.cantidad;
|
|
273
|
+
const sku = each === null || each === void 0 ? void 0 : each.bulto.sku_producto;
|
|
274
|
+
if (!cantidad || !sku)
|
|
275
|
+
return [];
|
|
276
|
+
const reference = yield this.services.warehouseService.getProductReferenceFromSku({
|
|
277
|
+
idUsuario,
|
|
278
|
+
sku
|
|
279
|
+
});
|
|
280
|
+
if (!(reference === null || reference === void 0 ? void 0 : reference.id)) {
|
|
281
|
+
throw new Error('no existe sku para referencia');
|
|
283
282
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
return Array.from({ length: cantidad }, () => ({
|
|
284
|
+
id_caja: -1,
|
|
285
|
+
referencias: {
|
|
286
|
+
[reference.id]: 1
|
|
287
|
+
}
|
|
288
|
+
}));
|
|
289
|
+
})))).flat();
|
|
290
|
+
return json_referencias_cantidades;
|
|
291
|
+
}
|
|
292
|
+
return [];
|
|
293
|
+
}
|
|
294
|
+
catch (e) {
|
|
295
|
+
return [];
|
|
287
296
|
}
|
|
288
|
-
return [];
|
|
289
297
|
});
|
|
290
298
|
}
|
|
291
299
|
insertQuantityRelatedLines(_a) {
|
|
@@ -338,6 +346,7 @@ class IntegrationManager {
|
|
|
338
346
|
}, {});
|
|
339
347
|
yield Promise.all(Object.entries(bultosYCantidadesGroupedByShipment).map((_c) => __awaiter(this, [_c], void 0, function* ([tempShipmentId, bultosYCantidades]) {
|
|
340
348
|
const json_referencias_cantidades = yield this.createJsonQuantityReferencesFromLines({
|
|
349
|
+
idUsuario,
|
|
341
350
|
warehouseId,
|
|
342
351
|
bultosYCantidades
|
|
343
352
|
});
|
package/index.ts
CHANGED
|
@@ -447,43 +447,53 @@ export class IntegrationManager {
|
|
|
447
447
|
};
|
|
448
448
|
|
|
449
449
|
async createJsonQuantityReferencesFromLines({
|
|
450
|
+
idUsuario,
|
|
450
451
|
warehouseId,
|
|
451
452
|
bultosYCantidades
|
|
452
453
|
}: {
|
|
454
|
+
idUsuario: number;
|
|
453
455
|
warehouseId: number;
|
|
454
456
|
bultosYCantidades: BultoYCantidad[];
|
|
455
457
|
}): Promise<JsonReferenciasCantidades | []> {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
[reference.id]: 1
|
|
458
|
+
try {
|
|
459
|
+
if (warehouseId) {
|
|
460
|
+
const json_referencias_cantidades = (
|
|
461
|
+
await Promise.all(
|
|
462
|
+
bultosYCantidades.map(async (each) => {
|
|
463
|
+
const cantidad = each?.cantidad;
|
|
464
|
+
const sku = each?.bulto.sku_producto;
|
|
465
|
+
|
|
466
|
+
if (!cantidad || !sku) return [];
|
|
467
|
+
|
|
468
|
+
const reference =
|
|
469
|
+
await this.services.warehouseService.getProductReferenceFromSku(
|
|
470
|
+
{
|
|
471
|
+
idUsuario,
|
|
472
|
+
sku
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
|
|
476
|
+
if (!reference?.id) {
|
|
477
|
+
throw new Error('no existe sku para referencia');
|
|
477
478
|
}
|
|
478
|
-
}));
|
|
479
|
-
})
|
|
480
|
-
)
|
|
481
|
-
).flat();
|
|
482
479
|
|
|
483
|
-
|
|
484
|
-
|
|
480
|
+
return Array.from({ length: cantidad }, () => ({
|
|
481
|
+
id_caja: -1,
|
|
482
|
+
referencias: {
|
|
483
|
+
[reference.id]: 1
|
|
484
|
+
}
|
|
485
|
+
}));
|
|
486
|
+
})
|
|
487
|
+
)
|
|
488
|
+
).flat();
|
|
489
|
+
|
|
490
|
+
return json_referencias_cantidades;
|
|
491
|
+
}
|
|
485
492
|
|
|
486
|
-
|
|
493
|
+
return [];
|
|
494
|
+
} catch (e) {
|
|
495
|
+
return [];
|
|
496
|
+
}
|
|
487
497
|
}
|
|
488
498
|
|
|
489
499
|
async insertQuantityRelatedLines({
|
|
@@ -567,6 +577,7 @@ export class IntegrationManager {
|
|
|
567
577
|
async ([tempShipmentId, bultosYCantidades]) => {
|
|
568
578
|
const json_referencias_cantidades =
|
|
569
579
|
await this.createJsonQuantityReferencesFromLines({
|
|
580
|
+
idUsuario,
|
|
570
581
|
warehouseId,
|
|
571
582
|
bultosYCantidades
|
|
572
583
|
});
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -264,9 +264,10 @@ export type LlmAPIService = {
|
|
|
264
264
|
};
|
|
265
265
|
|
|
266
266
|
export type WarehouseService = {
|
|
267
|
-
getProductReferenceFromSku: (
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
getProductReferenceFromSku: (params: {
|
|
268
|
+
idUsuario: number;
|
|
269
|
+
sku: string;
|
|
270
|
+
}) => Promise<{ id: number; sku: string }>;
|
|
270
271
|
};
|
|
271
272
|
|
|
272
273
|
export type JsonReferenciasCantidades = Array<{
|