Merge pull request 'fix: refs #6184 Minor change' (!2031) from 6184-externalCmr into dev
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
Reviewed-on: #2031 Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
commit
bbb3f3807a
|
@ -342,5 +342,6 @@
|
|||
"Bank entity must be specified": "La entidad bancaria es obligatoria",
|
||||
"An email is necessary": "Es necesario un email",
|
||||
"You cannot update these fields": "No puedes actualizar estos campos",
|
||||
"CountryFK cannot be empty": "El país no puede estar vacío"
|
||||
"CountryFK cannot be empty": "El país no puede estar vacío",
|
||||
"Cmr file does not exist": "El archivo del cmr no existe"
|
||||
}
|
|
@ -34,8 +34,7 @@ module.exports = Self => {
|
|||
const myOptions = {userId: ctx.req.accessToken.userId};
|
||||
let tx;
|
||||
let ticket;
|
||||
let dms;
|
||||
let gestDocCreated;
|
||||
let externalTickets = [];
|
||||
|
||||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
@ -86,12 +85,11 @@ module.exports = Self => {
|
|||
contentType: 'image/png',
|
||||
hasFile: true
|
||||
};
|
||||
dms = await models.Dms.uploadFile(ctxUploadFile, myOptions);
|
||||
gestDocCreated = true;
|
||||
const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions);
|
||||
await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions);
|
||||
}
|
||||
|
||||
try {
|
||||
let externalTickets = [];
|
||||
for (const ticketId of tickets) {
|
||||
ticket = await models.Ticket.findById(ticketId, {
|
||||
include: [{
|
||||
|
@ -137,9 +135,8 @@ module.exports = Self => {
|
|||
throw new UserError('Ticket is already signed');
|
||||
|
||||
if (location) await setLocation(ticketId);
|
||||
if (!await hasSignDms(ticketId) && !gestDocCreated)
|
||||
if (!await hasSignDms(ticketId))
|
||||
await createGestDoc(ticketId);
|
||||
await models.TicketDms.create({ticketFk: ticketId, dmsFk: dms[0].id}, myOptions);
|
||||
await ticket.updateAttribute('isSigned', true, myOptions);
|
||||
|
||||
const deliveryState = await models.State.findOne({
|
||||
|
@ -157,11 +154,10 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
if (tx) await tx.commit();
|
||||
await models.Route.cmrEmail(ctx, externalTickets);
|
||||
return;
|
||||
} catch (e) {
|
||||
if (tx) await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
await models.Route.cmrEmail(ctx, externalTickets);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue