From 6856ab0501d7dd14d80492271d85dd0030d5cfe2 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 16 Jul 2024 12:45:14 +0200 Subject: [PATCH 01/15] feat(salix): refs #7648 #7648 myEntries --- db/dump/fixtures.after.sql | 1 - db/dump/fixtures.before.sql | 9 +++-- .../11118-limeCymbidium/00-firstScript.sql | 21 ++++++++++ modules/entry/back/methods/entry/filter.js | 39 +++++++++++++++---- modules/entry/back/methods/entry/getBuys.js | 33 +++++++++++++--- 5 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 db/versions/11118-limeCymbidium/00-firstScript.sql diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 562ea02d8..84ce0d940 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -314,5 +314,4 @@ INSERT INTO mysql.roles_mapping (`User`, `Host`, `Role`, `Admin_option`) SELECT SUBSTR(`User`, @prefixLen + 1), `Host`, `Role`, `Admin_option` FROM mysql.roles_mapping WHERE `User` LIKE @prefixedLike AND `Host` = @genRoleHost; - FLUSH PRIVILEGES; diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 97e5f5f47..2eb0b8d1d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -118,7 +118,7 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) VALUES (1101, 'brucewayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es','1101'), - (1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en','1102'), + (1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 131, 1, 'PetterParker@mydomain.com', 'en','1102'), (1103, 'clarkkent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr','1103'), (1104, 'tonystark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es','1104'), (1105, 'maxeisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt','1105'), @@ -1477,7 +1477,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (5, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 3, 3, 1, 50.00, 500, 'fifth travel', 1, 1, 5), (6, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 4, 4, 1, 50.00, 500, 'sixth travel', 1, 2, 6), (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), - (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10); + (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10), + (10, DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`) VALUES @@ -1488,7 +1489,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (5, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 0, 442, 'IN2005', 'Movement 5', 0, 0, 'observation five'), (6, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 6, 0, 442, 'IN2006', 'Movement 6', 0, 0, 'observation six'), (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 0, 'observation seven'), - (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''); + (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''), + (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''); INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`) VALUES diff --git a/db/versions/11118-limeCymbidium/00-firstScript.sql b/db/versions/11118-limeCymbidium/00-firstScript.sql new file mode 100644 index 000000000..3921a8a13 --- /dev/null +++ b/db/versions/11118-limeCymbidium/00-firstScript.sql @@ -0,0 +1,21 @@ + +INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('Entry','filter','READ','ALLOW','ROLE','supplier'); + +INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('Entry','getBuys','READ','ALLOW','ROLE','supplier'); + +INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) + VALUES ('Entry','buyLabel','READ','ALLOW','ROLE','supplier'); + +INSERT IGNORE INTO `account`.`role` (`name`,`description`,`hasLogin`,`created`,`modified`) + VALUES ('supplier','Proveedores',1,'2017-10-10 14:58:58.000','2017-10-10 14:59:20.000'); +SET @supplierFk =LAST_INSERT_ID(); +INSERT IGNORE INTO account.roleInherit (`role`,`inheritsFrom`) + VALUES (@supplierFk,2); + +UPDATE salix.ACL + SET principalId='$authenticated' + WHERE id=264; + + diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 1cd12b737..5fbfd2d0f 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -95,6 +95,11 @@ module.exports = Self => { arg: 'to', type: 'date', description: `The to date filter` + }, + { + arg: 'days', + type: 'number', + description: `N days interval` } ], returns: { @@ -112,7 +117,6 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const conn = Self.dataSource.connector; const where = buildFilter(ctx.args, (param, value) => { switch (param) { @@ -146,7 +150,13 @@ module.exports = Self => { } }); filter = mergeFilters(ctx.args.filter, {where}); - + const userId = ctx.req.accessToken.userId; + const client = await Self.app.models.Client.findById(userId, myOptions); + const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions); + if (supplier) { + if (!filter.where) filter.where = {}; + filter.where[`e.supplierFk`] = supplier.id; + } const stmts = []; let stmt; stmt = new ParameterizedSQL( @@ -158,7 +168,7 @@ module.exports = Self => { e.invoiceNumber, e.isBooked, e.isExcludedFromAvailable, - e.evaNotes AS observation, + e.evaNotes observation, e.isConfirmed, e.isOrdered, e.isRaid, @@ -170,17 +180,32 @@ module.exports = Self => { e.gestDocFk, e.invoiceInFk, t.landed, - s.name AS supplierName, - s.nickname AS supplierAlias, - co.code AS companyCode, - cu.code AS currencyCode + s.name supplierName, + s.nickname supplierAlias, + co.code companyCode, + cu.code currencyCode, + t.shipped, + t.landed, + t.ref AS travelRef, + t.warehouseInFk, + w.name warehouseInName FROM vn.entry e JOIN vn.supplier s ON s.id = e.supplierFk JOIN vn.travel t ON t.id = e.travelFk + JOIN vn.warehouse w ON w.id = t.warehouseInFk JOIN vn.company co ON co.id = e.companyFk JOIN vn.currency cu ON cu.id = e.currencyFk` ); + if (ctx.args.days) { + stmt.merge({ + sql: ` + AND t.shipped <= util.VN_CURDATE() + INTERVAL ? DAY + AND t.shipped >= util.VN_CURDATE() + `, + params: [ctx.args.days] + }); + } stmt.merge(conn.makeSuffix(filter)); const itemsIndex = stmts.push(stmt) - 1; diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 0ed77e8d1..3a4d5cc47 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -1,7 +1,8 @@ +const UserError = require('vn-loopback/util/user-error'); const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethod('getBuys', { + Self.remoteMethodCtx('getBuys', { description: 'Returns buys for one entry', accessType: 'READ', accepts: [{ @@ -27,13 +28,20 @@ module.exports = Self => { } }); - Self.getBuys = async(id, filter, options) => { + Self.getBuys = async(ctx, id, filter, options) => { + const userId = ctx.req.accessToken.userId; const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); + const client = await Self.app.models.Client.findById(userId, myOptions); + const supplier = await Self.app.models.Supplier.findOne({where: {nif: client.fi}}, myOptions); + if (supplier) { + const isEntryOwner = (await Self.findById(id)).supplierFk === supplier.id; + if (!isEntryOwner) throw new UserError('Access Denied'); + } let defaultFilter = { where: {entryFk: id}, fields: [ @@ -49,9 +57,23 @@ module.exports = Self => { 'buyingValue', 'price2', 'price3', - 'printedStickers' + 'printedStickers', + 'entryFk' ], - include: { + include: [{ + relation: 'entry', + scope: { + fields: [ + 'id', 'supplierFk' + ], + include: { + relation: 'supplier', scope: { + fields: ['id'] + } + } + } + }, + { relation: 'item', scope: { fields: [ @@ -82,9 +104,8 @@ module.exports = Self => { } } } - } + }] }; - defaultFilter = mergeFilters(defaultFilter, filter); return models.Buy.find(defaultFilter, myOptions); From 8fe94772f332834cb43de5fb56f2a00d4db62a21 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 16 Jul 2024 12:45:31 +0200 Subject: [PATCH 02/15] feat(salix): refs #7648 #7648 buyLabels --- modules/entry/back/methods/entry/buyLabel.js | 3 ++- .../templates/reports/buy-label/buy-label.html | 2 +- print/templates/reports/buy-label/buy-label.js | 2 +- print/templates/reports/buy-label/sql/buys.sql | 18 ++++++++++++++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/entry/back/methods/entry/buyLabel.js b/modules/entry/back/methods/entry/buyLabel.js index 650b05c97..d9b0ebf1d 100644 --- a/modules/entry/back/methods/entry/buyLabel.js +++ b/modules/entry/back/methods/entry/buyLabel.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: '/:id/buy-label', verb: 'GET' - } + }, + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label'); diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label/buy-label.html index 494cdcbc5..b14e54759 100644 --- a/print/templates/reports/buy-label/buy-label.html +++ b/print/templates/reports/buy-label/buy-label.html @@ -59,7 +59,7 @@
- {{buy.id}} + {{buy.itemFk}} diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label/buy-label.js index b6e0a5031..7d626c052 100755 --- a/print/templates/reports/buy-label/buy-label.js +++ b/print/templates/reports/buy-label/buy-label.js @@ -7,7 +7,7 @@ module.exports = { name: 'buy-label', mixins: [vnReport], async serverPrefetch() { - this.buys = await this.rawSqlFromDef('buys', [this.id]); + this.buys = await this.rawSqlFromDef('buys', [this.id, this.id]); this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); const date = new Date(); this.weekNum = moment(date).isoWeek(); diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql index 50b34bd03..d75366815 100644 --- a/print/templates/reports/buy-label/sql/buys.sql +++ b/print/templates/reports/buy-label/sql/buys.sql @@ -1,4 +1,15 @@ -SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, +WITH RECURSIVE numbers AS ( + SELECT 1 n + UNION ALL + SELECT n + 1 + FROM numbers + WHERE n < ( + SELECT MAX(stickers) + FROM buy + WHERE entryFk = ? + ) +) +SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, i.name, i.`size`, i.category, @@ -8,10 +19,13 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, b.`grouping`, i.stems, b.id, + b.itemFk, p.name producer FROM buy b JOIN item i ON i.id = b.itemFk LEFT JOIN producer p ON p.id = i.producerFk LEFT JOIN ink ON ink.id = i.inkFk LEFT JOIN origin o ON o.id = i.originFk - WHERE b.entryFk = ? \ No newline at end of file + JOIN numbers num + WHERE b.entryFk = ? + AND num.n <= b.stickers From d558e3d9f4a4365cb9adde8834b77da7074a64b6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 16 Jul 2024 12:45:51 +0200 Subject: [PATCH 03/15] test(salix): refs #7648 #7648 test travels and entries --- .../back/methods/entry/specs/filter.spec.js | 98 ++++++++++++++----- .../back/methods/entry/specs/getBuys.spec.js | 86 +++++++++++++--- .../travel/specs/extraCommunityFilter.spec.js | 4 +- .../back/methods/travel/specs/filter.spec.js | 4 +- 4 files changed, 151 insertions(+), 41 deletions(-) diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 28763bc81..c7156062a 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -9,7 +9,8 @@ describe('Entry filter()', () => { const ctx = { args: { search: 1 - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); @@ -32,12 +33,13 @@ describe('Entry filter()', () => { const ctx = { args: { currencyFk: 1 - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(9); + expect(result.length).toEqual(11); await tx.rollback(); } catch (e) { @@ -46,26 +48,73 @@ describe('Entry filter()', () => { } }); - it('should return the entry matching the supplier', async() => { - const tx = await models.Entry.beginTransaction({}); - const options = {transaction: tx}; + describe('should return the entry matching the supplier', () => { + it('when userId is supplier ', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; - try { - const ctx = { - args: { - supplierFk: 2 - } - }; + try { + const ctx = { + args: {days: 6}, + req: {accessToken: {userId: 1102}} + }; - const result = await models.Entry.filter(ctx, options); + const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(2); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('when userId is supplier fetching other supplier', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: { + supplierFk: 1 + }, + req: {accessToken: {userId: 1102}} + }; + + const result = await models.Entry.filter(ctx, options); + + expect(result.length).toEqual(8); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('when userId is not supplier', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: { + supplierFk: 2 + }, + req: {accessToken: {userId: 9}} + }; + + const result = await models.Entry.filter(ctx, options); + + expect(result.length).toEqual(8); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); it('should return the entry matching the company', async() => { @@ -76,12 +125,13 @@ describe('Entry filter()', () => { const ctx = { args: { companyFk: 442 - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(8); + expect(result.length).toEqual(10); await tx.rollback(); } catch (e) { @@ -98,7 +148,8 @@ describe('Entry filter()', () => { const ctx = { args: { isBooked: true, - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); @@ -121,7 +172,8 @@ describe('Entry filter()', () => { args: { reference: 'movement', travelFk: '2' - } + }, + req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); diff --git a/modules/entry/back/methods/entry/specs/getBuys.spec.js b/modules/entry/back/methods/entry/specs/getBuys.spec.js index cf4462e48..2d3531249 100644 --- a/modules/entry/back/methods/entry/specs/getBuys.spec.js +++ b/modules/entry/back/methods/entry/specs/getBuys.spec.js @@ -1,24 +1,82 @@ +const UserError = require('vn-loopback/util/user-error'); const models = require('vn-loopback/server/server').models; describe('entry getBuys()', () => { const entryId = 4; - it('should get the buys and items of an entry', async() => { - const tx = await models.Entry.beginTransaction({}); - const options = {transaction: tx}; + describe('should get the buys and items of an entry ', () => { + it('when is supplier and entry owner', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; - try { - const result = await models.Entry.getBuys(entryId, options); + try { + const ctx = { + args: { + search: 1 + }, + req: {accessToken: {userId: 2}} + }; - const length = result.length; - const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; + const result = await models.Entry.getBuys(ctx, entryId, options); - expect(result.length).toEqual(4); - expect(anyResult.item).toBeDefined(); + const length = result.length; + const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(result.length).toEqual(4); + expect(anyResult.item).toBeDefined(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('when is supplier but not entry owner', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + const entryId = 1; + try { + const ctx = { + args: { + search: 1 + }, + req: {accessToken: {userId: 1102}} + }; + + const result = await models.Entry.getBuys(ctx, entryId, options); + + expect(result).toBeUndefined(); + } catch (error) { + expect(error).toBeInstanceOf(UserError); + expect(error.message).toBe('Access Denied'); + } + }); + + it('when is not supplier', async() => { + const tx = await models.Entry.beginTransaction({}); + const options = {transaction: tx}; + + try { + const ctx = { + args: { + search: 1 + }, + req: {accessToken: {userId: 9}} + }; + + const result = await models.Entry.getBuys(ctx, entryId, options); + + const length = result.length; + const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; + + expect(result.length).toEqual(4); + expect(anyResult.item).toBeDefined(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); }); diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 599851b55..7e90c7681 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -79,7 +79,7 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(8); + expect(result.length).toEqual(9); }); it('should return the travel matching "cargoSupplierFk"', async() => { @@ -110,6 +110,6 @@ describe('Travel extraCommunityFilter()', () => { const result = await app.models.Travel.extraCommunityFilter(ctx, filter); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); }); }); diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index 1a6ee895c..a608a980e 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -50,7 +50,7 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); }); it('should return the routes matching "shipped from" and "shipped to"', async() => { @@ -80,6 +80,6 @@ describe('Travel filter()', () => { const result = await app.models.Travel.filter(ctx); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); }); }); From b6761d3dc00057a4ab829fe2fd8407beea7b9c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 17 Jul 2024 19:08:01 +0200 Subject: [PATCH 04/15] =?UTF-8?q?fix:=20refs#7748=20solicitud=20de=20domic?= =?UTF-8?q?iliaci=C3=B3n=20bancaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print/templates/email/sepa-core/locale/es.yml | 4 +--- print/templates/email/sepa-core/locale/fr.yml | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/print/templates/email/sepa-core/locale/es.yml b/print/templates/email/sepa-core/locale/es.yml index 10a1d32fe..a8dd9032e 100644 --- a/print/templates/email/sepa-core/locale/es.yml +++ b/print/templates/email/sepa-core/locale/es.yml @@ -9,9 +9,7 @@ description: forma automatizada y electrónicamente, lo que supone para usted una reducción sustancial de costos en términos de honorarios y gastos bancarios.

En caso de que acepte nuestra propuesta, a la fecha de vencimiento de cada efecto, - se debitará a su cuenta automáticamente a través de su entidad bancaria. - Por tanto, le pedimos que firme y envíe a su banco la autorización original adjunta, - debidamente cumplimentada, y nos devuelva una fotocopia de dicha autorización.

+ se debitará a su cuenta automáticamente a través de su entidad bancaria.

Este sistema se basa en la transmisión electrónica de datos; el manejo de documentos físicos ha sido eliminado.

Le agradecemos su cooperación,

diff --git a/print/templates/email/sepa-core/locale/fr.yml b/print/templates/email/sepa-core/locale/fr.yml index 98bd7593a..6d76ef24f 100644 --- a/print/templates/email/sepa-core/locale/fr.yml +++ b/print/templates/email/sepa-core/locale/fr.yml @@ -14,11 +14,7 @@ description: et commissions bancaires.

Dans le cas où vous accepteriez notre proposition, à l’échéance de chaque effet, votre compte sera débité - automatiquement par votre Banque. - Ainsi, nous vous demandons de signer et envoyer à votre - Banque l'original de l'autorisation pour débit en annexe, - dûment remplie, et de nous retourner une photocopie de la - dite autorisation.

+ automatiquement par votre Banque.

Ce système étant basé sur la transmission de données de manière électronique, le maniement de documents physiques á été éliminé

From 684983ee424ecf8c03136548d4f8ff4b374d72a1 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 18 Jul 2024 15:14:18 +0200 Subject: [PATCH 05/15] fix: refs #7752 add new state after scan --- .../vn/procedures/expeditionPallet_build.sql | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index bea56eae6..2769190db 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -1,5 +1,10 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`(IN vExpeditions JSON, IN vArcId INT, IN vWorkerFk INT, OUT vPalletFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionPallet_build`( + vExpeditions JSON, + vArcId INT, + vWorkerFk INT, + OUT vPalletFk INT +) BEGIN /** Construye un pallet de expediciones. * @@ -7,28 +12,22 @@ BEGIN * en cuyo caso actualiza ese pallet. * * @param vExpeditions JSON_ARRAY con esta estructura [exp1, exp2, exp3, ...] - * @param vArcId INT Identificador de vn.arcRead - * @param vWorkerFk INT Identificador de vn.worker - * @param out vPalletFk Identificador de vn.expeditionPallet + * @param vArcId INT Identificador de arcRead + * @param vWorkerFk INT Identificador de worker + * @param out vPalletFk Identificador de expeditionPallet */ DECLARE vCounter INT; DECLARE vExpeditionFk INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; + DECLARE vExpeditionScanTypeFk INT; - DROP TEMPORARY TABLE IF EXISTS tExpedition; - CREATE TEMPORARY TABLE tExpedition - SELECT - e.id expeditionFk, - r.id routeFk, - ep.id palletFk - FROM - vn.expedition e, - vn.route r, - vn.expeditionPallet ep - LIMIT 0; - - ALTER TABLE tExpedition ADD PRIMARY KEY (expeditionFk); + CREATE OR REPLACE TEMPORARY TABLE tExpedition ( + expeditionFk INT, + routeFk INT, + palletFk INT, + PRIMARY KEY (expeditionFk) + ); SET vCounter = JSON_LENGTH(vExpeditions); @@ -39,53 +38,57 @@ BEGIN INSERT IGNORE INTO tExpedition(expeditionFk, routeFk, palletFk) SELECT vExpeditionFk, t.routeFk, es.palletFk - FROM vn.expedition e - LEFT JOIN vn.ticket t ON t.id = e.ticketFk - LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id + FROM expedition e + LEFT JOIN ticket t ON t.id = e.ticketFk + LEFT JOIN expeditionScan es ON es.expeditionFk = e.id WHERE e.id = vExpeditionFk; END WHILE; SELECT palletFk INTO vPalletFk FROM ( - SELECT palletFk, count(*) n - FROM tExpedition - WHERE palletFk > 0 - GROUP BY palletFk - ORDER BY n DESC - LIMIT 100 ) sub + SELECT palletFk, count(*) n + FROM tExpedition + WHERE palletFk > 0 + GROUP BY palletFk + ORDER BY n DESC + LIMIT 100 + ) sub LIMIT 1; IF vPalletFk IS NULL THEN - SELECT roadmapStopFk - INTO vTruckFk - FROM ( - SELECT rm.roadmapStopFk, count(*) n - FROM vn.routesMonitor rm - JOIN tExpedition e ON e.routeFk = rm.routeFk - GROUP BY roadmapStopFk - ORDER BY n DESC - LIMIT 1) sub; + SELECT roadmapStopFk INTO vTruckFk + FROM ( + SELECT rm.roadmapStopFk, count(*) n + FROM routesMonitor rm + JOIN tExpedition e ON e.routeFk = rm.routeFk + GROUP BY roadmapStopFk + ORDER BY n DESC + LIMIT 1 + ) sub; IF vTruckFk IS NULL THEN CALL util.throw ('TRUCK_NOT_AVAILABLE'); END IF; - INSERT INTO vn.expeditionPallet(truckFk) + INSERT INTO expeditionPallet(truckFk) VALUES(vTruckFk); SET vPalletFk = LAST_INSERT_ID(); END IF; - INSERT INTO vn.expeditionScan(expeditionFk, palletFk, workerFk) + INSERT INTO expeditionScan(expeditionFk, palletFk, workerFk) SELECT expeditionFk, vPalletFk, vWorkerFk FROM tExpedition ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; - SELECT printerFk INTO vPrinterFk - FROM vn.arcRead - WHERE id = vArcId; + SELECT id INTO vExpeditionScanTypeFk FROM expeditionScanType WHERE code = 'PALLETIZED'; - CALL vn.report_print( + INSERT INTO expeditionState(expeditionFk, typeFk) + SELECT expeditionFk, vExpeditionScanTypeFk FROM tExpedition; + + SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; + + CALL report_print( 'LabelPalletExpedition', vPrinterFk, account.myUser_getId(), @@ -93,7 +96,7 @@ BEGIN 'high' ); - UPDATE vn.expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; + UPDATE expeditionPallet SET isPrint = TRUE WHERE id = vPalletFk; DROP TEMPORARY TABLE tExpedition; END$$ From 3b529440ba45735aa62a0f9c8585a1e91ffe6076 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 18 Jul 2024 15:16:25 +0200 Subject: [PATCH 06/15] fix: refs #7752 refactor insert --- db/routines/vn/procedures/expeditionPallet_build.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 2769190db..aae10d5a5 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -70,8 +70,7 @@ BEGIN CALL util.throw ('TRUCK_NOT_AVAILABLE'); END IF; - INSERT INTO expeditionPallet(truckFk) - VALUES(vTruckFk); + INSERT INTO expeditionPallet SET truckFk = vTruckFk; SET vPalletFk = LAST_INSERT_ID(); END IF; From 29e7d9787867f5f46ee2cba687b7f07d1c077b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 18 Jul 2024 16:58:20 +0200 Subject: [PATCH 07/15] =?UTF-8?q?fix:=20refs#7748=20solicitud=20de=20domic?= =?UTF-8?q?iliaci=C3=B3n=20bancaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print/templates/email/sepa-core/locale/en.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 print/templates/email/sepa-core/locale/en.yml diff --git a/print/templates/email/sepa-core/locale/en.yml b/print/templates/email/sepa-core/locale/en.yml new file mode 100644 index 000000000..c6cc4dab4 --- /dev/null +++ b/print/templates/email/sepa-core/locale/en.yml @@ -0,0 +1,16 @@ +subject: Bank Direct Debit Request +title: SEPA CORE Direct Debit +description: + dear: Dear Customer + instructions:

Given the excellent relationship between our two companies + and to facilitate the payment processes of our invoices, we suggest the use + of the SEPA CORE direct debit system.

+

This service involves issuing our receipts to your company in an automated + and electronic manner, which represents a substantial reduction in costs for you + in terms of fees and bank charges.

+

If you accept our proposal, on the due date of each payment, it will be automatically + debited from your account through your bank.

+

This system is based on the electronic transmission of data; the handling of + physical documents has been eliminated.

+

We appreciate your cooperation,

+ conclusion: Thank you for your attention! From 9003f2db9119a7ad47ada29b8d8b8ef63e431b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 18 Jul 2024 19:37:03 +0200 Subject: [PATCH 08/15] =?UTF-8?q?fix:=20refs=20#7748=20solicitud=20de=20do?= =?UTF-8?q?miciliaci=C3=B3n=20bancaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/reports/sepa-core/sepa-core.js | 11 ---- .../reports/sepa-core/sql/client.sql | 26 ++++----- .../reports/sepa-core/sql/supplier.sql | 54 +++++++++---------- 3 files changed, 39 insertions(+), 52 deletions(-) diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 6b941556e..2600b596e 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -23,16 +23,5 @@ module.exports = { type: Number, required: true } - }, - methods: { - getSupplierCif() { - return db.findOne(` - SELECT DISTINCT ad.value - FROM supplierAccount sa - JOIN accountDetail ad ON ad.supplierAccountFk = sa.id - JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3 - WHERE sa.supplierFk = ?`) [this.companyId]; - } } - }; diff --git a/print/templates/reports/sepa-core/sql/client.sql b/print/templates/reports/sepa-core/sql/client.sql index b3ba180b3..6cdd7403f 100644 --- a/print/templates/reports/sepa-core/sql/client.sql +++ b/print/templates/reports/sepa-core/sql/client.sql @@ -1,19 +1,21 @@ -SELECT - c.id, +SELECT c.id, m.code mandateCode, c.socialName, c.street, c.postcode, c.city, c.fi, - p.name AS province, + p.name province, ct.name country, - ct.code AS countryCode, - ct.ibanLength AS ibanLength -FROM client c - JOIN country ct ON ct.id = c.countryFk - LEFT JOIN mandate m ON m.clientFk = c.id - AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN province p ON p.id = c.provinceFk -WHERE (m.companyFk = ? OR m.companyFk IS NULL) AND c.id = ? -ORDER BY m.created DESC LIMIT 1 \ No newline at end of file + ct.code countryCode, + ct.ibanLength ibanLength + FROM client c + JOIN country ct ON ct.id = c.countryFk + LEFT JOIN province p ON p.id = c.provinceFk + LEFT JOIN mandate m ON m.clientFk = c.id + AND m.companyFk = ? + AND m.finished IS NULL + WHERE (m.companyFk = ? OR m.companyFk IS NULL) + AND c.id = ? + ORDER BY m.created DESC + LIMIT 1 \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 1276f2437..749f2c430 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -1,29 +1,25 @@ -SELECT - m.code mandateCode, - s.name, - s.street, - sc.name country, - s.postCode, - s.city, - sp.name province, - s.nif, - sa.supplierFk, - be.name bankName, - ad.value accountDetailValue -FROM - client c - LEFT JOIN mandate m ON m.clientFk = c.id AND m.companyFk = ? AND m.finished IS NULL - LEFT JOIN supplier s ON s.id = m.companyFk - LEFT JOIN country sc ON sc.id = s.countryFk - LEFT JOIN province sp ON sp.id = s.provinceFk - LEFT JOIN province p ON p.id = c.provinceFk - LEFT JOIN supplierAccount sa ON sa.supplierFk = s.id - LEFT JOIN bankEntity be ON sa.bankEntityFk = be.id - LEFT JOIN accountDetail ad ON ad.supplierAccountFk = sa.id - JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk AND adt.id = 3 -WHERE - (m.companyFk = ? OR m.companyFk IS NULL) - AND (c.id = ? OR (c.id IS NULL AND c.countryFk = sa.countryFk)) -GROUP BY ad.value -ORDER BY -m.created DESC; +SELECT m.code mandateCode, + s.name, + s.street, + sc.name country, + s.postCode, + s.city, + sp.name province, + ad.value accountDetailValue + FROM client c + JOIN mandate m ON m.clientFk = c.id + JOIN mandateType mt ON mt.id = m.mandateTypeFk + JOIN supplier s ON s.id = m.companyFk + LEFT JOIN country sc ON sc.id = s.countryFk + LEFT JOIN province sp ON sp.id = s.provinceFk + JOIN supplierAccount sa ON sa.supplierFk = s.id + JOIN accountDetail ad ON ad.supplierAccountFk = sa.id + JOIN accountDetailType adt ON adt.id = ad.accountDetailTypeFk + WHERE m.companyFk = ? + AND m.finished IS NULL + AND c.id = ? + AND mt.name = 'CORE' + AND adt.description = 'Referencia Remesas' + GROUP BY m.id + ORDER BY m.created DESC + LIMIT 1; From 9d17a9e82720adee25d03003ca3551a43a5ea8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 18 Jul 2024 19:48:35 +0200 Subject: [PATCH 09/15] =?UTF-8?q?fix:=20refs=20#7748=20solicitud=20de=20do?= =?UTF-8?q?miciliaci=C3=B3n=20bancaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- print/templates/reports/sepa-core/sepa-core.js | 5 ++--- print/templates/reports/sepa-core/sql/client.sql | 11 ++--------- print/templates/reports/sepa-core/sql/supplier.sql | 5 ++--- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 2600b596e..8c4e4911c 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -1,13 +1,12 @@ const vnReport = require('../../../core/mixins/vn-report.js'); -const db = require('../../../core/database'); module.exports = { name: 'sepa-core', mixins: [vnReport], async serverPrefetch() { - this.client = await this.findOneFromDef('client', [this.companyId, this.companyId, this.id]); + this.client = await this.findOneFromDef('client', [this.id]); this.checkMainEntity(this.client); - const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.companyId, this.id]); + const suppliers = await this.rawSqlFromDef('supplier', [this.companyId, this.id]); this.supplier = { ...suppliers[0], accountDetailValue: suppliers.map(val => val?.accountDetailValue) diff --git a/print/templates/reports/sepa-core/sql/client.sql b/print/templates/reports/sepa-core/sql/client.sql index 6cdd7403f..6e0ec89eb 100644 --- a/print/templates/reports/sepa-core/sql/client.sql +++ b/print/templates/reports/sepa-core/sql/client.sql @@ -1,5 +1,4 @@ SELECT c.id, - m.code mandateCode, c.socialName, c.street, c.postcode, @@ -11,11 +10,5 @@ SELECT c.id, ct.ibanLength ibanLength FROM client c JOIN country ct ON ct.id = c.countryFk - LEFT JOIN province p ON p.id = c.provinceFk - LEFT JOIN mandate m ON m.clientFk = c.id - AND m.companyFk = ? - AND m.finished IS NULL - WHERE (m.companyFk = ? OR m.companyFk IS NULL) - AND c.id = ? - ORDER BY m.created DESC - LIMIT 1 \ No newline at end of file + JOIN province p ON p.id = c.provinceFk + WHERE c.id = ? \ No newline at end of file diff --git a/print/templates/reports/sepa-core/sql/supplier.sql b/print/templates/reports/sepa-core/sql/supplier.sql index 749f2c430..da543147a 100644 --- a/print/templates/reports/sepa-core/sql/supplier.sql +++ b/print/templates/reports/sepa-core/sql/supplier.sql @@ -20,6 +20,5 @@ SELECT m.code mandateCode, AND c.id = ? AND mt.name = 'CORE' AND adt.description = 'Referencia Remesas' - GROUP BY m.id - ORDER BY m.created DESC - LIMIT 1; + GROUP BY m.id, ad.value + ORDER BY m.created DESC \ No newline at end of file From 64b127d73c29e847f2b2ea80e5d0dd4873fef0ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 19 Jul 2024 11:27:14 +0200 Subject: [PATCH 10/15] =?UTF-8?q?fix:=20refs=20#7748=20solicitud=20de=20do?= =?UTF-8?q?miciliaci=C3=B3n=20bancaria?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/reports/sepa-core/locale/en.yml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 print/templates/reports/sepa-core/locale/en.yml diff --git a/print/templates/reports/sepa-core/locale/en.yml b/print/templates/reports/sepa-core/locale/en.yml new file mode 100644 index 000000000..6d7e23501 --- /dev/null +++ b/print/templates/reports/sepa-core/locale/en.yml @@ -0,0 +1,46 @@ +reportName: direct-debit-order +title: SEPA CORE Direct Debit Order +description: By signing this direct debit order, the debtor authorizes (A) the creditor + to send instructions to the debtor's bank to debit their account and (B) the bank to debit + their account according to the creditor's instructions. As part of their rights, + the debtor is entitled to a refund by their bank under the terms and conditions + of the contract signed with the bank. The refund request must be made within + eight weeks of the debit. You can obtain additional information about your rights + from your financial institution. +documentCopy: You must take a signed copy of this document to your Bank for registration to avoid returns. +mandatoryFields: ALL FIELDS MUST BE COMPLETED. +sendOrder: ONCE THIS DIRECT DEBIT ORDER IS SIGNED, IT MUST BE SENT TO THE CREDITOR + FOR SAFEGUARDING AND IT IS RECOMMENDED TO PROVIDE A COPY TO YOUR BANK. +supplier: + toCompleteBySupplier: To be completed by the creditor + orderReference: Direct debit order reference + identifier: Creditor identifier + name: Creditor's name + street: Address + location: Postal Code - City - Province + country: Country +client: + toCompleteByClient: To be completed by the debtor + name: Debtor's name(s) + fiscalId: NIF + street: Debtor's address + location: Postal Code - City - Province + country: Debtor's country + swift: Swift BIC + accountNumber: IBAN + accountHolder: "(Account holder(s))" + accountNumberFormat: In {0}, the IBAN consists of {1} characters always starting with {2} + paymentType: Payment type + recurrent: Recurrent + unique: Unique + signLocation: Date - City + sign: Debtor's signature and stamp +order: Direct Debit Order {0} +Francia: France +España: Spain +Portugal: Portugal +instructions: + title: Instructions + accountFields: Fill in the fields related to the bank account + signDocument: Sign and stamp the document. For it to be valid, the stamp must show the CIF/NIF. If not, the request must be accompanied by an account ownership certificate. + thanks: Thank you for your cooperation! \ No newline at end of file From 287f9edc836f38589c05696406b4c1b229e58412 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Jul 2024 11:54:21 +0200 Subject: [PATCH 11/15] fix(salix): refs #7648 #7648 improve update ACL --- db/versions/11118-limeCymbidium/00-firstScript.sql | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/db/versions/11118-limeCymbidium/00-firstScript.sql b/db/versions/11118-limeCymbidium/00-firstScript.sql index 3921a8a13..bc46e4a90 100644 --- a/db/versions/11118-limeCymbidium/00-firstScript.sql +++ b/db/versions/11118-limeCymbidium/00-firstScript.sql @@ -8,14 +8,8 @@ INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`prin INSERT IGNORE INTO salix.ACL (`model`,`property`,`accessType`,`permission`,`principalType`,`principalId`) VALUES ('Entry','buyLabel','READ','ALLOW','ROLE','supplier'); -INSERT IGNORE INTO `account`.`role` (`name`,`description`,`hasLogin`,`created`,`modified`) - VALUES ('supplier','Proveedores',1,'2017-10-10 14:58:58.000','2017-10-10 14:59:20.000'); -SET @supplierFk =LAST_INSERT_ID(); -INSERT IGNORE INTO account.roleInherit (`role`,`inheritsFrom`) - VALUES (@supplierFk,2); - UPDATE salix.ACL SET principalId='$authenticated' - WHERE id=264; + WHERE id=(SELECT id FROM salix.ACL WHERE model='StarredModule' and property='*' and `accessType`='*' ); From 2ba4ca088d79265bf14ddce799fdb4922877b717 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 09:46:20 +0200 Subject: [PATCH 12/15] fix: refs #7752 fix table name --- db/routines/vn/procedures/expeditionPallet_build.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index aae10d5a5..b2735c6bc 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -20,7 +20,7 @@ BEGIN DECLARE vExpeditionFk INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; - DECLARE vExpeditionScanTypeFk INT; + DECLARE vExpeditionStateTypeFk INT; CREATE OR REPLACE TEMPORARY TABLE tExpedition ( expeditionFk INT, @@ -80,10 +80,10 @@ BEGIN FROM tExpedition ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; - SELECT id INTO vExpeditionScanTypeFk FROM expeditionScanType WHERE code = 'PALLETIZED'; + SELECT id INTO vExpeditionStateTypeFk FROM expeditionStateType WHERE code = 'PALLETIZED'; INSERT INTO expeditionState(expeditionFk, typeFk) - SELECT expeditionFk, vExpeditionScanTypeFk FROM tExpedition; + SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; From 7b44e9f866c90360bdd73c0bc25b51cc04b5ac3a Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 09:49:54 +0200 Subject: [PATCH 13/15] fix: refs #7752 fix format --- db/routines/vn/procedures/expeditionPallet_build.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index b2735c6bc..e917c5eb2 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -80,7 +80,9 @@ BEGIN FROM tExpedition ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; - SELECT id INTO vExpeditionStateTypeFk FROM expeditionStateType WHERE code = 'PALLETIZED'; + SELECT id INTO vExpeditionStateTypeFk + FROM expeditionStateType + WHERE code = 'PALLETIZED'; INSERT INTO expeditionState(expeditionFk, typeFk) SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; From a0abc29167baa8b70dc0dd785d329ec11621b38a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 10:04:03 +0200 Subject: [PATCH 14/15] Revert "Merge pull request 'fix: refs #7752 fix table name' (!2767) from 7752-fixproc into master" This reverts commit d41262798cbaafa5cbf9efb9dc3b54063442e7c4, reversing changes made to 3d20908a42fef2f8a71e1186055963f0d5b198c9. --- db/routines/vn/procedures/expeditionPallet_build.sql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index e917c5eb2..aae10d5a5 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -20,7 +20,7 @@ BEGIN DECLARE vExpeditionFk INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; - DECLARE vExpeditionStateTypeFk INT; + DECLARE vExpeditionScanTypeFk INT; CREATE OR REPLACE TEMPORARY TABLE tExpedition ( expeditionFk INT, @@ -80,12 +80,10 @@ BEGIN FROM tExpedition ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; - SELECT id INTO vExpeditionStateTypeFk - FROM expeditionStateType - WHERE code = 'PALLETIZED'; + SELECT id INTO vExpeditionScanTypeFk FROM expeditionScanType WHERE code = 'PALLETIZED'; INSERT INTO expeditionState(expeditionFk, typeFk) - SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; + SELECT expeditionFk, vExpeditionScanTypeFk FROM tExpedition; SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; From 32e88532f91be74bb7f620cf1bc2dd24bdf05e8c Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 10:07:21 +0200 Subject: [PATCH 15/15] fix: refs #7752 fix table name (change pablo) --- db/routines/vn/procedures/expeditionPallet_build.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index aae10d5a5..e917c5eb2 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -20,7 +20,7 @@ BEGIN DECLARE vExpeditionFk INT; DECLARE vTruckFk INT; DECLARE vPrinterFk INT; - DECLARE vExpeditionScanTypeFk INT; + DECLARE vExpeditionStateTypeFk INT; CREATE OR REPLACE TEMPORARY TABLE tExpedition ( expeditionFk INT, @@ -80,10 +80,12 @@ BEGIN FROM tExpedition ON DUPLICATE KEY UPDATE palletFk = vPalletFk, workerFk = vWorkerFk; - SELECT id INTO vExpeditionScanTypeFk FROM expeditionScanType WHERE code = 'PALLETIZED'; + SELECT id INTO vExpeditionStateTypeFk + FROM expeditionStateType + WHERE code = 'PALLETIZED'; INSERT INTO expeditionState(expeditionFk, typeFk) - SELECT expeditionFk, vExpeditionScanTypeFk FROM tExpedition; + SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId;