cardus 0.0.12 → 0.0.14
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 +33 -1
- package/index.ts +66 -2
- package/package.json +1 -1
- package/types/index.ts +36 -0
package/dist/index.js
CHANGED
|
@@ -77,7 +77,9 @@ class IntegrationManager {
|
|
|
77
77
|
this.services = {
|
|
78
78
|
integrationsService: params.integrationsService,
|
|
79
79
|
addressesService: params.addressesService,
|
|
80
|
-
countriesService: params.countriesService
|
|
80
|
+
countriesService: params.countriesService,
|
|
81
|
+
configurationsService: params.configurationService,
|
|
82
|
+
usersService: params.userService
|
|
81
83
|
};
|
|
82
84
|
this.shipmentType = params.shipmentType;
|
|
83
85
|
this.type = params.type;
|
|
@@ -129,9 +131,39 @@ class IntegrationManager {
|
|
|
129
131
|
crearBulto,
|
|
130
132
|
estaAgrupado
|
|
131
133
|
});
|
|
134
|
+
yield this.insertUserDefaultConfigurationContent({
|
|
135
|
+
idUsuario,
|
|
136
|
+
tempShimpmentIds: successfullShipments.map((successfullShipment) => successfullShipment.idEnvioTemporal)
|
|
137
|
+
});
|
|
132
138
|
return filteredOrders;
|
|
133
139
|
});
|
|
134
140
|
}
|
|
141
|
+
insertUserDefaultConfigurationContent(_a) {
|
|
142
|
+
return __awaiter(this, arguments, void 0, function* ({ idUsuario, tempShimpmentIds }) {
|
|
143
|
+
const { usersService, configurationsService, integrationsService } = this.services;
|
|
144
|
+
const insert = (data, tempShimpmentId) => __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
return Promise.allSettled(data.map((tempContent) => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
yield integrationsService.insertTempContent(Object.assign(Object.assign({}, tempContent), { id_envio: tempShimpmentId }));
|
|
147
|
+
})));
|
|
148
|
+
});
|
|
149
|
+
const insertOrdersResult = yield new this.executionManager({
|
|
150
|
+
arrayParams: tempShimpmentIds,
|
|
151
|
+
executable: (order) => __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const userSavedData = (yield configurationsService.getDefaultProformaConfiguration(idUsuario)) || [];
|
|
153
|
+
if (userSavedData.length > 0) {
|
|
154
|
+
yield insert(userSavedData, order);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const user = yield usersService.obtenerUsuarioId(idUsuario);
|
|
158
|
+
const userFakeData = configurationsService.getFakeDefaultProformaConfiguration(idUsuario, user.dni);
|
|
159
|
+
yield insert(userFakeData, order);
|
|
160
|
+
}
|
|
161
|
+
}),
|
|
162
|
+
regularExecutionTime: 100, // ms
|
|
163
|
+
initialBatchQuantity: 5 // de cinco en cinco
|
|
164
|
+
}).upload();
|
|
165
|
+
});
|
|
166
|
+
}
|
|
135
167
|
insertQuantityRelatedLines(_a) {
|
|
136
168
|
return __awaiter(this, arguments, void 0, function* ({ orders, idUsuario, crearBulto, estaAgrupado }) {
|
|
137
169
|
const { integrationsService } = this.services;
|
package/index.ts
CHANGED
|
@@ -9,18 +9,23 @@ import {
|
|
|
9
9
|
InsertParams,
|
|
10
10
|
CountriesService,
|
|
11
11
|
AddressesService,
|
|
12
|
+
ConfigurationsService,
|
|
13
|
+
UsersService,
|
|
12
14
|
IntegrationsService,
|
|
13
15
|
Type,
|
|
14
16
|
SellerAddress,
|
|
15
17
|
OriginalOrder,
|
|
16
18
|
ModifiedOrder,
|
|
17
|
-
ShipmentType
|
|
19
|
+
ShipmentType,
|
|
20
|
+
UserDefaultConfigurationContent
|
|
18
21
|
} from './types';
|
|
19
22
|
|
|
20
23
|
interface Services {
|
|
21
24
|
integrationsService: IntegrationsService;
|
|
22
25
|
addressesService: AddressesService;
|
|
23
26
|
countriesService: CountriesService;
|
|
27
|
+
configurationsService: ConfigurationsService;
|
|
28
|
+
usersService: UsersService;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
export class IntegrationManager {
|
|
@@ -34,6 +39,8 @@ export class IntegrationManager {
|
|
|
34
39
|
integrationsService: IntegrationsService;
|
|
35
40
|
addressesService: AddressesService;
|
|
36
41
|
countriesService: CountriesService;
|
|
42
|
+
configurationService: ConfigurationsService;
|
|
43
|
+
userService: UsersService;
|
|
37
44
|
type: Type;
|
|
38
45
|
shipmentType: ShipmentType;
|
|
39
46
|
executionManager: ExecutionManager;
|
|
@@ -42,7 +49,9 @@ export class IntegrationManager {
|
|
|
42
49
|
this.services = {
|
|
43
50
|
integrationsService: params.integrationsService,
|
|
44
51
|
addressesService: params.addressesService,
|
|
45
|
-
countriesService: params.countriesService
|
|
52
|
+
countriesService: params.countriesService,
|
|
53
|
+
configurationsService: params.configurationService,
|
|
54
|
+
usersService: params.userService
|
|
46
55
|
};
|
|
47
56
|
this.shipmentType = params.shipmentType;
|
|
48
57
|
this.type = params.type;
|
|
@@ -111,9 +120,64 @@ export class IntegrationManager {
|
|
|
111
120
|
estaAgrupado
|
|
112
121
|
});
|
|
113
122
|
|
|
123
|
+
await this.insertUserDefaultConfigurationContent({
|
|
124
|
+
idUsuario,
|
|
125
|
+
tempShimpmentIds: successfullShipments.map(
|
|
126
|
+
(successfullShipment) => successfullShipment.idEnvioTemporal
|
|
127
|
+
)
|
|
128
|
+
});
|
|
129
|
+
|
|
114
130
|
return filteredOrders;
|
|
115
131
|
}
|
|
116
132
|
|
|
133
|
+
async insertUserDefaultConfigurationContent({
|
|
134
|
+
idUsuario,
|
|
135
|
+
tempShimpmentIds
|
|
136
|
+
}: {
|
|
137
|
+
idUsuario: number;
|
|
138
|
+
tempShimpmentIds: number[];
|
|
139
|
+
}) {
|
|
140
|
+
const { usersService, configurationsService, integrationsService } =
|
|
141
|
+
this.services;
|
|
142
|
+
const insert = async (
|
|
143
|
+
data: UserDefaultConfigurationContent[],
|
|
144
|
+
tempShimpmentId: number
|
|
145
|
+
) => {
|
|
146
|
+
return Promise.allSettled(
|
|
147
|
+
data.map(async (tempContent) => {
|
|
148
|
+
await integrationsService.insertTempContent({
|
|
149
|
+
...tempContent,
|
|
150
|
+
id_envio: tempShimpmentId
|
|
151
|
+
});
|
|
152
|
+
})
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
const insertOrdersResult = await new this.executionManager({
|
|
156
|
+
arrayParams: tempShimpmentIds,
|
|
157
|
+
executable: async (order: any) => {
|
|
158
|
+
const userSavedData =
|
|
159
|
+
(await configurationsService.getDefaultProformaConfiguration(
|
|
160
|
+
idUsuario
|
|
161
|
+
)) || [];
|
|
162
|
+
|
|
163
|
+
if (userSavedData.length > 0) {
|
|
164
|
+
await insert(userSavedData, order);
|
|
165
|
+
} else {
|
|
166
|
+
const user = await usersService.obtenerUsuarioId(idUsuario);
|
|
167
|
+
const userFakeData =
|
|
168
|
+
configurationsService.getFakeDefaultProformaConfiguration(
|
|
169
|
+
idUsuario,
|
|
170
|
+
user.dni
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
await insert(userFakeData, order);
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
regularExecutionTime: 100, // ms
|
|
177
|
+
initialBatchQuantity: 5 // de cinco en cinco
|
|
178
|
+
}).upload();
|
|
179
|
+
}
|
|
180
|
+
|
|
117
181
|
insertOrder = async ({
|
|
118
182
|
order,
|
|
119
183
|
agencyId,
|
package/package.json
CHANGED
package/types/index.ts
CHANGED
|
@@ -162,6 +162,9 @@ export type IntegrationsService = {
|
|
|
162
162
|
id_envio: number;
|
|
163
163
|
bulto: Bulto['bulto'];
|
|
164
164
|
}) => Promise<undefined>;
|
|
165
|
+
insertTempContent: (
|
|
166
|
+
params: UserDefaultConfigurationContent & { id_envio: number }
|
|
167
|
+
) => Promise<number | false>;
|
|
165
168
|
};
|
|
166
169
|
|
|
167
170
|
export type SellerAddress = {
|
|
@@ -202,6 +205,39 @@ export type CountriesService = {
|
|
|
202
205
|
) => Promise<Zone>;
|
|
203
206
|
};
|
|
204
207
|
|
|
208
|
+
export type UserDefaultConfigurationContent = {
|
|
209
|
+
id_usuario: number;
|
|
210
|
+
contenido: string;
|
|
211
|
+
valor: number;
|
|
212
|
+
dni: string;
|
|
213
|
+
taric: string;
|
|
214
|
+
eori_importacion: string;
|
|
215
|
+
eori_exportacion: string;
|
|
216
|
+
peso_bruto: number;
|
|
217
|
+
peso_neto: number;
|
|
218
|
+
origen: number;
|
|
219
|
+
cantidad: number;
|
|
220
|
+
reason_export: '1' | '2' | '3' | '4' | '5';
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
type User = {
|
|
224
|
+
dni: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
export type ConfigurationsService = {
|
|
228
|
+
getDefaultProformaConfiguration: (
|
|
229
|
+
id_usuario: number
|
|
230
|
+
) => Promise<UserDefaultConfigurationContent[] | false>;
|
|
231
|
+
getFakeDefaultProformaConfiguration: (
|
|
232
|
+
id_usuario: number,
|
|
233
|
+
dni: string
|
|
234
|
+
) => UserDefaultConfigurationContent[];
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export type UsersService = {
|
|
238
|
+
obtenerUsuarioId: (id_usuario: number) => Promise<User>;
|
|
239
|
+
};
|
|
240
|
+
|
|
205
241
|
export type FindNextPickupDate = (params: {
|
|
206
242
|
fecha?: string;
|
|
207
243
|
cp_salida: string;
|