cardus 0.0.39 → 0.0.41
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 -22
- package/index.ts +43 -30
- package/package.json +1 -1
- package/types/index.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -118,7 +118,6 @@ class IntegrationManager {
|
|
|
118
118
|
type: this.type
|
|
119
119
|
});
|
|
120
120
|
const checkIsPriorityByDefault = () => __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
// TODO sacar esto de aqui, no hay que hacerlo cada vez, con una vale
|
|
122
121
|
const usuariosGeneiPriority = yield this.services.customizationService.getUsersWithSection(8);
|
|
123
122
|
const esPotencialmentePriority = usuariosGeneiPriority.some((seccion) => seccion.id_usuario === user.id_usuario ||
|
|
124
123
|
seccion.tipo_cliente === user.tipo_cliente ||
|
|
@@ -132,7 +131,7 @@ class IntegrationManager {
|
|
|
132
131
|
});
|
|
133
132
|
const isPriorityByDefault = yield checkIsPriorityByDefault();
|
|
134
133
|
const insertOrdersResult = yield new this.executionManager({
|
|
135
|
-
arrayParams:
|
|
134
|
+
arrayParams: filteredOrders,
|
|
136
135
|
executable: (order) => __awaiter(this, void 0, void 0, function* () {
|
|
137
136
|
const parsedOrder = yield modificarOrdenOriginal({
|
|
138
137
|
originalOrder: order
|
|
@@ -204,27 +203,30 @@ class IntegrationManager {
|
|
|
204
203
|
}
|
|
205
204
|
insertQuantityRelatedLines(_a) {
|
|
206
205
|
return __awaiter(this, arguments, void 0, function* ({ orders, idUsuario, crearBulto, estaAgrupado }) {
|
|
207
|
-
const
|
|
208
|
-
|
|
206
|
+
const createBultoFromLine = (_b) => __awaiter(this, [_b], void 0, function* ({ line, idEnvioTemporal }) {
|
|
207
|
+
const { bulto, cantidad = 0 } = yield crearBulto({
|
|
208
|
+
lineItems: { idEnvioTemporal, line },
|
|
209
|
+
idUsuario
|
|
210
|
+
});
|
|
211
|
+
if (cantidad === 0)
|
|
209
212
|
return null;
|
|
210
|
-
return
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
bultosYCantidades.forEach(({ bulto, cantidad, idEnvioTemporal }) => {
|
|
213
|
+
return { bulto, cantidad, idEnvioTemporal };
|
|
214
|
+
});
|
|
215
|
+
const obtenerBultosYCantidades = [];
|
|
216
|
+
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
217
|
+
if (!idEnvioTemporal)
|
|
218
|
+
return;
|
|
219
|
+
lineas.forEach((line) => {
|
|
220
|
+
const bultoPromise = createBultoFromLine({ line, idEnvioTemporal });
|
|
221
|
+
obtenerBultosYCantidades.push(bultoPromise);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
let bultosYCantidades = yield Promise.all(obtenerBultosYCantidades);
|
|
225
|
+
bultosYCantidades = bultosYCantidades.filter(Boolean);
|
|
226
|
+
bultosYCantidades.forEach((each) => {
|
|
227
|
+
if (!each)
|
|
228
|
+
return;
|
|
229
|
+
const { bulto, cantidad, idEnvioTemporal } = each;
|
|
228
230
|
try {
|
|
229
231
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
230
232
|
arrayFake.forEach(() => {
|
package/index.ts
CHANGED
|
@@ -23,7 +23,9 @@ import {
|
|
|
23
23
|
GetAgencyIdForTempShipment,
|
|
24
24
|
IsPriority,
|
|
25
25
|
CustomizationService,
|
|
26
|
-
DataToInsert
|
|
26
|
+
DataToInsert,
|
|
27
|
+
InsertContentShipmentLine,
|
|
28
|
+
Bulto
|
|
27
29
|
} from './types';
|
|
28
30
|
|
|
29
31
|
const dataToInsert: DataToInsert = {
|
|
@@ -103,11 +105,14 @@ export class IntegrationManager {
|
|
|
103
105
|
});
|
|
104
106
|
|
|
105
107
|
const checkIsPriorityByDefault = async () => {
|
|
106
|
-
// TODO sacar esto de aqui, no hay que hacerlo cada vez, con una vale
|
|
107
108
|
const usuariosGeneiPriority =
|
|
108
109
|
await this.services.customizationService.getUsersWithSection(8);
|
|
109
110
|
const esPotencialmentePriority = usuariosGeneiPriority.some(
|
|
110
|
-
(seccion: {
|
|
111
|
+
(seccion: {
|
|
112
|
+
id_usuario: number | string;
|
|
113
|
+
tipo_cliente: number;
|
|
114
|
+
id_comercial: number | string;
|
|
115
|
+
}) =>
|
|
111
116
|
seccion.id_usuario === user.id_usuario ||
|
|
112
117
|
seccion.tipo_cliente === user.tipo_cliente ||
|
|
113
118
|
seccion.id_comercial === user.id_comercial
|
|
@@ -123,7 +128,7 @@ export class IntegrationManager {
|
|
|
123
128
|
const isPriorityByDefault = await checkIsPriorityByDefault();
|
|
124
129
|
|
|
125
130
|
const insertOrdersResult = await new this.executionManager({
|
|
126
|
-
arrayParams:
|
|
131
|
+
arrayParams: filteredOrders,
|
|
127
132
|
executable: async (order: OriginalOrder) => {
|
|
128
133
|
const parsedOrder = await modificarOrdenOriginal({
|
|
129
134
|
originalOrder: order
|
|
@@ -204,7 +209,7 @@ export class IntegrationManager {
|
|
|
204
209
|
});
|
|
205
210
|
};
|
|
206
211
|
|
|
207
|
-
let userConfiguration: UserDefaultConfigurationContent[] |
|
|
212
|
+
let userConfiguration: UserDefaultConfigurationContent[] | null = null;
|
|
208
213
|
const userSavedData =
|
|
209
214
|
(await configurationService.getDefaultProformaConfiguration(idUsuario)) ||
|
|
210
215
|
[];
|
|
@@ -356,35 +361,43 @@ export class IntegrationManager {
|
|
|
356
361
|
crearBulto: CrearBulto;
|
|
357
362
|
estaAgrupado: boolean;
|
|
358
363
|
}) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const { bulto, cantidad = 0 } = await crearBulto({
|
|
365
|
-
lineItems: { idEnvioTemporal, line },
|
|
366
|
-
idUsuario
|
|
367
|
-
});
|
|
368
|
-
if (cantidad === 0) return null;
|
|
369
|
-
return { bulto, cantidad, idEnvioTemporal };
|
|
370
|
-
})
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
);
|
|
364
|
+
type BultoYCantidad = {
|
|
365
|
+
bulto: Bulto['bulto'];
|
|
366
|
+
cantidad: Bulto['cantidad'];
|
|
367
|
+
idEnvioTemporal: number;
|
|
368
|
+
};
|
|
374
369
|
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
370
|
+
const createBultoFromLine = async ({
|
|
371
|
+
line,
|
|
372
|
+
idEnvioTemporal
|
|
373
|
+
}: {
|
|
374
|
+
line: InsertContentShipmentLine;
|
|
375
|
+
idEnvioTemporal: number;
|
|
376
|
+
}): Promise<BultoYCantidad | null> => {
|
|
377
|
+
const { bulto, cantidad = 0 } = await crearBulto({
|
|
378
|
+
lineItems: { idEnvioTemporal, line },
|
|
379
|
+
idUsuario
|
|
380
|
+
});
|
|
381
|
+
if (cantidad === 0) return null;
|
|
382
|
+
return { bulto, cantidad, idEnvioTemporal };
|
|
383
|
+
};
|
|
379
384
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
385
|
+
const obtenerBultosYCantidades: Array<Promise<BultoYCantidad | null>> = [];
|
|
386
|
+
|
|
387
|
+
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
388
|
+
if (!idEnvioTemporal) return;
|
|
389
|
+
lineas.forEach((line) => {
|
|
390
|
+
const bultoPromise = createBultoFromLine({ line, idEnvioTemporal });
|
|
391
|
+
obtenerBultosYCantidades.push(bultoPromise);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
383
394
|
|
|
384
|
-
|
|
385
|
-
|
|
395
|
+
let bultosYCantidades = await Promise.all(obtenerBultosYCantidades);
|
|
396
|
+
bultosYCantidades = bultosYCantidades.filter(Boolean);
|
|
386
397
|
|
|
387
|
-
bultosYCantidades.forEach((
|
|
398
|
+
bultosYCantidades.forEach((each) => {
|
|
399
|
+
if (!each) return;
|
|
400
|
+
const { bulto, cantidad, idEnvioTemporal } = each;
|
|
388
401
|
try {
|
|
389
402
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
390
403
|
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -77,7 +77,7 @@ export type Bulto = {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
export type ModifiedOrder = {
|
|
80
|
-
lineas: Array<
|
|
80
|
+
lineas: Array<InsertContentShipmentLine>;
|
|
81
81
|
codigoPaisLLegada: string | undefined;
|
|
82
82
|
codigoPostalLLegada: string | undefined;
|
|
83
83
|
primerApellidoLLegada: string | undefined;
|
|
@@ -328,7 +328,7 @@ export type DataToInsert = {
|
|
|
328
328
|
externals: InsertContentShipmentExternal[];
|
|
329
329
|
};
|
|
330
330
|
|
|
331
|
-
type InsertContentShipmentLine = {
|
|
331
|
+
export type InsertContentShipmentLine = {
|
|
332
332
|
id_envio: number;
|
|
333
333
|
bulto: Pick<Bulto['bulto'], 'peso' | 'alto' | 'ancho' | 'largo'>;
|
|
334
334
|
};
|