cardus 0.0.23 → 0.0.25

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
@@ -58,10 +58,12 @@ class IntegrationManager {
58
58
  fecha_hora_creacion: (0, moment_1.default)().format('YYYY-MM-DD HH:mm:ss'),
59
59
  servicio: this.type,
60
60
  id_interno_shopify: order.idInternoShopify,
61
- fecha_creacion_externa: (0, moment_1.default)(order === null || order === void 0 ? void 0 : order.fechaCreacionExterna).isValid() ? (0, moment_1.default)(order.fechaCreacionExterna).format("YYYY-MM-DD HH:mm:ss") : null,
61
+ fecha_creacion_externa: (0, moment_1.default)(order === null || order === void 0 ? void 0 : order.fechaCreacionExterna).isValid()
62
+ ? (0, moment_1.default)(order.fechaCreacionExterna).format('YYYY-MM-DD HH:mm:ss')
63
+ : null,
62
64
  marketplaceId: order.marketplaceId,
63
65
  id_documento_holded: order.idDocumentoHolded,
64
- tipo_documento_holded: order.tipoDocumentoHolded,
66
+ tipo_documento_holded: order.tipoDocumentoHolded || ''
65
67
  });
66
68
  return idEnvioExterno;
67
69
  });
@@ -89,6 +91,7 @@ class IntegrationManager {
89
91
  this.type = params.type;
90
92
  this.executionManager = params.executionManager;
91
93
  this.findNextPickupDate = params.findNextPickupDate;
94
+ this.getAgencyIdFromTempShipment = params.getAgencyIdFromTempShipment;
92
95
  }
93
96
  insertTempShipments(_a) {
94
97
  return __awaiter(this, arguments, void 0, function* ({ payload: { idUsuario, agencyId, addressId, warehouseId, group }, fetchAllOrders, crearBulto, modificarOrdenOriginal }) {
@@ -115,7 +118,11 @@ class IntegrationManager {
115
118
  throw new Error('Envio Duplicado');
116
119
  return this.insertOrder({
117
120
  order: parsedOrder,
118
- agencyId,
121
+ agencyId: yield this.getAgencyIdFromTempShipment({
122
+ defaultAgencyId: agencyId,
123
+ integrationId: this.shipmentType,
124
+ tempShipmentData: parsedOrder
125
+ }),
119
126
  warehouseId,
120
127
  sellerAddress,
121
128
  idUsuario,
package/index.ts CHANGED
@@ -19,7 +19,8 @@ import {
19
19
  OriginalOrder,
20
20
  ModifiedOrder,
21
21
  ShipmentType,
22
- UserDefaultConfigurationContent
22
+ UserDefaultConfigurationContent,
23
+ GetAgencyIdForTempShipment
23
24
  } from './types';
24
25
 
25
26
  interface Services {
@@ -36,6 +37,7 @@ export class IntegrationManager {
36
37
  executionManager: ExecutionManager;
37
38
  findNextPickupDate: FindNextPickupDate;
38
39
  shipmentType: ShipmentType;
40
+ getAgencyIdFromTempShipment: GetAgencyIdForTempShipment;
39
41
 
40
42
  constructor(params: {
41
43
  integrationsService: IntegrationsService;
@@ -47,6 +49,7 @@ export class IntegrationManager {
47
49
  shipmentType: ShipmentType;
48
50
  executionManager: ExecutionManager;
49
51
  findNextPickupDate: FindNextPickupDate;
52
+ getAgencyIdFromTempShipment: GetAgencyIdForTempShipment;
50
53
  }) {
51
54
  this.services = {
52
55
  integrationsService: params.integrationsService,
@@ -60,6 +63,7 @@ export class IntegrationManager {
60
63
  this.type = params.type;
61
64
  this.executionManager = params.executionManager;
62
65
  this.findNextPickupDate = params.findNextPickupDate;
66
+ this.getAgencyIdFromTempShipment = params.getAgencyIdFromTempShipment;
63
67
  }
64
68
 
65
69
  async insertTempShipments({
@@ -100,7 +104,11 @@ export class IntegrationManager {
100
104
 
101
105
  return this.insertOrder({
102
106
  order: parsedOrder,
103
- agencyId,
107
+ agencyId: await this.getAgencyIdFromTempShipment({
108
+ defaultAgencyId: agencyId,
109
+ integrationId: this.shipmentType,
110
+ tempShipmentData: parsedOrder
111
+ }),
104
112
  warehouseId,
105
113
  sellerAddress,
106
114
  idUsuario,
@@ -267,10 +275,12 @@ export class IntegrationManager {
267
275
  fecha_hora_creacion: moment().format('YYYY-MM-DD HH:mm:ss'),
268
276
  servicio: this.type,
269
277
  id_interno_shopify: order.idInternoShopify,
270
- fecha_creacion_externa: moment(order?.fechaCreacionExterna).isValid() ? moment(order.fechaCreacionExterna).format("YYYY-MM-DD HH:mm:ss") : null,
278
+ fecha_creacion_externa: moment(order?.fechaCreacionExterna).isValid()
279
+ ? moment(order.fechaCreacionExterna).format('YYYY-MM-DD HH:mm:ss')
280
+ : null,
271
281
  marketplaceId: order.marketplaceId,
272
282
  id_documento_holded: order.idDocumentoHolded,
273
- tipo_documento_holded: order.tipoDocumentoHolded,
283
+ tipo_documento_holded: order.tipoDocumentoHolded || ''
274
284
  });
275
285
 
276
286
  return idEnvioExterno;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cardus",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "an integration manager",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,4 +28,4 @@
28
28
  "dependencies": {
29
29
  "moment": "^2.30.1"
30
30
  }
31
- }
31
+ }
package/types/index.ts CHANGED
@@ -91,9 +91,9 @@ export type ModifiedOrder = {
91
91
  idInternoShopify?: string;
92
92
  precio: number | null;
93
93
  fechaCreacionExterna?: string | null;
94
- marketplaceId?: string | null
95
- idDocumentoHolded?: string
96
- tipoDocumentoHolded?: string
94
+ marketplaceId?: string | null;
95
+ idDocumentoHolded?: string;
96
+ tipoDocumentoHolded?: string;
97
97
  };
98
98
 
99
99
  export interface ModifiedOrderExtended extends ModifiedOrder {
@@ -160,10 +160,10 @@ export type IntegrationsService = {
160
160
  fecha_hora_creacion: string;
161
161
  servicio: Type;
162
162
  id_interno_shopify?: string;
163
- fecha_creacion_externa: string | null
164
- marketplaceId?: string | null
165
- id_documento_holded?: string
166
- tipo_documento_holded?: string
163
+ fecha_creacion_externa: string | null;
164
+ marketplaceId?: string | null;
165
+ id_documento_holded?: string;
166
+ tipo_documento_holded?: string;
167
167
  }) => number | false;
168
168
 
169
169
  insertTempShipmentLines: (params: {
@@ -281,7 +281,13 @@ type ExecutionManagerUploadReturn = {
281
281
  value: any;
282
282
  };
283
283
 
284
+ export type GetAgencyIdForTempShipment = (params: {
285
+ defaultAgencyId: number;
286
+ integrationId: number;
287
+ tempShipmentData: ModifiedOrder;
288
+ }) => Promise<number>;
289
+
284
290
  export type ExecutionManager = {
285
291
  upload(): ExecutionManagerUploadReturn[];
286
- new(params: ExecutionManagerConstructorParams): ExecutionManager;
292
+ new (params: ExecutionManagerConstructorParams): ExecutionManager;
287
293
  };