cardus 0.0.85 → 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 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
- if (warehouseId) {
270
- const json_referencias_cantidades = (yield Promise.all(bultosYCantidades.map((each) => __awaiter(this, void 0, void 0, function* () {
271
- const cantidad = each === null || each === void 0 ? void 0 : each.cantidad;
272
- const sku = each === null || each === void 0 ? void 0 : each.bulto.sku_producto;
273
- if (!cantidad || !sku)
274
- return [];
275
- const references = yield this.services.warehouseService.getProductReferenceFromSku(sku);
276
- const reference = references === null || references === void 0 ? void 0 : references[0];
277
- if (!(reference === null || reference === void 0 ? void 0 : reference.id_referencia))
278
- return [];
279
- return Array.from({ length: cantidad }, () => ({
280
- id_caja: -1,
281
- referencias: {
282
- [reference.id_referencia]: 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
- })))).flat();
286
- return json_referencias_cantidades;
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
- if (warehouseId) {
457
- const json_referencias_cantidades = (
458
- await Promise.all(
459
- bultosYCantidades.map(async (each) => {
460
- const cantidad = each?.cantidad;
461
- const sku = each?.bulto.sku_producto;
462
-
463
- if (!cantidad || !sku) return [];
464
-
465
- const references =
466
- await this.services.warehouseService.getProductReferenceFromSku(
467
- sku
468
- );
469
- const reference = references?.[0];
470
-
471
- if (!reference?.id_referencia) return [];
472
-
473
- return Array.from({ length: cantidad }, () => ({
474
- id_caja: -1,
475
- referencias: {
476
- [reference.id_referencia]: 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
- return json_referencias_cantidades;
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
- return [];
489
+ return [];
490
+ } catch (e) {
491
+ return [];
492
+ }
487
493
  }
488
494
 
489
495
  async insertQuantityRelatedLines({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cardus",
3
- "version": "0.0.85",
3
+ "version": "0.0.87",
4
4
  "description": "an integration manager",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/types/index.ts CHANGED
@@ -266,7 +266,7 @@ export type LlmAPIService = {
266
266
  export type WarehouseService = {
267
267
  getProductReferenceFromSku: (
268
268
  sku: string
269
- ) => Promise<{ id_referencia: number; sku: string }[]>;
269
+ ) => Promise<{ id: number; sku: string }[]>;
270
270
  };
271
271
 
272
272
  export type JsonReferenciasCantidades = Array<{