feat: refs #7273 refs#7273 driverRouteEmail

This commit is contained in:
Sergio De la torre 2024-11-28 16:23:37 +01:00
parent 699c6553a0
commit 557c29982a
5 changed files with 32 additions and 39 deletions

View File

@ -244,7 +244,9 @@
"You do not have permission to modify the booked field": "You do not have permission to modify the booked field", "You do not have permission to modify the booked field": "You do not have permission to modify the booked field",
"Invalid or expired verification code": "Invalid or expired verification code", "Invalid or expired verification code": "Invalid or expired verification code",
"ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}",
"The raid information is not correct": "The raid information is not correct",
"Payment method is required": "Payment method is required", "Payment method is required": "Payment method is required",
"Sales already moved": "Sales already moved" "The raid information is not correct": "The raid information is not correct",
"Sales already moved": "Sales already moved",
"This route does not have a worker": "This route does not have a worker",
"This user is not active": "This user is not active"
} }

View File

@ -389,6 +389,7 @@
"ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}",
"The web user's email already exists": "El correo del usuario web ya existe", "The web user's email already exists": "El correo del usuario web ya existe",
"Sales already moved": "Ya han sido transferidas", "Sales already moved": "Ya han sido transferidas",
"The raid information is not correct": "La información de la redada no es correcta" "The raid information is not correct": "La información de la redada no es correcta",
"This route does not have a worker": "La ruta no tiene trabajador",
"This user is not active": "El usuario no está activo"
} }

View File

@ -366,5 +366,7 @@
"The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne",
"You do not have permission to modify the booked field": "Vous n'avez pas la permission de modifier le champ comptabilisé", "You do not have permission to modify the booked field": "Vous n'avez pas la permission de modifier le champ comptabilisé",
"ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}", "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}",
"The web user's email already exists": "L'email de l'internaute existe déjà" "The web user's email already exists": "L'email de l'internaute existe déjà",
"This route does not have a worker": "Cet itinéraire n'a pas de travailleur.",
"This user is not active": "Cet utilisateur n'est pas actif"
} }

View File

@ -365,5 +365,7 @@
"Cannot send mail": "Não é possível enviar o email", "Cannot send mail": "Não é possível enviar o email",
"The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha",
"ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}", "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}",
"The web user's email already exists": "O e-mail do utilizador da web já existe." "The web user's email already exists": "O e-mail do utilizador da web já existe.",
"This route does not have a worker": "Esta rota não tem trabalhador.",
"This user is not active": "Este utilizador não está ativo"
} }

View File

@ -8,16 +8,8 @@ module.exports = Self => {
arg: 'id', arg: 'id',
type: 'number', type: 'number',
required: true, required: true,
description: 'The client id', description: 'The route id',
http: {source: 'path'} http: {source: 'path'}
}, {
arg: 'replyTo',
type: 'string',
description: 'The sender email to reply to',
}, {
arg: 'recipientId',
type: 'number',
description: 'The recipient id to send to the recipient preferred language',
} }
], ],
returns: { returns: {
@ -32,26 +24,20 @@ module.exports = Self => {
Self.driverRouteEmail = async(ctx, id) => { Self.driverRouteEmail = async(ctx, id) => {
const models = Self.app.models; const models = Self.app.models;
const {workerFk, agencyMode} = await Self.findById(id, { const route = await models.Route.findById(id, {
fields: ['workerFk', 'agencyModeFk'], fields: ['id', 'workerFk']
include: {relation: 'agencyMode'}
}); });
const {reportMail} = agencyMode(); if (!route.workerFk) throw new UserError('This route does not have a worker');
let user;
let account;
if (workerFk) { const user = await models.VnUser.findById(route.workerFk, {
user = await models.VnUser.findById(workerFk, {
fields: ['active', 'id'], fields: ['active', 'id'],
include: {relation: 'emailUser'} include: {relation: 'emailUser'}
}); });
account = await models.Account.findById(workerFk);
}
if (user?.active && account) ctx.args.recipient = user.emailUser().email; if (!user?.active) throw new UserError('The user is not active');
else ctx.args.recipient = reportMail; ctx.args.recipient = user.emailUser().email;
ctx.args.recipientId = route.workerFk;
if (!ctx.args.recipient) throw new UserError('An email is necessary');
return Self.sendTemplate(ctx, 'driver-route'); return Self.sendTemplate(ctx, 'driver-route');
}; };
}; };