cardus 0.0.53 → 0.0.55

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
@@ -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.insertOrder = (_a) => __awaiter(this, [_a], void 0, function* ({ order, agencyId, warehouseId, sellerAddress, idUsuario, isPriority }) {
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
- return this.insertOrder({
118
+ const idEnvioTemporal = yield this.insertTempShipment({
137
119
  order: parsedOrder,
138
120
  agencyId: yield this.getAgencyIdForTempShipment({
139
121
  defaultAgencyId: agencyId,
@@ -147,6 +129,15 @@ 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
+ });
140
+ return Object.assign(parsedOrder, { idEnvioTemporal });
150
141
  }),
151
142
  regularExecutionTime: 8000, // ms
152
143
  initialBatchQuantity: 5 // de cinco en cinco
@@ -208,13 +199,13 @@ class IntegrationManager {
208
199
  lineItems: { idEnvioTemporal, line },
209
200
  idUsuario
210
201
  });
211
- const { bulto, cantidad, forzarAgrupamiento } = result;
202
+ const { bulto, cantidad, forzarAgrupamientoDeLinea } = result;
212
203
  if (cantidad && bulto) {
213
204
  return {
214
205
  bulto,
215
206
  cantidad,
216
207
  idEnvioTemporal,
217
- forzarAgrupamiento: !!forzarAgrupamiento
208
+ forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
218
209
  };
219
210
  }
220
211
  return null;
@@ -236,9 +227,9 @@ class IntegrationManager {
236
227
  bultosYCantidades.forEach((each) => {
237
228
  if (!each)
238
229
  return;
239
- const { bulto, cantidad, idEnvioTemporal, forzarAgrupamiento } = each;
230
+ const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } = each;
240
231
  try {
241
- if (!grouped && forzarAgrupamiento) {
232
+ if (!grouped && forzarAgrupamientoDeLinea) {
242
233
  this.dataToInsert.lines.push({
243
234
  id_envio: idEnvioTemporal,
244
235
  bulto
@@ -250,7 +241,7 @@ class IntegrationManager {
250
241
  bulto,
251
242
  cantidad
252
243
  });
253
- if (!grouped && !forzarAgrupamiento) {
244
+ if (!grouped && !forzarAgrupamientoDeLinea) {
254
245
  arrayFake.forEach(() => {
255
246
  this.dataToInsert.lines.push({
256
247
  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
- return this.insertOrder({
142
+ const idEnvioTemporal = await this.insertTempShipment({
143
143
  order: parsedOrder,
144
144
  agencyId: await this.getAgencyIdForTempShipment({
145
145
  defaultAgencyId: agencyId,
@@ -153,6 +153,18 @@ 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
+ });
166
+
167
+ return Object.assign(parsedOrder, { idEnvioTemporal });
156
168
  },
157
169
  regularExecutionTime: 8000, // ms
158
170
  initialBatchQuantity: 5 // de cinco en cinco
@@ -237,42 +249,6 @@ export class IntegrationManager {
237
249
  }
238
250
  }
239
251
 
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
252
  insertTempShipment = async ({
277
253
  order,
278
254
  agencyId,
@@ -367,7 +343,7 @@ export class IntegrationManager {
367
343
  bulto: Bulto['bulto'];
368
344
  cantidad: Bulto['cantidad'];
369
345
  idEnvioTemporal: number;
370
- forzarAgrupamiento: boolean;
346
+ forzarAgrupamientoDeLinea: boolean;
371
347
  };
372
348
 
373
349
  const grouped = Number(group?.grouped === 1);
@@ -383,14 +359,14 @@ export class IntegrationManager {
383
359
  lineItems: { idEnvioTemporal, line },
384
360
  idUsuario
385
361
  });
386
- const { bulto, cantidad, forzarAgrupamiento } = result;
362
+ const { bulto, cantidad, forzarAgrupamientoDeLinea } = result;
387
363
 
388
364
  if (cantidad && bulto) {
389
365
  return {
390
366
  bulto,
391
367
  cantidad,
392
368
  idEnvioTemporal,
393
- forzarAgrupamiento: !!forzarAgrupamiento
369
+ forzarAgrupamientoDeLinea: !!forzarAgrupamientoDeLinea
394
370
  };
395
371
  }
396
372
  return null;
@@ -416,9 +392,10 @@ export class IntegrationManager {
416
392
 
417
393
  bultosYCantidades.forEach((each) => {
418
394
  if (!each) return;
419
- const { bulto, cantidad, idEnvioTemporal, forzarAgrupamiento } = each;
395
+ const { bulto, cantidad, idEnvioTemporal, forzarAgrupamientoDeLinea } =
396
+ each;
420
397
  try {
421
- if (!grouped && forzarAgrupamiento) {
398
+ if (!grouped && forzarAgrupamientoDeLinea) {
422
399
  this.dataToInsert.lines.push({
423
400
  id_envio: idEnvioTemporal,
424
401
  bulto
@@ -433,7 +410,7 @@ export class IntegrationManager {
433
410
  cantidad
434
411
  });
435
412
 
436
- if (!grouped && !forzarAgrupamiento) {
413
+ if (!grouped && !forzarAgrupamientoDeLinea) {
437
414
  arrayFake.forEach(() => {
438
415
  this.dataToInsert.lines.push({
439
416
  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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cardus",
3
- "version": "0.0.53",
3
+ "version": "0.0.55",
4
4
  "description": "an integration manager",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
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
- forzarAgrupamiento: boolean;
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: (params: Shipment, check?: boolean) => number | false;
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;