From 08728d3162dec76398ebcb7b5a029c30aa030cf3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 9 Feb 2024 07:51:51 +0100 Subject: [PATCH 1/6] refs #6651 feat:add urlImage --- db/routines/vn/procedures/itemShelving_get.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 98f865994..c6968e093 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -15,11 +15,13 @@ BEGIN p.code, ish.id, s.priority, - ish.isChecked + ish.isChecked, + CONCAT('http:', ic.url, '/catalog/200x200/', i.image) urlImage FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci LEFT JOIN parking p ON s.parkingFk = p.id + JOIN hedera.imageConfig ic WHERE ish.shelvingFk COLLATE utf8_unicode_ci = vSelf; END$$ DELIMITER ; From dcefc9d3822b6cb2f088614f91e1c184c6c5f775 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 9 Feb 2024 11:14:30 +0100 Subject: [PATCH 2/6] refs #6651 feat:add urlImage --- db/routines/vn/procedures/itemShelving_get.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index c6968e093..1be762f09 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -16,7 +16,7 @@ BEGIN ish.id, s.priority, ish.isChecked, - CONCAT('http:', ic.url, '/catalog/200x200/', i.image) urlImage + ic.url FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci From 4075375d6edd6542399d9ac98db9aad0b85f659b Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 9 Feb 2024 12:12:10 +0100 Subject: [PATCH 3/6] fix: refs #6379 get mail --- .../back/methods/route/driverRouteEmail.js | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/modules/route/back/methods/route/driverRouteEmail.js b/modules/route/back/methods/route/driverRouteEmail.js index 82b005e44..e4fd17b5f 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -9,24 +9,14 @@ module.exports = Self => { required: true, description: 'The client id', http: {source: 'path'} - }, - { - arg: 'recipient', - type: 'string', - description: 'The recipient email', - required: true, - }, - { + }, { arg: 'replyTo', type: 'string', description: 'The sender email to reply to', - required: false - }, - { + }, { arg: 'recipientId', type: 'number', description: 'The recipient id to send to the recipient preferred language', - required: false } ], returns: { @@ -39,5 +29,28 @@ module.exports = Self => { } }); - Self.driverRouteEmail = ctx => Self.sendTemplate(ctx, 'driver-route'); + Self.driverRouteEmail = async(ctx, id) => { + const models = Self.app.models; + const {workerFk, agencyMode} = await Self.findById(id, { + fields: ['workerFk', 'agencyModeFk'], + include: {relation: 'agencyMode'} + }); + const {reportMail} = agencyMode(); + let user; + let account; + + if (workerFk) { + user = await models.VnUser.findById(workerFk, { + fields: ['active', 'id'], + include: {relation: 'emailUser'} + }); + account = await models.Account.findById(workerFk); + } + + if (user?.active && !account) ctx.args.recipient = reportMail; + else if (user?.active && account) ctx.args.recipient = user.emailUser().email; + else // throws an error? + + Self.sendTemplate(ctx, 'driver-route'); + }; }; From e0de498f659733ec747b5cc0ac7cd865b55aac1d Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 9 Feb 2024 13:04:27 +0100 Subject: [PATCH 4/6] fix: refs #6379 add Error & locale --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 3 ++- modules/route/back/methods/route/driverRouteEmail.js | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 419775d1b..33db02516 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -206,5 +206,6 @@ "Incorrect pin": "Incorrect pin.", "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", "Name should be uppercase": "Name should be uppercase", - "You cannot update these fields": "You cannot update these fields" + "You cannot update these fields": "You cannot update these fields", + "CountryFK cannot be empty": "CountryFK cannot be empty" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index dac839085..42215edd6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -340,5 +340,6 @@ "Name should be uppercase": "El nombre debe ir en mayúscula", "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" + "You cannot update these fields": "No puedes actualizar estos campos", + "CountryFK cannot be empty": "CountryFK cannot be empty" } \ 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 e4fd17b5f..35814de3c 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('driverRouteEmail', { description: 'Sends the driver route email with an attached PDF', @@ -47,10 +48,10 @@ module.exports = Self => { account = await models.Account.findById(workerFk); } - if (user?.active && !account) ctx.args.recipient = reportMail; - else if (user?.active && account) ctx.args.recipient = user.emailUser().email; - else // throws an error? + if (user?.active && account) ctx.args.recipient = user.emailUser().email; + else ctx.args.recipient = reportMail; - Self.sendTemplate(ctx, 'driver-route'); + if (!ctx.args.recipient) throw new UserError('An email is necessary'); + Self.sendTemplate(ctx, 'driver-route'); }; }; From 362d825202e5ad3dc4a7ef9f4dd72246166c37dd Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 9 Feb 2024 13:38:09 +0100 Subject: [PATCH 5/6] fix: refs #6443 #6444 #6445 ChangeRevokeToGrant --- .../util/functions/accountNumberToIban.sql | 42 ++++++------- .../10866-whiteRaphis/00-firstScript.sql | 1 - .../10873-greenPaniculata/00-firstScript.sql | 61 ++++++++++++++++++- .../10879-maroonCymbidium/00-firstScript.sql | 34 +++++++++++ 4 files changed, 115 insertions(+), 23 deletions(-) delete mode 100644 db/versions/10866-whiteRaphis/00-firstScript.sql create mode 100644 db/versions/10879-maroonCymbidium/00-firstScript.sql diff --git a/db/routines/util/functions/accountNumberToIban.sql b/db/routines/util/functions/accountNumberToIban.sql index 2b38efe72..49d3c917e 100644 --- a/db/routines/util/functions/accountNumberToIban.sql +++ b/db/routines/util/functions/accountNumberToIban.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`( - vAccount VARCHAR(20) + vAccount VARCHAR(20) ) RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci DETERMINISTIC @@ -18,41 +18,41 @@ BEGIN CONCAT('ES', RIGHT( CONCAT(0, - 98-MOD( - CONCAT( - MOD( - CONCAT( - MOD( - CONCAT( - MOD( - SUBSTRING(vAccount, 1, 8), - 97 - ), - SUBSTRING(vAccount,9,8) + 98-MOD( + CONCAT( + MOD( + CONCAT( + MOD( + CONCAT( + MOD( + SUBSTRING(vAccount, 1, 8), + 97 + ), + SUBSTRING(vAccount,9,8) ), - 97 - ), + 97 + ), SUBSTRING( CONCAT(vAccount, 142800), 17, 8 ) ), - 97 - ), + 97 + ), SUBSTRING( CONCAT(vAccount, 142800), 25, 2 ) ), - 97 - ) + 97 + ) ), - 2 - ) + 2 + ) ) INTO vIban; - RETURN vIban; + RETURN vIban; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/10866-whiteRaphis/00-firstScript.sql b/db/versions/10866-whiteRaphis/00-firstScript.sql deleted file mode 100644 index bfbcb5dc9..000000000 --- a/db/versions/10866-whiteRaphis/00-firstScript.sql +++ /dev/null @@ -1 +0,0 @@ -REVOKE EXECUTE ON FUNCTION vn2008.red FROM hrBoss, salesPerson; diff --git a/db/versions/10873-greenPaniculata/00-firstScript.sql b/db/versions/10873-greenPaniculata/00-firstScript.sql index 59ab23944..3125eb7aa 100644 --- a/db/versions/10873-greenPaniculata/00-firstScript.sql +++ b/db/versions/10873-greenPaniculata/00-firstScript.sql @@ -1 +1,60 @@ -REVOKE EXECUTE ON FUNCTION vn2008.cc_to_iban FROM hr, financial; +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`accountNumberToIban`( + vAccount VARCHAR(20) +) + RETURNS varchar(4) CHARSET utf8mb3 COLLATE utf8mb3_general_ci + DETERMINISTIC +BEGIN +/** +* Calcula y genera el código IBAN correspondiente +* a un número de cuenta bancaria español. +* +* @param vAccount Número de cuenta bancaria +* @return vIban Código IBAN de 4 caracteres. +*/ + DECLARE vIban VARCHAR(4); + + SELECT + CONCAT('ES', + RIGHT( + CONCAT(0, + 98-MOD( + CONCAT( + MOD( + CONCAT( + MOD( + CONCAT( + MOD( + SUBSTRING(vAccount, 1, 8), + 97 + ), + SUBSTRING(vAccount,9,8) + ), + 97 + ), + SUBSTRING( + CONCAT(vAccount, 142800), + 17, + 8 + ) + ), + 97 + ), + SUBSTRING( + CONCAT(vAccount, 142800), + 25, + 2 + ) + ), + 97 + ) + ), + 2 + ) + ) INTO vIban; + + RETURN vIban; +END$$ +DELIMITER ; + +GRANT EXECUTE ON FUNCTION util.accountNumberToIban TO hr, financial; diff --git a/db/versions/10879-maroonCymbidium/00-firstScript.sql b/db/versions/10879-maroonCymbidium/00-firstScript.sql new file mode 100644 index 000000000..7efc4d6ab --- /dev/null +++ b/db/versions/10879-maroonCymbidium/00-firstScript.sql @@ -0,0 +1,34 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`intrastat_estimateNet`( + vSelf INT, + vStems INT +) + RETURNS double + DETERMINISTIC +BEGIN +/** +* Calcula un valor neto estimado en función de +* datos históricos de facturas intrastat. +* +* @param vSelf Id de intrastat +* @param vStems Número de unidades +* @return vNet +*/ + DECLARE vNet DOUBLE; + + SELECT ROUND(vStems / (SUM(average) / COUNT(average)), 2) INTO vNet + FROM ( + SELECT *, stems / net average + FROM invoiceInIntrastat + WHERE intrastatFk = vSelf + AND net + AND stems > 0 + ORDER BY dated DESC + LIMIT 20 + ) sub; + + RETURN vNet/2; +END$$ +DELIMITER ; + +GRANT EXECUTE ON FUNCTION vn.intrastat_estimateNet TO administrative; \ No newline at end of file From d60a95feaad736fb29fb0164c415c1c75e6a0359 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 12 Feb 2024 08:34:25 +0100 Subject: [PATCH 6/6] fix: refs #6379 await & locale --- loopback/locale/en.json | 2 +- loopback/locale/es.json | 2 +- modules/route/back/methods/route/driverRouteEmail.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 33db02516..39756a615 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -207,5 +207,5 @@ "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", "Name should be uppercase": "Name should be uppercase", "You cannot update these fields": "You cannot update these fields", - "CountryFK cannot be empty": "CountryFK cannot be empty" + "CountryFK cannot be empty": "Country cannot be empty" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 42215edd6..4f9a84b44 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -341,5 +341,5 @@ "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": "CountryFK cannot be empty" + "CountryFK cannot be empty": "El país no puede estar vacío" } \ 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 35814de3c..bbac2b0e8 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -52,6 +52,6 @@ module.exports = Self => { else ctx.args.recipient = reportMail; if (!ctx.args.recipient) throw new UserError('An email is necessary'); - Self.sendTemplate(ctx, 'driver-route'); + return Self.sendTemplate(ctx, 'driver-route'); }; };