cardus 0.0.88 → 0.0.90
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 +30 -22
- package/index.ts +45 -32
- package/package.json +1 -1
- package/types/index.ts +15 -5
package/dist/index.js
CHANGED
|
@@ -149,12 +149,18 @@ class IntegrationManager {
|
|
|
149
149
|
.filter(Boolean)
|
|
150
150
|
.filter((each) => each.status === 'fulfilled')
|
|
151
151
|
.map((each) => each.value);
|
|
152
|
+
const userIntegrationConfiguration = yield integrationsService.getDefaultIntegrationsData({
|
|
153
|
+
id_usuario: idUsuario,
|
|
154
|
+
id_integracion: this.integrationType
|
|
155
|
+
});
|
|
156
|
+
const shouldFindWarehouseSkus = !!userIntegrationConfiguration.buscar_sku_almacen;
|
|
152
157
|
yield this.insertQuantityRelatedLines({
|
|
153
158
|
orders: successfullShipments,
|
|
154
159
|
idUsuario,
|
|
155
160
|
crearBulto,
|
|
156
161
|
group,
|
|
157
|
-
warehouseId
|
|
162
|
+
warehouseId,
|
|
163
|
+
shouldFindWarehouseSkus
|
|
158
164
|
});
|
|
159
165
|
yield this.insertUserDefaultConfigurationContent({
|
|
160
166
|
user,
|
|
@@ -297,7 +303,7 @@ class IntegrationManager {
|
|
|
297
303
|
});
|
|
298
304
|
}
|
|
299
305
|
insertQuantityRelatedLines(_a) {
|
|
300
|
-
return __awaiter(this, arguments, void 0, function* ({ orders, idUsuario, crearBulto, group, warehouseId }) {
|
|
306
|
+
return __awaiter(this, arguments, void 0, function* ({ orders, idUsuario, crearBulto, group, warehouseId, shouldFindWarehouseSkus }) {
|
|
301
307
|
/*
|
|
302
308
|
basicamente la logica es:
|
|
303
309
|
1 - si esta agrupado, crea una linea por cada pedido
|
|
@@ -335,28 +341,30 @@ class IntegrationManager {
|
|
|
335
341
|
});
|
|
336
342
|
let bultosYCantidades = yield Promise.all(obtenerBultosYCantidades);
|
|
337
343
|
bultosYCantidades = bultosYCantidades.filter(Boolean);
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
344
|
+
if (shouldFindWarehouseSkus) {
|
|
345
|
+
const bultosYCantidadesGroupedByShipment = bultosYCantidades.reduce((acc, curr) => {
|
|
346
|
+
var _a;
|
|
347
|
+
const tempShipmentId = curr === null || curr === void 0 ? void 0 : curr.idEnvioTemporal;
|
|
348
|
+
if (!tempShipmentId)
|
|
349
|
+
return acc;
|
|
350
|
+
(_a = acc[tempShipmentId]) !== null && _a !== void 0 ? _a : (acc[tempShipmentId] = []);
|
|
351
|
+
acc[tempShipmentId].push(curr);
|
|
342
352
|
return acc;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
idUsuario,
|
|
350
|
-
warehouseId,
|
|
351
|
-
bultosYCantidades
|
|
352
|
-
});
|
|
353
|
-
if (json_referencias_cantidades.length > 0) {
|
|
354
|
-
this.dataToInsert.jsonQuantityReferences.push({
|
|
355
|
-
id_envio: Number(tempShipmentId),
|
|
356
|
-
json_referencias_cantidades
|
|
353
|
+
}, {});
|
|
354
|
+
yield Promise.all(Object.entries(bultosYCantidadesGroupedByShipment).map((_c) => __awaiter(this, [_c], void 0, function* ([tempShipmentId, bultosYCantidades]) {
|
|
355
|
+
const json_referencias_cantidades = yield this.createJsonQuantityReferencesFromLines({
|
|
356
|
+
idUsuario,
|
|
357
|
+
warehouseId,
|
|
358
|
+
bultosYCantidades
|
|
357
359
|
});
|
|
358
|
-
|
|
359
|
-
|
|
360
|
+
if (json_referencias_cantidades.length > 0) {
|
|
361
|
+
this.dataToInsert.jsonQuantityReferences.push({
|
|
362
|
+
id_envio: Number(tempShipmentId),
|
|
363
|
+
json_referencias_cantidades
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
})));
|
|
367
|
+
}
|
|
360
368
|
bultosYCantidades.forEach((each) => {
|
|
361
369
|
if (!each)
|
|
362
370
|
return;
|
package/index.ts
CHANGED
|
@@ -200,12 +200,21 @@ export class IntegrationManager {
|
|
|
200
200
|
agencyId: number;
|
|
201
201
|
})[];
|
|
202
202
|
|
|
203
|
+
const userIntegrationConfiguration =
|
|
204
|
+
await integrationsService.getDefaultIntegrationsData({
|
|
205
|
+
id_usuario: idUsuario,
|
|
206
|
+
id_integracion: this.integrationType
|
|
207
|
+
});
|
|
208
|
+
const shouldFindWarehouseSkus =
|
|
209
|
+
!!userIntegrationConfiguration.buscar_sku_almacen;
|
|
210
|
+
|
|
203
211
|
await this.insertQuantityRelatedLines({
|
|
204
212
|
orders: successfullShipments,
|
|
205
213
|
idUsuario,
|
|
206
214
|
crearBulto,
|
|
207
215
|
group,
|
|
208
|
-
warehouseId
|
|
216
|
+
warehouseId,
|
|
217
|
+
shouldFindWarehouseSkus
|
|
209
218
|
});
|
|
210
219
|
|
|
211
220
|
await this.insertUserDefaultConfigurationContent({
|
|
@@ -501,13 +510,15 @@ export class IntegrationManager {
|
|
|
501
510
|
idUsuario,
|
|
502
511
|
crearBulto,
|
|
503
512
|
group,
|
|
504
|
-
warehouseId
|
|
513
|
+
warehouseId,
|
|
514
|
+
shouldFindWarehouseSkus
|
|
505
515
|
}: {
|
|
506
516
|
orders: ModifiedOrderExtended[];
|
|
507
517
|
idUsuario: number;
|
|
508
518
|
crearBulto: CrearBulto;
|
|
509
519
|
group: Group;
|
|
510
520
|
warehouseId: number;
|
|
521
|
+
shouldFindWarehouseSkus: boolean;
|
|
511
522
|
}) {
|
|
512
523
|
/*
|
|
513
524
|
basicamente la logica es:
|
|
@@ -560,37 +571,39 @@ export class IntegrationManager {
|
|
|
560
571
|
let bultosYCantidades = await Promise.all(obtenerBultosYCantidades);
|
|
561
572
|
bultosYCantidades = bultosYCantidades.filter(Boolean);
|
|
562
573
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
574
|
+
if (shouldFindWarehouseSkus) {
|
|
575
|
+
const bultosYCantidadesGroupedByShipment = bultosYCantidades.reduce<
|
|
576
|
+
Record<number, BultoYCantidad[]>
|
|
577
|
+
>((acc, curr) => {
|
|
578
|
+
const tempShipmentId = curr?.idEnvioTemporal;
|
|
579
|
+
if (!tempShipmentId) return acc;
|
|
580
|
+
|
|
581
|
+
acc[tempShipmentId] ??= [];
|
|
582
|
+
acc[tempShipmentId].push(curr);
|
|
583
|
+
|
|
584
|
+
return acc;
|
|
585
|
+
}, {});
|
|
586
|
+
|
|
587
|
+
await Promise.all(
|
|
588
|
+
Object.entries(bultosYCantidadesGroupedByShipment).map(
|
|
589
|
+
async ([tempShipmentId, bultosYCantidades]) => {
|
|
590
|
+
const json_referencias_cantidades =
|
|
591
|
+
await this.createJsonQuantityReferencesFromLines({
|
|
592
|
+
idUsuario,
|
|
593
|
+
warehouseId,
|
|
594
|
+
bultosYCantidades
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
if (json_referencias_cantidades.length > 0) {
|
|
598
|
+
this.dataToInsert.jsonQuantityReferences.push({
|
|
599
|
+
id_envio: Number(tempShipmentId),
|
|
600
|
+
json_referencias_cantidades
|
|
601
|
+
});
|
|
602
|
+
}
|
|
590
603
|
}
|
|
591
|
-
|
|
592
|
-
)
|
|
593
|
-
|
|
604
|
+
)
|
|
605
|
+
);
|
|
606
|
+
}
|
|
594
607
|
|
|
595
608
|
bultosYCantidades.forEach((each) => {
|
|
596
609
|
if (!each) return;
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -230,22 +230,22 @@ export type IntegrationsService = {
|
|
|
230
230
|
|
|
231
231
|
insertTempShipmentMultipleLines: (
|
|
232
232
|
lines: DataToInsert['lines']
|
|
233
|
-
) => number | false
|
|
233
|
+
) => Promise<number | false>;
|
|
234
234
|
|
|
235
235
|
insertTempShipmentMultipleDetails: (
|
|
236
236
|
details: DataToInsert['details']
|
|
237
|
-
) => number | false
|
|
237
|
+
) => Promise<number | false>;
|
|
238
238
|
|
|
239
239
|
insertTempShipmentMultipleContents: (
|
|
240
240
|
contents: DataToInsert['contents']
|
|
241
|
-
) => number | false
|
|
241
|
+
) => Promise<number | false>;
|
|
242
242
|
|
|
243
243
|
insertTempShipmentMultipleExternals: (
|
|
244
244
|
externals: DataToInsert['externals']
|
|
245
|
-
) => number | false
|
|
245
|
+
) => Promise<number | false>;
|
|
246
246
|
insertTempShipmentMultipleJsonQuantityReferences: (
|
|
247
247
|
jsonQuantityReferences: DataToInsert['jsonQuantityReferences']
|
|
248
|
-
) => number | false
|
|
248
|
+
) => Promise<number | false>;
|
|
249
249
|
updateTempShimpment: ({
|
|
250
250
|
id_envio,
|
|
251
251
|
id_usuario,
|
|
@@ -255,6 +255,16 @@ export type IntegrationsService = {
|
|
|
255
255
|
id_usuario: number;
|
|
256
256
|
id_agencia: number;
|
|
257
257
|
}) => Promise<boolean>;
|
|
258
|
+
|
|
259
|
+
getDefaultIntegrationsData: ({
|
|
260
|
+
id_usuario,
|
|
261
|
+
id_integracion
|
|
262
|
+
}: {
|
|
263
|
+
id_usuario: number;
|
|
264
|
+
id_integracion: number;
|
|
265
|
+
}) => Promise<{
|
|
266
|
+
buscar_sku_almacen: 0 | 1;
|
|
267
|
+
}>;
|
|
258
268
|
};
|
|
259
269
|
|
|
260
270
|
export type LlmAPIService = {
|