From 7367d1cdfeb5f5b4ba9114229ced38bd920e70c9 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 27 Jul 2023 14:41:53 +0200 Subject: [PATCH 01/14] refs #6013 fix: add await --- .../back/methods/worker-time-control/weeklyHourRecordEmail.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index f44080559..3203dea82 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -51,7 +51,7 @@ module.exports = Self => { const salix = await models.Url.findOne({ where: { appName: 'salix', - environment: process.env.NODE_ENV || 'dev' + environment: process.env.NODE_ENV || 'development' } }, myOptions); @@ -61,7 +61,7 @@ module.exports = Self => { const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; ctx.args.url = url; - Self.sendTemplate(ctx, 'weekly-hour-record'); + await Self.sendTemplate(ctx, 'weekly-hour-record'); return models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, myOptions); }; From 0054f2d82f04b3a26bbf341be66f499918ee8676 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 27 Jul 2023 15:07:10 +0200 Subject: [PATCH 02/14] refs #6013 fix: codigo no bloqueante --- .../methods/worker-time-control/sendMail.js | 47 +++++++++++++++---- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index ab5e56a77..13317fc65 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -121,15 +121,18 @@ module.exports = Self => { `, [started, ended]); stmts.push(stmt); - stmt = new ParameterizedSQL(`INSERT INTO mail (receiver, subject, body) - SELECT CONCAT(u.name, '@verdnatura.es'), - CONCAT('Error registro de horas semana ', ?, ' año ', ?) , - CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName))) - FROM tmp.timeControlError tce - JOIN vn.workerTimeControl wtc ON wtc.id = tce.id - JOIN worker w ON w.id = wtc.userFK - JOIN account.user u ON u.id = w.bossFk - GROUP BY w.bossFk`, [args.week, args.year]); + stmt = new ParameterizedSQL(` + INSERT INTO mail (receiver, subject, body) + SELECT CONCAT(u.name, '@verdnatura.es'), + CONCAT('Error registro de horas semana ', ?, ' año ', ?) , + CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', + GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName))) + FROM tmp.timeControlError tce + JOIN vn.workerTimeControl wtc ON wtc.id = tce.id + JOIN worker w ON w.id = wtc.userFK + JOIN account.user u ON u.id = w.bossFk + GROUP BY w.bossFk + `, [args.week, args.year]); stmts.push(stmt); stmt = new ParameterizedSQL(` @@ -176,6 +179,7 @@ module.exports = Self => { const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); + console.log(days[index]); for (let day of days[index]) { if (!myOptions.transaction) { tx = await Self.beginTransaction({}); @@ -371,7 +375,30 @@ module.exports = Self => { } } catch (e) { if (tx) await tx.rollback(); - throw e; + delete myOptions.transaction; + + const stmts = []; + let stmt; + stmt = new ParameterizedSQL(` + INSERT INTO mail (receiver, subject, body) + SELECT CONCAT(u.name, '@verdnatura.es'), + CONCAT('Error registro de horas semana ', ?, ' año ', ?) , + CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', + GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName))) + FROM worker w + JOIN account.user u ON u.id = w.bossFk + WHERE w.id = ? + GROUP BY w.bossFk + `, [args.week, args.year, day.workerFk]); + stmts.push(stmt); + + const sql = ParameterizedSQL.join(stmts, ';'); + await conn.executeStmt(sql); + + previousWorkerFk = day.workerFk; + previousReceiver = day.receiver; + + continue; } } From 251ed36eca664a9c015bcc15003d49dc39a774cc Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 28 Jul 2023 10:51:48 +0200 Subject: [PATCH 03/14] refs #6013 feat: mostrar error en el mail --- .../back/methods/worker-time-control/sendMail.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 13317fc65..4988d1f46 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -179,7 +179,6 @@ module.exports = Self => { const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); - console.log(days[index]); for (let day of days[index]) { if (!myOptions.transaction) { tx = await Self.beginTransaction({}); @@ -374,22 +373,18 @@ module.exports = Self => { delete myOptions.transaction; } } catch (e) { - if (tx) await tx.rollback(); - delete myOptions.transaction; - const stmts = []; let stmt; stmt = new ParameterizedSQL(` INSERT INTO mail (receiver, subject, body) SELECT CONCAT(u.name, '@verdnatura.es'), CONCAT('Error registro de horas semana ', ?, ' año ', ?) , - CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', - GROUP_CONCAT(DISTINCT CONCAT('
', w.id, ' ', w.firstName, ' ', w.lastName))) + CONCAT('No se ha podido enviar el registro de horas al empleado: ', + w.id, ' ', w.firstName, ' ', w.lastName, ' por el motivo: ', ?) FROM worker w JOIN account.user u ON u.id = w.bossFk WHERE w.id = ? - GROUP BY w.bossFk - `, [args.week, args.year, day.workerFk]); + `, [args.week, args.year, e.message, day.workerFk]); stmts.push(stmt); const sql = ParameterizedSQL.join(stmts, ';'); @@ -398,6 +393,9 @@ module.exports = Self => { previousWorkerFk = day.workerFk; previousReceiver = day.receiver; + if (tx) await tx.rollback(); + delete myOptions.transaction; + continue; } } From 6b630722782ae9d12ff5c6329633bd49092f4247 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 18 Aug 2023 11:52:04 +0200 Subject: [PATCH 04/14] refs #6041 hotfix agricola --- print/templates/reports/entry-order/sql/supplier.sql | 2 +- print/templates/reports/invoiceIn/invoiceIn.html | 1 + print/templates/reports/invoiceIn/sql/invoice.sql | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/print/templates/reports/entry-order/sql/supplier.sql b/print/templates/reports/entry-order/sql/supplier.sql index 11a2bc602..81ed7e883 100644 --- a/print/templates/reports/entry-order/sql/supplier.sql +++ b/print/templates/reports/entry-order/sql/supplier.sql @@ -8,4 +8,4 @@ SELECT FROM supplier s JOIN entry e ON e.supplierFk = s.id LEFT JOIN province p ON p.id = s.provinceFk -WHERE e.id = ? \ No newline at end of file +WHERE e.id = ? diff --git a/print/templates/reports/invoiceIn/invoiceIn.html b/print/templates/reports/invoiceIn/invoiceIn.html index 8f072947f..a86fd42b0 100644 --- a/print/templates/reports/invoiceIn/invoiceIn.html +++ b/print/templates/reports/invoiceIn/invoiceIn.html @@ -32,6 +32,7 @@

{{invoice.name}}

{{invoice.postalAddress}}
{{invoice.postcodeCity}}
+
{{invoice.postCode}}, {{invoice.city}}, ({{invoice.province}})
{{$t('fiscalId')}}: {{invoice.nif}}
{{$t('phone')}}: {{invoice.phone}}
diff --git a/print/templates/reports/invoiceIn/sql/invoice.sql b/print/templates/reports/invoiceIn/sql/invoice.sql index dae979011..82eeebce0 100644 --- a/print/templates/reports/invoiceIn/sql/invoice.sql +++ b/print/templates/reports/invoiceIn/sql/invoice.sql @@ -4,6 +4,9 @@ SELECT i.issued, s.name, s.street AS postalAddress, + s.city, + s.postCode, + pr.name province, s.nif, s.phone, p.name payMethod @@ -11,4 +14,5 @@ SELECT JOIN supplier s ON s.id = i.supplierFk JOIN company c ON c.id = i.companyFk JOIN payMethod p ON p.id = s.payMethodFk + LEFT JOIN province pr ON pr.id = s.provinceFk WHERE i.id = ? From a26652045c46efa6303c48f6db8c3c63b1454a6c Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 22 Aug 2023 10:17:46 +0200 Subject: [PATCH 05/14] refs #5712 hotFix(docuware): tickets. hotFix(catalog): search_panel --- back/methods/docuware/checkFile.js | 7 +++---- back/methods/docuware/deliveryNoteEmail.js | 2 +- back/methods/docuware/specs/checkFile.spec.js | 16 +++------------- back/methods/docuware/upload.js | 2 +- .../order/front/catalog-search-panel/index.js | 4 ---- modules/order/front/catalog/index.js | 2 +- modules/order/front/catalog/index.spec.js | 4 ++-- .../back/methods/ticket/docuwareDownload.js | 10 +++++++++- modules/ticket/back/models/ticket-methods.js | 1 + modules/ticket/front/descriptor-menu/index.js | 7 ++++--- 10 files changed, 25 insertions(+), 30 deletions(-) diff --git a/back/methods/docuware/checkFile.js b/back/methods/docuware/checkFile.js index 19224057c..76789649f 100644 --- a/back/methods/docuware/checkFile.js +++ b/back/methods/docuware/checkFile.js @@ -71,11 +71,10 @@ module.exports = Self => { } try { - const response = await Self.get(fileCabinet, filter); - const [documents] = response.Items; - if (!documents) return false; + const [response] = await Self.get(fileCabinet, filter); + if (!response) return false; - return {id: documents.Id}; + return {id: response['Document ID']}; } catch (error) { return false; } diff --git a/back/methods/docuware/deliveryNoteEmail.js b/back/methods/docuware/deliveryNoteEmail.js index 1557a3a87..a654eb262 100644 --- a/back/methods/docuware/deliveryNoteEmail.js +++ b/back/methods/docuware/deliveryNoteEmail.js @@ -65,7 +65,7 @@ module.exports = Self => { const email = new Email('delivery-note', params); - const docuwareFile = await models.Docuware.download(ctx, id, 'deliveryNote'); + const docuwareFile = await models.Docuware.download(id, 'deliveryNote'); return email.send({ overrideAttachments: true, diff --git a/back/methods/docuware/specs/checkFile.spec.js b/back/methods/docuware/specs/checkFile.spec.js index 8460bb561..c60809e85 100644 --- a/back/methods/docuware/specs/checkFile.spec.js +++ b/back/methods/docuware/specs/checkFile.spec.js @@ -16,19 +16,9 @@ describe('docuware download()', () => { it('should return the document data', async() => { const docuwareId = 1; - const response = { - Items: [ - { - Id: docuwareId, - Fields: [ - { - FieldName: 'ESTADO', - Item: 'Firmado' - } - ] - } - ] - }; + const response = [{ + 'Document ID': docuwareId + }]; spyOn(docuwareModel, 'get').and.returnValue((new Promise(resolve => resolve(response)))); const result = await models.Docuware.checkFile(ticketId, fileCabinetName, null, true); diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index 096301e56..7055bf8d5 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -111,7 +111,7 @@ module.exports = Self => { throw new UserError('Action not allowed on the test environment'); // delete old - const docuwareFile = await models.Docuware.checkFile(ctx, id, fileCabinet, false); + const docuwareFile = await models.Docuware.checkFile(id, fileCabinet, false); if (docuwareFile) { const deleteJson = { 'Field': [{'FieldName': 'ESTADO', 'Item': 'Pendiente eliminar', 'ItemElementName': 'String'}] diff --git a/modules/order/front/catalog-search-panel/index.js b/modules/order/front/catalog-search-panel/index.js index 21c0c50fa..b84243ca7 100644 --- a/modules/order/front/catalog-search-panel/index.js +++ b/modules/order/front/catalog-search-panel/index.js @@ -25,10 +25,6 @@ class Controller extends SearchPanel { this.filter.values.push({}); setTimeout(() => this.parentPopover.relocate()); } - - changeTag() { - - } } ngModule.vnComponent('vnOrderCatalogSearchPanel', { diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index c0777ebc9..f25c4a35e 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -236,7 +236,7 @@ class Controller extends Section { tagGroups: this.tagGroups, }; - return model.applyFilter({where: newFilter}, newParams); + return model.addFilter({where: newFilter}, newParams); } openPanel(event) { diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index 03d7c41ba..ef96e1ed0 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -191,14 +191,14 @@ describe('Order', () => { describe('applyFilters()', () => { it(`should call model applyFilter() method with a new filter`, () => { - jest.spyOn(controller.$.model, 'applyFilter'); + jest.spyOn(controller.$.model, 'addFilter'); controller._categoryId = 2; controller._typeId = 4; controller.applyFilters(); - expect(controller.$.model.applyFilter).toHaveBeenCalledWith( + expect(controller.$.model.addFilter).toHaveBeenCalledWith( {where: {categoryFk: 2, typeFk: 4}}, {orderFk: 4, orderBy: controller.getOrderBy(), tagGroups: []}); }); diff --git a/modules/ticket/back/methods/ticket/docuwareDownload.js b/modules/ticket/back/methods/ticket/docuwareDownload.js index e9b74b1a9..7084bbdd4 100644 --- a/modules/ticket/back/methods/ticket/docuwareDownload.js +++ b/modules/ticket/back/methods/ticket/docuwareDownload.js @@ -32,6 +32,14 @@ module.exports = Self => { }); Self.docuwareDownload = async id => { + const models = Self.app.models; + const docuwareInfo = await models.Docuware.findOne({ + where: { + code: 'deliveryNote', + action: 'find' + } + }); + const filter = { condition: [ { @@ -50,6 +58,6 @@ module.exports = Self => { } ] }; - return Self.app.models.Docuware.download(id, 'deliveryNote', filter); + return models.Docuware.download(id, 'deliveryNote', filter); }; }; diff --git a/modules/ticket/back/models/ticket-methods.js b/modules/ticket/back/models/ticket-methods.js index c37337253..14cb104be 100644 --- a/modules/ticket/back/models/ticket-methods.js +++ b/modules/ticket/back/models/ticket-methods.js @@ -42,4 +42,5 @@ module.exports = function(Self) { require('../methods/ticket/expeditionPalletLabel')(Self); require('../methods/ticket/saveSign')(Self); require('../methods/ticket/invoiceTickets')(Self); + require('../methods/ticket/docuwareDownload')(Self); }; diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index 360d93564..d1f39fd19 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -3,10 +3,11 @@ import Section from 'salix/components/section'; import './style.scss'; class Controller extends Section { - constructor($element, $, vnReport, vnEmail) { + constructor($element, $, vnReport, vnEmail, vnFile) { super($element, $); this.vnReport = vnReport; this.vnEmail = vnEmail; + this.vnFile = vnFile; } get ticketId() { @@ -322,7 +323,7 @@ class Controller extends Section { } docuwareDownload() { - this.vnFile.download(`api/Ticket/${this.ticket.id}/docuwareDownload`); + this.vnFile.download(`api/Tickets/${this.ticket.id}/docuwareDownload`); } setTicketWeight(weight) { @@ -335,7 +336,7 @@ class Controller extends Section { } } -Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail']; +Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail', 'vnFile']; ngModule.vnComponent('vnTicketDescriptorMenu', { template: require('./index.html'), From 5a5e3ebddb40382eef2cd6c117312adddd77ad15 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 22 Aug 2023 13:39:57 +0200 Subject: [PATCH 06/14] refs #5712 hotFix(catalog): undo last fix search_panel --- modules/order/front/catalog/index.js | 2 +- modules/order/front/catalog/index.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index f25c4a35e..c0777ebc9 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -236,7 +236,7 @@ class Controller extends Section { tagGroups: this.tagGroups, }; - return model.addFilter({where: newFilter}, newParams); + return model.applyFilter({where: newFilter}, newParams); } openPanel(event) { diff --git a/modules/order/front/catalog/index.spec.js b/modules/order/front/catalog/index.spec.js index ef96e1ed0..03d7c41ba 100644 --- a/modules/order/front/catalog/index.spec.js +++ b/modules/order/front/catalog/index.spec.js @@ -191,14 +191,14 @@ describe('Order', () => { describe('applyFilters()', () => { it(`should call model applyFilter() method with a new filter`, () => { - jest.spyOn(controller.$.model, 'addFilter'); + jest.spyOn(controller.$.model, 'applyFilter'); controller._categoryId = 2; controller._typeId = 4; controller.applyFilters(); - expect(controller.$.model.addFilter).toHaveBeenCalledWith( + expect(controller.$.model.applyFilter).toHaveBeenCalledWith( {where: {categoryFk: 2, typeFk: 4}}, {orderFk: 4, orderBy: controller.getOrderBy(), tagGroups: []}); }); From 4657bf4e433c9292d2604321d2f0dab865073cce Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 22 Aug 2023 14:58:26 +0200 Subject: [PATCH 07/14] refs #6143 refactor: ibanValidation with countryCode param --- loopback/util/validateIban.js | 3 ++- modules/client/back/models/client.js | 8 +++----- modules/supplier/back/models/supplier-account.js | 9 +++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/loopback/util/validateIban.js b/loopback/util/validateIban.js index 3ca09ef95..ed3e00426 100644 --- a/loopback/util/validateIban.js +++ b/loopback/util/validateIban.js @@ -1,6 +1,7 @@ -module.exports = function(iban) { +module.exports = function(iban, countryCode) { if (iban == null) return true; if (typeof iban != 'string') return false; + if (countryCode?.toLowerCase() != 'es') return true; iban = iban.toUpperCase(); iban = trim(iban); diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 129924b78..bdf2f91b5 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -90,16 +90,14 @@ module.exports = Self => { }); async function ibanNeedsValidation(err, done) { + const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk); const filter = { fields: ['code'], - where: {id: this.countryFk} + where: {id: bankEntity.countryFk} }; const country = await Self.app.models.Country.findOne(filter); - const code = country ? country.code.toLowerCase() : null; - if (code != 'es') - return done(); - if (!validateIban(this.iban)) + if (!validateIban(this.iban, country?.code)) err(); done(); } diff --git a/modules/supplier/back/models/supplier-account.js b/modules/supplier/back/models/supplier-account.js index 51da113ec..7a9e14421 100644 --- a/modules/supplier/back/models/supplier-account.js +++ b/modules/supplier/back/models/supplier-account.js @@ -7,18 +7,15 @@ module.exports = Self => { }); async function ibanValidation(err, done) { - const supplier = await Self.app.models.Supplier.findById(this.supplierFk); + const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk); const filter = { fields: ['code'], - where: {id: supplier.countryFk} + where: {id: bankEntity.countryFk} }; const country = await Self.app.models.Country.findOne(filter); - const code = country ? country.code.toLowerCase() : null; - if (code != 'es') - return done(); - if (!validateIban(this.iban)) + if (!validateIban(this.iban, country?.code)) err(); done(); } From 7349d4496f8ed79ec44a5f3f56bb922d18be3298 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 23 Aug 2023 07:34:01 +0200 Subject: [PATCH 08/14] refs #5351 hotFix(worker_sip): use worker.id not worker.userFk --- modules/worker/front/pbx/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js index d37f6f7d8..3b6443d3c 100644 --- a/modules/worker/front/pbx/index.js +++ b/modules/worker/front/pbx/index.js @@ -5,7 +5,7 @@ class Controller extends Section { onSubmit() { const sip = this.worker.sip; const params = { - userFk: this.worker.userFk, + userFk: this.worker.id, extension: sip.extension }; this.$.watcher.check(); From 8454d208e16c7be5999d3fe5b55102bdea881ac7 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 23 Aug 2023 12:02:52 +0200 Subject: [PATCH 09/14] hotFix(route_tickets): orderBy nickname --- modules/route/front/tickets/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index ea6755cca..46b62c5ba 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -58,7 +58,7 @@ Street City PC - Client + Client Warehouse Packages @@ -100,9 +100,9 @@ {{::ticket.street}} - From 470f511b3048b8bedebc18085afd148f73038668 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 24 Aug 2023 08:05:27 +0200 Subject: [PATCH 10/14] refs #5881 createRolAndGrantAcl --- db/changes/233601/00-createClaimReader.sql | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 db/changes/233601/00-createClaimReader.sql diff --git a/db/changes/233601/00-createClaimReader.sql b/db/changes/233601/00-createClaimReader.sql new file mode 100644 index 000000000..10ab03d29 --- /dev/null +++ b/db/changes/233601/00-createClaimReader.sql @@ -0,0 +1,33 @@ +INSERT INTO `account`.`role` (`id`, `name`, `description`, `hasLogin`) + VALUES (122, 'claimViewer','Trabajadores que consulta las reclamaciones ',1); + +INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) + VALUES (35, 122); +INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) + VALUES (18, 122); +INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) + VALUES (41, 122); +INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) + VALUES (57, 122); + +DELETE FROM `salix`.`ACL` + WHERE `model`= 'claim' + AND `property` = 'filter'; +DELETE FROM `salix`.`ACL` + WHERE `model`= 'claim' + AND `property` = 'find'; +DELETE FROM `salix`.`ACL` + WHERE `model`= 'claim' + AND `property` = 'findById'; +DELETE FROM `salix`.`ACL` + WHERE `model`= 'claim' + AND `property` = 'getSummary'; + +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) + VALUES ('Claim','filter','READ','ALLOW','ROLE','claimViewer'); +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) + VALUES ('Claim','find','READ','ALLOW','ROLE','claimViewer'); +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) + VALUES ('Claim','findById','READ','ALLOW','ROLE','claimViewer'); +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) + VALUES ('Claim','getSummary','READ','ALLOW','ROLE','claimViewer'); From beeebbdf9c7522e7f9eaf1519001e815780ba313 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 24 Aug 2023 09:33:58 +0200 Subject: [PATCH 11/14] =?UTF-8?q?refs=20#6013=20refactor:=20siempre=20se?= =?UTF-8?q?=20crea=20una=20tranacci=C3=B3n=20para=20cada=20dia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/methods/worker-time-control/sendMail.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 4988d1f46..66fb7cc23 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -180,10 +180,8 @@ module.exports = Self => { const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); for (let day of days[index]) { - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; try { workerFk = day.workerFk; if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null @@ -368,10 +366,7 @@ module.exports = Self => { previousReceiver = day.receiver; } - if (tx) { - await tx.commit(); - delete myOptions.transaction; - } + if (tx) await tx.commit(); } catch (e) { const stmts = []; let stmt; @@ -394,7 +389,6 @@ module.exports = Self => { previousReceiver = day.receiver; if (tx) await tx.rollback(); - delete myOptions.transaction; continue; } From 3694fcbbfb6c24d17538b0323efa764764e35c77 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 24 Aug 2023 10:04:32 +0200 Subject: [PATCH 12/14] refs #5881 fixCreateRol --- db/changes/233601/00-createClaimReader.sql | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/db/changes/233601/00-createClaimReader.sql b/db/changes/233601/00-createClaimReader.sql index 10ab03d29..b1accf329 100644 --- a/db/changes/233601/00-createClaimReader.sql +++ b/db/changes/233601/00-createClaimReader.sql @@ -1,33 +1,33 @@ INSERT INTO `account`.`role` (`id`, `name`, `description`, `hasLogin`) - VALUES (122, 'claimViewer','Trabajadores que consulta las reclamaciones ',1); + VALUES ('claimViewer','Trabajadores que consulta las reclamaciones ',1); INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) - VALUES (35, 122); -INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) - VALUES (18, 122); -INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) - VALUES (41, 122); -INSERT INTO `account`.`roleInherit` (`role`,`inheritsFrom`) - VALUES (57, 122); + SELECT `r`.`id`, `r2`.`id` + FROM `account`.`role` `r` + JOIN `account`.`role` `r2` ON `r2`.`name` = 'claimViewer' + WHERE `r`.`name` IN ( + 'salesPerson', + 'buyer', + 'deliveryBoss', + 'handmadeBoss' + ) DELETE FROM `salix`.`ACL` WHERE `model`= 'claim' - AND `property` = 'filter'; -DELETE FROM `salix`.`ACL` - WHERE `model`= 'claim' - AND `property` = 'find'; -DELETE FROM `salix`.`ACL` - WHERE `model`= 'claim' - AND `property` = 'findById'; -DELETE FROM `salix`.`ACL` - WHERE `model`= 'claim' - AND `property` = 'getSummary'; + AND `property` IN ( + 'filter', + 'find', + 'findById', + 'getSummary' + ); INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) - VALUES ('Claim','filter','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) - VALUES ('Claim','find','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) - VALUES ('Claim','findById','READ','ALLOW','ROLE','claimViewer'); -INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) - VALUES ('Claim','getSummary','READ','ALLOW','ROLE','claimViewer'); + SELECT 'Claim',`property`,'READ','ALLOW','ROLE','claimViewer' + FROM `salix`.`ACL` + WHERE `property` IN ( + 'filter', + 'find', + 'findById', + 'getSummary' + ) + GROUP BY `property`; From c5006b6be685b23a96f1917f215f2c812385e03b Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 24 Aug 2023 11:31:12 +0200 Subject: [PATCH 13/14] refs #5881 insertAcl --- db/changes/233601/00-createClaimReader.sql | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/db/changes/233601/00-createClaimReader.sql b/db/changes/233601/00-createClaimReader.sql index b1accf329..666bf232e 100644 --- a/db/changes/233601/00-createClaimReader.sql +++ b/db/changes/233601/00-createClaimReader.sql @@ -22,12 +22,11 @@ DELETE FROM `salix`.`ACL` ); INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) - SELECT 'Claim',`property`,'READ','ALLOW','ROLE','claimViewer' - FROM `salix`.`ACL` - WHERE `property` IN ( - 'filter', - 'find', - 'findById', - 'getSummary' - ) - GROUP BY `property`; + VALUES ('Claim','filter','READ','ALLOW','ROLE','claimViewer'); +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) + VALUES ('Claim','find','READ','ALLOW','ROLE','claimViewer'); +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) + VALUES ('Claim','findById','READ','ALLOW','ROLE','claimViewer'); +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`permission`,`principalType`,`principalid`) + VALUES ('Claim','getSummary','READ','ALLOW','ROLE','claimViewer'); + From f54a23922904e7afba8b5b69aff839769de337ff Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 25 Aug 2023 09:46:53 +0200 Subject: [PATCH 14/14] fixes #6143 fixes: this.bankEntityFk no existe --- loopback/util/specs/validateIban.spec.js | 44 ++++++++++++++----- modules/client/back/models/client.js | 3 ++ .../supplier/back/models/supplier-account.js | 3 ++ 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/loopback/util/specs/validateIban.spec.js b/loopback/util/specs/validateIban.spec.js index a5d08d4c4..dd096c1b5 100644 --- a/loopback/util/specs/validateIban.spec.js +++ b/loopback/util/specs/validateIban.spec.js @@ -1,21 +1,45 @@ const validateIban = require('../validateIban'); describe('IBAN validation', () => { - it('should return false for non-IBAN input', () => { - let isValid = validateIban('Pepinillos'); + it('should return false for invalid Spanish IBAN format', () => { + let isValid = validateIban('ES00 9999 0000 9999 0000 9999', 'ES'); expect(isValid).toBeFalsy(); }); - it('should return false for invalid spanish IBAN input', () => { - let isValid = validateIban('ES00 9999 0000 9999 0000 9999'); - - expect(isValid).toBeFalsy(); - }); - - it('should return true for valid spanish IBAN', () => { - let isValid = validateIban('ES91 2100 0418 4502 0005 1332'); + it('should return true for valid Spanish IBAN', () => { + let isValid = validateIban('ES91 2100 0418 4502 0005 1332', 'ES'); expect(isValid).toBeTruthy(); }); + + it('should return false for invalid Spanish IBAN with incorrect length', () => { + let isValid = validateIban('ES91210004184502000513', 'ES'); + + expect(isValid).toBeFalsy(); + }); + + it('should return false for invalid Spanish IBAN with incorrect module97 result', () => { + let isValid = validateIban('ES9121000418450200051331', 'ES'); + + expect(isValid).toBeFalsy(); + }); + + it('should return true for a non-Spanish countryCode', () => { + let isValid = validateIban('DE89370400440532013000', 'AT'); + + expect(isValid).toBeTruthy(); + }); + + it('should return true for null IBAN', () => { + let isValid = validateIban(null, 'ES'); + + expect(isValid).toBeTruthy(); + }); + + it('should return false for non-string IBAN', () => { + let isValid = validateIban(12345, 'ES'); + + expect(isValid).toBeFalsy(); + }); }); diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index bdf2f91b5..8e720484f 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -90,6 +90,9 @@ module.exports = Self => { }); async function ibanNeedsValidation(err, done) { + if (!this.bankEntityFk) + return done(); + const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk); const filter = { fields: ['code'], diff --git a/modules/supplier/back/models/supplier-account.js b/modules/supplier/back/models/supplier-account.js index 7a9e14421..691e72580 100644 --- a/modules/supplier/back/models/supplier-account.js +++ b/modules/supplier/back/models/supplier-account.js @@ -7,6 +7,9 @@ module.exports = Self => { }); async function ibanValidation(err, done) { + if (!this.bankEntityFk) + return done(); + const bankEntity = await Self.app.models.BankEntity.findById(this.bankEntityFk); const filter = { fields: ['code'],