From 534b5bb05a021488fac049abc411590caebc6976 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 12 Feb 2024 11:26:00 +0100 Subject: [PATCH 01/10] fix: refs #6106 where filter --- modules/route/back/methods/route/getTickets.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index d1ebf9ee7..59ba389ed 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -1,5 +1,5 @@ -const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; +const {ParameterizedSQL} = require('loopback-connector'); module.exports = Self => { Self.remoteMethod('getTickets', { @@ -83,13 +83,15 @@ module.exports = Self => { const where = filter.where; where['r.id'] = filter.id; + where.and = [{or: [ + {'t.packages': {gt: 0}}, + {and: [{'ot.code': 'delivery'}, {'tob.observationTypeFk': {neq: null}}]} + ]}]; stmt.merge(conn.makeWhere(filter.where)); stmt.merge(conn.makeGroupBy('t.id')); stmt.merge(conn.makeOrderBy(filter.order)); - const tickets = await conn.executeStmt(stmt, myOptions); - - return tickets; + return conn.executeStmt(stmt, myOptions); }; }; From a897a05e8b6a931b0288a67bf61964738cc170ca Mon Sep 17 00:00:00 2001 From: josepd Date: Tue, 13 Feb 2024 07:52:09 +0100 Subject: [PATCH 02/10] feat: refs#6685RestoreViewCredit --- db/routines/vn2008/views/credit.sql | 9 +++++++++ db/versions/10883-azureRuscus/00-firstScript.sql | 1 + 2 files changed, 10 insertions(+) create mode 100644 db/routines/vn2008/views/credit.sql create mode 100644 db/versions/10883-azureRuscus/00-firstScript.sql diff --git a/db/routines/vn2008/views/credit.sql b/db/routines/vn2008/views/credit.sql new file mode 100644 index 000000000..4bd3cef39 --- /dev/null +++ b/db/routines/vn2008/views/credit.sql @@ -0,0 +1,9 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`credit` +AS SELECT `c`.`id` AS `id`, + `c`.`clientFk` AS `Id_Cliente`, + `c`.`workerFk` AS `Id_Trabajador`, + `c`.`amount` AS `amount`, + `c`.`created` AS `odbc_date` +FROM `vn`.`clientCredit` `c` \ No newline at end of file diff --git a/db/versions/10883-azureRuscus/00-firstScript.sql b/db/versions/10883-azureRuscus/00-firstScript.sql new file mode 100644 index 000000000..8e046d95b --- /dev/null +++ b/db/versions/10883-azureRuscus/00-firstScript.sql @@ -0,0 +1 @@ +GRANT SELECT ON TABLE vn2008.credit TO financialBoss; \ No newline at end of file From 3b35e4dae89622a01a9fbd27426ae0f4f3389f02 Mon Sep 17 00:00:00 2001 From: josepd Date: Tue, 13 Feb 2024 08:57:49 +0100 Subject: [PATCH 03/10] refs#6685 RestoreViewCredit --- db/versions/10883-azureRuscus/00-firstScript.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/versions/10883-azureRuscus/00-firstScript.sql b/db/versions/10883-azureRuscus/00-firstScript.sql index 8e046d95b..89fdbf781 100644 --- a/db/versions/10883-azureRuscus/00-firstScript.sql +++ b/db/versions/10883-azureRuscus/00-firstScript.sql @@ -1 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`credit`AS +SELECT 1; + GRANT SELECT ON TABLE vn2008.credit TO financialBoss; \ No newline at end of file From e08fb3d229485a9d0453a7e4e35cbe0a66ab44c4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Feb 2024 08:59:58 +0100 Subject: [PATCH 04/10] fix: refs #6184 Minor change --- loopback/locale/es.json | 5 +++-- modules/ticket/back/methods/ticket/saveSign.js | 11 ++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index b48772f0d..b0eb59cd5 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -339,8 +339,9 @@ "No tickets to invoice": "No hay tickets para facturar", "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado", "Name should be uppercase": "El nombre debe ir en mayúscula", - "Bank entity must be specified": "La entidad bancaria es obligatoria", + "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" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 0fcd41102..3718dfcda 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -34,8 +34,6 @@ module.exports = Self => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; let ticket; - let dms; - let gestDocCreated; if (typeof options == 'object') Object.assign(myOptions, options); @@ -86,8 +84,8 @@ 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 { @@ -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({ @@ -160,7 +157,7 @@ module.exports = Self => { await models.Route.cmrEmail(ctx, externalTickets); return; } catch (e) { - if (tx) await tx.rollback(); + if (tx && tx.isActive()) await tx.rollback(); throw e; } }; From 41db1c924f3c3875c27f08f3993c66ff4c79235d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Feb 2024 09:20:21 +0100 Subject: [PATCH 05/10] refactor: refs #6781 Deleted timeControlDevice --- db/versions/10884-maroonGerbera/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/10884-maroonGerbera/00-firstScript.sql diff --git a/db/versions/10884-maroonGerbera/00-firstScript.sql b/db/versions/10884-maroonGerbera/00-firstScript.sql new file mode 100644 index 000000000..704342a7c --- /dev/null +++ b/db/versions/10884-maroonGerbera/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE vn.timeControlDevice; From 6116ada156dd68e2b5e1e94fef8c8811c8fc9e7b Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Feb 2024 09:35:39 +0100 Subject: [PATCH 06/10] fix: refs #6813 remove inserts --- db/routines/vn2008/procedures/recobro_credito.sql | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql index ca5304b6c..0db9d6e70 100644 --- a/db/routines/vn2008/procedures/recobro_credito.sql +++ b/db/routines/vn2008/procedures/recobro_credito.sql @@ -8,16 +8,10 @@ BEGIN END; START TRANSACTION; - INSERT INTO vn.clientCredit(clientFk, amount) - SELECT c.id, 0 - FROM vn.`client` c - JOIN vn.payMethod pm ON pm.id = c.payMethodFk - WHERE c.credit <> 0 AND pm.`code` = 'card'; - UPDATE vn.`client` c - JOIN vn.payMethod pm ON pm.id = c.payMethodFk + JOIN vn.payMethod pm ON pm.id = c.payMethodFk SET credit = 0 - WHERE pm.`code` = 'card'; + WHERE pm.`code` = 'card'; DROP TEMPORARY TABLE IF EXISTS clientes_credit; CREATE TEMPORARY TABLE clientes_credit @@ -44,10 +38,6 @@ BEGIN UPDATE Clientes JOIN clientes_credit USING(Id_Cliente) SET Clientes.Credito = newCredit; - - INSERT INTO credit(Id_Cliente, amount, Id_Trabajador) - SELECT Id_Cliente, newCredit, NULL - FROM clientes_credit; DROP TEMPORARY TABLE clientes_credit; COMMIT; From 744171dd4c33af9e2bfd94e5d9cf06628471b99e Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 13 Feb 2024 09:41:26 +0100 Subject: [PATCH 07/10] fix: refs #6184 Requested changes --- modules/ticket/back/methods/ticket/saveSign.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 3718dfcda..9c6e8181a 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -34,6 +34,7 @@ module.exports = Self => { const myOptions = {userId: ctx.req.accessToken.userId}; let tx; let ticket; + let externalTickets = []; if (typeof options == 'object') Object.assign(myOptions, options); @@ -89,7 +90,6 @@ module.exports = Self => { } try { - let externalTickets = []; for (const ticketId of tickets) { ticket = await models.Ticket.findById(ticketId, { include: [{ @@ -154,11 +154,10 @@ module.exports = Self => { } } if (tx) await tx.commit(); - await models.Route.cmrEmail(ctx, externalTickets); - return; } catch (e) { - if (tx && tx.isActive()) await tx.rollback(); + if (tx) await tx.rollback(); throw e; } + await models.Route.cmrEmail(ctx, externalTickets); }; }; From 4f9b46346f38ee77b8328333fc4f84a5867df44e Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 13 Feb 2024 09:49:33 +0100 Subject: [PATCH 08/10] fix: refs#6706 back tests spec timeout reduced --- back/tests.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/back/tests.js b/back/tests.js index 6c1b366e2..50698eb92 100644 --- a/back/tests.js +++ b/back/tests.js @@ -17,7 +17,8 @@ const opts = getopts(process.argv.slice(2), { let server; const PARALLEL = false; -const TIMEOUT = 900000; +const SETUP_TIMEOUT = 15 * 60 * 1000; +const SPEC_TIMEOUT = 30 * 1000; process.on('exit', teardown); process.on('uncaughtException', onError); @@ -74,9 +75,9 @@ async function test() { let runner; const config = { globalSetup: setup, - globalSetupTimeout: TIMEOUT, + globalSetupTimeout: SETUP_TIMEOUT, globalTeardown: teardown, - globalTeardownTimeout: TIMEOUT, + globalTeardownTimeout: SETUP_TIMEOUT, spec_dir: '.', spec_files: [ 'back/**/*[sS]pec.js', @@ -111,7 +112,7 @@ async function test() { runner.addReporter(new JunitReporter.JUnitXmlReporter()); } if (opts.ci) - runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT; + runner.jasmine.DEFAULT_TIMEOUT_INTERVAL = SPEC_TIMEOUT; // runner.loadConfigFile('back/jasmine.json'); runner.loadConfig(config); From db2919b48208cd634ab8cea4d7d9f567fca32354 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Feb 2024 11:05:21 +0100 Subject: [PATCH 09/10] fix: refs #6813 procedure --- db/routines/vn2008/procedures/recobro_credito.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql index 0db9d6e70..3c8b6fbfe 100644 --- a/db/routines/vn2008/procedures/recobro_credito.sql +++ b/db/routines/vn2008/procedures/recobro_credito.sql @@ -8,10 +8,10 @@ BEGIN END; START TRANSACTION; - UPDATE vn.`client` c + UPDATE vn.client c JOIN vn.payMethod pm ON pm.id = c.payMethodFk SET credit = 0 - WHERE pm.`code` = 'card'; + WHERE pm.code = 'card'; DROP TEMPORARY TABLE IF EXISTS clientes_credit; CREATE TEMPORARY TABLE clientes_credit From 579f2abe5bd48bd05f5d25b7a9b66daf45038278 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 13 Feb 2024 11:16:00 +0100 Subject: [PATCH 10/10] fix: refs #6813 remove quotation marks --- db/routines/vn2008/procedures/recobro_credito.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql index 3c8b6fbfe..0db9d6e70 100644 --- a/db/routines/vn2008/procedures/recobro_credito.sql +++ b/db/routines/vn2008/procedures/recobro_credito.sql @@ -8,10 +8,10 @@ BEGIN END; START TRANSACTION; - UPDATE vn.client c + UPDATE vn.`client` c JOIN vn.payMethod pm ON pm.id = c.payMethodFk SET credit = 0 - WHERE pm.code = 'card'; + WHERE pm.`code` = 'card'; DROP TEMPORARY TABLE IF EXISTS clientes_credit; CREATE TEMPORARY TABLE clientes_credit