cardus 0.0.56 → 0.0.59
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 +17 -11
- package/index.ts +52 -38
- package/package.json +1 -1
- package/types/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -83,7 +83,7 @@ class IntegrationManager {
|
|
|
83
83
|
this.getAgencyIdForTempShipment = params.getAgencyIdForTempShipment;
|
|
84
84
|
}
|
|
85
85
|
insertTempShipments(_a) {
|
|
86
|
-
return __awaiter(this, arguments, void 0, function* ({ payload: { idUsuario, agencyId, addressId, warehouseId, group }, fetchAllOrders, crearBulto, modificarOrdenOriginal }) {
|
|
86
|
+
return __awaiter(this, arguments, void 0, function* ({ payload: { idUsuario, agencyId, addressId, warehouseId, group, sequentialInsertion = false }, fetchAllOrders, crearBulto, modificarOrdenOriginal }) {
|
|
87
87
|
const user = yield this.services.usersService.obtenerUsuarioId(idUsuario);
|
|
88
88
|
const { integrationsService, addressesService } = this.services;
|
|
89
89
|
// esto hay que pasarlo ya en los parametros
|
|
@@ -134,7 +134,7 @@ class IntegrationManager {
|
|
|
134
134
|
return Object.assign(parsedOrder, { idEnvioTemporal, agencyId });
|
|
135
135
|
}),
|
|
136
136
|
regularExecutionTime: 8000, // ms
|
|
137
|
-
initialBatchQuantity: 5 // de cinco en cinco
|
|
137
|
+
initialBatchQuantity: sequentialInsertion ? 1 : 5 // si la insercion no es secuencial, de cinco en cinco
|
|
138
138
|
}).upload();
|
|
139
139
|
const successfullShipments = insertOrdersResult
|
|
140
140
|
.filter(Boolean)
|
|
@@ -151,7 +151,7 @@ class IntegrationManager {
|
|
|
151
151
|
tempShimpmentIds: successfullShipments.map((successfullShipment) => successfullShipment.idEnvioTemporal)
|
|
152
152
|
});
|
|
153
153
|
// modificamos la agencia, cuando se tenga que hacer
|
|
154
|
-
successfullShipments.
|
|
154
|
+
yield Promise.allSettled(successfullShipments.map((order) => __awaiter(this, void 0, void 0, function* () {
|
|
155
155
|
const shipmentDetails = this.dataToInsert.details.filter(({ id_envio }) => {
|
|
156
156
|
return id_envio === order.idEnvioTemporal;
|
|
157
157
|
});
|
|
@@ -164,18 +164,24 @@ class IntegrationManager {
|
|
|
164
164
|
shipmentDetails
|
|
165
165
|
});
|
|
166
166
|
if (newAgencyId !== order.agencyId) {
|
|
167
|
-
integrationsService.updateTempShimpment({
|
|
167
|
+
yield integrationsService.updateTempShimpment({
|
|
168
168
|
id_envio: order.idEnvioTemporal,
|
|
169
169
|
id_usuario: idUsuario,
|
|
170
170
|
id_agencia: newAgencyId
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
|
-
}));
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
})));
|
|
174
|
+
yield Promise.allSettled([
|
|
175
|
+
integrationsService.insertTempShipmentMultipleLines(this.dataToInsert.lines),
|
|
176
|
+
integrationsService.insertTempShipmentMultipleDetails(this.dataToInsert.details),
|
|
177
|
+
integrationsService.insertTempShipmentMultipleContents(this.dataToInsert.contents),
|
|
178
|
+
integrationsService.insertTempShipmentMultipleExternals(this.dataToInsert.externals)
|
|
179
|
+
]);
|
|
180
|
+
return {
|
|
181
|
+
filteredOrders,
|
|
182
|
+
insertedTempShipments: successfullShipments,
|
|
183
|
+
sequentialInsertion
|
|
184
|
+
};
|
|
179
185
|
});
|
|
180
186
|
}
|
|
181
187
|
insertUserDefaultConfigurationContent(_a) {
|
|
@@ -197,7 +203,7 @@ class IntegrationManager {
|
|
|
197
203
|
const userFakeData = configurationService.getFakeDefaultProformaConfiguration(idUsuario, user.dni);
|
|
198
204
|
userConfiguration = userFakeData;
|
|
199
205
|
}
|
|
200
|
-
if (userConfiguration
|
|
206
|
+
if (userConfiguration) {
|
|
201
207
|
tempShimpmentIds.forEach((tempShimpmentId) => {
|
|
202
208
|
if (userConfiguration) {
|
|
203
209
|
insert(userConfiguration, tempShimpmentId);
|
package/index.ts
CHANGED
|
@@ -88,7 +88,14 @@ export class IntegrationManager {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
async insertTempShipments({
|
|
91
|
-
payload: {
|
|
91
|
+
payload: {
|
|
92
|
+
idUsuario,
|
|
93
|
+
agencyId,
|
|
94
|
+
addressId,
|
|
95
|
+
warehouseId,
|
|
96
|
+
group,
|
|
97
|
+
sequentialInsertion = false
|
|
98
|
+
},
|
|
92
99
|
fetchAllOrders,
|
|
93
100
|
crearBulto,
|
|
94
101
|
modificarOrdenOriginal
|
|
@@ -161,7 +168,7 @@ export class IntegrationManager {
|
|
|
161
168
|
return Object.assign(parsedOrder, { idEnvioTemporal, agencyId });
|
|
162
169
|
},
|
|
163
170
|
regularExecutionTime: 8000, // ms
|
|
164
|
-
initialBatchQuantity: 5 // de cinco en cinco
|
|
171
|
+
initialBatchQuantity: sequentialInsertion ? 1 : 5 // si la insercion no es secuencial, de cinco en cinco
|
|
165
172
|
}).upload();
|
|
166
173
|
|
|
167
174
|
const successfullShipments = insertOrdersResult
|
|
@@ -187,46 +194,53 @@ export class IntegrationManager {
|
|
|
187
194
|
});
|
|
188
195
|
|
|
189
196
|
// modificamos la agencia, cuando se tenga que hacer
|
|
197
|
+
await Promise.allSettled(
|
|
198
|
+
successfullShipments.map(async (order) => {
|
|
199
|
+
const shipmentDetails = this.dataToInsert.details.filter(
|
|
200
|
+
({ id_envio }) => {
|
|
201
|
+
return id_envio === order.idEnvioTemporal;
|
|
202
|
+
}
|
|
203
|
+
);
|
|
190
204
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
const newAgencyId = await this.getAgencyIdForTempShipment({
|
|
199
|
-
defaultAgencyId: agencyId,
|
|
200
|
-
userId: idUsuario,
|
|
201
|
-
integrationId: this.integrationType,
|
|
202
|
-
tempShipmentData: order,
|
|
203
|
-
sellerAddress,
|
|
204
|
-
shipmentDetails
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
if (newAgencyId !== order.agencyId) {
|
|
208
|
-
integrationsService.updateTempShimpment({
|
|
209
|
-
id_envio: order.idEnvioTemporal,
|
|
210
|
-
id_usuario: idUsuario,
|
|
211
|
-
id_agencia: newAgencyId
|
|
205
|
+
const newAgencyId = await this.getAgencyIdForTempShipment({
|
|
206
|
+
defaultAgencyId: agencyId,
|
|
207
|
+
userId: idUsuario,
|
|
208
|
+
integrationId: this.integrationType,
|
|
209
|
+
tempShipmentData: order,
|
|
210
|
+
sellerAddress,
|
|
211
|
+
shipmentDetails
|
|
212
212
|
});
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
213
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
);
|
|
225
|
-
integrationsService.insertTempShipmentMultipleExternals(
|
|
226
|
-
this.dataToInsert.externals
|
|
214
|
+
if (newAgencyId !== order.agencyId) {
|
|
215
|
+
await integrationsService.updateTempShimpment({
|
|
216
|
+
id_envio: order.idEnvioTemporal,
|
|
217
|
+
id_usuario: idUsuario,
|
|
218
|
+
id_agencia: newAgencyId
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
})
|
|
227
222
|
);
|
|
228
223
|
|
|
229
|
-
|
|
224
|
+
await Promise.allSettled([
|
|
225
|
+
integrationsService.insertTempShipmentMultipleLines(
|
|
226
|
+
this.dataToInsert.lines
|
|
227
|
+
),
|
|
228
|
+
integrationsService.insertTempShipmentMultipleDetails(
|
|
229
|
+
this.dataToInsert.details
|
|
230
|
+
),
|
|
231
|
+
integrationsService.insertTempShipmentMultipleContents(
|
|
232
|
+
this.dataToInsert.contents
|
|
233
|
+
),
|
|
234
|
+
integrationsService.insertTempShipmentMultipleExternals(
|
|
235
|
+
this.dataToInsert.externals
|
|
236
|
+
)
|
|
237
|
+
]);
|
|
238
|
+
|
|
239
|
+
return {
|
|
240
|
+
filteredOrders,
|
|
241
|
+
insertedTempShipments: successfullShipments,
|
|
242
|
+
sequentialInsertion
|
|
243
|
+
};
|
|
230
244
|
}
|
|
231
245
|
|
|
232
246
|
async insertUserDefaultConfigurationContent({
|
|
@@ -265,7 +279,7 @@ export class IntegrationManager {
|
|
|
265
279
|
);
|
|
266
280
|
userConfiguration = userFakeData;
|
|
267
281
|
}
|
|
268
|
-
if (userConfiguration
|
|
282
|
+
if (userConfiguration) {
|
|
269
283
|
tempShimpmentIds.forEach((tempShimpmentId) => {
|
|
270
284
|
if (userConfiguration) {
|
|
271
285
|
insert(userConfiguration, tempShimpmentId);
|
package/package.json
CHANGED