cardus 0.0.41 → 0.0.43
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 +21 -19
- package/index.ts +27 -21
- package/package.json +1 -1
- package/types/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -15,12 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.IntegrationManager = void 0;
|
|
16
16
|
const moment_1 = __importDefault(require("moment"));
|
|
17
17
|
const insertTempShipment_1 = require("./insertTempShipment");
|
|
18
|
-
const dataToInsert = {
|
|
19
|
-
lines: [],
|
|
20
|
-
contents: [],
|
|
21
|
-
details: [],
|
|
22
|
-
externals: []
|
|
23
|
-
};
|
|
24
18
|
class IntegrationManager {
|
|
25
19
|
constructor(params) {
|
|
26
20
|
this.insertOrder = (_a) => __awaiter(this, [_a], void 0, function* ({ order, agencyId, warehouseId, sellerAddress, idUsuario, group, isPriority }) {
|
|
@@ -59,7 +53,7 @@ class IntegrationManager {
|
|
|
59
53
|
return yield this.services.integrationsService.insertTempShipment(tempShipmentData, false);
|
|
60
54
|
});
|
|
61
55
|
this.insertExternalShipment = ({ idUsuario, order, idEnvioTemporal }) => {
|
|
62
|
-
dataToInsert.externals.push({
|
|
56
|
+
this.dataToInsert.externals.push({
|
|
63
57
|
id_envio_temporal_usuario: idEnvioTemporal,
|
|
64
58
|
codigo_envio_externo: order.codigoEnvioExterno,
|
|
65
59
|
id_usuario: idUsuario,
|
|
@@ -77,7 +71,7 @@ class IntegrationManager {
|
|
|
77
71
|
this.insertTempShipmentLines = (_c) => __awaiter(this, [_c], void 0, function* ({ idEnvioTemporal, group }) {
|
|
78
72
|
const grouped = group.grouped === 1 || group.grouped === '1';
|
|
79
73
|
if (grouped) {
|
|
80
|
-
dataToInsert.lines.push({
|
|
74
|
+
this.dataToInsert.lines.push({
|
|
81
75
|
id_envio: idEnvioTemporal,
|
|
82
76
|
bulto: {
|
|
83
77
|
peso: group.weight,
|
|
@@ -96,6 +90,12 @@ class IntegrationManager {
|
|
|
96
90
|
usersService: params.usersService,
|
|
97
91
|
customizationService: params.customizationService
|
|
98
92
|
};
|
|
93
|
+
this.dataToInsert = {
|
|
94
|
+
lines: [],
|
|
95
|
+
contents: [],
|
|
96
|
+
details: [],
|
|
97
|
+
externals: []
|
|
98
|
+
};
|
|
99
99
|
this.shipmentType = params.shipmentType;
|
|
100
100
|
this.type = params.type;
|
|
101
101
|
this.executionManager = params.executionManager;
|
|
@@ -168,10 +168,10 @@ class IntegrationManager {
|
|
|
168
168
|
user,
|
|
169
169
|
tempShimpmentIds: successfullShipments.map((successfullShipment) => successfullShipment.idEnvioTemporal)
|
|
170
170
|
});
|
|
171
|
-
yield integrationsService.insertTempShipmentMultipleLines(dataToInsert.lines);
|
|
172
|
-
yield integrationsService.insertTempShipmentMultipleDetails(dataToInsert.details);
|
|
173
|
-
yield integrationsService.insertTempShipmentMultipleContents(dataToInsert.contents);
|
|
174
|
-
yield integrationsService.insertTempShipmentMultipleExternals(dataToInsert.externals);
|
|
171
|
+
yield integrationsService.insertTempShipmentMultipleLines(this.dataToInsert.lines);
|
|
172
|
+
yield integrationsService.insertTempShipmentMultipleDetails(this.dataToInsert.details);
|
|
173
|
+
yield integrationsService.insertTempShipmentMultipleContents(this.dataToInsert.contents);
|
|
174
|
+
yield integrationsService.insertTempShipmentMultipleExternals(this.dataToInsert.externals);
|
|
175
175
|
return { filteredOrders, insertedTempShipments: successfullShipments };
|
|
176
176
|
});
|
|
177
177
|
}
|
|
@@ -181,7 +181,7 @@ class IntegrationManager {
|
|
|
181
181
|
const { configurationService } = this.services;
|
|
182
182
|
const insert = (data, tempShimpmentId) => {
|
|
183
183
|
data.forEach((tempContent) => {
|
|
184
|
-
dataToInsert.contents.push(Object.assign(Object.assign({}, tempContent), { id_envio: tempShimpmentId }));
|
|
184
|
+
this.dataToInsert.contents.push(Object.assign(Object.assign({}, tempContent), { id_envio: tempShimpmentId }));
|
|
185
185
|
});
|
|
186
186
|
};
|
|
187
187
|
let userConfiguration = null;
|
|
@@ -204,13 +204,15 @@ class IntegrationManager {
|
|
|
204
204
|
insertQuantityRelatedLines(_a) {
|
|
205
205
|
return __awaiter(this, arguments, void 0, function* ({ orders, idUsuario, crearBulto, estaAgrupado }) {
|
|
206
206
|
const createBultoFromLine = (_b) => __awaiter(this, [_b], void 0, function* ({ line, idEnvioTemporal }) {
|
|
207
|
-
const
|
|
207
|
+
const result = yield crearBulto({
|
|
208
208
|
lineItems: { idEnvioTemporal, line },
|
|
209
209
|
idUsuario
|
|
210
210
|
});
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
const { bulto, cantidad } = result;
|
|
212
|
+
if (cantidad && bulto) {
|
|
213
|
+
return { bulto, cantidad, idEnvioTemporal };
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
214
216
|
});
|
|
215
217
|
const obtenerBultosYCantidades = [];
|
|
216
218
|
orders.forEach(({ idEnvioTemporal, lineas }) => {
|
|
@@ -231,12 +233,12 @@ class IntegrationManager {
|
|
|
231
233
|
const arrayFake = Array.from({ length: Number(cantidad) });
|
|
232
234
|
arrayFake.forEach(() => {
|
|
233
235
|
if (!estaAgrupado) {
|
|
234
|
-
dataToInsert.lines.push({
|
|
236
|
+
this.dataToInsert.lines.push({
|
|
235
237
|
id_envio: idEnvioTemporal,
|
|
236
238
|
bulto
|
|
237
239
|
});
|
|
238
240
|
}
|
|
239
|
-
dataToInsert.details.push({
|
|
241
|
+
this.dataToInsert.details.push({
|
|
240
242
|
id_envio: idEnvioTemporal,
|
|
241
243
|
bulto
|
|
242
244
|
});
|
package/index.ts
CHANGED
|
@@ -23,18 +23,11 @@ import {
|
|
|
23
23
|
GetAgencyIdForTempShipment,
|
|
24
24
|
IsPriority,
|
|
25
25
|
CustomizationService,
|
|
26
|
-
DataToInsert,
|
|
27
26
|
InsertContentShipmentLine,
|
|
28
|
-
Bulto
|
|
27
|
+
Bulto,
|
|
28
|
+
DataToInsert
|
|
29
29
|
} from './types';
|
|
30
30
|
|
|
31
|
-
const dataToInsert: DataToInsert = {
|
|
32
|
-
lines: [],
|
|
33
|
-
contents: [],
|
|
34
|
-
details: [],
|
|
35
|
-
externals: []
|
|
36
|
-
};
|
|
37
|
-
|
|
38
31
|
interface Services {
|
|
39
32
|
integrationsService: IntegrationsService;
|
|
40
33
|
addressesService: AddressesService;
|
|
@@ -52,6 +45,8 @@ export class IntegrationManager {
|
|
|
52
45
|
shipmentType: ShipmentType;
|
|
53
46
|
getAgencyIdForTempShipment: GetAgencyIdForTempShipment;
|
|
54
47
|
|
|
48
|
+
dataToInsert: DataToInsert;
|
|
49
|
+
|
|
55
50
|
constructor(params: {
|
|
56
51
|
integrationsService: IntegrationsService;
|
|
57
52
|
addressesService: AddressesService;
|
|
@@ -74,6 +69,13 @@ export class IntegrationManager {
|
|
|
74
69
|
customizationService: params.customizationService
|
|
75
70
|
};
|
|
76
71
|
|
|
72
|
+
this.dataToInsert = {
|
|
73
|
+
lines: [],
|
|
74
|
+
contents: [],
|
|
75
|
+
details: [],
|
|
76
|
+
externals: []
|
|
77
|
+
};
|
|
78
|
+
|
|
77
79
|
this.shipmentType = params.shipmentType;
|
|
78
80
|
this.type = params.type;
|
|
79
81
|
this.executionManager = params.executionManager;
|
|
@@ -172,16 +174,16 @@ export class IntegrationManager {
|
|
|
172
174
|
)
|
|
173
175
|
});
|
|
174
176
|
await integrationsService.insertTempShipmentMultipleLines(
|
|
175
|
-
dataToInsert.lines
|
|
177
|
+
this.dataToInsert.lines
|
|
176
178
|
);
|
|
177
179
|
await integrationsService.insertTempShipmentMultipleDetails(
|
|
178
|
-
dataToInsert.details
|
|
180
|
+
this.dataToInsert.details
|
|
179
181
|
);
|
|
180
182
|
await integrationsService.insertTempShipmentMultipleContents(
|
|
181
|
-
dataToInsert.contents
|
|
183
|
+
this.dataToInsert.contents
|
|
182
184
|
);
|
|
183
185
|
await integrationsService.insertTempShipmentMultipleExternals(
|
|
184
|
-
dataToInsert.externals
|
|
186
|
+
this.dataToInsert.externals
|
|
185
187
|
);
|
|
186
188
|
|
|
187
189
|
return { filteredOrders, insertedTempShipments: successfullShipments };
|
|
@@ -202,7 +204,7 @@ export class IntegrationManager {
|
|
|
202
204
|
tempShimpmentId: number
|
|
203
205
|
) => {
|
|
204
206
|
data.forEach((tempContent) => {
|
|
205
|
-
dataToInsert.contents.push({
|
|
207
|
+
this.dataToInsert.contents.push({
|
|
206
208
|
...tempContent,
|
|
207
209
|
id_envio: tempShimpmentId
|
|
208
210
|
});
|
|
@@ -312,7 +314,7 @@ export class IntegrationManager {
|
|
|
312
314
|
order: ModifiedOrder;
|
|
313
315
|
idEnvioTemporal: number;
|
|
314
316
|
}): undefined => {
|
|
315
|
-
dataToInsert.externals.push({
|
|
317
|
+
this.dataToInsert.externals.push({
|
|
316
318
|
id_envio_temporal_usuario: idEnvioTemporal,
|
|
317
319
|
codigo_envio_externo: order.codigoEnvioExterno,
|
|
318
320
|
id_usuario: idUsuario,
|
|
@@ -338,7 +340,7 @@ export class IntegrationManager {
|
|
|
338
340
|
const grouped = group.grouped === 1 || group.grouped === '1';
|
|
339
341
|
|
|
340
342
|
if (grouped) {
|
|
341
|
-
dataToInsert.lines.push({
|
|
343
|
+
this.dataToInsert.lines.push({
|
|
342
344
|
id_envio: idEnvioTemporal,
|
|
343
345
|
bulto: {
|
|
344
346
|
peso: group.weight,
|
|
@@ -374,12 +376,16 @@ export class IntegrationManager {
|
|
|
374
376
|
line: InsertContentShipmentLine;
|
|
375
377
|
idEnvioTemporal: number;
|
|
376
378
|
}): Promise<BultoYCantidad | null> => {
|
|
377
|
-
const
|
|
379
|
+
const result = await crearBulto({
|
|
378
380
|
lineItems: { idEnvioTemporal, line },
|
|
379
381
|
idUsuario
|
|
380
382
|
});
|
|
381
|
-
|
|
382
|
-
|
|
383
|
+
const { bulto, cantidad } = result;
|
|
384
|
+
|
|
385
|
+
if (cantidad && bulto) {
|
|
386
|
+
return { bulto, cantidad, idEnvioTemporal };
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
383
389
|
};
|
|
384
390
|
|
|
385
391
|
const obtenerBultosYCantidades: Array<Promise<BultoYCantidad | null>> = [];
|
|
@@ -403,12 +409,12 @@ export class IntegrationManager {
|
|
|
403
409
|
|
|
404
410
|
arrayFake.forEach(() => {
|
|
405
411
|
if (!estaAgrupado) {
|
|
406
|
-
dataToInsert.lines.push({
|
|
412
|
+
this.dataToInsert.lines.push({
|
|
407
413
|
id_envio: idEnvioTemporal,
|
|
408
414
|
bulto
|
|
409
415
|
});
|
|
410
416
|
}
|
|
411
|
-
dataToInsert.details.push({
|
|
417
|
+
this.dataToInsert.details.push({
|
|
412
418
|
id_envio: idEnvioTemporal,
|
|
413
419
|
bulto
|
|
414
420
|
});
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -108,7 +108,7 @@ type FetchAllOrders = () => Promise<OriginalOrder[]>;
|
|
|
108
108
|
export type CrearBulto = (params: {
|
|
109
109
|
lineItems: { idEnvioTemporal: number; line: AnyObject };
|
|
110
110
|
idUsuario: number;
|
|
111
|
-
}) => Promise<Bulto>;
|
|
111
|
+
}) => Promise<Bulto | { bulto: null; cantidad: 0 }>;
|
|
112
112
|
|
|
113
113
|
type ModificarOrdenOriginal = (param: {
|
|
114
114
|
originalOrder: OriginalOrder;
|