cardus 0.0.86 → 0.0.87
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 -18
- package/index.ts +34 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -266,26 +266,32 @@ class IntegrationManager {
|
|
|
266
266
|
}
|
|
267
267
|
createJsonQuantityReferencesFromLines(_a) {
|
|
268
268
|
return __awaiter(this, arguments, void 0, function* ({ warehouseId, bultosYCantidades }) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
id_caja: -1,
|
|
281
|
-
referencias: {
|
|
282
|
-
[reference.id]: 1
|
|
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 references = yield this.services.warehouseService.getProductReferenceFromSku(sku);
|
|
277
|
+
const reference = references === null || references === void 0 ? void 0 : references[0];
|
|
278
|
+
if (!(reference === null || reference === void 0 ? void 0 : reference.id)) {
|
|
279
|
+
throw new Error('no existe sku para referencia');
|
|
283
280
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
281
|
+
return Array.from({ length: cantidad }, () => ({
|
|
282
|
+
id_caja: -1,
|
|
283
|
+
referencias: {
|
|
284
|
+
[reference.id]: 1
|
|
285
|
+
}
|
|
286
|
+
}));
|
|
287
|
+
})))).flat();
|
|
288
|
+
return json_referencias_cantidades;
|
|
289
|
+
}
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
292
|
+
catch (e) {
|
|
293
|
+
return [];
|
|
287
294
|
}
|
|
288
|
-
return [];
|
|
289
295
|
});
|
|
290
296
|
}
|
|
291
297
|
insertQuantityRelatedLines(_a) {
|
package/index.ts
CHANGED
|
@@ -453,37 +453,43 @@ export class IntegrationManager {
|
|
|
453
453
|
warehouseId: number;
|
|
454
454
|
bultosYCantidades: BultoYCantidad[];
|
|
455
455
|
}): Promise<JsonReferenciasCantidades | []> {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
id_caja: -1,
|
|
475
|
-
referencias: {
|
|
476
|
-
[reference.id]: 1
|
|
456
|
+
try {
|
|
457
|
+
if (warehouseId) {
|
|
458
|
+
const json_referencias_cantidades = (
|
|
459
|
+
await Promise.all(
|
|
460
|
+
bultosYCantidades.map(async (each) => {
|
|
461
|
+
const cantidad = each?.cantidad;
|
|
462
|
+
const sku = each?.bulto.sku_producto;
|
|
463
|
+
|
|
464
|
+
if (!cantidad || !sku) return [];
|
|
465
|
+
|
|
466
|
+
const references =
|
|
467
|
+
await this.services.warehouseService.getProductReferenceFromSku(
|
|
468
|
+
sku
|
|
469
|
+
);
|
|
470
|
+
const reference = references?.[0];
|
|
471
|
+
|
|
472
|
+
if (!reference?.id) {
|
|
473
|
+
throw new Error('no existe sku para referencia');
|
|
477
474
|
}
|
|
478
|
-
}));
|
|
479
|
-
})
|
|
480
|
-
)
|
|
481
|
-
).flat();
|
|
482
475
|
|
|
483
|
-
|
|
484
|
-
|
|
476
|
+
return Array.from({ length: cantidad }, () => ({
|
|
477
|
+
id_caja: -1,
|
|
478
|
+
referencias: {
|
|
479
|
+
[reference.id]: 1
|
|
480
|
+
}
|
|
481
|
+
}));
|
|
482
|
+
})
|
|
483
|
+
)
|
|
484
|
+
).flat();
|
|
485
|
+
|
|
486
|
+
return json_referencias_cantidades;
|
|
487
|
+
}
|
|
485
488
|
|
|
486
|
-
|
|
489
|
+
return [];
|
|
490
|
+
} catch (e) {
|
|
491
|
+
return [];
|
|
492
|
+
}
|
|
487
493
|
}
|
|
488
494
|
|
|
489
495
|
async insertQuantityRelatedLines({
|