From 98d2b5a0ffcfd3a7099c12955c0105867a2ebd04 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 15 Feb 2024 12:59:30 +0100 Subject: [PATCH 01/18] hotfix creditClient --- .../client/back/methods/client/setRating.js | 2 +- .../methods/client/specs/setRating.spec.js | 22 +++++++++++++++++++ modules/client/back/models/client.js | 3 ++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/setRating.js b/modules/client/back/methods/client/setRating.js index 21ac0c914..e3f866683 100644 --- a/modules/client/back/methods/client/setRating.js +++ b/modules/client/back/methods/client/setRating.js @@ -28,7 +28,6 @@ module.exports = Self => { Self.setRating = async function(ctx, id, rating, recommendedCredit, options) { let tx; const myOptions = {}; - if (typeof options == 'object') Object.assign(myOptions, options); @@ -42,6 +41,7 @@ module.exports = Self => { const clientUpdated = await client.updateAttributes({ rating: rating, recommendedCredit: recommendedCredit + }, myOptions); if (tx) await tx.commit(); diff --git a/modules/client/back/methods/client/specs/setRating.spec.js b/modules/client/back/methods/client/specs/setRating.spec.js index a7d0fb03a..353095e31 100644 --- a/modules/client/back/methods/client/specs/setRating.spec.js +++ b/modules/client/back/methods/client/specs/setRating.spec.js @@ -40,4 +40,26 @@ describe('Client setRating()', () => { throw e; } }); + + it('should change rating and recommendedCredit to 0', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const clientId = 1101; + const newRating = 0; + const newRecommendedCredit = 0; + + const updatedClient = await models.Client.setRating(ctx, clientId, newRating, newRecommendedCredit, options); + + expect(updatedClient.rating).toEqual(newRating); + expect(updatedClient.recommendedCredit).toEqual(newRecommendedCredit); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index a9e14effa..0a8ebcae5 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -319,7 +319,8 @@ module.exports = Self => { await Self.changeCredit(ctx, finalState, changes); // Credit management changes - if (changes?.rating || changes?.recommendedCredit) + + if (changes?.rating >= 0 || changes?.recommendedCredit >= 0) await Self.changeCreditManagement(ctx, finalState, changes); const oldInstance = {}; From ae0ce91127bd780e33ab9263fd3cb0edd09276bd Mon Sep 17 00:00:00 2001 From: davidd Date: Fri, 16 Feb 2024 06:10:09 +0100 Subject: [PATCH 02/18] refs #6685 --- db/routines/vn2008/views/credit.sql | 11 +++++++++++ db/versions/10888-brownBirch/00-firstScript.sql | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 db/routines/vn2008/views/credit.sql create mode 100644 db/versions/10888-brownBirch/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..04b44f42b --- /dev/null +++ b/db/routines/vn2008/views/credit.sql @@ -0,0 +1,11 @@ +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/10888-brownBirch/00-firstScript.sql b/db/versions/10888-brownBirch/00-firstScript.sql new file mode 100644 index 000000000..7c8f96339 --- /dev/null +++ b/db/versions/10888-brownBirch/00-firstScript.sql @@ -0,0 +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; From 8328dd6f4c9dd85f4d7493e0ed89f46201c3f5c2 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 19 Feb 2024 12:31:14 +0100 Subject: [PATCH 03/18] hotFix: workerTimeControl use department.hasToRefill --- .../worker/back/methods/worker-time-control/sendMail.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 6f67bbea3..7757ba14d 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -149,7 +149,8 @@ module.exports = Self => { FROM tmp.timeControlError tce JOIN vn.workerTimeControl wtc ON wtc.id = tce.id )sub ON sub.userFk = tb.userFk - WHERE sub.userFK IS NULL + WHERE d.hasToRefill + AND sub.userFK IS NULL AND IFNULL(?, u.id) = u.id AND b.companyCodeFk = 'VNL' AND w.businessFk @@ -163,7 +164,7 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const days = await conn.executeStmt(sql, myOptions); - + console.log(days[index][0]); let previousWorkerFk = days[index][0].workerFk; let previousReceiver = days[index][0].receiver; @@ -356,7 +357,7 @@ module.exports = Self => { previousReceiver = day.receiver; } - if (tx) await tx.commit(); + if (tx) await tx.rollback(); } catch (e) { const stmts = []; let stmt; From 231ebf78d76c8dc74f88677890fe67e60c46684a Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 19 Feb 2024 12:33:33 +0100 Subject: [PATCH 04/18] hotFix: remove console.log --- modules/worker/back/methods/worker-time-control/sendMail.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 7757ba14d..3c3b0c06f 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -164,7 +164,7 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const days = await conn.executeStmt(sql, myOptions); - console.log(days[index][0]); + let previousWorkerFk = days[index][0].workerFk; let previousReceiver = days[index][0].receiver; @@ -357,7 +357,7 @@ module.exports = Self => { previousReceiver = day.receiver; } - if (tx) await tx.rollback(); + if (tx) await tx.commit(); } catch (e) { const stmts = []; let stmt; From 7b0dd6975d5dba526f1b08591902f8ffb646f8c0 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 19 Feb 2024 14:13:36 +0100 Subject: [PATCH 05/18] fix(usesMana): refs #6879 add mana excluded worker --- .../back/methods/sale/specs/usesMana.spec.js | 31 +++++++++++++++---- modules/ticket/back/methods/sale/usesMana.js | 3 ++ modules/worker/back/model-config.json | 3 ++ .../back/models/worker-mana-excluded.json | 22 +++++++++++++ 4 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 modules/worker/back/models/worker-mana-excluded.json diff --git a/modules/ticket/back/methods/sale/specs/usesMana.spec.js b/modules/ticket/back/methods/sale/specs/usesMana.spec.js index 777bdc8f0..e82645d0b 100644 --- a/modules/ticket/back/methods/sale/specs/usesMana.spec.js +++ b/modules/ticket/back/methods/sale/specs/usesMana.spec.js @@ -1,11 +1,7 @@ const models = require('vn-loopback/server/server').models; -describe('sale usesMana()', () => { - const ctx = { - req: { - accessToken: {userId: 18} - } - }; +fdescribe('sale usesMana()', () => { + const ctx = {req: { accessToken: {userId: 18}}}; it('should return that the worker uses mana', async() => { const tx = await models.Sale.beginTransaction({}); @@ -45,4 +41,27 @@ describe('sale usesMana()', () => { throw e; } }); + + it('should return that the worker does not use mana because it is excluded', async() => { + const tx = await models.Sale.beginTransaction({}); + const buyerId = 35; + const franceDepartmentId = 133; + const buyerCtx = {req: {accessToken: {userId: buyerId}}}; + + try { + const options = {transaction: tx} + + await models.WorkerManaExcluded.create({workerFk: buyerId}, options); + await models.Business.updateAll({workerFk: buyerId}, {departmentFk: franceDepartmentId}, options); + + const usesMana = await models.Sale.usesMana(buyerCtx, options); + + expect(usesMana).toBe(false); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js index 75d8cdda7..31beb3a4c 100644 --- a/modules/ticket/back/methods/sale/usesMana.js +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -21,6 +21,9 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + const isManaExcluded = await models.WorkerManaExcluded.findById(userId, null, myOptions); + if (isManaExcluded) return false; + const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); const departments = await models.Department.getLeaves(ctx, salesDepartment.id, null, myOptions); const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions); diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index 8352eb070..e12ceada5 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -86,6 +86,9 @@ "WorkerMana": { "dataSource": "vn" }, + "WorkerManaExcluded": { + "dataSource": "vn" + }, "WorkerMistake": { "dataSource": "vn" }, diff --git a/modules/worker/back/models/worker-mana-excluded.json b/modules/worker/back/models/worker-mana-excluded.json new file mode 100644 index 000000000..6610b701b --- /dev/null +++ b/modules/worker/back/models/worker-mana-excluded.json @@ -0,0 +1,22 @@ +{ + "name": "WorkerManaExcluded", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerManaExcluded" + } + }, + "properties": { + "workerFk": { + "id": true, + "type": "number" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + } + } +} From 011880eb728ea6029c59e60e5c71b0bce550775a Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 19 Feb 2024 14:15:44 +0100 Subject: [PATCH 06/18] fix(spec): refs #6879 remove f from describe --- modules/ticket/back/methods/sale/specs/usesMana.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/sale/specs/usesMana.spec.js b/modules/ticket/back/methods/sale/specs/usesMana.spec.js index e82645d0b..74465ab27 100644 --- a/modules/ticket/back/methods/sale/specs/usesMana.spec.js +++ b/modules/ticket/back/methods/sale/specs/usesMana.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('sale usesMana()', () => { +describe('sale usesMana()', () => { const ctx = {req: { accessToken: {userId: 18}}}; it('should return that the worker uses mana', async() => { From 668903fa5f67c48c6944b1536945014803f059a2 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 20 Feb 2024 09:08:32 +0100 Subject: [PATCH 07/18] hotFix(getUrl): fix prop name environment --- back/methods/url/getUrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/url/getUrl.js b/back/methods/url/getUrl.js index f30719b9f..ef741e5a0 100644 --- a/back/methods/url/getUrl.js +++ b/back/methods/url/getUrl.js @@ -22,7 +22,7 @@ module.exports = Self => { const {url} = await Self.app.models.Url.findOne({ where: { appName, - enviroment: process.env.NODE_ENV || 'development' + environment: process.env.NODE_ENV || 'development' } }); return url; From ab9c952afc301909352a0ae595914bfb1f126444 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 20 Feb 2024 12:13:49 +0100 Subject: [PATCH 08/18] hotFix(sendMail): hasToRefill --- .../worker/back/methods/worker-time-control/sendMail.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 3c3b0c06f..e43f4a8ab 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -137,7 +137,8 @@ module.exports = Self => { tb.type, tb.businessFk, tb.permissionRate, - d.isTeleworking + d.isTeleworking, + d.hasToRefill FROM tmp.timeBusinessCalculate tb JOIN account.user u ON u.id = tb.userFk JOIN department d ON d.id = tb.departmentFk @@ -149,8 +150,7 @@ module.exports = Self => { FROM tmp.timeControlError tce JOIN vn.workerTimeControl wtc ON wtc.id = tce.id )sub ON sub.userFk = tb.userFk - WHERE d.hasToRefill - AND sub.userFK IS NULL + WHERE sub.userFK IS NULL AND IFNULL(?, u.id) = u.id AND b.companyCodeFk = 'VNL' AND w.businessFk @@ -175,7 +175,7 @@ module.exports = Self => { myOptions.transaction = tx; try { workerFk = day.workerFk; - if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null + if (day.hasToRefill && day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null && (day.permissionRate == null ? true : day.permissionRate)) { if (day.timeTable == null) { const timed = new Date(day.dated); From 0a16335eaa0b11e8efa4514a00ca807be695ee07 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 21 Feb 2024 18:48:39 +0100 Subject: [PATCH 09/18] fix: refs #6371 restore tables --- db/versions/10835-brownCarnation/00-firstScript.sql | 8 -------- 1 file changed, 8 deletions(-) diff --git a/db/versions/10835-brownCarnation/00-firstScript.sql b/db/versions/10835-brownCarnation/00-firstScript.sql index e66b84ee5..be53d866c 100644 --- a/db/versions/10835-brownCarnation/00-firstScript.sql +++ b/db/versions/10835-brownCarnation/00-firstScript.sql @@ -97,10 +97,6 @@ ALTER TABLE IF EXISTS vn2008.Tickets_stack__ COMMENT='refs #6371 deprecated 2024 ALTER TABLE IF EXISTS vn2008.Tipos_f11 RENAME vn2008.Tipos_f11__; ALTER TABLE IF EXISTS vn2008.Tipos_f11__ COMMENT='refs #6371 deprecated 2024-01-11'; --- Para la tabla Tramos -ALTER TABLE IF EXISTS vn2008.Tramos RENAME vn2008.Tramos__; -ALTER TABLE IF EXISTS vn2008.Tramos__ COMMENT='refs #6371 deprecated 2024-01-11'; - -- Para la tabla accion_dits ALTER TABLE IF EXISTS vn2008.accion_dits RENAME vn2008.accion_dits__; ALTER TABLE IF EXISTS vn2008.accion_dits__ COMMENT='refs #6371 deprecated 2024-01-11'; @@ -161,10 +157,6 @@ ALTER TABLE IF EXISTS vn2008.cyc__ COMMENT='refs #6371 deprecated 2024-01-11'; ALTER TABLE IF EXISTS vn2008.cyc_declaration RENAME vn2008.cyc_declaration__; ALTER TABLE IF EXISTS vn2008.cyc_declaration__ COMMENT='refs #6371 deprecated 2024-01-11'; --- Para la tabla dock -ALTER TABLE IF EXISTS vn2008.dock RENAME vn2008.dock__; -ALTER TABLE IF EXISTS vn2008.dock__ COMMENT='refs #6371 deprecated 2024-01-11'; - -- Para la tabla edi_testigos ALTER TABLE IF EXISTS vn2008.edi_testigos RENAME vn2008.edi_testigos__; ALTER TABLE IF EXISTS vn2008.edi_testigos__ COMMENT='refs #6371 deprecated 2024-01-11'; From 0344a8178510b156253257a3c49b2453aa75aec9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 22 Feb 2024 09:08:37 +0100 Subject: [PATCH 10/18] fix: refs #6780 Rollback vn2008.versiones --- db/routines/vn2008/views/versiones.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/routines/vn2008/views/versiones.sql diff --git a/db/routines/vn2008/views/versiones.sql b/db/routines/vn2008/views/versiones.sql new file mode 100644 index 000000000..3d27f4f92 --- /dev/null +++ b/db/routines/vn2008/views/versiones.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`versiones` +AS SELECT `m`.`app` AS `programa`, + `m`.`version` AS `version`, + 0 AS `critical` +FROM `vn`.`mdbVersion` `m` +WHERE `m`.`branchFk` = 'master' \ No newline at end of file From dd3249ea59af1a34d74774be7a1e7cbd88aec5c9 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 22 Feb 2024 09:36:48 +0100 Subject: [PATCH 11/18] ci: HOTFIX Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index c77c88201..a39540173 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -172,6 +172,7 @@ pipeline { if (index != -1) message = message.substring(0, index) + setEnv() rocketSend( channel: 'vn-database', message: "*DB version uploaded:* ${message}" From 80fc9e4472bb29e879d511dd0694aa4955c0f8a1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 22 Feb 2024 10:16:29 +0100 Subject: [PATCH 12/18] fix: refs #6184 Quitadas transacciones en los SELECT en saveSign.js --- modules/ticket/back/methods/ticket/saveSign.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 9c6e8181a..d7cc63ada 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -47,7 +47,7 @@ module.exports = Self => { const dmsTypeTicket = await models.DmsType.findOne({ where: {code: 'ticket'}, fields: ['id'] - }, myOptions); + }); async function setLocation(ticketId) { await models.Delivery.create({ @@ -70,7 +70,7 @@ module.exports = Self => { } } ] - }, myOptions); + }); if (ticketDms?.dms()?.id) return true; } @@ -113,17 +113,17 @@ module.exports = Self => { fields: ['id'] } }] - }, myOptions); + }); const ticketState = await models.TicketState.findOne({ where: {ticketFk: ticketId}, fields: ['alertLevel'] - }, myOptions); + }); const packedAlertLevel = await models.AlertLevel.findOne({ where: {code: 'PACKED'}, fields: ['id'] - }, myOptions); + }); if (!ticketState) throw new UserError('Ticket does not exist'); @@ -141,7 +141,7 @@ module.exports = Self => { const deliveryState = await models.State.findOne({ where: {code: 'DELIVERED'} - }, myOptions); + }); await models.Ticket.state(ctx, { ticketFk: ticketId, From 9f067fc9b3113913eb9d4cb1b28e8b62a51a1054 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 22 Feb 2024 10:20:15 +0100 Subject: [PATCH 13/18] build: HOTFIX Myt updated --- package.json | 2 +- pnpm-lock.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 6f0624360..d7dea767e 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "@babel/plugin-syntax-dynamic-import": "^7.7.4", "@babel/preset-env": "^7.11.0", "@babel/register": "^7.7.7", - "@verdnatura/myt": "^1.6.7", + "@verdnatura/myt": "^1.6.8", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", "babel-loader": "^8.2.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 025be234e..36bff2fe1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -131,8 +131,8 @@ devDependencies: specifier: ^7.7.7 version: 7.23.7(@babel/core@7.23.9) '@verdnatura/myt': - specifier: ^1.6.7 - version: 1.6.7 + specifier: ^1.6.8 + version: 1.6.8 angular-mocks: specifier: ^1.7.9 version: 1.8.3 @@ -2633,8 +2633,8 @@ packages: dev: false optional: true - /@verdnatura/myt@1.6.7: - resolution: {integrity: sha512-t/Q1T3QzHpZFdxwIyQL/CV5g+HJvWE6Q65VeA9k0svZdX/vezgnQ21nkI+wuvIurIl6BXqq2Arx7EWYkAhGNNA==} + /@verdnatura/myt@1.6.8: + resolution: {integrity: sha512-jpadr6yAR9TQXPv+has5yOYAolR/YEzsxbLgMR7BoDrpLyVFLHJEy4Dfe+Hy11r3AmxCB/8lWM+La1YGvXMWOA==} hasBin: true dependencies: '@sqltools/formatter': 1.2.5 From b6086e74c119c64e9f280c6262aa8e35557cf89e Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 22 Feb 2024 10:39:34 +0100 Subject: [PATCH 14/18] refs #6922 change order --- print/templates/reports/invoice/sql/sales.sql | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/print/templates/reports/invoice/sql/sales.sql b/print/templates/reports/invoice/sql/sales.sql index 3833a3700..8e5ad1102 100644 --- a/print/templates/reports/invoice/sql/sales.sql +++ b/print/templates/reports/invoice/sql/sales.sql @@ -7,7 +7,8 @@ SELECT s.discount, s.itemFk, s.concept, - tc.code vatType + tc.code vatType, + it.isPackaging FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.supplier su ON su.id = io.companyFk @@ -34,9 +35,10 @@ SELECT ts.quantity, ts.price, 0 discount, - '', - ts.description concept, - tc.code vatType + NULL, + ts.description, + tc.code, + NULL FROM vn.invoiceOut io JOIN vn.ticket t ON t.refFk = io.ref JOIN vn.ticketService ts ON ts.ticketFk = t.id @@ -46,3 +48,4 @@ SELECT JOIN vn.supplierAccount sa ON sa.id = co.supplierAccountFk JOIN vn.taxClass tc ON tc.id = ts.taxClassFk WHERE t.refFk = ? +ORDER BY (isPackaging), concept, itemFk From 13249fae0888203210551726f4e0b02398d6e4cb Mon Sep 17 00:00:00 2001 From: davidd Date: Thu, 22 Feb 2024 10:47:27 +0100 Subject: [PATCH 15/18] refs #6372 --- .../10896-salmonOrchid/03-gastos_resumen.sql | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/db/versions/10896-salmonOrchid/03-gastos_resumen.sql b/db/versions/10896-salmonOrchid/03-gastos_resumen.sql index 2308cb1fd..29152bdd8 100644 --- a/db/versions/10896-salmonOrchid/03-gastos_resumen.sql +++ b/db/versions/10896-salmonOrchid/03-gastos_resumen.sql @@ -1,24 +1,33 @@ ALTER TABLE IF EXISTS vn2008.gastos_resumen DROP FOREIGN KEY IF EXISTS gastos_resumen_expense_FK; ALTER TABLE IF EXISTS `vn2008`.`gastos_resumen` RENAME `vn`.`expenseManual`; -ALTER TABLE IF EXISTS `vn`.`expenseManual` +ALTER TABLE `vn`.`expenseManual` CHANGE COLUMN IF EXISTS `Id_Gasto` `expenseFk` varchar(10) NOT NULL, CHANGE COLUMN IF EXISTS `importe` `amount` decimal(10,2) DEFAULT NULL, CHANGE COLUMN IF EXISTS `empresa_id` `companyFk` int(11) NOT NULL; -ALTER TABLE IF EXISTS vn.expenseManual COLLATE=utf8mb3_general_ci; +ALTER TABLE vn.expenseManual COLLATE=utf8mb3_general_ci; -ALTER TABLE IF EXISTS vn.expenseManual MODIFY COLUMN IF EXISTS expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; +ALTER TABLE vn.expenseManual MODIFY COLUMN IF EXISTS expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; -ALTER TABLE IF EXISTS vn.expenseManual ADD CONSTRAINT expenseManual_expense_FK FOREIGN KEY IF NOT EXISTS (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE IF EXISTS vn.expenseManual MODIFY COLUMN IF EXISTS companyFk int(10) unsigned NOT NULL; +ALTER TABLE vn.expenseManual DROP PRIMARY KEY; ALTER TABLE vn.expenseManual MODIFY COLUMN companyFk int(10) unsigned NULL; +ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_expense_FK FOREIGN KEY IF NOT EXISTS (expenseFk) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_company_FK FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE vn.expenseManual ADD IF NOT EXISTS id INT unsigned NOT NULL FIRST; + +ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_pk PRIMARY KEY IF NOT EXISTS (id); + +ALTER TABLE vn.expenseManual ADD CONSTRAINT expenseManual_unique UNIQUE KEY IF NOT EXISTS (expenseFk,`year`,`month`,companyFk); + +ALTER TABLE vn.expenseManual MODIFY COLUMN IF EXISTS companyFk int(10) unsigned NOT NULL; + UPDATE vn.expenseManual SET companyFK= NULL - WHERE companyFk= 0 + WHERE companyFk= 0; -ALTER TABLE IF EXISTS vn.expenseManual ADD CONSTRAINT expenseManual_company_FK FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company(id) ON DELETE CASCADE ON UPDATE CASCADE; From 7d3cf162b8579d16d97d01c6c392f597463f557d Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 22 Feb 2024 11:22:39 +0100 Subject: [PATCH 16/18] fix: refs #6184 uploadFile --- back/methods/dms/uploadFile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/dms/uploadFile.js b/back/methods/dms/uploadFile.js index 8456cf2d3..9748b8225 100644 --- a/back/methods/dms/uploadFile.js +++ b/back/methods/dms/uploadFile.js @@ -88,7 +88,7 @@ module.exports = Self => { warehouseFk: args.warehouseId, reference: args.reference, description: args.description, - contentType: args.contentType, + contentType: uploadedFile.type, hasFile: args.hasFile }; const extension = await models.DmsContainer.getFileExtension(uploadedFile.name); From df5e9bc830473f6d97e1ae714804a1045abc4828 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 22 Feb 2024 14:46:10 +0100 Subject: [PATCH 17/18] fix: refs #6184 Rollback saveSign.js --- .../ticket/back/methods/ticket/saveSign.js | 131 ++++++++---------- 1 file changed, 61 insertions(+), 70 deletions(-) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index d7cc63ada..fd40c1c22 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -33,8 +33,8 @@ module.exports = Self => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; let tx; - let ticket; - let externalTickets = []; + let dms; + let gestDocCreated = false; if (typeof options == 'object') Object.assign(myOptions, options); @@ -44,11 +44,6 @@ module.exports = Self => { myOptions.transaction = tx; } - const dmsTypeTicket = await models.DmsType.findOne({ - where: {code: 'ticket'}, - fields: ['id'] - }); - async function setLocation(ticketId) { await models.Delivery.create({ ticketFk: ticketId, @@ -58,106 +53,102 @@ module.exports = Self => { }, myOptions); } - async function hasSignDms(ticketId) { + async function gestDocExists(ticketId) { const ticketDms = await models.TicketDms.findOne({ where: {ticketFk: ticketId}, - include: [ - { - relation: 'dms', - fields: ['id'], - scope: { - where: {dmsTypeFk: dmsTypeTicket.id} - } - } - ] - }); - if (ticketDms?.dms()?.id) return true; + fields: ['dmsFk'] + }, myOptions); + + if (!ticketDms) return false; + + const ticket = await models.Ticket.findById(ticketId, {fields: ['isSigned']}, myOptions); + if (ticket.isSigned == true) + return true; + else + await models.Dms.destroyAll({where: {reference: ticketId}}, myOptions); + + return false; } - async function createGestDoc() { + async function createGestDoc(id) { + const ticket = await models.Ticket.findById(id, + { + include: [ + { + relation: 'warehouse', + scope: { + fields: ['id'] + } + }, { + relation: 'client', + scope: { + fields: ['name'] + } + }, { + relation: 'route', + scope: { + fields: ['id'] + } + } + ] + }, myOptions); + const dmsType = await models.DmsType.findOne({where: {code: 'Ticket'}, fields: ['id']}, myOptions); const ctxUploadFile = Object.assign({}, ctx); + if (ticket.route() === null) + throw new UserError('Ticket without route'); ctxUploadFile.args = { warehouseId: ticket.warehouseFk, companyId: ticket.companyFk, - dmsTypeId: dmsTypeTicket.id, - reference: ticket.id, + dmsTypeId: dmsType.id, + reference: '', description: `Firma del cliente - Ruta ${ticket.route().id}`, - contentType: 'image/png', - hasFile: true + hasFile: false }; - const dms = await models.Dms.uploadFile(ctxUploadFile, myOptions); - await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); + dms = await models.Dms.uploadFile(ctxUploadFile, myOptions); + gestDocCreated = true; } try { for (const ticketId of tickets) { - ticket = await models.Ticket.findById(ticketId, { - include: [{ - relation: 'address', - scope: { - include: { - relation: 'province', - scope: { - include: { - relation: 'country', - scope: { - fields: ['code'] - } - } - } - } - } - }, { - relation: 'route', - scope: { - fields: ['id'] - } - }] - }); + const ticketState = await models.TicketState.findOne( + {where: {ticketFk: ticketId}, + fields: ['alertLevel'] + }, myOptions); - const ticketState = await models.TicketState.findOne({ - where: {ticketFk: ticketId}, - fields: ['alertLevel'] - }); - - const packedAlertLevel = await models.AlertLevel.findOne({ - where: {code: 'PACKED'}, + const packedAlertLevel = await models.AlertLevel.findOne({where: {code: 'PACKED'}, fields: ['id'] - }); + }, myOptions); if (!ticketState) throw new UserError('Ticket does not exist'); - if (!ticket.route()) - throw new UserError('Ticket without route'); if (ticketState.alertLevel < packedAlertLevel.id) throw new UserError('This ticket cannot be signed because it has not been boxed'); - if (await ticket.isSigned) + if (await gestDocExists(ticketId)) throw new UserError('Ticket is already signed'); if (location) await setLocation(ticketId); - if (!await hasSignDms(ticketId)) - await createGestDoc(ticketId); + if (!gestDocCreated) await createGestDoc(ticketId); + await models.TicketDms.create({ticketFk: ticketId, dmsFk: dms[0].id}, myOptions); + const ticket = await models.Ticket.findById(ticketId, null, myOptions); await ticket.updateAttribute('isSigned', true, myOptions); const deliveryState = await models.State.findOne({ - where: {code: 'DELIVERED'} - }); + where: { + code: 'DELIVERED' + } + }, myOptions); await models.Ticket.state(ctx, { ticketFk: ticketId, stateFk: deliveryState.id }, myOptions); - - if (ticket?.address()?.province()?.country()?.code != 'ES') { - await models.Ticket.saveCmr(ctx, [ticketId], myOptions); - externalTickets.push(ticketId); - } } + if (tx) await tx.commit(); + return; } catch (e) { if (tx) await tx.rollback(); throw e; } - await models.Route.cmrEmail(ctx, externalTickets); }; }; From 20e5eda4d14ddd7292b077f3b59a41f0f20bccc6 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Thu, 22 Feb 2024 16:16:32 +0100 Subject: [PATCH 18/18] fix: refs #6915 broken view vn.doc removed --- db/routines/vn/views/doc.sql | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 db/routines/vn/views/doc.sql diff --git a/db/routines/vn/views/doc.sql b/db/routines/vn/views/doc.sql deleted file mode 100644 index 31ac20640..000000000 --- a/db/routines/vn/views/doc.sql +++ /dev/null @@ -1,14 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`doc` -AS SELECT `g`.`id` AS `id`, - `g`.`sref` AS `sref`, - `g`.`brief` AS `brief`, - `g`.`emp_id` AS `companyFk`, - `g`.`orden` AS `order`, - `g`.`file` AS `file`, - `g`.`original` AS `original`, - `g`.`trabajador_id` AS `workerFk`, - `g`.`odbc_date` AS `created`, - `g`.`warehouse_id` AS `warehouseFk` -FROM `vn2008`.`gestdoc` `g`