cardus 0.0.53 → 0.0.54
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 +15 -25
- package/dist/insertTempShipment/index.js +5 -1
- package/index.ts +18 -43
- package/insertTempShipment/index.ts +6 -1
- package/package.json +1 -1
- package/types/index.ts +6 -2
package/dist/index.js
CHANGED
|
@@ -17,25 +17,7 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
17
17
|
const insertTempShipment_1 = require("./insertTempShipment");
|
|
18
18
|
class IntegrationManager {
|
|
19
19
|
constructor(params) {
|
|
20
|
-
this.
|
|
21
|
-
const idEnvioTemporal = yield this.insertTempShipment({
|
|
22
|
-
order,
|
|
23
|
-
agencyId,
|
|
24
|
-
warehouseId,
|
|
25
|
-
sellerAddress,
|
|
26
|
-
idUsuario,
|
|
27
|
-
isPriority
|
|
28
|
-
});
|
|
29
|
-
if (!idEnvioTemporal)
|
|
30
|
-
throw new Error('Temp shipments could not be created');
|
|
31
|
-
this.insertExternalShipment({
|
|
32
|
-
idUsuario,
|
|
33
|
-
order,
|
|
34
|
-
idEnvioTemporal
|
|
35
|
-
});
|
|
36
|
-
return Object.assign(order, { idEnvioTemporal });
|
|
37
|
-
});
|
|
38
|
-
this.insertTempShipment = (_b) => __awaiter(this, [_b], void 0, function* ({ order, agencyId, warehouseId, sellerAddress, idUsuario, isPriority }) {
|
|
20
|
+
this.insertTempShipment = (_a) => __awaiter(this, [_a], void 0, function* ({ order, agencyId, warehouseId, sellerAddress, idUsuario, isPriority }) {
|
|
39
21
|
const tempShipmentData = yield (0, insertTempShipment_1.cookTempShipment)({
|
|
40
22
|
order,
|
|
41
23
|
shipmentType: this.shipmentType,
|
|
@@ -133,7 +115,7 @@ class IntegrationManager {
|
|
|
133
115
|
const parsedOrder = yield modificarOrdenOriginal({
|
|
134
116
|
originalOrder: order
|
|
135
117
|
});
|
|
136
|
-
|
|
118
|
+
const idEnvioTemporal = yield this.insertTempShipment({
|
|
137
119
|
order: parsedOrder,
|
|
138
120
|
agencyId: yield this.getAgencyIdForTempShipment({
|
|
139
121
|
defaultAgencyId: agencyId,
|
|
@@ -147,6 +129,14 @@ class IntegrationManager {
|
|
|
147
129
|
idUsuario,
|
|
148
130
|
isPriority: isPriorityByDefault
|
|
149
131
|
});
|
|
132
|
+
if (!idEnvioTemporal) {
|
|
133
|
+
throw new Error('Temp shipments could not be created');
|
|
134
|
+
}
|
|
135
|
+
this.insertExternalShipment({
|
|
136
|
+
idUsuario,
|
|
137
|
+
order: parsedOrder,
|
|
138
|
+
idEnvioTemporal
|
|
139
|
+
});
|
|
150
140
|
}),
|
|
151
141
|
regularExecutionTime: 8000, // ms
|
|
152
142
|
initialBatchQuantity: 5 // de cinco en cinco
|
|
@@ -208,13 +198,13 @@ class IntegrationManager {
|
|
|
208
198
|
lineItems: { idEnvioTemporal, line },
|
|
209
199
|
idUsuario
|
|
210
200
|
});
|
|
211
|
-
const { bulto, cantidad,
|
|
201
|
+
const { bulto, cantidad, forzarAgrupamientoDeLinea } = result;
|
|
212
202
|
if (cantidad && bulto) {
|
|
213
203
|
return {
|
|
214
204
|
bulto,
|
|
215
205
|
cantidad,
|
|
216
206
|
idEnvioTemporal,
|
|
217
|
-
|
|
207
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
218
208
|
};
|
|
219
209
|
}
|
|
220
210
|
return null;
|
|
@@ -236,9 +226,9 @@ class IntegrationManager {
|
|
|
236
226
|
bultosYCantidades.forEach((each) => {
|
|
237
227
|
if (!each)
|
|
238
228
|
return;
|
|
239
|
-
const { bulto, cantidad, idEnvioTemporal,
|
|
229
|
+
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } = each;
|
|
240
230
|
try {
|
|
241
|
-
if (!grouped &&
|
|
231
|
+
if (!grouped && forzarAgrupamientoDeLinea) {
|
|
242
232
|
this.dataToInsert.lines.push({
|
|
243
233
|
id_envio: idEnvioTemporal,
|
|
244
234
|
bulto
|
|
@@ -250,7 +240,7 @@ class IntegrationManager {
|
|
|
250
240
|
bulto,
|
|
251
241
|
cantidad
|
|
252
242
|
});
|
|
253
|
-
if (!grouped && !
|
|
243
|
+
if (!grouped && !forzarAgrupamientoDeLinea) {
|
|
254
244
|
arrayFake.forEach(() => {
|
|
255
245
|
this.dataToInsert.lines.push({
|
|
256
246
|
id_envio: idEnvioTemporal,
|
|
@@ -106,13 +106,17 @@ const cookTempShipment = (_a) => __awaiter(void 0, [_a], void 0, function* ({ or
|
|
|
106
106
|
id_almacen: warehouseId,
|
|
107
107
|
agencia_envio_integracion: order.agenciaEnvioIntegracion
|
|
108
108
|
});
|
|
109
|
+
const setReferenciaCliente = (order) => ({
|
|
110
|
+
referencia_cliente: order.referenciaCliente || null
|
|
111
|
+
});
|
|
109
112
|
const setters = [
|
|
110
113
|
setDatosVendedor,
|
|
111
114
|
setDatosComprador,
|
|
112
115
|
setUbicacionComprador,
|
|
113
116
|
setReembolso,
|
|
114
117
|
setFechas,
|
|
115
|
-
setBultos
|
|
118
|
+
setBultos,
|
|
119
|
+
setReferenciaCliente
|
|
116
120
|
];
|
|
117
121
|
const dataInsert = (yield setters.reduce((acc, curr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
122
|
const accumulated = yield acc;
|
package/index.ts
CHANGED
|
@@ -139,7 +139,7 @@ export class IntegrationManager {
|
|
|
139
139
|
originalOrder: order
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
-
|
|
142
|
+
const idEnvioTemporal = await this.insertTempShipment({
|
|
143
143
|
order: parsedOrder,
|
|
144
144
|
agencyId: await this.getAgencyIdForTempShipment({
|
|
145
145
|
defaultAgencyId: agencyId,
|
|
@@ -153,6 +153,16 @@ export class IntegrationManager {
|
|
|
153
153
|
idUsuario,
|
|
154
154
|
isPriority: isPriorityByDefault
|
|
155
155
|
});
|
|
156
|
+
|
|
157
|
+
if (!idEnvioTemporal) {
|
|
158
|
+
throw new Error('Temp shipments could not be created');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.insertExternalShipment({
|
|
162
|
+
idUsuario,
|
|
163
|
+
order: parsedOrder,
|
|
164
|
+
idEnvioTemporal
|
|
165
|
+
});
|
|
156
166
|
},
|
|
157
167
|
regularExecutionTime: 8000, // ms
|
|
158
168
|
initialBatchQuantity: 5 // de cinco en cinco
|
|
@@ -237,42 +247,6 @@ export class IntegrationManager {
|
|
|
237
247
|
}
|
|
238
248
|
}
|
|
239
249
|
|
|
240
|
-
insertOrder = async ({
|
|
241
|
-
order,
|
|
242
|
-
agencyId,
|
|
243
|
-
warehouseId,
|
|
244
|
-
sellerAddress,
|
|
245
|
-
idUsuario,
|
|
246
|
-
isPriority
|
|
247
|
-
}: {
|
|
248
|
-
order: ModifiedOrder;
|
|
249
|
-
agencyId: number;
|
|
250
|
-
warehouseId: number;
|
|
251
|
-
sellerAddress: SellerAddress;
|
|
252
|
-
idUsuario: number;
|
|
253
|
-
isPriority: IsPriority;
|
|
254
|
-
}): Promise<ModifiedOrderExtended> => {
|
|
255
|
-
const idEnvioTemporal = await this.insertTempShipment({
|
|
256
|
-
order,
|
|
257
|
-
agencyId,
|
|
258
|
-
warehouseId,
|
|
259
|
-
sellerAddress,
|
|
260
|
-
idUsuario,
|
|
261
|
-
isPriority
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
if (!idEnvioTemporal)
|
|
265
|
-
throw new Error('Temp shipments could not be created');
|
|
266
|
-
|
|
267
|
-
this.insertExternalShipment({
|
|
268
|
-
idUsuario,
|
|
269
|
-
order,
|
|
270
|
-
idEnvioTemporal
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
return Object.assign(order, { idEnvioTemporal });
|
|
274
|
-
};
|
|
275
|
-
|
|
276
250
|
insertTempShipment = async ({
|
|
277
251
|
order,
|
|
278
252
|
agencyId,
|
|
@@ -367,7 +341,7 @@ export class IntegrationManager {
|
|
|
367
341
|
bulto: Bulto['bulto'];
|
|
368
342
|
cantidad: Bulto['cantidad'];
|
|
369
343
|
idEnvioTemporal: number;
|
|
370
|
-
|
|
344
|
+
forzarAgrupamientoDeLinea: boolean;
|
|
371
345
|
};
|
|
372
346
|
|
|
373
347
|
const grouped = Number(group?.grouped === 1);
|
|
@@ -383,14 +357,14 @@ export class IntegrationManager {
|
|
|
383
357
|
lineItems: { idEnvioTemporal, line },
|
|
384
358
|
idUsuario
|
|
385
359
|
});
|
|
386
|
-
const { bulto, cantidad,
|
|
360
|
+
const { bulto, cantidad, forzarAgrupamientoDeLinea } = result;
|
|
387
361
|
|
|
388
362
|
if (cantidad && bulto) {
|
|
389
363
|
return {
|
|
390
364
|
bulto,
|
|
391
365
|
cantidad,
|
|
392
366
|
idEnvioTemporal,
|
|
393
|
-
|
|
367
|
+
forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
|
|
394
368
|
};
|
|
395
369
|
}
|
|
396
370
|
return null;
|
|
@@ -416,9 +390,10 @@ export class IntegrationManager {
|
|
|
416
390
|
|
|
417
391
|
bultosYCantidades.forEach((each) => {
|
|
418
392
|
if (!each) return;
|
|
419
|
-
const { bulto, cantidad, idEnvioTemporal,
|
|
393
|
+
const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } =
|
|
394
|
+
each;
|
|
420
395
|
try {
|
|
421
|
-
if (!grouped &&
|
|
396
|
+
if (!grouped && forzarAgrupamientoDeLinea) {
|
|
422
397
|
this.dataToInsert.lines.push({
|
|
423
398
|
id_envio: idEnvioTemporal,
|
|
424
399
|
bulto
|
|
@@ -433,7 +408,7 @@ export class IntegrationManager {
|
|
|
433
408
|
cantidad
|
|
434
409
|
});
|
|
435
410
|
|
|
436
|
-
if (!grouped && !
|
|
411
|
+
if (!grouped && !forzarAgrupamientoDeLinea) {
|
|
437
412
|
arrayFake.forEach(() => {
|
|
438
413
|
this.dataToInsert.lines.push({
|
|
439
414
|
id_envio: idEnvioTemporal,
|
|
@@ -154,13 +154,18 @@ export const cookTempShipment = async ({
|
|
|
154
154
|
agencia_envio_integracion: order.agenciaEnvioIntegracion
|
|
155
155
|
});
|
|
156
156
|
|
|
157
|
+
const setReferenciaCliente = (order: ModifiedOrder) => ({
|
|
158
|
+
referencia_cliente: order.referenciaCliente || null
|
|
159
|
+
});
|
|
160
|
+
|
|
157
161
|
const setters = [
|
|
158
162
|
setDatosVendedor,
|
|
159
163
|
setDatosComprador,
|
|
160
164
|
setUbicacionComprador,
|
|
161
165
|
setReembolso,
|
|
162
166
|
setFechas,
|
|
163
|
-
setBultos
|
|
167
|
+
setBultos,
|
|
168
|
+
setReferenciaCliente
|
|
164
169
|
];
|
|
165
170
|
|
|
166
171
|
const dataInsert = (await setters.reduce(async (acc, curr) => {
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -93,7 +93,7 @@ export type Bulto = {
|
|
|
93
93
|
nombre_producto: string | null;
|
|
94
94
|
};
|
|
95
95
|
cantidad: number;
|
|
96
|
-
|
|
96
|
+
forzarAgrupamientoDeLinea: boolean;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
export type ModifiedOrder = {
|
|
@@ -118,6 +118,7 @@ export type ModifiedOrder = {
|
|
|
118
118
|
isPriority: 0 | 1;
|
|
119
119
|
idCarrier?: number | null;
|
|
120
120
|
agenciaEnvioIntegracion: string | null;
|
|
121
|
+
referenciaCliente?: string;
|
|
121
122
|
};
|
|
122
123
|
|
|
123
124
|
export interface ModifiedOrderExtended extends ModifiedOrder {
|
|
@@ -174,7 +175,10 @@ export type IntegrationsService = {
|
|
|
174
175
|
idUsuario: number
|
|
175
176
|
) => Promise<boolean>;
|
|
176
177
|
|
|
177
|
-
insertTempShipment: (
|
|
178
|
+
insertTempShipment: (
|
|
179
|
+
params: Shipment,
|
|
180
|
+
check?: boolean
|
|
181
|
+
) => Promise<number | false>;
|
|
178
182
|
|
|
179
183
|
insertExternalShipment: (params: {
|
|
180
184
|
id_envio_temporal_usuario: number;
|