cardus 0.0.70 → 0.0.72

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
@@ -91,6 +91,7 @@ class IntegrationManager {
91
91
  const sellerAddress = warehouseId > 0
92
92
  ? yield addressesService.getWarehouseAddress(idUsuario)
93
93
  : yield addressesService.getAddress(addressId, idUsuario);
94
+ const country = yield this.services.countriesService.getCountry(sellerAddress.id_pais);
94
95
  const allOrders = yield fetchAllOrders();
95
96
  const filteredOrders = yield integrationsService.filterExternalDuplicatedOrders({
96
97
  id_usuario: idUsuario,
@@ -149,7 +150,8 @@ class IntegrationManager {
149
150
  });
150
151
  yield this.insertUserDefaultConfigurationContent({
151
152
  user,
152
- tempShimpmentIds: successfullShipments.map((successfullShipment) => successfullShipment.idEnvioTemporal)
153
+ tempShimpmentIds: successfullShipments.map((successfullShipment) => successfullShipment.idEnvioTemporal),
154
+ countryName: country.nombre_pais_en
153
155
  });
154
156
  // modificamos la agencia, cuando se tenga que hacer
155
157
  yield Promise.allSettled(successfullShipments.map((order) => __awaiter(this, void 0, void 0, function* () {
@@ -174,7 +176,7 @@ class IntegrationManager {
174
176
  })));
175
177
  yield Promise.allSettled([
176
178
  integrationsService.insertTempShipmentMultipleLines(this.dataToInsert.lines),
177
- integrationsService.insertTempShipmentMultipleDetails(this.dataToInsert.details.map((detail) => (Object.assign(Object.assign({}, detail), { url_producto: JSON.stringify(this.dataToInsert.details) })))),
179
+ integrationsService.insertTempShipmentMultipleDetails(this.dataToInsert.details),
178
180
  integrationsService.insertTempShipmentMultipleContents(this.dataToInsert.contents),
179
181
  integrationsService.insertTempShipmentMultipleExternals(this.dataToInsert.externals)
180
182
  ]);
@@ -186,7 +188,7 @@ class IntegrationManager {
186
188
  });
187
189
  }
188
190
  insertUserDefaultConfigurationContent(_a) {
189
- return __awaiter(this, arguments, void 0, function* ({ user, tempShimpmentIds }) {
191
+ return __awaiter(this, arguments, void 0, function* ({ user, tempShimpmentIds, countryName }) {
190
192
  const idUsuario = user.id_usuario;
191
193
  const { configurationService, llmAPIService } = this.services;
192
194
  const insert = (data, tempShimpmentId) => {
@@ -208,18 +210,20 @@ class IntegrationManager {
208
210
  [];
209
211
  if (integrationShipmentDetails) {
210
212
  const shipmentContentFromDetails = yield Promise.all(integrationShipmentDetails.map((detail) => __awaiter(this, void 0, void 0, function* () {
211
- const taric = yield llmAPIService.getTaricCode('chatgpt', detail.bulto.nombre_producto || '');
213
+ const taric = detail.bulto.nombre_producto
214
+ ? yield llmAPIService.getTaricCode('chatgpt', detail.bulto.nombre_producto)
215
+ : null;
212
216
  return {
213
217
  id_usuario: idUsuario,
214
218
  contenido: detail.bulto.nombre_producto,
215
219
  valor: detail.bulto.valor || getRandomContentValue(),
216
220
  dni: user.dni,
217
- taric: JSON.stringify(this.dataToInsert.details),
221
+ taric,
218
222
  eori_importacion: user.eori_import,
219
223
  eori_exportacion: user.eori_export,
220
224
  peso_bruto: detail.bulto.peso,
221
225
  peso_neto: detail.bulto.peso,
222
- origen: 1, // Sacar del país de origen de la orden pendiente. Nombre de país en inglés.
226
+ origen: countryName,
223
227
  cantidad: detail.cantidad,
224
228
  reason_export: '1'
225
229
  };
package/index.ts CHANGED
@@ -111,6 +111,9 @@ export class IntegrationManager {
111
111
  warehouseId > 0
112
112
  ? await addressesService.getWarehouseAddress(idUsuario)
113
113
  : await addressesService.getAddress(addressId, idUsuario);
114
+ const country = await this.services.countriesService.getCountry(
115
+ sellerAddress.id_pais
116
+ );
114
117
 
115
118
  const allOrders = await fetchAllOrders();
116
119
  const filteredOrders =
@@ -194,7 +197,8 @@ export class IntegrationManager {
194
197
  user,
195
198
  tempShimpmentIds: successfullShipments.map(
196
199
  (successfullShipment) => successfullShipment.idEnvioTemporal
197
- )
200
+ ),
201
+ countryName: country.nombre_pais_en
198
202
  });
199
203
 
200
204
  // modificamos la agencia, cuando se tenga que hacer
@@ -230,10 +234,7 @@ export class IntegrationManager {
230
234
  this.dataToInsert.lines
231
235
  ),
232
236
  integrationsService.insertTempShipmentMultipleDetails(
233
- this.dataToInsert.details.map((detail) => ({
234
- ...detail,
235
- url_producto: JSON.stringify(this.dataToInsert.details)
236
- }))
237
+ this.dataToInsert.details
237
238
  ),
238
239
  integrationsService.insertTempShipmentMultipleContents(
239
240
  this.dataToInsert.contents
@@ -252,10 +253,12 @@ export class IntegrationManager {
252
253
 
253
254
  async insertUserDefaultConfigurationContent({
254
255
  user,
255
- tempShimpmentIds
256
+ tempShimpmentIds,
257
+ countryName
256
258
  }: {
257
259
  user: Record<string, string | number>;
258
260
  tempShimpmentIds: number[];
261
+ countryName: string;
259
262
  }) {
260
263
  const idUsuario = user.id_usuario as number;
261
264
  const { configurationService, llmAPIService } = this.services;
@@ -297,22 +300,24 @@ export class IntegrationManager {
297
300
  if (integrationShipmentDetails) {
298
301
  const shipmentContentFromDetails = await Promise.all(
299
302
  integrationShipmentDetails.map(async (detail) => {
300
- const taric = await llmAPIService.getTaricCode(
301
- 'chatgpt',
302
- detail.bulto.nombre_producto || ''
303
- );
303
+ const taric = detail.bulto.nombre_producto
304
+ ? await llmAPIService.getTaricCode(
305
+ 'chatgpt',
306
+ detail.bulto.nombre_producto
307
+ )
308
+ : null;
304
309
 
305
310
  return {
306
311
  id_usuario: idUsuario,
307
312
  contenido: detail.bulto.nombre_producto,
308
313
  valor: detail.bulto.valor || getRandomContentValue(),
309
314
  dni: user.dni,
310
- taric: JSON.stringify(this.dataToInsert.details),
315
+ taric,
311
316
  eori_importacion: user.eori_import,
312
317
  eori_exportacion: user.eori_export,
313
318
  peso_bruto: detail.bulto.peso,
314
319
  peso_neto: detail.bulto.peso,
315
- origen: 1, // Sacar del país de origen de la orden pendiente. Nombre de país en inglés.
320
+ origen: countryName,
316
321
  cantidad: detail.cantidad,
317
322
  reason_export: '1'
318
323
  } as UserDefaultConfigurationContent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cardus",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "description": "an integration manager",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/types/index.ts CHANGED
@@ -266,11 +266,17 @@ export type AddressesService = {
266
266
  getAddress: (addressId: number, idUsuario: number) => Promise<SellerAddress>;
267
267
  };
268
268
 
269
- type Country = { nombre_pais: string; id_pais?: number };
269
+ type Country = {
270
+ nombre_pais: string;
271
+ id_pais?: number;
272
+ nombre_pais_en: string;
273
+ };
270
274
  type Provincia = { nombre_provincia?: string };
271
275
  type Zone = string;
272
276
 
273
277
  export type CountriesService = {
278
+ getCountry: (id_pais: Country['id_pais']) => Promise<Country>;
279
+
274
280
  getCountryFromCountryCode: (
275
281
  countryCode: string
276
282
  ) => Promise<{ nombre_pais: string; id_pais?: number }>;
@@ -298,7 +304,7 @@ export type UserDefaultConfigurationContent = {
298
304
  eori_exportacion: string;
299
305
  peso_bruto: number;
300
306
  peso_neto: number;
301
- origen: number;
307
+ origen: string;
302
308
  cantidad: number;
303
309
  reason_export: '1' | '2' | '3' | '4' | '5';
304
310
  };