cardus 0.0.71 → 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 +10 -6
- package/index.ts +17 -13
- package/package.json +1 -1
- package/types/index.ts +8 -2
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
|
|
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,10 +210,12 @@ 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 =
|
|
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
|
-
contenido:
|
|
218
|
+
contenido: detail.bulto.nombre_producto,
|
|
215
219
|
valor: detail.bulto.valor || getRandomContentValue(),
|
|
216
220
|
dni: user.dni,
|
|
217
221
|
taric,
|
|
@@ -219,7 +223,7 @@ class IntegrationManager {
|
|
|
219
223
|
eori_exportacion: user.eori_export,
|
|
220
224
|
peso_bruto: detail.bulto.peso,
|
|
221
225
|
peso_neto: detail.bulto.peso,
|
|
222
|
-
origen:
|
|
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,11 +234,7 @@ export class IntegrationManager {
|
|
|
230
234
|
this.dataToInsert.lines
|
|
231
235
|
),
|
|
232
236
|
integrationsService.insertTempShipmentMultipleDetails(
|
|
233
|
-
this.dataToInsert.details
|
|
234
|
-
...detail,
|
|
235
|
-
url_producto: JSON.stringify(this.dataToInsert.details),
|
|
236
|
-
ski_producto: 'AAAAA'
|
|
237
|
-
}))
|
|
237
|
+
this.dataToInsert.details
|
|
238
238
|
),
|
|
239
239
|
integrationsService.insertTempShipmentMultipleContents(
|
|
240
240
|
this.dataToInsert.contents
|
|
@@ -253,10 +253,12 @@ export class IntegrationManager {
|
|
|
253
253
|
|
|
254
254
|
async insertUserDefaultConfigurationContent({
|
|
255
255
|
user,
|
|
256
|
-
tempShimpmentIds
|
|
256
|
+
tempShimpmentIds,
|
|
257
|
+
countryName
|
|
257
258
|
}: {
|
|
258
259
|
user: Record<string, string | number>;
|
|
259
260
|
tempShimpmentIds: number[];
|
|
261
|
+
countryName: string;
|
|
260
262
|
}) {
|
|
261
263
|
const idUsuario = user.id_usuario as number;
|
|
262
264
|
const { configurationService, llmAPIService } = this.services;
|
|
@@ -298,14 +300,16 @@ export class IntegrationManager {
|
|
|
298
300
|
if (integrationShipmentDetails) {
|
|
299
301
|
const shipmentContentFromDetails = await Promise.all(
|
|
300
302
|
integrationShipmentDetails.map(async (detail) => {
|
|
301
|
-
const taric =
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
303
|
+
const taric = detail.bulto.nombre_producto
|
|
304
|
+
? await llmAPIService.getTaricCode(
|
|
305
|
+
'chatgpt',
|
|
306
|
+
detail.bulto.nombre_producto
|
|
307
|
+
)
|
|
308
|
+
: null;
|
|
305
309
|
|
|
306
310
|
return {
|
|
307
311
|
id_usuario: idUsuario,
|
|
308
|
-
contenido:
|
|
312
|
+
contenido: detail.bulto.nombre_producto,
|
|
309
313
|
valor: detail.bulto.valor || getRandomContentValue(),
|
|
310
314
|
dni: user.dni,
|
|
311
315
|
taric,
|
|
@@ -313,7 +317,7 @@ export class IntegrationManager {
|
|
|
313
317
|
eori_exportacion: user.eori_export,
|
|
314
318
|
peso_bruto: detail.bulto.peso,
|
|
315
319
|
peso_neto: detail.bulto.peso,
|
|
316
|
-
origen:
|
|
320
|
+
origen: countryName,
|
|
317
321
|
cantidad: detail.cantidad,
|
|
318
322
|
reason_export: '1'
|
|
319
323
|
} as UserDefaultConfigurationContent;
|
package/package.json
CHANGED
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 = {
|
|
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:
|
|
307
|
+
origen: string;
|
|
302
308
|
cantidad: number;
|
|
303
309
|
reason_export: '1' | '2' | '3' | '4' | '5';
|
|
304
310
|
};
|