From 557c29982a24868be2b236938c7eaa323f141669 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 28 Nov 2024 16:23:37 +0100 Subject: [PATCH 1/3] feat: refs #7273 refs#7273 driverRouteEmail --- loopback/locale/en.json | 8 +++-- loopback/locale/es.json | 9 ++--- loopback/locale/fr.json | 12 ++++--- loopback/locale/pt.json | 6 ++-- .../back/methods/route/driverRouteEmail.js | 36 ++++++------------- 5 files changed, 32 insertions(+), 39 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 6756db37d..c692de22f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -244,7 +244,9 @@ "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", "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", - "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" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 0b10d4702..92db51288 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,7 +388,8 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "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", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta" -} - + "Sales already moved": "Ya han sido transferidas", + "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" +} \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 9941358be..36f094a03 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -362,9 +362,11 @@ "The invoices have been created but the PDFs could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré", "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", "Cannot send mail": "Impossible d'envoyer le mail", - "Original invoice not found": "Facture originale introuvable", - "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é", + "Original invoice not found": "Facture originale introuvable", + "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é", "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" +} \ No newline at end of file diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index e84b30f3d..6489a47dc 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -365,5 +365,7 @@ "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", "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" +} \ No newline at end of file diff --git a/modules/route/back/methods/route/driverRouteEmail.js b/modules/route/back/methods/route/driverRouteEmail.js index bbac2b0e8..9811da448 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -8,16 +8,8 @@ module.exports = Self => { arg: 'id', type: 'number', required: true, - description: 'The client id', + description: 'The route id', 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: { @@ -32,26 +24,20 @@ module.exports = Self => { Self.driverRouteEmail = async(ctx, id) => { const models = Self.app.models; - const {workerFk, agencyMode} = await Self.findById(id, { - fields: ['workerFk', 'agencyModeFk'], - include: {relation: 'agencyMode'} + const route = await models.Route.findById(id, { + fields: ['id', 'workerFk'] }); - const {reportMail} = agencyMode(); - let user; - let account; + if (!route.workerFk) throw new UserError('This route does not have a worker'); - if (workerFk) { - user = await models.VnUser.findById(workerFk, { - fields: ['active', 'id'], - include: {relation: 'emailUser'} - }); - account = await models.Account.findById(workerFk); - } + const user = await models.VnUser.findById(route.workerFk, { + fields: ['active', 'id'], + include: {relation: 'emailUser'} + }); - if (user?.active && account) ctx.args.recipient = user.emailUser().email; - else ctx.args.recipient = reportMail; + if (!user?.active) throw new UserError('The user is not active'); + 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'); }; }; -- 2.40.1 From 60aa4cc950174c0f0d3b0dd862222e812c4d37b3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 28 Nov 2024 16:33:14 +0100 Subject: [PATCH 2/3] feat: refs #7273 refs#7273 driverRouteEmail --- db/versions/11370-orangeRoebelini/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11370-orangeRoebelini/00-firstScript.sql diff --git a/db/versions/11370-orangeRoebelini/00-firstScript.sql b/db/versions/11370-orangeRoebelini/00-firstScript.sql new file mode 100644 index 000000000..29baf8046 --- /dev/null +++ b/db/versions/11370-orangeRoebelini/00-firstScript.sql @@ -0,0 +1,3 @@ + + +ALTER TABLE vn.agencyMode CHANGE reportMail reportMail__ varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL COMMENT '@deprecated 2024-11-28'; -- 2.40.1 From 4a61b5b9fe533cc78e21ecd1f66d71fd867d3175 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 29 Nov 2024 06:48:59 +0100 Subject: [PATCH 3/3] feat: refs #7273 refs#7273 driverRouteEmail --- db/dump/fixtures.before.sql | 2 +- db/routines/vn2008/views/Agencias.sql | 2 +- modules/zone/back/models/agency-mode.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e5d5f53dc..eaf3d14bf 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -317,7 +317,7 @@ UPDATE `vn`.`agencyMode` SET `description` = 'Gotham247Expensive' WHERE `id` = 8 UPDATE `vn`.`agencyMode` SET `description` = 'Other agency' WHERE `id` = 10; UPDATE `vn`.`agencyMode` SET `description` = 'Refund' WHERE `id` = 23; -UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com'; +UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail__` = 'no-reply@gothamcity.com'; UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; diff --git a/db/routines/vn2008/views/Agencias.sql b/db/routines/vn2008/views/Agencias.sql index 1176d02c4..c719a24e8 100644 --- a/db/routines/vn2008/views/Agencias.sql +++ b/db/routines/vn2008/views/Agencias.sql @@ -10,7 +10,7 @@ AS SELECT `am`.`id` AS `Id_Agencia`, `am`.`agencyFk` AS `agency_id`, `am`.`inflation` AS `inflacion`, `am`.`isVolumetric` AS `is_volumetric`, - `am`.`reportMail` AS `send_mail`, + `am`.`reportMail__` AS `send_mail`, `am`.`isActive` AS `tpv`, `am`.`code` AS `code`, `am`.`isRiskFree` AS `isRiskFree` diff --git a/modules/zone/back/models/agency-mode.json b/modules/zone/back/models/agency-mode.json index 6033e26c6..9dddf814a 100644 --- a/modules/zone/back/models/agency-mode.json +++ b/modules/zone/back/models/agency-mode.json @@ -29,7 +29,7 @@ "inflation": { "type": "number" }, - "reportMail": { + "reportMail__": { "type": "string" }, "isActive": { -- 2.40.1