cardus 0.0.108 → 0.0.111
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/__tests__/insertTempShipments.test.ts +1 -1
- package/dist/__tests__/insertTempShipments.test.js +1 -1
- package/dist/index.js +18 -17
- package/index.ts +33 -26
- package/package.json +1 -1
- package/types/index.ts +3 -3
|
@@ -376,7 +376,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
376
376
|
expect(addressesService.getAddress).not.toHaveBeenCalledWith(10, 77);
|
|
377
377
|
});
|
|
378
378
|
|
|
379
|
-
it('uses sellerAddress from the order when addressId is not provided', async () => {
|
|
379
|
+
it('uses sellerAddress from the order when addressId is not provided ', async () => {
|
|
380
380
|
const { manager, addressesService, integrationsService } = buildFixture();
|
|
381
381
|
arrangeDefaultStubs({ manager, shipmentId: 12345 });
|
|
382
382
|
|
|
@@ -316,7 +316,7 @@ describe('IntegrationManager.insertTempShipments', () => {
|
|
|
316
316
|
expect(addressesService.getWarehouseAddress).toHaveBeenCalledWith(77);
|
|
317
317
|
expect(addressesService.getAddress).not.toHaveBeenCalledWith(10, 77);
|
|
318
318
|
}));
|
|
319
|
-
it('uses sellerAddress from the order when addressId is not provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
319
|
+
it('uses sellerAddress from the order when addressId is not provided ', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
320
320
|
const { manager, addressesService, integrationsService } = buildFixture();
|
|
321
321
|
arrangeDefaultStubs({ manager, shipmentId: 12345 });
|
|
322
322
|
yield manager.insertTempShipments({
|
package/dist/index.js
CHANGED
|
@@ -103,11 +103,10 @@ class IntegrationManager {
|
|
|
103
103
|
if (parsedOrder.direccionSalidaId) {
|
|
104
104
|
direccionSalida = yield addressesService.getAddress(parsedOrder.direccionSalidaId, idUsuario);
|
|
105
105
|
}
|
|
106
|
-
const currentSellerAddress = (_b = direccionSalida !== null && direccionSalida !== void 0 ? direccionSalida : parsedOrder.
|
|
106
|
+
const currentSellerAddress = (_b = direccionSalida !== null && direccionSalida !== void 0 ? direccionSalida : parsedOrder.direccionSalidaPersonalizada) !== null && _b !== void 0 ? _b : defaultSellerAddress;
|
|
107
107
|
if (!currentSellerAddress) {
|
|
108
108
|
throw new Error('Seller address could not be resolved');
|
|
109
109
|
}
|
|
110
|
-
sellerAddressForContents !== null && sellerAddressForContents !== void 0 ? sellerAddressForContents : (sellerAddressForContents = currentSellerAddress);
|
|
111
110
|
const tempShipmentData = yield (0, insertTempShipment_1.cookTempShipment)({
|
|
112
111
|
order: parsedOrder,
|
|
113
112
|
shipmentType: this.shipmentType,
|
|
@@ -193,6 +192,13 @@ class IntegrationManager {
|
|
|
193
192
|
});
|
|
194
193
|
// details
|
|
195
194
|
this.dataToInsert.details.push(...shipmentDetails);
|
|
195
|
+
const country = yield this.services.countriesService.getCountry(currentSellerAddress.id_pais);
|
|
196
|
+
// mete los contents
|
|
197
|
+
yield this.insertUserDefaultConfigurationContent({
|
|
198
|
+
user,
|
|
199
|
+
countryName: country.nombre_pais_en,
|
|
200
|
+
shipmentDetails
|
|
201
|
+
});
|
|
196
202
|
return Object.assign(parsedOrder, { idEnvioTemporal, agencyId });
|
|
197
203
|
}),
|
|
198
204
|
regularExecutionTime: 8000, // ms
|
|
@@ -201,12 +207,6 @@ class IntegrationManager {
|
|
|
201
207
|
if (!sellerAddressForContents) {
|
|
202
208
|
throw new Error('Seller address could not be resolved');
|
|
203
209
|
}
|
|
204
|
-
const country = yield this.services.countriesService.getCountry(sellerAddressForContents.id_pais);
|
|
205
|
-
// content (dentro de esta funcion coge los detalles y evoluciona a partir de ahi)
|
|
206
|
-
yield this.insertUserDefaultConfigurationContent({
|
|
207
|
-
user,
|
|
208
|
-
countryName: country.nombre_pais_en
|
|
209
|
-
});
|
|
210
210
|
const arrayPackages = [...this.dataToInsert.lines.values()].flat().flat();
|
|
211
211
|
yield Promise.allSettled([
|
|
212
212
|
integrationsService.insertTempShipmentMultipleLines(arrayPackages),
|
|
@@ -227,7 +227,7 @@ class IntegrationManager {
|
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
insertUserDefaultConfigurationContent(_a) {
|
|
230
|
-
return __awaiter(this, arguments, void 0, function* ({ user, countryName }) {
|
|
230
|
+
return __awaiter(this, arguments, void 0, function* ({ user, countryName, shipmentDetails }) {
|
|
231
231
|
const idUsuario = user.id_usuario;
|
|
232
232
|
const { configurationService, llmAPIService } = this.services;
|
|
233
233
|
const insert = (data) => {
|
|
@@ -245,10 +245,8 @@ class IntegrationManager {
|
|
|
245
245
|
const getRandomContentValue = () => {
|
|
246
246
|
return Math.floor(Math.random() * 5) + 1;
|
|
247
247
|
};
|
|
248
|
-
const integrationShipmentDetails =
|
|
248
|
+
const integrationShipmentDetails = shipmentDetails;
|
|
249
249
|
let shipmentContent = null;
|
|
250
|
-
const userSavedData = (yield configurationService.getDefaultProformaConfiguration(idUsuario)) ||
|
|
251
|
-
[];
|
|
252
250
|
if (integrationShipmentDetails) {
|
|
253
251
|
const shipmentContentFromDetails = yield Promise.all(integrationShipmentDetails.map((detail) => __awaiter(this, void 0, void 0, function* () {
|
|
254
252
|
let taric = null;
|
|
@@ -281,12 +279,15 @@ class IntegrationManager {
|
|
|
281
279
|
})));
|
|
282
280
|
shipmentContent = shipmentContentFromDetails;
|
|
283
281
|
}
|
|
284
|
-
else if (userSavedData.length > 0) {
|
|
285
|
-
shipmentContent = userSavedData;
|
|
286
|
-
}
|
|
287
282
|
else {
|
|
288
|
-
const
|
|
289
|
-
|
|
283
|
+
const userSavedData = (yield configurationService.getDefaultProformaConfiguration(idUsuario)) || [];
|
|
284
|
+
if (userSavedData.length > 0) {
|
|
285
|
+
shipmentContent = userSavedData;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
const userFakeData = configurationService.getFakeDefaultProformaConfiguration(idUsuario, user.dni);
|
|
289
|
+
shipmentContent = userFakeData;
|
|
290
|
+
}
|
|
290
291
|
}
|
|
291
292
|
if (shipmentContent) {
|
|
292
293
|
shipmentContent = cleanContentData(shipmentContent);
|
package/index.ts
CHANGED
|
@@ -175,14 +175,14 @@ export class IntegrationManager {
|
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
177
|
const currentSellerAddress =
|
|
178
|
-
direccionSalida ??
|
|
178
|
+
direccionSalida ??
|
|
179
|
+
parsedOrder.direccionSalidaPersonalizada ??
|
|
180
|
+
defaultSellerAddress;
|
|
179
181
|
|
|
180
182
|
if (!currentSellerAddress) {
|
|
181
183
|
throw new Error('Seller address could not be resolved');
|
|
182
184
|
}
|
|
183
185
|
|
|
184
|
-
sellerAddressForContents ??= currentSellerAddress;
|
|
185
|
-
|
|
186
186
|
const tempShipmentData = await cookTempShipment({
|
|
187
187
|
order: parsedOrder,
|
|
188
188
|
shipmentType: this.shipmentType,
|
|
@@ -307,6 +307,17 @@ export class IntegrationManager {
|
|
|
307
307
|
// details
|
|
308
308
|
this.dataToInsert.details.push(...shipmentDetails);
|
|
309
309
|
|
|
310
|
+
const country = await this.services.countriesService.getCountry(
|
|
311
|
+
currentSellerAddress.id_pais
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
// mete los contents
|
|
315
|
+
await this.insertUserDefaultConfigurationContent({
|
|
316
|
+
user,
|
|
317
|
+
countryName: country.nombre_pais_en,
|
|
318
|
+
shipmentDetails
|
|
319
|
+
});
|
|
320
|
+
|
|
310
321
|
return Object.assign(parsedOrder, { idEnvioTemporal, agencyId });
|
|
311
322
|
},
|
|
312
323
|
regularExecutionTime: 8000, // ms
|
|
@@ -317,16 +328,6 @@ export class IntegrationManager {
|
|
|
317
328
|
throw new Error('Seller address could not be resolved');
|
|
318
329
|
}
|
|
319
330
|
|
|
320
|
-
const country = await this.services.countriesService.getCountry(
|
|
321
|
-
sellerAddressForContents.id_pais
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
// content (dentro de esta funcion coge los detalles y evoluciona a partir de ahi)
|
|
325
|
-
await this.insertUserDefaultConfigurationContent({
|
|
326
|
-
user,
|
|
327
|
-
countryName: country.nombre_pais_en
|
|
328
|
-
});
|
|
329
|
-
|
|
330
331
|
const arrayPackages = [...this.dataToInsert.lines.values()].flat().flat();
|
|
331
332
|
|
|
332
333
|
await Promise.allSettled([
|
|
@@ -362,10 +363,12 @@ export class IntegrationManager {
|
|
|
362
363
|
|
|
363
364
|
async insertUserDefaultConfigurationContent({
|
|
364
365
|
user,
|
|
365
|
-
countryName
|
|
366
|
+
countryName,
|
|
367
|
+
shipmentDetails
|
|
366
368
|
}: {
|
|
367
369
|
user: Record<string, string | number>;
|
|
368
370
|
countryName: string;
|
|
371
|
+
shipmentDetails: InsertContentShipmentDetail[];
|
|
369
372
|
}) {
|
|
370
373
|
const idUsuario = user.id_usuario as number;
|
|
371
374
|
const { configurationService, llmAPIService } = this.services;
|
|
@@ -396,11 +399,8 @@ export class IntegrationManager {
|
|
|
396
399
|
return Math.floor(Math.random() * 5) + 1;
|
|
397
400
|
};
|
|
398
401
|
|
|
399
|
-
const integrationShipmentDetails =
|
|
402
|
+
const integrationShipmentDetails = shipmentDetails;
|
|
400
403
|
let shipmentContent: UserDefaultConfigurationContent[] | null = null;
|
|
401
|
-
const userSavedData =
|
|
402
|
-
(await configurationService.getDefaultProformaConfiguration(idUsuario)) ||
|
|
403
|
-
[];
|
|
404
404
|
|
|
405
405
|
if (integrationShipmentDetails) {
|
|
406
406
|
const shipmentContentFromDetails = await Promise.all(
|
|
@@ -438,15 +438,22 @@ export class IntegrationManager {
|
|
|
438
438
|
);
|
|
439
439
|
|
|
440
440
|
shipmentContent = shipmentContentFromDetails;
|
|
441
|
-
} else if (userSavedData.length > 0) {
|
|
442
|
-
shipmentContent = userSavedData;
|
|
443
441
|
} else {
|
|
444
|
-
const
|
|
445
|
-
configurationService.
|
|
446
|
-
idUsuario
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
442
|
+
const userSavedData =
|
|
443
|
+
(await configurationService.getDefaultProformaConfiguration(
|
|
444
|
+
idUsuario
|
|
445
|
+
)) || [];
|
|
446
|
+
|
|
447
|
+
if (userSavedData.length > 0) {
|
|
448
|
+
shipmentContent = userSavedData;
|
|
449
|
+
} else {
|
|
450
|
+
const userFakeData =
|
|
451
|
+
configurationService.getFakeDefaultProformaConfiguration(
|
|
452
|
+
idUsuario,
|
|
453
|
+
user.dni as string
|
|
454
|
+
);
|
|
455
|
+
shipmentContent = userFakeData;
|
|
456
|
+
}
|
|
450
457
|
}
|
|
451
458
|
|
|
452
459
|
if (shipmentContent) {
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -123,7 +123,7 @@ export type ModifiedOrder = {
|
|
|
123
123
|
telefonoLLegada: string | undefined;
|
|
124
124
|
emailLLegada: string | undefined;
|
|
125
125
|
cantidadContrareembolso: number | null;
|
|
126
|
-
codigoEnvioExterno
|
|
126
|
+
codigoEnvioExterno?: string;
|
|
127
127
|
idInternoShopify?: string;
|
|
128
128
|
precio: number | null;
|
|
129
129
|
fechaCreacionExterna?: string | null;
|
|
@@ -139,7 +139,7 @@ export type ModifiedOrder = {
|
|
|
139
139
|
observacionesLLegada?: string;
|
|
140
140
|
observaciones?: string;
|
|
141
141
|
direccionSalidaId?: number | null;
|
|
142
|
-
|
|
142
|
+
direccionSalidaPersonalizada?: SellerAddress | null;
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
export interface ModifiedOrderExtended extends ModifiedOrder {
|
|
@@ -469,7 +469,7 @@ export type InsertContentShipmentDetail = {
|
|
|
469
469
|
|
|
470
470
|
type InsertContentShipmentExternal = {
|
|
471
471
|
id_envio_temporal_usuario: number;
|
|
472
|
-
codigo_envio_externo: string;
|
|
472
|
+
codigo_envio_externo: string | undefined;
|
|
473
473
|
id_usuario: number;
|
|
474
474
|
fecha_hora_creacion: string;
|
|
475
475
|
servicio: Type;
|