From 1ea357a5dd5ac3ec047b14a89992fe63ac02a8bd Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 10:01:46 +0200 Subject: [PATCH 001/181] feat: refs #7126 Refactor and added columns in bs.waste table & proc --- db/dump/fixtures.before.sql | 32 ++++----- db/routines/bs/procedures/waste_addSales.sql | 67 ++++++++++++------- .../00-firstScript.sql | 22 ++++++ 3 files changed, 80 insertions(+), 41 deletions(-) create mode 100644 db/versions/11042-turquoiseAspidistra/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 06e94c99e..1f023f19c 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1473,23 +1473,23 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (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, ''); -INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleWaste`, `rate`) +INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleQuantity`, `saleInternalWaste`, `saleExternalWaste`) VALUES - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation', 1, 1, '1062', '51', '4.8'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Colombia', 2, 1, '35074', '687', '2.0'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Mini', 3, 1, '1777', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Carnation Short', 4, 1, '3182', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Crisantemo', 5, 1, '1747', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Lilium Oriental', 6, 1, '7182', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Alstroemeria', 7, 1, '1777', '13', '0.7'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 1, 1, '4181', '59', '0.6'), - ('CharlesXavier', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Cymbidium', 2, 1, '7268', '59', '0.6'), - ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Containers', 2, 1, '-74', '0', '0.0'), - ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Packagings', 3, 1, '-7', '0', '0.0'), - ('DavidCharlesHaller', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Freight', 4, 1, '1100', '0', '0.0'), - ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Funeral Accessories', 5, 1, '848', '-187', '-22.1'), - ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Miscellaneous Accessories', 6, 1, '186', '0', '0.0'), - ('HankPym', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 'Adhesives', 7, 1, '277', '0', '0.0'); + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 1, 1, '1062', '51', '56.20', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '35074', '687', '53.12', '89.69'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '1777', '13', '12.02', '53.12'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '3182', '59', '51', '56.20'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '1747', '13', '53.12', '53.12'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '7182', '59', '51', '53.12'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '1777', '13', '89.69', '89.69'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 8, 1, '4181', '59', '53.12', '53.12'), + ('35', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 9, 1, '7268', '59', '12.02', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 2, 1, '-74', '0', '51', '89.69'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 3, 1, '-7', '0', '12.02', '53.12'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 4, 1, '1100', '0', '51', '56.20'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 5, 1, '848', '-187', '12.02', '89.69'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 6, 1, '186', '0', '51', '53.12'), + ('103', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK)), WEEK(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 WEEK), 1), 7, 1, '277', '0', '53.12', '56.20'); INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) VALUES diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 0ab328b49..b705208c3 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -1,31 +1,48 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`() BEGIN - DECLARE vWeek INT; - DECLARE vYear INT; - - SELECT week, year - INTO vWeek, vYear - FROM vn.time - WHERE dated = util.VN_CURDATE(); - REPLACE bs.waste - SELECT *, 100 * mermas / total as porcentaje - FROM ( - SELECT buyer, - year, - week, - family, - itemFk, - itemTypeFk, - floor(sum(value)) as total, - floor(sum(IF(typeFk = 'loses', value, 0))) as mermas - FROM vn.saleValue - where year = vYear and week = vWeek - - GROUP BY family, itemFk - - ) sub - ORDER BY mermas DESC; + SELECT YEAR(t.shipped), + WEEK(t.shipped, 4), + it.workerFk, + it.id, + s.itemFk, + SUM(s.quantity), + SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) value, + SUM ( + IF( + a.nickname IN ( + 'MERMA: FALTAS', + 'MERMA: CONTENEDOR', + 'MERMA: TRANSPORTE/OTROS' + ), + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ) internalWaste, + SUM ( + IF( + a.nickname IN ( + 'MERMA: RECLAMACION BASURA', + 'MERMA: RECLAMACION TALLER', + 'MERMA: RECLAMACION FALTAS' + ), + (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, + 0 + ) + ) externalWaste + FROM vn.sale s + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN vn.ticket t ON t.id = s.ticketFk + STRAIGHT_JOIN vn.address a ON a.id = t.addressFk + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN cache.last_buy lb ON lb.item_id = i.id + AND lb.warehouse_id = w.id + JOIN vn.buy b ON b.id = lb.buy_id + WHERE w.isManaged + AND YEAR(t.shipped) = YEAR(util.VN_CURDATE()) + AND WEEK(t.shipped, 4) = WEEK(util.VN_CURDATE(), 4) + GROUP BY it.id, s.itemFk END$$ DELIMITER ; diff --git a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql new file mode 100644 index 000000000..5a0b23bc9 --- /dev/null +++ b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql @@ -0,0 +1,22 @@ +ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL; + +UPDATE bs.waste w + JOIN account.`user` u ON u.name = w.buyer COLLATE utf8mb3_unicode_ci + SET w.buyerFk = u.id; + +ALTER TABLE bs.waste + DROP PRIMARY KEY, + DROP COLUMN family, + DROP COLUMN rate, + DROP COLUMN buyer; + +ALTER TABLE bs.waste CHANGE buyerFk buyerFk int(10) unsigned NOT NULL AFTER `week`; +ALTER TABLE bs.waste ADD CONSTRAINT waste_user_FK FOREIGN KEY (buyerFk) REFERENCES account.user(id) ON DELETE RESTRICT ON UPDATE RESTRICT; +ALTER TABLE bs.waste ADD saleQuantity int(11) DEFAULT NULL NULL; +ALTER TABLE bs.waste MODIFY COLUMN saleTotal decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste MODIFY COLUMN saleWaste decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste CHANGE saleWaste saleInternalWaste decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste ADD saleExternalWaste decimal(10,2) DEFAULT NULL NULL; +ALTER TABLE bs.waste CHANGE saleQuantity saleQuantity decimal(10,2) DEFAULT NULL NULL AFTER itemTypeFk; +ALTER TABLE bs.waste CHANGE itemFk itemFk int(11) DEFAULT 0 NOT NULL AFTER itemTypeFk; +ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk); \ No newline at end of file From eea04520adac7fa085296bd9426fd6f4db9a8da9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 10:05:02 +0200 Subject: [PATCH 002/181] Fix: refs #7126 Fix proc --- db/routines/bs/procedures/waste_addSales.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index b705208c3..5b7f620c7 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -43,6 +43,6 @@ BEGIN WHERE w.isManaged AND YEAR(t.shipped) = YEAR(util.VN_CURDATE()) AND WEEK(t.shipped, 4) = WEEK(util.VN_CURDATE(), 4) - GROUP BY it.id, s.itemFk + GROUP BY it.id, s.itemFk; END$$ DELIMITER ; From b1e136aa47cbbb585431de51eae40bfab757d673 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 11:05:20 +0200 Subject: [PATCH 003/181] Fix: refs #7126 Tests back --- .../item/back/methods/item/getWasteByItem.js | 42 ++++++++++------ .../back/methods/item/getWasteByWorker.js | 48 +++++++++++-------- .../methods/item/specs/getWasteByItem.spec.js | 8 ++-- .../item/specs/getWasteByWorker.spec.js | 6 +-- .../buyer-week-waste/sql/wasteWeekly.sql | 18 +++---- 5 files changed, 72 insertions(+), 50 deletions(-) diff --git a/modules/item/back/methods/item/getWasteByItem.js b/modules/item/back/methods/item/getWasteByItem.js index 56b90b04a..548f28008 100644 --- a/modules/item/back/methods/item/getWasteByItem.js +++ b/modules/item/back/methods/item/getWasteByItem.js @@ -27,28 +27,42 @@ module.exports = Self => { }); Self.getWasteByItem = async(buyer, family, options) => { + const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); + const user = await models.VnUser.findOne({ + fields: ['id'], + where: {name: buyer} + }); + + const itemType = await models.ItemType.findOne({ + fields: ['id'], + where: {name: family} + }, options); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - ws.itemFk, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE buyer = ? AND family = ? - AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) - AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) - GROUP BY buyer, itemFk - ) sub - ORDER BY family, percentage DESC`, [buyer, family, date, date], myOptions); + SELECT *, 100 * dwindle / total percentage + FROM ( + SELECT u.name buyer, + it.name family, + w.itemFk, + SUM(w.saleTotal) total, + SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle + FROM bs.waste w + JOIN account.user u ON u.id = w.buyerFk + JOIN vn.itemType it ON it.id = w.itemTypeFk + WHERE w.buyerFk = ? AND w.itemTypeFk = ? + AND w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?)) + AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1) + GROUP BY w.buyerFk, w.itemFk + ) sub + ORDER BY family, percentage DESC + `, [user.id, itemType.id, date, date], myOptions); const details = []; diff --git a/modules/item/back/methods/item/getWasteByWorker.js b/modules/item/back/methods/item/getWasteByWorker.js index 8fa351eed..9af49478f 100644 --- a/modules/item/back/methods/item/getWasteByWorker.js +++ b/modules/item/back/methods/item/getWasteByWorker.js @@ -22,31 +22,37 @@ module.exports = Self => { const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` - SELECT *, 100 * dwindle / total AS percentage - FROM ( - SELECT buyer, - ws.family, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) - AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) - GROUP BY buyer, family - ) sub - ORDER BY percentage DESC`, [date, date], myOptions); + SELECT *, 100 * dwindle / total percentage + FROM ( + SELECT u.name buyer, + it.name family, + w.itemFk, + SUM(w.saleTotal) total, + SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle + FROM bs.waste w + JOIN account.user u ON u.id = w.buyerFk + JOIN vn.itemType it ON it.id = w.itemTypeFk + WHERE year = YEAR(TIMESTAMPADD(WEEK, -1, ?)) + AND week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1) + GROUP BY buyerFk, itemTypeFk + ) sub + ORDER BY percentage DESC + `, [date, date], myOptions); const wastesTotal = await Self.rawSql(` - SELECT *, 100 * dwindle / total AS percentage + SELECT *, 100 * dwindle / total percentage FROM ( - SELECT buyer, - sum(ws.saleTotal) AS total, - sum(ws.saleWaste) AS dwindle - FROM bs.waste ws - WHERE year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) - AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) - GROUP BY buyer + SELECT u.name buyer, + SUM(w.saleTotal) total, + SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle + FROM bs.waste w + JOIN account.user u ON u.id = w.buyerFk + WHERE w.year = YEAR(TIMESTAMPADD(WEEK, -1, ?)) + AND w.week = WEEK(TIMESTAMPADD(WEEK, -1, ?), 1) + GROUP BY w.buyerFk ) sub - ORDER BY percentage DESC`, [date, date], myOptions); + ORDER BY percentage DESC + `, [date, date], myOptions); const details = []; diff --git a/modules/item/back/methods/item/specs/getWasteByItem.spec.js b/modules/item/back/methods/item/specs/getWasteByItem.spec.js index 68ba02887..ac3d6c8af 100644 --- a/modules/item/back/methods/item/specs/getWasteByItem.spec.js +++ b/modules/item/back/methods/item/specs/getWasteByItem.spec.js @@ -1,18 +1,18 @@ const models = require('vn-loopback/server/server').models; -describe('Item getWasteByItem()', () => { +fdescribe('Item getWasteByItem()', () => { it('should check for the waste breakdown by worker and item', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const result = await models.Item.getWasteByItem('CharlesXavier', 'Cymbidium', options); + const result = await models.Item.getWasteByItem('buyer', 'Crisantemo', options); const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - expect(anyResult.buyer).toEqual('CharlesXavier'); - expect(anyResult.family).toEqual('Cymbidium'); + expect(anyResult.buyer).toEqual('buyer'); + expect(anyResult.family).toEqual('Crisantemo'); expect(anyResult.lines.length).toBeGreaterThanOrEqual(2); await tx.rollback(); diff --git a/modules/item/back/methods/item/specs/getWasteByWorker.spec.js b/modules/item/back/methods/item/specs/getWasteByWorker.spec.js index 52f806bd3..4dbd5b14b 100644 --- a/modules/item/back/methods/item/specs/getWasteByWorker.spec.js +++ b/modules/item/back/methods/item/specs/getWasteByWorker.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Item getWasteByWorker()', () => { +fdescribe('Item getWasteByWorker()', () => { it('should check for the waste breakdown for every worker', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; @@ -11,9 +11,9 @@ describe('Item getWasteByWorker()', () => { const length = result.length; const anyResult = result[Math.floor(Math.random() * Math.floor(length))]; - expect(anyResult.buyer).toMatch(/(CharlesXavier|HankPym|DavidCharlesHaller)/); + expect(anyResult.buyer).toMatch(/(buyer|it)/); expect(anyResult.total).toBeGreaterThanOrEqual(1000); - expect(anyResult.lines.length).toBeGreaterThanOrEqual(3); + expect(anyResult.lines.length).toBeGreaterThanOrEqual(1); await tx.rollback(); } catch (e) { diff --git a/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql b/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql index 943c085d0..1b486a004 100644 --- a/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql +++ b/print/templates/email/buyer-week-waste/sql/wasteWeekly.sql @@ -1,11 +1,13 @@ -SELECT *, 100 * dwindle / total AS percentage +SELECT *, 100 * dwindle / total `percentage` FROM ( - SELECT buyer, - sum(saleTotal) as total, - sum(saleWaste) as dwindle + SELECT u.name buyer, + SUM(saleTotal) total, + SUM(w.saleInternalWaste + w.saleExternalWaste) dwindle FROM bs.waste w - JOIN vn.time t ON w.year = t.year AND w.week = t.week - WHERE t.dated = DATE_ADD(CURDATE(), INTERVAL -1 WEEK) - GROUP BY buyer + JOIN account.user u ON u.id = w.buyerFk + JOIN vn.itemType it ON it.id = w.itemTypeFk + WHERE w.year = YEAR(util.VN_CURDATE() - INTERVAL 1 WEEK) + AND w.week = WEEK(util.VN_CURDATE() - INTERVAL 1 WEEK, 4) + GROUP BY buyerFk ) sub - ORDER BY percentage DESC; \ No newline at end of file + ORDER BY `percentage` DESC; From 13ed86d26d235538ed43d5e14182b2e849b15d07 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 11:06:49 +0200 Subject: [PATCH 004/181] Fix: refs #7126 Tests back --- modules/item/back/methods/item/specs/getWasteByItem.spec.js | 2 +- modules/item/back/methods/item/specs/getWasteByWorker.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/item/back/methods/item/specs/getWasteByItem.spec.js b/modules/item/back/methods/item/specs/getWasteByItem.spec.js index ac3d6c8af..51ee28a33 100644 --- a/modules/item/back/methods/item/specs/getWasteByItem.spec.js +++ b/modules/item/back/methods/item/specs/getWasteByItem.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Item getWasteByItem()', () => { +describe('Item getWasteByItem()', () => { it('should check for the waste breakdown by worker and item', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; diff --git a/modules/item/back/methods/item/specs/getWasteByWorker.spec.js b/modules/item/back/methods/item/specs/getWasteByWorker.spec.js index 4dbd5b14b..fba35d716 100644 --- a/modules/item/back/methods/item/specs/getWasteByWorker.spec.js +++ b/modules/item/back/methods/item/specs/getWasteByWorker.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Item getWasteByWorker()', () => { +describe('Item getWasteByWorker()', () => { it('should check for the waste breakdown for every worker', async() => { const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; From 4d1031e0313cce0eb1bd06362878fdb28e8bf206 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 13:20:15 +0200 Subject: [PATCH 005/181] feat: refs #7126 Added manaClaim calc --- db/routines/bs/procedures/waste_addSales.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 5b7f620c7..07ae088e5 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -28,7 +28,10 @@ BEGIN 'MERMA: RECLAMACION FALTAS' ), (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, - 0 + IF(c.code = 'manaClaim', + sc.value * s.quantity, + 0 + ) ) ) externalWaste FROM vn.sale s @@ -40,9 +43,11 @@ BEGIN JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = w.id JOIN vn.buy b ON b.id = lb.buy_id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN component c ON c.id = sc.componentFk WHERE w.isManaged AND YEAR(t.shipped) = YEAR(util.VN_CURDATE()) AND WEEK(t.shipped, 4) = WEEK(util.VN_CURDATE(), 4) - GROUP BY it.id, s.itemFk; + GROUP BY it.id, i.id; END$$ DELIMITER ; From 52400ab62651a38c3180b7b2eee3850986957b5c Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 20 May 2024 15:17:41 +0200 Subject: [PATCH 006/181] refs #7393 Modify night ticket closing report --- modules/ticket/back/methods/ticket/closeAll.js | 9 ++++++--- .../invoice-ticket-closure/invoice-ticket-closure.html | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index e3cbc83e2..d38cee491 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -71,7 +71,8 @@ module.exports = Self => { JSON_ARRAYAGG( JSON_OBJECT( 'ticketId', ticketFk, - 'reason', reason + 'reason', reason, + 'clientId', clientFk ) ) )errors @@ -83,7 +84,8 @@ module.exports = Self => { IF(hasErrorDeleted, 'Eliminado', NULL), IF(hasErrorItemTaxCountry, 'Impuesto no informado', NULL), IF(hasErrorAddress, 'Sin dirección', NULL), - IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason + IF(hasErrorInfoTaxAreaWorld, 'Datos exportaciones', NULL)) reason, + clientFk FROM ( SELECT t.id ticketFk, SUM(NOT c.hasToInvoice) hasErrorToInvoice, @@ -93,7 +95,8 @@ module.exports = Self => { SUM(a.id IS NULL) hasErrorAddress, SUM(ios.code IS NOT NULL AND(ad.customsAgentFk IS NULL - OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld + OR ad.incotermsFk IS NULL)) hasErrorInfoTaxAreaWorld, + t.clientFk clientFk FROM ticket t LEFT JOIN address ad ON ad.id = t.addressFk JOIN sale s ON s.ticketFk = t.id diff --git a/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html b/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html index 2effa8917..f72b2177f 100644 --- a/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html +++ b/print/templates/email/invoice-ticket-closure/invoice-ticket-closure.html @@ -7,6 +7,7 @@

{{ $t('ticketId') }}: {{ticket.ticketId}}

{{ $t('reason') }}: {{ticket.reason}}

+

{{ $t('clientId')}}{{ticket.clientId}}


From 624f4707aca2ac1e13f2e5d97c8d1be816c2979e Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 26 Jun 2024 10:43:02 +0200 Subject: [PATCH 007/181] feat: refs #7197 filter by correcting --- .../invoiceIn/back/methods/invoice-in/filter.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 0d3b5f14a..91d358016 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -82,7 +82,11 @@ module.exports = Self => { { arg: 'correctedFk', type: 'number', - description: 'The corrected invoice', + description: 'The rectified invoice', + }, + { + arg: 'correctingFk', + type: 'Boolean', } ], returns: { @@ -111,6 +115,7 @@ module.exports = Self => { } let correctings; + let correcteds; if (args.correctedFk) { correctings = await models.InvoiceInCorrection.find({ fields: ['correctingFk'], @@ -118,6 +123,9 @@ module.exports = Self => { }); } + if (args.correctingFk || args.correctingFk === false) + correcteds = await models.InvoiceInCorrection.find(); + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': @@ -141,6 +149,10 @@ module.exports = Self => { return {[`ii.${param}`]: value}; case 'awbCode': return {'sub.code': value}; + case 'correctingFk': + return args.correctingFk + ? {'ii.id': {inq: correcteds.map(x => x.correctingFk)}} + : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; } From 4bef3e9107375adbe80e844f71b9c5de8526b889 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 3 Jul 2024 17:09:10 +0200 Subject: [PATCH 008/181] refs #7531 Modify zone_getAddresses --- .../vn/procedures/zone_getAddresses.sql | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index ce7b0204e..c3a21aa83 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,7 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, - vLanded DATE + vDated DATE, + vDepartment INT ) BEGIN /** @@ -12,6 +13,7 @@ BEGIN * * @param vSelf Id de zona * @param vDated Fecha de entrega + * @param vDepartment Departamento del trabajador * @return Un select */ CALL zone_getPostalCode(vSelf); @@ -22,34 +24,47 @@ BEGIN WHERE id NOT IN ( SELECT clientFk FROM vn.ticket - WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded) + WHERE landed BETWEEN vDated AND util.dayEnd(vDated) ) + ), + hasTicketShippedToday AS ( + SELECT clientFk, + IF (COUNT(*) > 0, TRUE, FALSE) hasTicketShipped + FROM vn.ticket + WHERE shipped BETWEEN vDated AND util.dayEnd(vDated) + GROUP BY clientFk ) SELECT c.id clientFk, - c.name, - c.phone, - bt.description, - c.salesPersonFk, - u.name username, - aai.invoiced, - cnb.lastShipped - FROM vn.client c - JOIN notHasTicket ON notHasTicket.id = c.id - LEFT JOIN account.`user` u ON u.id = c.salesPersonFk - JOIN vn.`address` a ON a.clientFk = c.id - JOIN vn.postCode pc ON pc.code = a.postalCode - JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk - JOIN vn.zoneGeo zg ON zg.name = a.postalCode - JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk - LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id - LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id - JOIN vn.clientType ct ON ct.code = c.typeFk - JOIN vn.businessType bt ON bt.code = c.businessTypeFk - WHERE a.isActive - AND c.isActive - AND ct.code = 'normal' - AND bt.code <> 'worker' - GROUP BY c.id; + c.name, + c.phone, + bt.description, + c.salesPersonFk, + u.name username, + aai.invoiced, + cnb.lastShipped, + ht.hasTicketShipped + FROM vn.client c + JOIN vn.worker w ON w.id = c.salesPersonFk + JOIN vn.workerDepartment wd ON wd.workerFk = w.id + JOIN vn.department d ON d.id = wd.departmentFk + JOIN notHasTicket ON notHasTicket.id = c.id + LEFT JOIN account.`user` u ON u.id = c.salesPersonFk + JOIN vn.`address` a ON a.clientFk = c.id + JOIN vn.postCode pc ON pc.code = a.postalCode + JOIN vn.town t ON t.id = pc.townFk AND t.provinceFk = a.provinceFk + JOIN vn.zoneGeo zg ON zg.name = a.postalCode + JOIN tmp.zoneNodes zn ON zn.geoFk = pc.geoFk + LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = c.id + LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id + JOIN vn.clientType ct ON ct.code = c.typeFk + JOIN vn.businessType bt ON bt.code = c.businessTypeFk + LEFT JOIN hasTicketShippedToday ht ON ht.clientFk = c.id + WHERE a.isActive + AND c.isActive + AND ct.code = 'normal' + AND bt.code <> 'worker' + AND d.id = vDepartment + GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; END$$ From dce62245e9ffbe7cb639776b0785c8f0a262a0bb Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 4 Jul 2024 13:10:32 +0200 Subject: [PATCH 009/181] chore: refs #7197 add supplierActivityFk filter --- modules/invoiceIn/back/methods/invoice-in/filter.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 91d358016..d72d7fc63 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -87,6 +87,10 @@ module.exports = Self => { { arg: 'correctingFk', type: 'Boolean', + }, + { + arg: 'supplierActivityFk', + type: 'string', } ], returns: { @@ -155,6 +159,8 @@ module.exports = Self => { : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; + case 'supplierActivityFk': + return {'s.supplierActivityFk': value}; } }); From 460723bd7aaf4c6503c90126b01187adefeb6f5d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 8 Jul 2024 10:08:04 +0200 Subject: [PATCH 010/181] refactor: refs #6453 order_confirmWithUser --- .../procedures/order_confirmWithUser.sql | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 9c932aaa1..d85eb7f71 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -28,11 +28,8 @@ BEGIN DECLARE vClientId INT; DECLARE vCompanyId INT; DECLARE vAgencyModeId INT; - DECLARE TICKET_FREE INT DEFAULT 2; DECLARE vCalc INT; DECLARE vIsLogifloraItem BOOL; - DECLARE vOldQuantity INT; - DECLARE vNewQuantity INT; DECLARE vIsTaxDataChecked BOOL; DECLARE cDates CURSOR FOR @@ -40,14 +37,15 @@ BEGIN FROM `order` o JOIN order_row r ON r.order_id = o.id LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id - WHERE o.id = vSelf AND r.amount != 0 + WHERE o.id = vSelf + AND r.amount GROUP BY r.warehouse_id; DECLARE cRows CURSOR FOR SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo FROM order_row r JOIN vn.item i ON i.id = r.item_id - WHERE r.amount != 0 + WHERE r.amount AND r.warehouse_id = vWarehouse AND r.order_id = vSelf ORDER BY r.rate DESC; @@ -62,10 +60,20 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, a.clientFk, - o.company_id, o.agency_id, c.isTaxDataChecked - INTO vDelivery, vAddress, vNotes, vClientId, - vCompanyId, vAgencyModeId, vIsTaxDataChecked + SELECT o.date_send, + o.address_id, + o.note, + a.clientFk, + o.company_id, + o.agency_id, + c.isTaxDataChecked + INTO vDelivery, + vAddress, + vNotes, + vClientId, + vCompanyId, + vAgencyModeId, + vIsTaxDataChecked FROM hedera.`order` o JOIN vn.address a ON a.id = o.address_id JOIN vn.client c ON c.id = a.clientFk @@ -73,11 +81,11 @@ BEGIN -- Verifica si el cliente tiene los datos comprobados IF NOT vIsTaxDataChecked THEN - CALL util.throw ('clientNotVerified'); + CALL util.throw('clientNotVerified'); END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped (vDelivery, vAddress, vAgencyModeId, FALSE); + CALL vn.zone_getShipped(vDelivery, vAddress, vAgencyModeId, FALSE); -- Trabajador que realiza la accion IF vUserId IS NULL THEN @@ -94,7 +102,7 @@ BEGIN FROM order_row WHERE order_id = vSelf AND amount > 0; IF NOT vOk THEN - CALL util.throw ('ORDER_EMPTY'); + CALL util.throw('ORDER_EMPTY'); END IF; -- Crea los tickets del pedido @@ -112,23 +120,22 @@ BEGIN END IF; -- Busca un ticket existente que coincida con los parametros - WITH tPrevia AS - (SELECT DISTINCT s.ticketFk + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) + ) SELECT t.id INTO vTicket FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o - ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND vWarehouse = t.warehouseFk + AND o.date_send = t.landed + AND DATE(t.shipped) = vShipment WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL @@ -136,11 +143,8 @@ BEGIN LIMIT 1; -- Crea el ticket en el caso de no existir uno adecuado - IF vTicket IS NULL - THEN - + IF vTicket IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( vClientId, vShipment, @@ -158,7 +162,7 @@ BEGIN INSERT INTO vn.ticketTracking SET ticketFk = vTicket, userFk = vUserId, - stateFk = TICKET_FREE; + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); END IF; INSERT IGNORE INTO vn.orderTicket @@ -166,21 +170,17 @@ BEGIN ticketFk = vTicket; -- Añade las notas - - IF vNotes IS NOT NULL AND vNotes != '' - THEN + IF vNotes IS NOT NULL AND vNotes <> '' THEN INSERT INTO vn.ticketObservation SET ticketFk = vTicket, - observationTypeFk = 4 /* salesperson */ , + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE `description` = CONCAT(VALUES(`description`),'. ', `description`); END IF; -- Añade los movimientos y sus componentes - OPEN cRows; - lRows: LOOP SET vDone = FALSE; FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; @@ -191,7 +191,7 @@ BEGIN SET vSale = NULL; - SELECT s.id, s.quantity INTO vSale, vOldQuantity + SELECT s.id INTO vSale FROM vn.sale s WHERE ticketFk = vTicket AND price = vPrice @@ -204,10 +204,6 @@ BEGIN SET quantity = quantity + vAmount, originalQuantity = quantity WHERE id = vSale; - - SELECT s.quantity INTO vNewQuantity - FROM vn.sale s - WHERE id = vSale; ELSE -- Obtiene el coste SELECT SUM(rc.`price`) valueSum INTO vPriceFixed @@ -236,7 +232,8 @@ BEGIN GROUP BY vSale, rc.componentFk; END IF; - UPDATE order_row SET Id_Movimiento = vSale + UPDATE order_row + SET Id_Movimiento = vSale WHERE id = vRowId; -- Inserta en putOrder si la compra es de Floramondo @@ -245,13 +242,13 @@ BEGIN SET @available := 0; - SELECT GREATEST(0,available) INTO @available + SELECT GREATEST(0, available) INTO @available FROM cache.availableNoRaids WHERE calc_id = vCalc AND item_id = vItem; UPDATE cache.availableNoRaids - SET available = GREATEST(0,available - vAmount) + SET available = GREATEST(0, available - vAmount) WHERE item_id = vItem AND calc_id = vCalc; @@ -283,13 +280,13 @@ BEGIN LIMIT 1; END IF; END LOOP; - CLOSE cRows; END LOOP; - CLOSE cDates; - UPDATE `order` SET confirmed = TRUE, confirm_date = util.VN_NOW() + UPDATE `order` + SET confirmed = TRUE, + confirm_date = util.VN_NOW() WHERE id = vSelf; COMMIT; From b06832735260c32f1388512e15c00a02a7050fe5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 8 Jul 2024 10:49:39 +0200 Subject: [PATCH 011/181] refactor: refs #6453 order_confirmWithUser --- db/routines/hedera/procedures/order_confirmWithUser.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index d85eb7f71..3801e935b 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -97,18 +97,17 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty - SELECT COUNT(*) > 0 INTO vOk - FROM order_row WHERE order_id = vSelf AND amount > 0; + FROM order_row + WHERE order_id = vSelf + AND amount > 0; IF NOT vOk THEN CALL util.throw('ORDER_EMPTY'); END IF; -- Crea los tickets del pedido - OPEN cDates; - lDates: LOOP SET vTicket = NULL; From 8469b2ac3f0fbf08cdd740c72392644eaa658a59 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 9 Jul 2024 08:24:50 +0200 Subject: [PATCH 012/181] feat: refs #7683 productionControl --- .../vn/procedures/productionControl.sql | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index dad46393d..1b4a8e88a 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -174,27 +174,30 @@ proc: BEGIN WHERE NOT `lines`; -- Lineas por linea de encajado + CREATE OR REPLACE TEMPORARY TABLE tItemPackingType + (PRIMARY KEY(ticketFk)) + ENGINE = MEMORY + SELECT ticketFk, + SUM(sub.H) H, + SUM(sub.V) V, + SUM(sub.N) N + FROM ( + SELECT t.ticketFk, + SUM(i.itemPackingTypeFk = 'H') H, + SUM(i.itemPackingTypeFk = 'V') V, + SUM(i.itemPackingTypeFk IS NULL) N + FROM tmp.productionTicket t + JOIN sale s ON s.ticketFk = t.ticketFk + JOIN item i ON i.id = s.itemFk + GROUP BY t.ticketFk, i.itemPackingTypeFk + ) sub + GROUP BY ticketFk; + UPDATE tmp.productionBuffer pb - JOIN ( - SELECT ticketFk, - SUM(sub.H) H, - SUM(sub.V) V, - SUM(sub.N) N - FROM ( - SELECT t.ticketFk, - SUM(i.itemPackingTypeFk = 'H') H, - SUM(i.itemPackingTypeFk = 'V') V, - SUM(i.itemPackingTypeFk IS NULL) N - FROM tmp.productionTicket t - JOIN sale s ON s.ticketFk = t.ticketFk - JOIN item i ON i.id = s.itemFk - GROUP BY t.ticketFk, i.itemPackingTypeFk - ) sub - GROUP BY ticketFk - ) sub2 ON sub2.ticketFk = pb.ticketFk - SET pb.H = sub2.H, - pb.V = sub2.V, - pb.N = sub2.N; + JOIN tItemPackingType ti ON ti.ticketFk = pb.ticketFk + SET pb.H = ti.H, + pb.V = ti.V, + pb.N = ti.N; -- Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb From 2078bf58ff474db4d99f1fe66c4e67bea7c135da Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:09:00 +0200 Subject: [PATCH 013/181] feat: refs #7681 Optimization and refactor --- db/routines/vn/procedures/route_updateM3.sql | 39 +++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index 92d26b753..a2adf5b14 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -1,14 +1,35 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`(vRoute INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`route_updateM3`( + vSelf INT +) BEGIN +/** + * Actualiza el volumen de la ruta. + * + * @param vSelf Id ruta + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; - UPDATE vn.route r - LEFT JOIN ( - SELECT routeFk, SUM(volume) AS m3 - FROM saleVolume - WHERE routeFk = vRoute - ) v ON v.routeFk = r.id - SET r.m3 = IFNULL(v.m3,0) - WHERE r.id =vRoute; + CREATE OR REPLACE TEMPORARY TABLE tRouteVolume + ENGINE = MEMORY + SELECT IFNULL(SUM(volume), 0) volume + FROM saleVolume + WHERE routeFk = vSelf; + + START TRANSACTION; + + SELECT id FROM `route` WHERE id = vSelf FOR UPDATE; + + UPDATE `route` + SET m3 = (SELECT volume FROM tRouteVolume) + WHERE id = vSelf; + + COMMIT; + + DROP TEMPORARY TABLE tRouteVolume; END$$ DELIMITER ; From 042ea840558403519b68a8ff4b09d4289be124aa Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:14:55 +0200 Subject: [PATCH 014/181] feat: refs #7681 Changes --- db/routines/vn/procedures/route_updateM3.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index a2adf5b14..07ceaaf5c 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -22,8 +22,6 @@ BEGIN START TRANSACTION; - SELECT id FROM `route` WHERE id = vSelf FOR UPDATE; - UPDATE `route` SET m3 = (SELECT volume FROM tRouteVolume) WHERE id = vSelf; From a725cd2840f4af816833b3a29277d26d3fb9721c Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:19:04 +0200 Subject: [PATCH 015/181] feat: refs #7681 Changes --- db/routines/vn/procedures/route_updateM3.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index 07ceaaf5c..c2049ca26 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -22,6 +22,9 @@ BEGIN START TRANSACTION; + -- Hago el into para que no de error en los triggers + SELECT id INTO vSelf FROM `route` WHERE id = vSelf FOR UPDATE; + UPDATE `route` SET m3 = (SELECT volume FROM tRouteVolume) WHERE id = vSelf; From 376adebe9d93a7dbe7562fc47d15a94c33baa916 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:19:18 +0200 Subject: [PATCH 016/181] feat: refs #7681 Changes --- db/routines/vn/procedures/route_updateM3.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index c2049ca26..c5c85544c 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -22,7 +22,7 @@ BEGIN START TRANSACTION; - -- Hago el into para que no de error en los triggers + -- Hago el INTO para que no de error en los triggers SELECT id INTO vSelf FROM `route` WHERE id = vSelf FOR UPDATE; UPDATE `route` From 96d2bacb3dc2317e96aa679a7f82a62e9d9fa0c2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:22:42 +0200 Subject: [PATCH 017/181] feat: refs #7681 Changes --- db/routines/vn/procedures/route_updateM3.sql | 9 --------- 1 file changed, 9 deletions(-) diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index c5c85544c..6b73b3858 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -8,11 +8,6 @@ BEGIN * * @param vSelf Id ruta */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; CREATE OR REPLACE TEMPORARY TABLE tRouteVolume ENGINE = MEMORY @@ -20,8 +15,6 @@ BEGIN FROM saleVolume WHERE routeFk = vSelf; - START TRANSACTION; - -- Hago el INTO para que no de error en los triggers SELECT id INTO vSelf FROM `route` WHERE id = vSelf FOR UPDATE; @@ -29,8 +22,6 @@ BEGIN SET m3 = (SELECT volume FROM tRouteVolume) WHERE id = vSelf; - COMMIT; - DROP TEMPORARY TABLE tRouteVolume; END$$ DELIMITER ; From 769ee33ab21effdc47c4a5eba644318eac773400 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 11:40:24 +0200 Subject: [PATCH 018/181] fix: refs #7126 Added addressWaste type --- db/routines/bs/procedures/waste_addSales.sql | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 07ae088e5..14559e617 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -11,22 +11,14 @@ BEGIN SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) value, SUM ( IF( - a.nickname IN ( - 'MERMA: FALTAS', - 'MERMA: CONTENEDOR', - 'MERMA: TRANSPORTE/OTROS' - ), + aw.type = 'internal', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, 0 ) ) internalWaste, SUM ( IF( - a.nickname IN ( - 'MERMA: RECLAMACION BASURA', - 'MERMA: RECLAMACION TALLER', - 'MERMA: RECLAMACION FALTAS' - ), + aw.type = 'external', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, IF(c.code = 'manaClaim', sc.value * s.quantity, @@ -39,6 +31,7 @@ BEGIN JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.ticket t ON t.id = s.ticketFk STRAIGHT_JOIN vn.address a ON a.id = t.addressFk + LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id JOIN vn.warehouse w ON w.id = t.warehouseFk JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = w.id From c3051ebcfbe70dc2dc923e705d2d00daf4ca00c6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 11:43:15 +0200 Subject: [PATCH 019/181] fix: refs #7126 Fix --- db/routines/bs/procedures/waste_addSales.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 14559e617..4727efec9 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -36,8 +36,8 @@ BEGIN JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = w.id JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk + LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id + LEFT JOIN vn.component c ON c.id = sc.componentFk WHERE w.isManaged AND YEAR(t.shipped) = YEAR(util.VN_CURDATE()) AND WEEK(t.shipped, 4) = WEEK(util.VN_CURDATE(), 4) From f4e5f0205dc28621ea5b779a0abce2e03bb1c331 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 11:56:32 +0200 Subject: [PATCH 020/181] fix: refs #7126 Fix --- db/routines/bs/procedures/waste_addSales.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 4727efec9..ab87a0392 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -1,6 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`() BEGIN + CALL cache.last_buy_refresh (FALSE); + REPLACE bs.waste SELECT YEAR(t.shipped), WEEK(t.shipped, 4), @@ -11,14 +13,14 @@ BEGIN SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) value, SUM ( IF( - aw.type = 'internal', + aw.`type` = 'internal', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, 0 ) ) internalWaste, SUM ( IF( - aw.type = 'external', + aw.`type` = 'external', (b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity, IF(c.code = 'manaClaim', sc.value * s.quantity, @@ -30,7 +32,7 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN vn.itemType it ON it.id = i.typeFk JOIN vn.ticket t ON t.id = s.ticketFk - STRAIGHT_JOIN vn.address a ON a.id = t.addressFk + JOIN vn.address a FORCE INDEX (PRIMARY) ON a.id = t.addressFk LEFT JOIN vn.addressWaste aw ON aw.addressFk = a.id JOIN vn.warehouse w ON w.id = t.warehouseFk JOIN cache.last_buy lb ON lb.item_id = i.id From bb7002b7022a12d30d8deeefe18856a9c0ece812 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 12:00:55 +0200 Subject: [PATCH 021/181] fix: refs #7126 Minor change --- db/routines/bs/procedures/waste_addSales.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index ab87a0392..234719582 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -10,7 +10,7 @@ BEGIN it.id, s.itemFk, SUM(s.quantity), - SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) value, + SUM((b.buyingValue + b.freightValue + b.comissionValue + b.packageValue) * s.quantity) `value`, SUM ( IF( aw.`type` = 'internal', From 46e8f5b8110f1bf6d11d3e3dae15b8c66174f49f Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 07:46:18 +0200 Subject: [PATCH 022/181] feat: refs #7511 Rename to multiConfig tables --- back/methods/edi/updateData.js | 6 +++--- back/model-config.json | 2 +- back/models/user-config.json | 2 +- db/dump/fixtures.before.sql | 2 +- db/routines/pbx/views/queueConf.sql | 2 +- db/routines/vn/procedures/company_getFiscaldata.sql | 2 +- db/routines/vn/procedures/invoiceOut_new.sql | 4 ++-- db/routines/vn/procedures/item_devalueA2.sql | 2 +- db/versions/11146-maroonCordyline/00-firstScript.sql | 9 +++++++++ modules/route/back/methods/route/getExpeditionSummary.js | 2 +- myt.config.yml | 4 ++-- 11 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 db/versions/11146-maroonCordyline/00-firstScript.sql diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js index 6bebad1e4..c9789d2d8 100644 --- a/back/methods/edi/updateData.js +++ b/back/methods/edi/updateData.js @@ -24,7 +24,7 @@ module.exports = Self => { try { const options = {transaction: tx, userId: ctx.req.accessToken.userId}; - const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileConfig', null, options); + const files = await Self.rawSql('SELECT name, checksum, keyValue FROM edi.fileMultiConfig', null, options); const updatableFiles = []; for (const file of files) { @@ -54,7 +54,7 @@ module.exports = Self => { const tables = await Self.rawSql(` SELECT fileName, toTable, file - FROM edi.tableConfig + FROM edi.tableMultiConfig WHERE file IN (?)`, [fileNames], options); for (const table of tables) { @@ -228,7 +228,7 @@ module.exports = Self => { await Self.rawSql(sqlTemplate, [filePath], options); await Self.rawSql(` - UPDATE edi.tableConfig + UPDATE edi.tableMultiConfig SET updated = ? WHERE fileName = ? `, [Date.vnNew(), baseName], options); diff --git a/back/model-config.json b/back/model-config.json index 58fa86797..ecd6ed168 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -40,7 +40,7 @@ "ChatConfig": { "dataSource": "vn" }, - "DefaultViewConfig": { + "DefaultViewMultiConfig": { "dataSource": "vn" }, "Delivery": { diff --git a/back/models/user-config.json b/back/models/user-config.json index 5c5df1b9e..f8e563dc3 100644 --- a/back/models/user-config.json +++ b/back/models/user-config.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "userConfig" + "table": "userMultiConfig" } }, "properties": { diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 4f85db98a..85f689f55 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1943,7 +1943,7 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) (21, 21), (22, 22); -INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) +INSERT INTO `vn`.`userMultiConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (1, 1, 69), (5, 1, 442), diff --git a/db/routines/pbx/views/queueConf.sql b/db/routines/pbx/views/queueConf.sql index 07c241589..107989801 100644 --- a/db/routines/pbx/views/queueConf.sql +++ b/db/routines/pbx/views/queueConf.sql @@ -10,5 +10,5 @@ AS SELECT `q`.`name` AS `name`, `c`.`ringInUse` AS `ringinuse` FROM ( `pbx`.`queue` `q` - JOIN `pbx`.`queueConfig` `c` ON(`q`.`config` = `c`.`id`) + JOIN `pbx`.`queueMultiConfig` `c` ON(`q`.`config` = `c`.`id`) ) diff --git a/db/routines/vn/procedures/company_getFiscaldata.sql b/db/routines/vn/procedures/company_getFiscaldata.sql index 7c56382e9..b59ae38e1 100644 --- a/db/routines/vn/procedures/company_getFiscaldata.sql +++ b/db/routines/vn/procedures/company_getFiscaldata.sql @@ -7,7 +7,7 @@ DECLARE vCompanyFk INT; SELECT IFNULL(uc.companyFk, rc.defaultCompanyFk) INTO vCompanyFk FROM vn.routeConfig rc - LEFT JOIN userConfig uc ON uc.userFk = workerFk; + LEFT JOIN userMultiConfig uc ON uc.userFk = workerFk; SELECT diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql index 42c3f99da..c9b94027e 100644 --- a/db/routines/vn/procedures/invoiceOut_new.sql +++ b/db/routines/vn/procedures/invoiceOut_new.sql @@ -216,7 +216,7 @@ BEGIN i.transactionTypeSageFk, @vTaxCodeGeneral := i.taxClassCodeFk FROM tmp.ticketServiceTax tst - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tst.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tst.code WHERE i.isService HAVING taxableBase ) sub; @@ -229,7 +229,7 @@ BEGIN i.taxTypeSageFk , i.transactionTypeSageFk FROM tmp.ticketTax tt - JOIN invoiceOutTaxConfig i ON i.taxClassCodeFk = tt.code + JOIN invoiceOutTaxMultiConfig i ON i.taxClassCodeFk = tt.code WHERE !i.isService GROUP BY tt.pgcFk HAVING taxableBase diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index c9f716d8f..5b03fc872 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -42,7 +42,7 @@ BEGIN END IF; SELECT warehouseFk INTO vWarehouseFk - FROM userConfig + FROM userMultiConfig WHERE userFk = account.myUser_getId(); IF NOT vWarehouseFk OR vWarehouseFk IS NULL THEN diff --git a/db/versions/11146-maroonCordyline/00-firstScript.sql b/db/versions/11146-maroonCordyline/00-firstScript.sql new file mode 100644 index 000000000..16093311e --- /dev/null +++ b/db/versions/11146-maroonCordyline/00-firstScript.sql @@ -0,0 +1,9 @@ +RENAME TABLE hedera.shelfConfig TO hedera.shelfMultiConfig ; +RENAME TABLE pbx.queueConfig TO pbx.queueMultiConfig ; +RENAME TABLE salix.defaultViewConfig TO salix.defaultViewMultiConfig; +RENAME TABLE edi.fileConfig TO edi.fileMultiConfig; +RENAME TABLE edi.imapConfig TO edi.imapMultiConfig; +RENAME TABLE edi.tableConfig TO edi.tableMultiConfig; +RENAME TABLE vn.invoiceOutTaxConfig TO vn.invoiceOutTaxMultiConfig; +RENAME TABLE vn.userConfig TO vn.userMultiConfig; +RENAME TABLE vn.conveyorConfig TO vn.conveyorMultiConfig; diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index 2bd2ca43a..afe54b030 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -48,7 +48,7 @@ module.exports = Self => { LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk - LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() + LEFT JOIN vn.userMultiConfig uc ON uc.userFk = account.myUser_getId() WHERE t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub diff --git a/myt.config.yml b/myt.config.yml index 56239ca3c..116e3668a 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -42,7 +42,7 @@ fixtures: - ACL - fieldAcl - module - - defaultViewConfig + - defaultViewMultiConfig vn: - alertLevel - bookingPlanner @@ -363,7 +363,7 @@ localFixtures: - travelConfig - travelRecalc - travelThermograph - - userConfig + - userMultiConfig - vehicle - wagonConfig - wagonType From d660043df2db6ff5bd3bd6e245c8698342c3099a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 07:48:42 +0200 Subject: [PATCH 023/181] feat: refs #7511 Fix tests --- back/model-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/model-config.json b/back/model-config.json index ecd6ed168..58fa86797 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -40,7 +40,7 @@ "ChatConfig": { "dataSource": "vn" }, - "DefaultViewMultiConfig": { + "DefaultViewConfig": { "dataSource": "vn" }, "Delivery": { From b75bdc07c29f78b248357f3c445277bdfd0009d0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 08:10:34 +0200 Subject: [PATCH 024/181] refactor: refs #6453 order_confirmWithUser --- .../procedures/order_confirmWithUser.sql | 142 +++++++++--------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 3801e935b..76ff4e723 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -1,36 +1,40 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`(vSelf INT, vUserId INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWithUser`( + vSelf INT, + vUserFk INT +) BEGIN /** - * Confirms an order, creating each of its tickets on the corresponding - * date, store and user. + * Confirms an order, creating each of its tickets on + * the corresponding date, store and user. * * @param vSelf The order identifier * @param vUser The user identifier */ - DECLARE vOk BOOL; - DECLARE vDone BOOL DEFAULT FALSE; - DECLARE vWarehouse INT; + DECLARE vIsOk BOOL; + DECLARE vDone BOOL; + DECLARE vWarehouseFk INT; DECLARE vShipment DATE; - DECLARE vTicket INT; + DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); DECLARE vItem INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; DECLARE vPrice DECIMAL(10,2); - DECLARE vSale INT; + DECLARE vSaleFk INT; DECLARE vRate INT; - DECLARE vRowId INT; + DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); DECLARE vDelivery DATE; - DECLARE vAddress INT; + DECLARE vAddressFk INT; DECLARE vIsConfirmed BOOL; - DECLARE vClientId INT; - DECLARE vCompanyId INT; - DECLARE vAgencyModeId INT; - DECLARE vCalc INT; + DECLARE vClientFk INT; + DECLARE vCompanyFk INT; + DECLARE vAgencyModeFk INT; + DECLARE vCalcFk INT; DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; + DECLARE vAvailable INT; DECLARE cDates CURSOR FOR SELECT zgs.shipped, r.warehouse_id @@ -46,12 +50,11 @@ BEGIN FROM order_row r JOIN vn.item i ON i.id = r.item_id WHERE r.amount - AND r.warehouse_id = vWarehouse + AND r.warehouse_id = vWarehouseFk AND r.order_id = vSelf ORDER BY r.rate DESC; - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -68,13 +71,13 @@ BEGIN o.agency_id, c.isTaxDataChecked INTO vDelivery, - vAddress, + vAddressFk, vNotes, - vClientId, - vCompanyId, - vAgencyModeId, + vClientFk, + vCompanyFk, + vAgencyModeFk, vIsTaxDataChecked - FROM hedera.`order` o + FROM `order` o JOIN vn.address a ON a.id = o.address_id JOIN vn.client c ON c.id = a.clientFk WHERE o.id = vSelf; @@ -85,11 +88,11 @@ BEGIN END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped(vDelivery, vAddress, vAgencyModeId, FALSE); + CALL vn.zone_getShipped(vDelivery, vAddressFk, vAgencyModeFk, FALSE); -- Trabajador que realiza la accion - IF vUserId IS NULL THEN - SELECT employeeFk INTO vUserId FROM orderConfig; + IF vUserFk IS NULL THEN + SELECT employeeFk INTO vUserFk FROM orderConfig; END IF; START TRANSACTION; @@ -97,12 +100,12 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty - SELECT COUNT(*) > 0 INTO vOk + SELECT COUNT(*) > 0 INTO vIsOk FROM order_row WHERE order_id = vSelf AND amount > 0; - IF NOT vOk THEN + IF NOT vIsOk THEN CALL util.throw('ORDER_EMPTY'); END IF; @@ -110,9 +113,9 @@ BEGIN OPEN cDates; lDates: LOOP - SET vTicket = NULL; + SET vTicketFk = NULL; SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouse; + FETCH cDates INTO vShipment, vWarehouseFk; IF vDone THEN LEAVE lDates; @@ -126,13 +129,13 @@ BEGIN JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) ) - SELECT t.id INTO vTicket + SELECT t.id INTO vTicketFk FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id JOIN hedera.`order` o ON o.address_id = t.addressFk - AND vWarehouse = t.warehouseFk + AND vWarehouseFk = t.warehouseFk AND o.date_send = t.landed AND DATE(t.shipped) = vShipment WHERE o.id = vSelf @@ -142,36 +145,36 @@ BEGIN LIMIT 1; -- Crea el ticket en el caso de no existir uno adecuado - IF vTicket IS NULL THEN + IF vTicketFk IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); CALL vn.ticket_add( - vClientId, + vClientFk, vShipment, - vWarehouse, - vCompanyId, - vAddress, - vAgencyModeId, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, NULL, vDelivery, - vUserId, + vUserFk, TRUE, - vTicket + vTicketFk ); ELSE INSERT INTO vn.ticketTracking - SET ticketFk = vTicket, - userFk = vUserId, + SET ticketFk = vTicketFk, + userFk = vUserFk, stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); END IF; INSERT IGNORE INTO vn.orderTicket SET orderFk = vSelf, - ticketFk = vTicket; + ticketFk = vTicketFk; -- Añade las notas IF vNotes IS NOT NULL AND vNotes <> '' THEN INSERT INTO vn.ticketObservation SET - ticketFk = vTicket, + ticketFk = vTicketFk, observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE @@ -182,74 +185,71 @@ BEGIN OPEN cRows; lRows: LOOP SET vDone = FALSE; - FETCH cRows INTO vRowId, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH cRows INTO vRowFk, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; IF vDone THEN LEAVE lRows; END IF; - SET vSale = NULL; + SET vSaleFk = NULL; - SELECT s.id INTO vSale + SELECT s.id INTO vSaleFk FROM vn.sale s - WHERE ticketFk = vTicket + WHERE ticketFk = vTicketFk AND price = vPrice AND itemFk = vItem AND discount = 0 LIMIT 1; - IF vSale THEN + IF vSaleFk THEN UPDATE vn.sale SET quantity = quantity + vAmount, originalQuantity = quantity - WHERE id = vSale; + WHERE id = vSaleFk; ELSE -- Obtiene el coste SELECT SUM(rc.`price`) valueSum INTO vPriceFixed FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase - WHERE rc.rowFk = vRowId; + WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale SET itemFk = vItem, - ticketFk = vTicket, + ticketFk = vTicketFk, concept = vConcept, quantity = vAmount, price = vPrice, priceFixed = vPriceFixed, isPriceFixed = TRUE; - SET vSale = LAST_INSERT_ID(); + SET vSaleFk = LAST_INSERT_ID(); - INSERT INTO vn.saleComponent - (saleFk, componentFk, `value`) - SELECT vSale, rc.componentFk, rc.price + INSERT INTO vn.saleComponent (saleFk, componentFk, `value`) + SELECT vSaleFk, rc.componentFk, rc.price FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - WHERE rc.rowFk = vRowId - GROUP BY vSale, rc.componentFk; + WHERE rc.rowFk = vRowFk + GROUP BY vSaleFk, rc.componentFk; END IF; UPDATE order_row - SET Id_Movimiento = vSale - WHERE id = vRowId; + SET Id_Movimiento = vSaleFk + WHERE id = vRowFk; -- Inserta en putOrder si la compra es de Floramondo IF vIsLogifloraItem THEN - CALL cache.availableNoRaids_refresh(vCalc,FALSE,vWarehouse,vShipment); + CALL cache.availableNoRaids_refresh(vCalcFk, FALSE,vWarehouseFk, vShipment); - SET @available := 0; - - SELECT GREATEST(0, available) INTO @available + SELECT GREATEST(0, available) INTO vAvailable FROM cache.availableNoRaids - WHERE calc_id = vCalc + WHERE calc_id = vCalcFk AND item_id = vItem; UPDATE cache.availableNoRaids SET available = GREATEST(0, available - vAmount) WHERE item_id = vItem - AND calc_id = vCalc; + AND calc_id = vCalcFk; INSERT INTO edi.putOrder ( deliveryInformationID, @@ -262,20 +262,20 @@ BEGIN ) SELECT di.ID, i.supplyResponseFk, - CEIL((vAmount - @available)/ sr.NumberOfItemsPerCask), + CEIL((vAmount - vAvailable)/ sr.NumberOfItemsPerCask), o.address_id , - vClientId, + vClientFk, IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber), - vSale + vSaleFk FROM edi.deliveryInformation di JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientId + LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientFk JOIN edi.floraHollandConfig fhc - JOIN hedera.`order` o ON o.id = vSelf + JOIN `order` o ON o.id = vSelf WHERE i.id = vItem AND di.LatestOrderDateTime > util.VN_NOW() - AND vAmount > @available + AND vAmount > vAvailable LIMIT 1; END IF; END LOOP; From a8d03450732bd24292696ca17ba73c5efe703586 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 08:18:33 +0200 Subject: [PATCH 025/181] refactor: refs #6453 order_confirmWithUser --- .../procedures/order_confirmWithUser.sql | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 76ff4e723..61a7421cf 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -17,7 +17,7 @@ BEGIN DECLARE vShipment DATE; DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); - DECLARE vItem INT; + DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; DECLARE vPrice DECIMAL(10,2); @@ -46,12 +46,12 @@ BEGIN GROUP BY r.warehouse_id; DECLARE cRows CURSOR FOR - SELECT r.id, r.item_id, i.name, r.amount, r.price, r.rate, i.isFloramondo - FROM order_row r - JOIN vn.item i ON i.id = r.item_id + SELECT r.id, r.itemFk, i.name, r.amount, r.price, r.rate, i.isFloramondo + FROM orderRow r + JOIN vn.item i ON i.id = r.itemFk WHERE r.amount - AND r.warehouse_id = vWarehouseFk - AND r.order_id = vSelf + AND r.warehouseFk = vWarehouseFk + AND r.orderFk = vSelf ORDER BY r.rate DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -185,7 +185,7 @@ BEGIN OPEN cRows; lRows: LOOP SET vDone = FALSE; - FETCH cRows INTO vRowFk, vItem, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH cRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; IF vDone THEN LEAVE lRows; @@ -197,7 +197,7 @@ BEGIN FROM vn.sale s WHERE ticketFk = vTicketFk AND price = vPrice - AND itemFk = vItem + AND itemFk = vItemFk AND discount = 0 LIMIT 1; @@ -215,7 +215,7 @@ BEGIN WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale - SET itemFk = vItem, + SET itemFk = vItemFk, ticketFk = vTicketFk, concept = vConcept, quantity = vAmount, @@ -244,11 +244,11 @@ BEGIN SELECT GREATEST(0, available) INTO vAvailable FROM cache.availableNoRaids WHERE calc_id = vCalcFk - AND item_id = vItem; + AND item_id = vItemFk; UPDATE cache.availableNoRaids SET available = GREATEST(0, available - vAmount) - WHERE item_id = vItem + WHERE item_id = vItemFk AND calc_id = vCalcFk; INSERT INTO edi.putOrder ( @@ -273,7 +273,7 @@ BEGIN LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientFk JOIN edi.floraHollandConfig fhc JOIN `order` o ON o.id = vSelf - WHERE i.id = vItem + WHERE i.id = vItemFk AND di.LatestOrderDateTime > util.VN_NOW() AND vAmount > vAvailable LIMIT 1; From 0e760ba5057b97b55e97c9d1c3bd6a5481eed5dd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 08:23:43 +0200 Subject: [PATCH 026/181] refactor: refs #6453 order_confirmWithUser --- .../hedera/procedures/order_confirmWithUser.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 61a7421cf..b5962ec88 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -37,13 +37,13 @@ BEGIN DECLARE vAvailable INT; DECLARE cDates CURSOR FOR - SELECT zgs.shipped, r.warehouse_id + SELECT zgs.shipped, r.warehouseFk FROM `order` o - JOIN order_row r ON r.order_id = o.id - LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouse_id + JOIN orderRow r ON r.orderFk = o.id + LEFT JOIN tmp.zoneGetShipped zgs ON zgs.warehouseFk = r.warehouseFk WHERE o.id = vSelf AND r.amount - GROUP BY r.warehouse_id; + GROUP BY r.warehouseFk; DECLARE cRows CURSOR FOR SELECT r.id, r.itemFk, i.name, r.amount, r.price, r.rate, i.isFloramondo @@ -101,8 +101,8 @@ BEGIN -- Check order is not empty SELECT COUNT(*) > 0 INTO vIsOk - FROM order_row - WHERE order_id = vSelf + FROM orderRow + WHERE orderFk = vSelf AND amount > 0; IF NOT vIsOk THEN @@ -233,8 +233,8 @@ BEGIN GROUP BY vSaleFk, rc.componentFk; END IF; - UPDATE order_row - SET Id_Movimiento = vSaleFk + UPDATE orderRow + SET saleFk = vSaleFk WHERE id = vRowFk; -- Inserta en putOrder si la compra es de Floramondo From a1d3d2f2f8ea12ef313e705cf372bf4ceae82674 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 10:30:24 +0200 Subject: [PATCH 027/181] refactor: refs #6453 Major changes --- .../procedures/order_confirmWithUser.sql | 214 ++++++++++++------ 1 file changed, 141 insertions(+), 73 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index b5962ec88..bf4408fbc 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -5,8 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_confirmWi ) BEGIN /** - * Confirms an order, creating each of its tickets on - * the corresponding date, store and user. + * Confirms an order, creating each of its tickets + * on the corresponding date, store and user. * * @param vSelf The order identifier * @param vUser The user identifier @@ -25,7 +25,7 @@ BEGIN DECLARE vRate INT; DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); - DECLARE vDelivery DATE; + DECLARE vLanded DATE; DECLARE vAddressFk INT; DECLARE vIsConfirmed BOOL; DECLARE vClientFk INT; @@ -35,8 +35,9 @@ BEGIN DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; DECLARE vAvailable INT; + DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE cDates CURSOR FOR + DECLARE vDates CURSOR FOR SELECT zgs.shipped, r.warehouseFk FROM `order` o JOIN orderRow r ON r.orderFk = o.id @@ -45,8 +46,25 @@ BEGIN AND r.amount GROUP BY r.warehouseFk; - DECLARE cRows CURSOR FOR - SELECT r.id, r.itemFk, i.name, r.amount, r.price, r.rate, i.isFloramondo + DECLARE vDistinctItemPackingType CURSOR FOR + SELECT DISTINCT i.itemPackingTypeFk + FROM `order` o + JOIN orderRow r ON r.orderFk = o.id + JOIN vn.item i ON i.id = r.itemFk + WHERE o.id = vSelf + AND r.warehouseFk = vWarehouseFk + AND r.amount + ORDER BY i.itemPackingTypeFk DESC; + + DECLARE vRows CURSOR FOR + SELECT r.id, + r.itemFk, + i.name, + r.amount, + r.price, + r.rate, + i.itemPackingTypeFk, + i.isFloramondo FROM orderRow r JOIN vn.item i ON i.id = r.itemFk WHERE r.amount @@ -70,7 +88,7 @@ BEGIN o.company_id, o.agency_id, c.isTaxDataChecked - INTO vDelivery, + INTO vLanded, vAddressFk, vNotes, vClientFk, @@ -88,7 +106,7 @@ BEGIN END IF; -- Carga las fechas de salida de cada almacen - CALL vn.zone_getShipped(vDelivery, vAddressFk, vAgencyModeFk, FALSE); + CALL vn.zone_getShipped(vLanded, vAddressFk, vAgencyModeFk, FALSE); -- Trabajador que realiza la accion IF vUserFk IS NULL THEN @@ -110,88 +128,135 @@ BEGIN END IF; -- Crea los tickets del pedido - OPEN cDates; - lDates: - LOOP + OPEN vDates; + lDates: LOOP SET vTicketFk = NULL; SET vDone = FALSE; - FETCH cDates INTO vShipment, vWarehouseFk; + FETCH vDates INTO vShipment, vWarehouseFk; IF vDone THEN LEAVE lDates; END IF; + CREATE OR REPLACE TEMPORARY TABLE tTicketByItemPackingType( + itemPackingTypeFk VARCHAR(1), + ticketFk INT, + PRIMARY KEY(itemPackingTypeFk, ticketFk) + ) ENGINE = MEMORY; + -- Busca un ticket existente que coincida con los parametros - WITH tPrevia AS ( - SELECT DISTINCT s.ticketFk - FROM vn.sale s - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) - SELECT t.id INTO vTicketFk - FROM vn.ticket t - JOIN vn.alertLevel al ON al.code = 'FREE' - LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o ON o.address_id = t.addressFk - AND vWarehouseFk = t.warehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment - WHERE o.id = vSelf - AND t.refFk IS NULL - AND tp.ticketFk IS NULL - AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) - LIMIT 1; + OPEN vDistinctItemPackingType; + lDistinctItemPackingType: LOOP + SET vItemPackingTypeFk = NULL; + SET vDone = FALSE; + FETCH vDistinctItemPackingType INTO vItemPackingTypeFk; - -- Crea el ticket en el caso de no existir uno adecuado - IF vTicketFk IS NULL THEN - SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( - vClientFk, - vShipment, - vWarehouseFk, - vCompanyFk, - vAddressFk, - vAgencyModeFk, - NULL, - vDelivery, - vUserFk, - TRUE, - vTicketFk - ); - ELSE - INSERT INTO vn.ticketTracking - SET ticketFk = vTicketFk, - userFk = vUserFk, - stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); - END IF; + IF vDone THEN + LEAVE lDistinctItemPackingType; + END IF; - INSERT IGNORE INTO vn.orderTicket - SET orderFk = vSelf, - ticketFk = vTicketFk; + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk + FROM vn.sale s + JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk + WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) + ), + tTicketSameItemPackingType AS ( + SELECT t.id, COUNT(*) = SUM(IF( + vItemPackingTypeFk IS NOT NULL, + i.itemPackingTypeFk = vItemPackingTypeFk, + i.itemPackingTypeFk IS NULL + )) hasSameItemPackingType + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.shipped = vShipment + GROUP BY t.id + HAVING hasSameItemPackingType + ) + SELECT t.id INTO vTicketFk + FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' + LEFT JOIN tPrevia tp ON tp.ticketFk = t.id + LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.warehouseFk = vWarehouseFk + AND o.date_send = t.landed + AND DATE(t.shipped) = vShipment + JOIN tTicketSameItemPackingType tt ON tt.id = t.id + WHERE o.id = vSelf + AND t.refFk IS NULL + AND tp.ticketFk IS NULL + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) + LIMIT 1; - -- Añade las notas - IF vNotes IS NOT NULL AND vNotes <> '' THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicketFk, - observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), - `description` = vNotes - ON DUPLICATE KEY UPDATE - `description` = CONCAT(VALUES(`description`),'. ', `description`); - END IF; + -- Crea el ticket en el caso de no existir uno adecuado + IF vTicketFk IS NULL THEN + SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); + CALL vn.ticket_add( + vClientFk, + vShipment, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + NULL, + vLanded, + vUserFk, + TRUE, + vTicketFk + ); + ELSE + INSERT INTO vn.ticketTracking + SET ticketFk = vTicketFk, + userFk = vUserFk, + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); + END IF; + + INSERT IGNORE INTO vn.orderTicket + SET orderFk = vSelf, + ticketFk = vTicketFk; + + -- Añade las notas + IF vNotes IS NOT NULL AND vNotes <> '' THEN + INSERT INTO vn.ticketObservation SET + ticketFk = vTicketFk, + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), + `description` = vNotes + ON DUPLICATE KEY UPDATE + `description` = CONCAT(VALUES(`description`),'. ', `description`); + END IF; + + INSERT INTO tTicketByItemPackingType + SET itemPackingTypeFk = vItemPackingTypeFk, + ticketFk = vTicketFk; + END LOOP; + CLOSE vDistinctItemPackingType; -- Añade los movimientos y sus componentes - OPEN cRows; + OPEN vRows; lRows: LOOP + SET vSaleFk = NULL; SET vDone = FALSE; - FETCH cRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice, vRate, vIsLogifloraItem; + FETCH vRows INTO vRowFk, + vItemFk, + vConcept, + vAmount, + vPrice, + vRate, + vItemPackingTypeFk, + vIsLogifloraItem; IF vDone THEN LEAVE lRows; END IF; - SET vSaleFk = NULL; + SELECT ticketFk INTO vTicketFk + FROM tTicketByItemPackingType + WHERE IF(vItemPackingTypeFk IS NOT NULL, + itemPackingTypeFk = vItemPackingTypeFk, + itemPackingTypeFk IS NULL) SELECT s.id INTO vSaleFk FROM vn.sale s @@ -211,7 +276,8 @@ BEGIN SELECT SUM(rc.`price`) valueSum INTO vPriceFixed FROM orderRowComponent rc JOIN vn.component c ON c.id = rc.componentFk - JOIN vn.componentType ct ON ct.id = c.typeFk AND ct.isBase + JOIN vn.componentType ct ON ct.id = c.typeFk + AND ct.isBase WHERE rc.rowFk = vRowFk; INSERT INTO vn.sale @@ -279,9 +345,9 @@ BEGIN LIMIT 1; END IF; END LOOP; - CLOSE cRows; + CLOSE vRows; END LOOP; - CLOSE cDates; + CLOSE vDates; UPDATE `order` SET confirmed = TRUE, @@ -289,5 +355,7 @@ BEGIN WHERE id = vSelf; COMMIT; + + DROP TEMPORARY TABLE tTicketByItemPackingType; END$$ DELIMITER ; From 7e415181c2afb40421ca3bf109533ea674c9606b Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 11:26:45 +0200 Subject: [PATCH 028/181] refactor: refs #6453 Major changes --- .../procedures/order_confirmWithUser.sql | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index bf4408fbc..246648e18 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -36,6 +36,7 @@ BEGIN DECLARE vIsTaxDataChecked BOOL; DECLARE vAvailable INT; DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vCountDistinctItemPackingTypeFk INT; DECLARE vDates CURSOR FOR SELECT zgs.shipped, r.warehouseFk @@ -54,7 +55,7 @@ BEGIN WHERE o.id = vSelf AND r.warehouseFk = vWarehouseFk AND r.amount - ORDER BY i.itemPackingTypeFk DESC; + ORDER BY i.itemPackingTypeFk DESC; -- El último siempre NULL!! DECLARE vRows CURSOR FOR SELECT r.id, @@ -155,6 +156,28 @@ BEGIN LEAVE lDistinctItemPackingType; END IF; + IF vItemPackingTypeFk IS NULL THEN + SELECT COUNT(*) INTO vCountDistinctItemPackingTypeFk + FROM tTicketByItemPackingType; + + CASE + WHEN vCountDistinctItemPackingTypeFk = 1 THEN + INSERT INTO tTicketByItemPackingType + SET itemPackingTypeFk = vItemPackingTypeFk, + ticketFk = (SELECT ticketFk FROM tTicketByItemPackingType); + LEAVE lDistinctItemPackingType; + WHEN vCountDistinctItemPackingTypeFk > 1 THEN + INSERT INTO tTicketByItemPackingType + SET itemPackingTypeFk = vItemPackingTypeFk, + ticketFk = ( + SELECT ticketFk + FROM tTicketByItemPackingType + WHERE itemPackingTypeFk = 'H' + ); + LEAVE lDistinctItemPackingType; + END CASE; + END IF; + WITH tPrevia AS ( SELECT DISTINCT s.ticketFk FROM vn.sale s From 15f580508bf3e4cfcb32bd63b49847c8e8e6ba98 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 11:29:14 +0200 Subject: [PATCH 029/181] refactor: refs #6453 Minor changes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 246648e18..fe0f33b3f 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -55,7 +55,8 @@ BEGIN WHERE o.id = vSelf AND r.warehouseFk = vWarehouseFk AND r.amount - ORDER BY i.itemPackingTypeFk DESC; -- El último siempre NULL!! + ORDER BY i.itemPackingTypeFk DESC; + -- El último siempre NULL, es imprescindible para la lógica !!! DECLARE vRows CURSOR FOR SELECT r.id, From 889982dd82e09e038ae3a89766b50481742b4a56 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 12:00:54 +0200 Subject: [PATCH 030/181] refactor: refs #7126 Requested changes --- db/routines/bs/procedures/waste_addSales.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 234719582..3e189d2e6 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -1,7 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`() BEGIN - CALL cache.last_buy_refresh (FALSE); + DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(CURDATE()) DAY; + DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY; + + CALL cache.last_buy_refresh(FALSE); REPLACE bs.waste SELECT YEAR(t.shipped), @@ -40,9 +43,8 @@ BEGIN JOIN vn.buy b ON b.id = lb.buy_id LEFT JOIN vn.saleComponent sc ON sc.saleFk = s.id LEFT JOIN vn.component c ON c.id = sc.componentFk - WHERE w.isManaged - AND YEAR(t.shipped) = YEAR(util.VN_CURDATE()) - AND WEEK(t.shipped, 4) = WEEK(util.VN_CURDATE(), 4) + WHERE t.shipped BETWEEN vDateFrom AND vDateTo + AND w.isManaged GROUP BY it.id, i.id; END$$ DELIMITER ; From a2f2ed743d7cb516f15d47073b00378d88334aec Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 13:31:48 +0200 Subject: [PATCH 031/181] refactor: refs #7681 Changes --- db/routines/vn/procedures/route_updateM3.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index 6b73b3858..1df37ec8e 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -8,16 +8,12 @@ BEGIN * * @param vSelf Id ruta */ - CREATE OR REPLACE TEMPORARY TABLE tRouteVolume ENGINE = MEMORY SELECT IFNULL(SUM(volume), 0) volume FROM saleVolume WHERE routeFk = vSelf; - -- Hago el INTO para que no de error en los triggers - SELECT id INTO vSelf FROM `route` WHERE id = vSelf FOR UPDATE; - UPDATE `route` SET m3 = (SELECT volume FROM tRouteVolume) WHERE id = vSelf; From 6dc464d26b15de4f83815ff01a44bce620f74233 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 11 Jul 2024 07:14:02 +0200 Subject: [PATCH 032/181] refactor: refs #6453 Minor changes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index fe0f33b3f..c48b74dd7 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -162,6 +162,8 @@ BEGIN FROM tTicketByItemPackingType; CASE + WHEN NOT vCountDistinctItemPackingTypeFk THEN + -- Code WHEN vCountDistinctItemPackingTypeFk = 1 THEN INSERT INTO tTicketByItemPackingType SET itemPackingTypeFk = vItemPackingTypeFk, @@ -196,6 +198,7 @@ BEGIN JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk WHERE t.shipped = vShipment + AND t.warehouseFk= vWarehouseFk GROUP BY t.id HAVING hasSameItemPackingType ) From 94470915daf97f387269ad9fe011344776c7ab3c Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 15 Jul 2024 08:21:54 +0200 Subject: [PATCH 033/181] feat: redirect to lilium page not found --- front/salix/routes.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/front/salix/routes.js b/front/salix/routes.js index be210b749..ee3a9cd10 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -4,7 +4,14 @@ import getMainRoute from 'core/lib/get-main-route'; config.$inject = ['$stateProvider', '$urlRouterProvider']; function config($stateProvider, $urlRouterProvider) { $urlRouterProvider - .otherwise('/'); + .otherwise(async($injector, {$location}) => { + const url = $location.$$absUrl + .replace('5000', '9000') + .replace('salix', 'lilium') + .replace('#!', '#') + .replace('client', 'customer'); + window.location.href = url; + }); $stateProvider .state('layout', { From 200a6714bb019781ddd1577c6c9f8e847263d802 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 15 Jul 2024 12:02:00 +0200 Subject: [PATCH 034/181] fix: refs #7722 delete sms --- db/routines/vn/procedures/clean.sql | 4 ++++ db/versions/11152-goldenRaphis/00-firstScript.sql | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 db/versions/11152-goldenRaphis/00-firstScript.sql diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 6645b9cb2..613139fc7 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -28,6 +28,10 @@ BEGIN DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE FROM entryLog WHERE creationDate < v2Months; DELETE IGNORE FROM expedition WHERE created < v26Months; + DELETE cs.* + FROM sms s + JOIN clientSms cs ON cs.smsFk = s.id + WHERE s. created < v18Months; DELETE FROM sms WHERE created < v18Months; DELETE FROM saleTracking WHERE created < v1Years; DELETE FROM productionError WHERE dated < v1Years; diff --git a/db/versions/11152-goldenRaphis/00-firstScript.sql b/db/versions/11152-goldenRaphis/00-firstScript.sql new file mode 100644 index 000000000..ad58a570a --- /dev/null +++ b/db/versions/11152-goldenRaphis/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.ticketSms__ DROP FOREIGN KEY IF EXISTS ticketSms_FK; +ALTER TABLE vn.ticketSms__ ADD CONSTRAINT ticketSms_FK FOREIGN KEY (smsFk) REFERENCES vn.sms(id) ON DELETE CASCADE ON UPDATE CASCADE; From 8f41546829f4bcf59eb9c720ef2e65168d1172f6 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 15 Jul 2024 14:25:42 +0200 Subject: [PATCH 035/181] feat: refs #7222 --- db/routines/vn/procedures/clean.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 613139fc7..0799c8fda 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -31,7 +31,7 @@ BEGIN DELETE cs.* FROM sms s JOIN clientSms cs ON cs.smsFk = s.id - WHERE s. created < v18Months; + WHERE s.created < v18Months; DELETE FROM sms WHERE created < v18Months; DELETE FROM saleTracking WHERE created < v1Years; DELETE FROM productionError WHERE dated < v1Years; From 0fb882e6886fffedb3fed642b2855d03c8959433 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 15 Jul 2024 14:55:11 +0200 Subject: [PATCH 036/181] feat: refs #7722 changes required --- db/routines/vn/procedures/clean.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 0799c8fda..f479d5b3e 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -28,7 +28,7 @@ BEGIN DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE FROM entryLog WHERE creationDate < v2Months; DELETE IGNORE FROM expedition WHERE created < v26Months; - DELETE cs.* + DELETE cs FROM sms s JOIN clientSms cs ON cs.smsFk = s.id WHERE s.created < v18Months; From 8d61cb762bf33c725c98892cce2ea1028ab1e2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 15 Jul 2024 17:53:23 +0200 Subject: [PATCH 037/181] feat: tabla config dias margen vctos. refs #7728 --- db/routines/vn/procedures/invoiceInDueDay_calculate.sql | 9 ++++++--- db/versions/11155-purpleMoss/00-firstScript.sql | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 db/versions/11155-purpleMoss/00-firstScript.sql diff --git a/db/routines/vn/procedures/invoiceInDueDay_calculate.sql b/db/routines/vn/procedures/invoiceInDueDay_calculate.sql index e51b5f64d..7929bee6f 100644 --- a/db/routines/vn/procedures/invoiceInDueDay_calculate.sql +++ b/db/routines/vn/procedures/invoiceInDueDay_calculate.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`(vInvoiceInFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInDueDay_calculate`( +vInvoiceInFk INT +) BEGIN /** * Calcula los vctos. de una factura recibida @@ -56,12 +58,13 @@ BEGIN COUNT(DISTINCT(pdd.detail)) cont, s.payDay, ii.issued, - DATE(ii.created) + INTERVAL 2 DAY created + DATE(ii.created) + INTERVAL iic.dueDateMarginDays DAY created FROM invoiceIn ii JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id LEFT JOIN sage.TiposIva ti ON ti.CodigoIva= iit.taxTypeSageFk JOIN supplier s ON s.id = ii.supplierFk - JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN payDemDetail pdd ON pdd.id = s.payDemFk + JOIN invoiceInConfig iic WHERE ii.id = vInvoiceInFk GROUP BY ii.id )sub diff --git a/db/versions/11155-purpleMoss/00-firstScript.sql b/db/versions/11155-purpleMoss/00-firstScript.sql new file mode 100644 index 000000000..fec63b193 --- /dev/null +++ b/db/versions/11155-purpleMoss/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.invoiceInConfig + ADD dueDateMarginDays INT UNSIGNED DEFAULT 2 NULL; From c086de264489f3aa6e91a3d7d098596b2fc3cebc Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Jul 2024 11:38:44 +0200 Subject: [PATCH 038/181] hotFix itemShelvingSale refs #6861 --- db/versions/11157-limeDendro/00-firstScript.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/versions/11157-limeDendro/00-firstScript.sql diff --git a/db/versions/11157-limeDendro/00-firstScript.sql b/db/versions/11157-limeDendro/00-firstScript.sql new file mode 100644 index 000000000..21071ee3f --- /dev/null +++ b/db/versions/11157-limeDendro/00-firstScript.sql @@ -0,0 +1,11 @@ + +ALTER TABLE vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_3; +ALTER TABLE vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_2; +ALTER TABLE vn.sectorCollectionSaleGroup DROP KEY saleGroupFk; + + +ALTER TABLE vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_saleGroup_FK + FOREIGN KEY (saleGroupFk) REFERENCES vn.saleGroup(id) ON DELETE CASCADE ON UPDATE CASCADE; + + +ALTER TABLE vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_unique UNIQUE KEY (sectorCollectionFk,saleGroupFk); \ No newline at end of file From 6856ab0501d7dd14d80492271d85dd0030d5cfe2 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 16 Jul 2024 12:45:14 +0200 Subject: [PATCH 039/181] 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 040/181] 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 041/181] 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 3f297acbd388cc7388d284e4abfb0b63f10c9266 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Jul 2024 13:06:04 +0200 Subject: [PATCH 042/181] hotFix itemShelvingSale refs #6861 --- db/versions/11157-limeDendro/00-firstScript.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/versions/11157-limeDendro/00-firstScript.sql b/db/versions/11157-limeDendro/00-firstScript.sql index 21071ee3f..fa13f14a2 100644 --- a/db/versions/11157-limeDendro/00-firstScript.sql +++ b/db/versions/11157-limeDendro/00-firstScript.sql @@ -1,11 +1,11 @@ -ALTER TABLE vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_3; -ALTER TABLE vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_2; -ALTER TABLE vn.sectorCollectionSaleGroup DROP KEY saleGroupFk; +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_3; +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup DROP FOREIGN KEY sectorCollectionSaleGroup_ibfk_2; +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup DROP KEY saleGroupFk; -ALTER TABLE vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_saleGroup_FK +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_saleGroup_FK FOREIGN KEY (saleGroupFk) REFERENCES vn.saleGroup(id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_unique UNIQUE KEY (sectorCollectionFk,saleGroupFk); \ No newline at end of file +ALTER TABLE IF EXISTS vn.sectorCollectionSaleGroup ADD CONSTRAINT sectorCollectionSaleGroup_unique UNIQUE KEY (sectorCollectionFk,saleGroupFk); \ No newline at end of file From 38d863aac63c76873eed12cdf8461c99786e587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 18:44:24 +0200 Subject: [PATCH 043/181] feat: refactor buyUltimate refs #7736 --- .../cache/procedures/last_buy_refresh.sql | 2 +- .../vn/procedures/available_traslate.sql | 2 +- db/routines/vn/procedures/buyUltimate.sql | 31 +--- .../vn/procedures/buyUltimateFromInterval.sql | 150 +-------------- db/routines/vn/procedures/buy_getUltimate.sql | 48 +++++ .../buy_getUltimateFromInterval .sql | 174 ++++++++++++++++++ .../vn/procedures/buy_updateGrouping.sql | 2 +- .../vn/procedures/buy_updatePacking.sql | 2 +- .../vn/procedures/catalog_calculate.sql | 2 +- .../vn/procedures/entry_getTransfer.sql | 2 +- .../vn/procedures/itemShelving_addByClaim.sql | 2 +- .../itemShelving_getItemDetails.sql | 2 +- db/routines/vn/procedures/item_devalueA2.sql | 2 +- db/routines/vn/procedures/item_getInfo.sql | 6 +- .../vn/procedures/item_multipleBuy.sql | 2 +- .../vn/procedures/item_valuateInventory.sql | 2 +- .../vn/procedures/sale_getProblems.sql | 2 +- .../vn/procedures/sale_recalcComponent.sql | 2 +- .../vn/procedures/sale_replaceItem.sql | 4 +- .../vn/procedures/sale_setProblemRounding.sql | 2 +- db/routines/vn/procedures/stockTraslation.sql | 2 +- .../vn/procedures/ticket_componentPreview.sql | 7 +- .../procedures/ticket_setProblemRounding.sql | 2 +- .../entry/back/methods/entry/addFromBuy.js | 4 +- .../entry/back/methods/entry/importBuys.js | 3 +- .../entry/back/methods/entry/lastItemBuys.js | 3 +- .../methods/order/getItemTypeAvailable.js | 15 +- 27 files changed, 265 insertions(+), 212 deletions(-) create mode 100644 db/routines/vn/procedures/buy_getUltimate.sql create mode 100644 db/routines/vn/procedures/buy_getUltimateFromInterval .sql diff --git a/db/routines/cache/procedures/last_buy_refresh.sql b/db/routines/cache/procedures/last_buy_refresh.sql index 49ef4ee5e..0f80163fb 100644 --- a/db/routines/cache/procedures/last_buy_refresh.sql +++ b/db/routines/cache/procedures/last_buy_refresh.sql @@ -30,7 +30,7 @@ proc: BEGIN SELECT inventoried INTO started FROM vn.config LIMIT 1; SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); - CALL vn.buyUltimateFromInterval(NULL, started, ended); + CALL vn.buy_getUltimateFromInterval (NULL, NULL, started, ended); DELETE FROM last_buy; diff --git a/db/routines/vn/procedures/available_traslate.sql b/db/routines/vn/procedures/available_traslate.sql index d33a8e10e..e4ba13d79 100644 --- a/db/routines/vn/procedures/available_traslate.sql +++ b/db/routines/vn/procedures/available_traslate.sql @@ -47,7 +47,7 @@ proc: BEGIN -- Tabla con el ultimo dia de last_buy para cada producto -- que hace un replace de la anterior. - CALL buyUltimate(vWarehouseShipment, util.VN_CURDATE()); + CALL buy_getUltimate (NULL, vWarehouseShipment, util.VN_CURDATE()); INSERT INTO tItemRange SELECT t.itemFk, tr.landed diff --git a/db/routines/vn/procedures/buyUltimate.sql b/db/routines/vn/procedures/buyUltimate.sql index 98b16cbc0..7026c8c82 100644 --- a/db/routines/vn/procedures/buyUltimate.sql +++ b/db/routines/vn/procedures/buyUltimate.sql @@ -5,39 +5,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`( ) BEGIN /** + * DEPRECATED usar buy_getUltimate * Calcula las últimas compras realizadas hasta una fecha * + * @param vItemFk Id del artículo * @param vWarehouseFk Id del almacén * @param vDated Compras hasta fecha * @return tmp.buyUltimate */ - CALL cache.last_buy_refresh (FALSE); - - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; - CREATE TEMPORARY TABLE tmp.buyUltimate - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(itemFk)) - ENGINE = MEMORY - SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing - FROM cache.last_buy - WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - - IF vDated >= util.VN_CURDATE() THEN - CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); - - REPLACE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed <= vDated - AND NOT isIgnored; - - INSERT IGNORE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed > vDated - ORDER BY isIgnored = FALSE DESC; - END IF; + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 5879b58e1..75dfff489 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -6,6 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInte ) BEGIN /** + * DEPRECATED usar buy_getUltimateFromInterval * Calcula las últimas compras realizadas * desde un rango de fechas. * @@ -14,153 +15,6 @@ BEGIN * @param vEnded Fecha fin * @return tmp.buyUltimateFromInterval */ - IF vEnded IS NULL THEN - SET vEnded = vStarted; - END IF; - - IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); - END IF; - - -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) - ENGINE = MEMORY - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - -- ItemOriginal - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM - (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; + CALL vn.buy_getUltimateFromInterval (NULL,vWarehouseFk,vStarted,vEnded); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql new file mode 100644 index 000000000..36ae10fd8 --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -0,0 +1,48 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( + vItemFk INT, + vWarehouseFk SMALLINT, + vDated DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas hasta una fecha + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @param vDated Compras hasta fecha + * @return tmp.buyUltimate + */ + CALL cache.last_buy_refresh (FALSE); + + DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; + CREATE TEMPORARY TABLE tmp.buyUltimate + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(itemFk)) + ENGINE = MEMORY + SELECT item_id itemFk, buy_id buyFk, warehouse_id warehouseFk, landing + FROM cache.last_buy + WHERE (warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL) + AND (item_id = vItemFk OR vItemFk IS NULL); + + IF vDated >= util.VN_CURDATE() THEN + CALL buyUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); + + REPLACE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed <= vDated + AND NOT isIgnored; + + INSERT IGNORE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND (itemFk = vItemFk OR vItemFk IS NULL) + AND landed > vDated + ORDER BY isIgnored = FALSE DESC; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval .sql b/db/routines/vn/procedures/buy_getUltimateFromInterval .sql new file mode 100644 index 000000000..4dafd105f --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval .sql @@ -0,0 +1,174 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval `( + vItemFk INT, + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas + * desde un rango de fechas. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén si es NULL se actualizan todos + * @param vStarted Fecha inicial + * @param vEnded Fecha fin + * @return tmp.buyUltimateFromInterval + */ + IF vEnded IS NULL THEN + SET vEnded = vStarted; + END IF; + + IF vEnded < vStarted THEN + SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); + END IF; + + -- Item + DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; + CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + -- ItemOriginal + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/buy_updateGrouping.sql b/db/routines/vn/procedures/buy_updateGrouping.sql index fb7adc0a3..45a619262 100644 --- a/db/routines/vn/procedures/buy_updateGrouping.sql +++ b/db/routines/vn/procedures/buy_updateGrouping.sql @@ -8,7 +8,7 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL vn.buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE vn.buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk diff --git a/db/routines/vn/procedures/buy_updatePacking.sql b/db/routines/vn/procedures/buy_updatePacking.sql index d86edc98f..0ee9d4c80 100644 --- a/db/routines/vn/procedures/buy_updatePacking.sql +++ b/db/routines/vn/procedures/buy_updatePacking.sql @@ -8,7 +8,7 @@ BEGIN * @param vItemFk id del item * @param vPacking packing a actualizar */ - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 963e33507..887492b35 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -74,7 +74,7 @@ BEGIN CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buyUltimate(vWarehouseFk, vShipped); + CALL vn.buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) SELECT vWarehouseFk, diff --git a/db/routines/vn/procedures/entry_getTransfer.sql b/db/routines/vn/procedures/entry_getTransfer.sql index 165c87dc7..5bf049b6e 100644 --- a/db/routines/vn/procedures/entry_getTransfer.sql +++ b/db/routines/vn/procedures/entry_getTransfer.sql @@ -97,7 +97,7 @@ BEGIN FROM tmp.itemList; END IF; - CALL buyUltimateFromInterval(vWarehouseIn,vInventoryDate, vDateLanded); + CALL buy_getUltimateFromInterval(NULL, vWarehouseIn,vInventoryDate, vDateLanded); CREATE OR REPLACE TEMPORARY TABLE tTransfer ENGINE = MEMORY diff --git a/db/routines/vn/procedures/itemShelving_addByClaim.sql b/db/routines/vn/procedures/itemShelving_addByClaim.sql index 851162952..4ff2955c7 100644 --- a/db/routines/vn/procedures/itemShelving_addByClaim.sql +++ b/db/routines/vn/procedures/itemShelving_addByClaim.sql @@ -15,7 +15,7 @@ BEGIN JOIN ticket t ON t.id = c.ticketFk WHERE c.id = vClaimFk; - CALL buyUltimate (vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(NULL, vWarehouseFk, util.VN_CURDATE()); INSERT INTO itemShelving (itemFk, shelvingFk, packing, `grouping`, visible) SELECT s.itemFk, vShelvingFk, b.packing, b.`grouping`, cb.quantity AS visible diff --git a/db/routines/vn/procedures/itemShelving_getItemDetails.sql b/db/routines/vn/procedures/itemShelving_getItemDetails.sql index c01bc348c..b097c2d17 100644 --- a/db/routines/vn/procedures/itemShelving_getItemDetails.sql +++ b/db/routines/vn/procedures/itemShelving_getItemDetails.sql @@ -23,7 +23,7 @@ BEGIN FROM operator WHERE workerFk = account.myUser_getId(); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vBarcodeItem, vWarehouseFk, util.VN_CURDATE()); SELECT buyFk INTO vBuyFk FROM tmp.buyUltimate diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index c9f716d8f..0cfcfcc7e 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -93,7 +93,7 @@ BEGIN ORDER BY created DESC LIMIT 1; - CALL buyUltimate(vWarehouseFk, vCurdate); + CALL buy_getUltimate(vSelf, vWarehouseFk, vCurdate); SELECT b.entryFk, bu.buyFk,IFNULL(b.buyingValue, 0) INTO vLastEntryFk, vLastBuyFk, vBuyingValueOriginal FROM tmp.buyUltimate bu diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql index 50ab880a0..f569d235b 100644 --- a/db/routines/vn/procedures/item_getInfo.sql +++ b/db/routines/vn/procedures/item_getInfo.sql @@ -14,9 +14,11 @@ BEGIN CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - CALL buyUltimate(vWarehouseFk, util.VN_CURDATE()); - + SELECT barcodeToItem(vBarcode) INTO vItemFk; + + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); + SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock WHERE itemFk = vItemFk diff --git a/db/routines/vn/procedures/item_multipleBuy.sql b/db/routines/vn/procedures/item_multipleBuy.sql index ba49f8d36..0a08f5015 100644 --- a/db/routines/vn/procedures/item_multipleBuy.sql +++ b/db/routines/vn/procedures/item_multipleBuy.sql @@ -13,7 +13,7 @@ BEGIN */ ALTER TABLE tmp.itemInventory ADD IF NOT EXISTS buy_id INT; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate (NULL, vWarehouseFk, vDate); CREATE OR REPLACE TEMPORARY TABLE tmp (KEY (itemFk)) diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql index 18aefdf7b..71f1459eb 100644 --- a/db/routines/vn/procedures/item_valuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -181,7 +181,7 @@ BEGIN AND e.isConfirmed ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); - CALL buyUltimate(NULL, vDateDayEnd); + CALL buy_getUltimate (NULL, NULL, vDateDayEnd); DELETE FROM tInventory WHERE quantity IS NULL OR NOT quantity; diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index ba4ff5857..64ecb898d 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -276,7 +276,7 @@ BEGIN ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(NULL, vWarehouseFk, vDate); INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) SELECT ticketFk, problem ,saleFk FROM ( diff --git a/db/routines/vn/procedures/sale_recalcComponent.sql b/db/routines/vn/procedures/sale_recalcComponent.sql index 54297571a..f3c188404 100644 --- a/db/routines/vn/procedures/sale_recalcComponent.sql +++ b/db/routines/vn/procedures/sale_recalcComponent.sql @@ -78,7 +78,7 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.zoneGetLanded; -- rellena la tabla buyUltimate con la ultima compra - CALL buyUltimate (vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (PRIMARY KEY (saleFk)) ENGINE = MEMORY diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index a4aefc088..573d5b488 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -53,7 +53,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSaleFk; - CALL buyUltimate(vWarehouseFk, vDate); + CALL buy_getUltimate(vNewItemFk, vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing INTO vGrouping,vGroupingMode,vPacking @@ -61,6 +61,8 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; + DROP TEMPORARY TABLE tmp.buyUltimate; + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; diff --git a/db/routines/vn/procedures/sale_setProblemRounding.sql b/db/routines/vn/procedures/sale_setProblemRounding.sql index f58d00799..894749c7b 100644 --- a/db/routines/vn/procedures/sale_setProblemRounding.sql +++ b/db/routines/vn/procedures/sale_setProblemRounding.sql @@ -19,7 +19,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSelf; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale SELECT vSelf saleFk, diff --git a/db/routines/vn/procedures/stockTraslation.sql b/db/routines/vn/procedures/stockTraslation.sql index c681112f1..f9175dc2a 100644 --- a/db/routines/vn/procedures/stockTraslation.sql +++ b/db/routines/vn/procedures/stockTraslation.sql @@ -36,6 +36,6 @@ BEGIN WHERE warehouse_id = vAuctionWarehouseFk ON DUPLICATE KEY UPDATE quantity = tmp.item.quantity + VALUES(quantity); - CALL buyUltimate(vAuctionWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vAuctionWarehouseFk, vDated); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_componentPreview.sql b/db/routines/vn/procedures/ticket_componentPreview.sql index 729e3a743..4bcd8c8ec 100644 --- a/db/routines/vn/procedures/ticket_componentPreview.sql +++ b/db/routines/vn/procedures/ticket_componentPreview.sql @@ -56,13 +56,12 @@ BEGIN FROM zone WHERE id = vZoneFk; - CALL buyUltimate(vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot ENGINE = MEMORY ( - SELECT - vWarehouseFk AS warehouseFk, - NULL AS available, + SELECT vWarehouseFk warehouseFk, + NULL available, s.itemFk, bu.buyFk, vZoneFk zoneFk diff --git a/db/routines/vn/procedures/ticket_setProblemRounding.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql index fb580eacf..551cf67d1 100644 --- a/db/routines/vn/procedures/ticket_setProblemRounding.sql +++ b/db/routines/vn/procedures/ticket_setProblemRounding.sql @@ -16,7 +16,7 @@ BEGIN FROM ticket WHERE id = vSelf; - CALL buyUltimate(vWarehouseFk, vDated); + CALL buy_getUltimate(NULL, vWarehouseFk, vDated); CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk, isProblemCalcNeeded)) diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index e5cc427a8..212aed7ea 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -52,8 +52,8 @@ module.exports = Self => { else { const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions); await Self.rawSql( - 'CALL vn.buyUltimate(?,?)', - [userConfig.warehouseFk, null], + 'CALL vn.buy_getUltimate(?,?,?)', + [args.item, userConfig.warehouseFk, null], myOptions ); let buyUltimate = await Self.rawSql( diff --git a/modules/entry/back/methods/entry/importBuys.js b/modules/entry/back/methods/entry/importBuys.js index 812775a1b..e3fd653bb 100644 --- a/modules/entry/back/methods/entry/importBuys.js +++ b/modules/entry/back/methods/entry/importBuys.js @@ -73,7 +73,8 @@ module.exports = Self => { }, myOptions); const travel = entry.travel(); - await Self.rawSql('CALL buyUltimate(?, ?)', [ + await Self.rawSql('CALL buy_getUltimate(?, ?, ?)', [ + null, travel.warehouseInFk, travel.landed ], myOptions); diff --git a/modules/entry/back/methods/entry/lastItemBuys.js b/modules/entry/back/methods/entry/lastItemBuys.js index 63e6d38f2..012b99d17 100644 --- a/modules/entry/back/methods/entry/lastItemBuys.js +++ b/modules/entry/back/methods/entry/lastItemBuys.js @@ -50,7 +50,8 @@ module.exports = Self => { const stmts = []; let stmt; - stmt = new ParameterizedSQL(`CALL buyUltimate(?, ?)`, [ + stmt = new ParameterizedSQL(`CALL buy_getUltimate(?, ?, ?)`, [ + null, travel.warehouseInFk, travel.landed ]); diff --git a/modules/order/back/methods/order/getItemTypeAvailable.js b/modules/order/back/methods/order/getItemTypeAvailable.js index b84863953..fd7be5d57 100644 --- a/modules/order/back/methods/order/getItemTypeAvailable.js +++ b/modules/order/back/methods/order/getItemTypeAvailable.js @@ -44,16 +44,14 @@ module.exports = Self => { ]); stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.item'); - stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.item + `CREATE OR REPLACE TEMPORARY TABLE tmp.item (PRIMARY KEY (itemFk)) ENGINE = MEMORY SELECT DISTINCT - i.id AS itemFk, - it.id AS typeFk, + i.id itemFk, + it.id typeFk, it.name, - ic.name AS categoryName + ic.name categoryName FROM tmp.availableCalc ac JOIN cache.available a ON a.calc_id = ac.calcFk JOIN vn.item i ON i.id = a.item_id @@ -64,7 +62,7 @@ module.exports = Self => { stmts.push(stmt); stmt = new ParameterizedSQL( - 'CALL vn.catalog_calculate(?, ?, ?,?)', [ + 'CALL vn.catalog_calculate(?, ?, ?, ?)', [ order.landed, order.addressFk, order.agencyModeFk, @@ -74,7 +72,7 @@ module.exports = Self => { stmts.push(stmt); stmt = new ParameterizedSQL(` - SELECT i.typeFk AS id, i.name, i.categoryName + SELECT i.typeFk id, i.name, i.categoryName FROM tmp.item i JOIN tmp.ticketCalculateItem tci ON tci.itemFk = i.itemFk GROUP BY i.typeFk` @@ -85,7 +83,6 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const result = await Self.rawStmt(sql, myOptions); - return result[categoriesIndex]; }; }; From d6a949a9f38f22bfd2487bf93b246e9e7527f687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 18:55:58 +0200 Subject: [PATCH 044/181] feat: refactor buyUltimate refs #7736 --- .../cache/procedures/last_buy_refresh.sql | 2 +- .../vn/procedures/buyUltimateFromInterval.sql | 2 +- .../buy_getUltimateFromInterval .sql | 174 ------------------ 3 files changed, 2 insertions(+), 176 deletions(-) delete mode 100644 db/routines/vn/procedures/buy_getUltimateFromInterval .sql diff --git a/db/routines/cache/procedures/last_buy_refresh.sql b/db/routines/cache/procedures/last_buy_refresh.sql index 0f80163fb..555ae0b8d 100644 --- a/db/routines/cache/procedures/last_buy_refresh.sql +++ b/db/routines/cache/procedures/last_buy_refresh.sql @@ -30,7 +30,7 @@ proc: BEGIN SELECT inventoried INTO started FROM vn.config LIMIT 1; SET ended = util.VN_CURDATE(); -- TIMESTAMPADD(DAY, -1, util.VN_CURDATE()); - CALL vn.buy_getUltimateFromInterval (NULL, NULL, started, ended); + CALL vn.buy_getUltimateFromInterval(NULL, NULL, started, ended); DELETE FROM last_buy; diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 75dfff489..8aea38ee0 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -15,6 +15,6 @@ BEGIN * @param vEnded Fecha fin * @return tmp.buyUltimateFromInterval */ - CALL vn.buy_getUltimateFromInterval (NULL,vWarehouseFk,vStarted,vEnded); + CALL vn.buy_getUltimateFromInterval(NULL,vWarehouseFk,vStarted,vEnded); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval .sql b/db/routines/vn/procedures/buy_getUltimateFromInterval .sql deleted file mode 100644 index 4dafd105f..000000000 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval .sql +++ /dev/null @@ -1,174 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval `( - vItemFk INT, - vWarehouseFk SMALLINT, - vStarted DATE, - vEnded DATE -) -BEGIN -/** - * Calcula las últimas compras realizadas - * desde un rango de fechas. - * - * @param vItemFk Id del artículo - * @param vWarehouseFk Id del almacén si es NULL se actualizan todos - * @param vStarted Fecha inicial - * @param vEnded Fecha fin - * @return tmp.buyUltimateFromInterval - */ - IF vEnded IS NULL THEN - SET vEnded = vStarted; - END IF; - - IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); - END IF; - - -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), - INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) - ENGINE = MEMORY - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.quantity = 0 - ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - -- ItemOriginal - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT itemFk, - warehouseFk, - buyFk, - landed, - isIgnored - FROM - (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.quantity = 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemFk, warehouseFk; -END$$ -DELIMITER ; From 50e2c03d3e1a2caac3643d49ad2cf220c5050a04 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 16 Jul 2024 18:56:00 +0200 Subject: [PATCH 045/181] refs #7531 Requested modifications in redmine --- .../vn/procedures/zone_getAddresses.sql | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index c3a21aa83..417b8c7a3 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -1,40 +1,28 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( vSelf INT, - vDated DATE, - vDepartment INT + vShipped DATE, + vDepartmentFk INT ) BEGIN /** * Devuelve un listado de todos los clientes activos * con consignatarios a los que se les puede - * vender producto para esa zona y no tiene un ticket - * para ese día. + * vender producto para esa zona. * * @param vSelf Id de zona - * @param vDated Fecha de entrega - * @param vDepartment Departamento del trabajador + * @param vShipped Fecha de envio + * @param vDepartmentFk Id de departamento * @return Un select */ CALL zone_getPostalCode(vSelf); - WITH notHasTicket AS ( - SELECT id - FROM vn.client - WHERE id NOT IN ( - SELECT clientFk - FROM vn.ticket - WHERE landed BETWEEN vDated AND util.dayEnd(vDated) - ) - ), - hasTicketShippedToday AS ( - SELECT clientFk, - IF (COUNT(*) > 0, TRUE, FALSE) hasTicketShipped + WITH clientWithTicket AS ( + SELECT clientFk FROM vn.ticket - WHERE shipped BETWEEN vDated AND util.dayEnd(vDated) - GROUP BY clientFk + WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped) ) - SELECT c.id clientFk, + SELECT c.id, c.name, c.phone, bt.description, @@ -42,12 +30,12 @@ BEGIN u.name username, aai.invoiced, cnb.lastShipped, - ht.hasTicketShipped + cwt.clientFk FROM vn.client c JOIN vn.worker w ON w.id = c.salesPersonFk JOIN vn.workerDepartment wd ON wd.workerFk = w.id JOIN vn.department d ON d.id = wd.departmentFk - JOIN notHasTicket ON notHasTicket.id = c.id + LEFT JOIN clientWithTicket cwt ON cwt.clientFk = c.id LEFT JOIN account.`user` u ON u.id = c.salesPersonFk JOIN vn.`address` a ON a.clientFk = c.id JOIN vn.postCode pc ON pc.code = a.postalCode @@ -58,12 +46,11 @@ BEGIN LEFT JOIN vn.annualAverageInvoiced aai ON aai.clientFk = c.id JOIN vn.clientType ct ON ct.code = c.typeFk JOIN vn.businessType bt ON bt.code = c.businessTypeFk - LEFT JOIN hasTicketShippedToday ht ON ht.clientFk = c.id WHERE a.isActive AND c.isActive AND ct.code = 'normal' AND bt.code <> 'worker' - AND d.id = vDepartment + AND d.id = vDepartmentFk GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; From 5ca2a432daece8d1013b7c0737a50f3c859f4472 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 18:58:26 +0200 Subject: [PATCH 046/181] feat: refactor buyUltimate refs #7736 --- .../buy_getUltimateFromInterval.sql | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 db/routines/vn/procedures/buy_getUltimateFromInterval.sql diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql new file mode 100644 index 000000000..45d1122ae --- /dev/null +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -0,0 +1,174 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimateFromInterval`( + vItemFk INT, + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) +BEGIN +/** + * Calcula las últimas compras realizadas + * desde un rango de fechas. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén si es NULL se actualizan todos + * @param vStarted Fecha inicial + * @param vEnded Fecha fin + * @return tmp.buyUltimateFromInterval + */ + IF vEnded IS NULL THEN + SET vEnded = vStarted; + END IF; + + IF vEnded < vStarted THEN + SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); + END IF; + + -- Item + DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; + CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + ENGINE = MEMORY + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + -- ItemOriginal + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; +END$$ +DELIMITER ; From 4ee0bd687fb040f2cc9fae0a9594be4c268fdbdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 16 Jul 2024 19:01:02 +0200 Subject: [PATCH 047/181] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buyUltimateFromInterval.sql | 2 +- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 8aea38ee0..9709f2edc 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -15,6 +15,6 @@ BEGIN * @param vEnded Fecha fin * @return tmp.buyUltimateFromInterval */ - CALL vn.buy_getUltimateFromInterval(NULL,vWarehouseFk,vStarted,vEnded); + CALL vn.buy_getUltimateFromInterval(NULL, vWarehouseFk, vStarted, vEnded); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 36ae10fd8..d16f89295 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -26,7 +26,7 @@ BEGIN AND (item_id = vItemFk OR vItemFk IS NULL); IF vDated >= util.VN_CURDATE() THEN - CALL buyUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); + CALL buy_getUltimateFromInterval(vItemFk, vWarehouseFk, util.VN_CURDATE(), vDated); REPLACE INTO tmp.buyUltimate SELECT itemFk, buyFk, warehouseFk, landed landing From 0ea69427ecfff06efb288206340747b4b2545035 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 17 Jul 2024 08:16:01 +0200 Subject: [PATCH 048/181] feat: refs #6403 add cancelShipment on deleteExpeditions --- back/methods/mrw-config/cancelShipment.js | 5 +++-- .../methods/expedition/deleteExpeditions.js | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 10d556575..57b764858 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -13,7 +13,7 @@ module.exports = Self => { required: true }], returns: { - type: ['object'], + type: 'boolean', root: true }, http: { @@ -39,6 +39,7 @@ module.exports = Self => { const xmlString = response.data; const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - return xmlDoc.getElementsByTagName('Mensaje')[0].textContent; + const [{textContent}] = xmlDoc.getElementsByTagName('Mensaje'); + return textContent.toLowerCase().includes('se ha cancelado correctamente'); }; }; diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 55ca474d7..90a649425 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -44,15 +44,21 @@ module.exports = Self => { const expedition = await models.Expedition.findOne(filter); const {code} = expedition.agencyMode(); + let isDeleted = true; - if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') { - const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId); + if (code?.toLowerCase()?.includes('mrw')) { + const result = await models.MrwConfig.cancelShipment(expeditionId); + isDeleted = result; + } - if (isDeleted === 'true') { - const deletedExpedition = await models.Expedition.destroyById(expeditionId); - deletedExpeditions.push(deletedExpedition); - } else notDeletedExpeditions.push(expeditionId); - } else { + if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') { + const result = await models.ViaexpressConfig.deleteExpedition(expeditionId); + if (result !== 'true') isDeleted = false; + } + + if (!isDeleted) + notDeletedExpeditions.push(expeditionId); + else { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); } From f83dd37a28d891083d3ea3828cde70a5da8cd51d Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 17 Jul 2024 08:23:33 +0200 Subject: [PATCH 049/181] fix: refs #6403 remove line --- modules/ticket/back/methods/expedition/deleteExpeditions.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 90a649425..1255f19b8 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -46,10 +46,8 @@ module.exports = Self => { const {code} = expedition.agencyMode(); let isDeleted = true; - if (code?.toLowerCase()?.includes('mrw')) { - const result = await models.MrwConfig.cancelShipment(expeditionId); - isDeleted = result; - } + if (code?.toLowerCase()?.includes('mrw')) + isDeleted = await models.MrwConfig.cancelShipment(expeditionId); if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') { const result = await models.ViaexpressConfig.deleteExpedition(expeditionId); From 4ff388198b0fada3b022004dc618768a6e0a7b8a Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 17 Jul 2024 10:14:41 +0200 Subject: [PATCH 050/181] fix(deletExpeditions): add try catch --- .../methods/expedition/deleteExpeditions.js | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 1255f19b8..75993a485 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -27,38 +27,33 @@ module.exports = Self => { const deletedExpeditions = []; for (let expeditionId of expeditionIds) { - const filter = { - fields: [], - where: { - id: expeditionId - }, - include: [ - { - relation: 'agencyMode', - scope: { - fields: ['code'], + try { + const expedition = await models.Expedition.findById(expeditionId, { + include: [ + { + relation: 'agencyMode', + scope: { + fields: ['code'], + } } - } - ] - }; + ] + }); + const {code} = expedition.agencyMode(); - const expedition = await models.Expedition.findOne(filter); - const {code} = expedition.agencyMode(); - let isDeleted = true; + if (code?.toLowerCase()?.includes('mrw') && expedition.externalId) { + const result = await models.MrwConfig.cancelShipment(expeditionId); + if (!result) throw new Error('not deleted'); + } - if (code?.toLowerCase()?.includes('mrw')) - isDeleted = await models.MrwConfig.cancelShipment(expeditionId); + if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') { + const result = await models.ViaexpressConfig.deleteExpedition(expeditionId); + if (result !== 'true') throw new Error('not deleted'); + } - if (code?.toLowerCase()?.substring(0, 10) == 'viaexpress') { - const result = await models.ViaexpressConfig.deleteExpedition(expeditionId); - if (result !== 'true') isDeleted = false; - } - - if (!isDeleted) - notDeletedExpeditions.push(expeditionId); - else { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); + } catch (e) { + notDeletedExpeditions.push(expeditionId); } } From 563c70c65d882833c3550ed54c7a2364f791da49 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 17 Jul 2024 11:18:12 +0200 Subject: [PATCH 051/181] fix(cancelShipment): fix --- back/methods/mrw-config/cancelShipment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 57b764858..56d206529 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -39,7 +39,7 @@ module.exports = Self => { const xmlString = response.data; const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - const [{textContent}] = xmlDoc.getElementsByTagName('Mensaje'); - return textContent.toLowerCase().includes('se ha cancelado correctamente'); + const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; + return result.toLowerCase().includes('se ha cancelado correctamente'); }; }; From ae2ddcb8c7d291bd14d8e58854a98ff6c881d26a Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 17 Jul 2024 12:20:58 +0200 Subject: [PATCH 052/181] add console.log --- back/methods/mrw-config/cancelShipment.js | 1 + modules/ticket/back/methods/expedition/deleteExpeditions.js | 1 + 2 files changed, 2 insertions(+) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 56d206529..0efd00874 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -37,6 +37,7 @@ module.exports = Self => { }); const xmlString = response.data; + console.log('xmlString: ', xmlString); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 75993a485..d7a090b00 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -53,6 +53,7 @@ module.exports = Self => { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); } catch (e) { + console.log('e: ', e); notDeletedExpeditions.push(expeditionId); } } From 021d315a010559cdf9ba1c1550df8778100a67b0 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 17 Jul 2024 13:30:47 +0200 Subject: [PATCH 053/181] fix: weeklyHourRecordEmail workerId prop and correct request in frontend --- modules/worker/back/methods/worker-time-control/sendMail.js | 4 ++-- .../back/methods/worker-time-control/weeklyHourRecordEmail.js | 2 +- modules/worker/front/time-control/index.js | 2 +- modules/worker/front/time-control/index.spec.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index e43f4a8ab..2e1e00d83 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -165,8 +165,8 @@ module.exports = Self => { const sql = ParameterizedSQL.join(stmts, ';'); const days = await conn.executeStmt(sql, myOptions); - let previousWorkerFk = days[index][0].workerFk; - let previousReceiver = days[index][0].receiver; + let previousWorkerFk = days[index][0]?.workerFk; + let previousReceiver = days[index][0]?.receiver; const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index f19ab17e1..e352eb3cb 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -61,7 +61,7 @@ module.exports = Self => { const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; ctx.args.url = url; - await models.WorkerTimeControl.updateMailState(ctx, ctx.workerId, myOptions); + await models.WorkerTimeControl.updateMailState(ctx, ctx.args.workerId, myOptions); return Self.sendTemplate(ctx, 'weekly-hour-record'); }; diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 7f7bad137..5bad04593 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -389,7 +389,7 @@ class Controller extends Section { if (reason) params.reason = reason; - const query = `WorkerTimeControls/updateWorkerTimeControlMail`; + const query = `WorkerTimeControls/updateMailState`; this.$http.post(query, params).then(() => { this.getMailStates(this.date); this.getWeekData(); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 42df4ba9b..88a599e96 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -201,7 +201,7 @@ describe('Component vnWorkerTimeControl', () => { controller.date = today; controller.weekNumber = 1; - $httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond(); + $httpBackend.expect('POST', 'WorkerTimeControls/updateMailState').respond(); controller.isSatisfied(); $httpBackend.flush(); @@ -236,7 +236,7 @@ describe('Component vnWorkerTimeControl', () => { controller.weekNumber = 1; controller.reason = 'reason'; - $httpBackend.expect('POST', 'WorkerTimeControls/updateWorkerTimeControlMail').respond(); + $httpBackend.expect('POST', 'WorkerTimeControls/updateMailState').respond(); controller.isSatisfied(); $httpBackend.flush(); From d52a2296137ccf75115c2796c0150b975b113524 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 17 Jul 2024 13:40:57 +0200 Subject: [PATCH 054/181] hotFix(workerTimeControl): confirm correct url --- modules/worker/front/time-control/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 5bad04593..2993e3986 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -380,7 +380,6 @@ class Controller extends Section { updateWorkerTimeControlMail(state, reason) { const params = { - workerId: this.worker.id, year: this.date.getFullYear(), week: this.weekNumber, state @@ -389,7 +388,7 @@ class Controller extends Section { if (reason) params.reason = reason; - const query = `WorkerTimeControls/updateMailState`; + const query = `WorkerTimeControls/${this.worker.id}/updateMailState`; this.$http.post(query, params).then(() => { this.getMailStates(this.date); this.getWeekData(); From 2763839c549c38d13d814ac1856308e72044fc7e Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 17 Jul 2024 13:42:23 +0200 Subject: [PATCH 055/181] hotFix(workerTimeControl): confirm correct url --- modules/worker/front/time-control/index.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 88a599e96..3868ded75 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -201,7 +201,7 @@ describe('Component vnWorkerTimeControl', () => { controller.date = today; controller.weekNumber = 1; - $httpBackend.expect('POST', 'WorkerTimeControls/updateMailState').respond(); + $httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond(); controller.isSatisfied(); $httpBackend.flush(); @@ -236,7 +236,7 @@ describe('Component vnWorkerTimeControl', () => { controller.weekNumber = 1; controller.reason = 'reason'; - $httpBackend.expect('POST', 'WorkerTimeControls/updateMailState').respond(); + $httpBackend.expect('POST', 'WorkerTimeControls/1/updateMailState').respond(); controller.isSatisfied(); $httpBackend.flush(); From 70475788090b9e0cc5117165ce07a57fba3dbc0e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Jul 2024 16:09:09 +0200 Subject: [PATCH 056/181] hotFix reservas refs #686 --- .../procedures/collection_addWithReservation.sql | 5 +++-- .../itemShelvingSale_addByCollection.sql | 2 +- .../vn/procedures/itemShelvingSale_addBySale.sql | 5 ++++- .../itemShelvingSale_addBySectorCollection.sql | 7 ++++++- .../vn/procedures/itemShelvingSale_doReserve.sql | 10 ++++++---- .../vn/procedures/itemShelvingSale_reallocate.sql | 7 +++++-- .../vn/procedures/itemShelvingSale_setQuantity.sql | 10 ++++++---- db/versions/11158-redRaphis/00-firstScript.sql | 5 +++++ .../itemShelvingSaleSetQuantity.js | 14 ++++++++++---- 9 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 db/versions/11158-redRaphis/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index e3f4eb8d2..18a3e8ab2 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithR vItemFk INT, vQuantity INT, vTicketFk INT, - vSaleGroupFk INT + vSaleGroupFk INT, + vSectorFk INT ) BEGIN /** @@ -67,7 +68,7 @@ BEGIN SELECT LAST_INSERT_ID() INTO vSaleFk; CALL sale_calculateComponent(vSaleFk, NULL); - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN SET vHasThrow = TRUE; diff --git a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql index 7f9cc6616..a6f9b3e8c 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql @@ -44,7 +44,7 @@ BEGIN LEAVE l; END IF; - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, NULL); END LOOP; CLOSE vSales; END$$ diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 909ce5155..96c49b788 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`( - vSaleFk INT + vSaleFk INT, + vSectorFk INT ) proc: BEGIN /** @@ -8,6 +9,7 @@ proc: BEGIN * * @param vSaleFk Id de sale * @param vItemShelvingSaleFk Id de reserva + * @param vSectorFk Id del sector del operator */ DECLARE vLastPickingOrder INT; DECLARE vDone INT DEFAULT FALSE; @@ -30,6 +32,7 @@ proc: BEGIN JOIN productionConfig pc WHERE s.id = vSaleFk AND NOT sc.isHideForPickers + AND (sc.id = vSectorFk OR vSectorFk IS NULL) ORDER BY s.id, p.pickingOrder >= vLastPickingOrder, sh.priority DESC, diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql index 442abcf5d..c359c7c8d 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql @@ -10,6 +10,7 @@ BEGIN */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vSaleFk INT; + DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR SELECT s.id FROM sectorCollectionSaleGroup sc @@ -25,6 +26,10 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + OPEN vSales; l: LOOP SET vDone = FALSE; @@ -34,7 +39,7 @@ BEGIN LEAVE l; END IF; - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); END LOOP; CLOSE vSales; END$$ diff --git a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql index 629e303b3..810900434 100644 --- a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql +++ b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql @@ -6,6 +6,7 @@ proc: BEGIN */ DECLARE vDone BOOL; DECLARE vSaleFk INT; + DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR SELECT DISTINCT saleFk FROM tSale; @@ -26,24 +27,25 @@ proc: BEGIN CREATE OR REPLACE TEMPORARY TABLE tSale ENGINE = MEMORY - SELECT id, saleFk FROM itemShelvingSaleReserve; + SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve; OPEN vSales; myLoop: LOOP SET vDone = FALSE; - FETCH vSales INTO vSaleFk; + FETCH vSales INTO vSaleFk, vSectorFk; IF vDone THEN LEAVE myLoop; END IF; - CALL itemShelvingSale_addBySale (vSaleFk); + CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk); END LOOP; CLOSE vSales; - DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id; + DELETE iss FROM itemShelvingSaleReserve iss + JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk; DROP TEMPORARY TABLE tSale; diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index 85230a386..2b9f927e4 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -1,13 +1,16 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( vItemShelvingFk INT(10), - vItemFk INT(10) + vItemFk INT(10), + vSectorFk INT ) BEGIN /** * Elimina reservas de un itemShelving e intenta reservar en otra ubicación * * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector */ DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -28,7 +31,7 @@ BEGIN WHERE id = vItemShelvingFk AND itemFk = vItemFk; - INSERT INTO itemShelvingSaleReserve (saleFk) + INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) SELECT DISTINCT iss.saleFk FROM itemShelvingSale iss JOIN itemShelving ish ON ish.id = iss.itemShelvingFk diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 85f56ee68..b65c5df7f 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -2,7 +2,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`( vItemShelvingSaleFk INT(10), vQuantity DECIMAL(10,0), - vIsItemShelvingSaleEmpty BOOLEAN + vIsItemShelvingSaleEmpty BOOLEAN, + vSectorFk INT ) BEGIN /** @@ -14,6 +15,7 @@ BEGIN * @param vQuantity Cantidad real que se ha cogido de la ubicación * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha * quedado vacio tras el movimiento + * @param vSectorFk Id del sector */ DECLARE vSaleFk INT; DECLARE vItemShelvingFk INT; @@ -72,7 +74,7 @@ BEGIN SET visible = GREATEST(0, visible - vQuantity) WHERE id = vItemShelvingFk; - SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity) + SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity) INTO vRemainingQuantity, vTotalQuantity FROM itemShelvingSale WHERE saleFk = vSaleFk; @@ -96,9 +98,9 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserve (saleFk) + INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) SELECT vSaleFk; - CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk); + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/11158-redRaphis/00-firstScript.sql b/db/versions/11158-redRaphis/00-firstScript.sql new file mode 100644 index 000000000..49fb852d0 --- /dev/null +++ b/db/versions/11158-redRaphis/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here + + +ALTER TABLE vn.itemShelvingSaleReserve ADD sectorFk int(11) NULL; +ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js b/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js index 90e66c066..add2aa404 100644 --- a/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js +++ b/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('itemShelvingSaleSetQuantity', { - description: 'Set quanitity of a sale in itemShelvingSale', + description: 'Set quantity of a sale in itemShelvingSale', accessType: 'WRITE', accepts: [ { @@ -20,6 +20,12 @@ module.exports = Self => { type: 'boolean', required: true, description: 'True if the shelvingFk is empty ', + }, + { + arg: 'sectorFk', + type: 'number', + required: true, + description: 'Sector Id', } ], http: { @@ -28,14 +34,14 @@ module.exports = Self => { } }); - Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, options) => { + Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, sectorFk, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); - await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`, - [id, quantity, isItemShelvingSaleEmpty], + await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ?, ?)`, + [id, quantity, isItemShelvingSaleEmpty, sectorFk], myOptions); }; }; From 3aea6fdd4634fd42cd27c4fdc81953c9a2ed2498 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Jul 2024 16:09:09 +0200 Subject: [PATCH 057/181] hotFix reservas refs #6861 --- .../procedures/collection_addWithReservation.sql | 5 +++-- .../itemShelvingSale_addByCollection.sql | 2 +- .../vn/procedures/itemShelvingSale_addBySale.sql | 5 ++++- .../itemShelvingSale_addBySectorCollection.sql | 7 ++++++- .../vn/procedures/itemShelvingSale_doReserve.sql | 10 ++++++---- .../vn/procedures/itemShelvingSale_reallocate.sql | 7 +++++-- .../vn/procedures/itemShelvingSale_setQuantity.sql | 10 ++++++---- db/versions/11158-redRaphis/00-firstScript.sql | 5 +++++ .../itemShelvingSaleSetQuantity.js | 14 ++++++++++---- 9 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 db/versions/11158-redRaphis/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index e3f4eb8d2..18a3e8ab2 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -3,7 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithR vItemFk INT, vQuantity INT, vTicketFk INT, - vSaleGroupFk INT + vSaleGroupFk INT, + vSectorFk INT ) BEGIN /** @@ -67,7 +68,7 @@ BEGIN SELECT LAST_INSERT_ID() INTO vSaleFk; CALL sale_calculateComponent(vSaleFk, NULL); - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN SET vHasThrow = TRUE; diff --git a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql index 7f9cc6616..a6f9b3e8c 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql @@ -44,7 +44,7 @@ BEGIN LEAVE l; END IF; - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, NULL); END LOOP; CLOSE vSales; END$$ diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 909ce5155..96c49b788 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`( - vSaleFk INT + vSaleFk INT, + vSectorFk INT ) proc: BEGIN /** @@ -8,6 +9,7 @@ proc: BEGIN * * @param vSaleFk Id de sale * @param vItemShelvingSaleFk Id de reserva + * @param vSectorFk Id del sector del operator */ DECLARE vLastPickingOrder INT; DECLARE vDone INT DEFAULT FALSE; @@ -30,6 +32,7 @@ proc: BEGIN JOIN productionConfig pc WHERE s.id = vSaleFk AND NOT sc.isHideForPickers + AND (sc.id = vSectorFk OR vSectorFk IS NULL) ORDER BY s.id, p.pickingOrder >= vLastPickingOrder, sh.priority DESC, diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql index 442abcf5d..c359c7c8d 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql @@ -10,6 +10,7 @@ BEGIN */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vSaleFk INT; + DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR SELECT s.id FROM sectorCollectionSaleGroup sc @@ -25,6 +26,10 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + OPEN vSales; l: LOOP SET vDone = FALSE; @@ -34,7 +39,7 @@ BEGIN LEAVE l; END IF; - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); END LOOP; CLOSE vSales; END$$ diff --git a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql index 629e303b3..810900434 100644 --- a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql +++ b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql @@ -6,6 +6,7 @@ proc: BEGIN */ DECLARE vDone BOOL; DECLARE vSaleFk INT; + DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR SELECT DISTINCT saleFk FROM tSale; @@ -26,24 +27,25 @@ proc: BEGIN CREATE OR REPLACE TEMPORARY TABLE tSale ENGINE = MEMORY - SELECT id, saleFk FROM itemShelvingSaleReserve; + SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve; OPEN vSales; myLoop: LOOP SET vDone = FALSE; - FETCH vSales INTO vSaleFk; + FETCH vSales INTO vSaleFk, vSectorFk; IF vDone THEN LEAVE myLoop; END IF; - CALL itemShelvingSale_addBySale (vSaleFk); + CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk); END LOOP; CLOSE vSales; - DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id; + DELETE iss FROM itemShelvingSaleReserve iss + JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk; DROP TEMPORARY TABLE tSale; diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index 85230a386..2b9f927e4 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -1,13 +1,16 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( vItemShelvingFk INT(10), - vItemFk INT(10) + vItemFk INT(10), + vSectorFk INT ) BEGIN /** * Elimina reservas de un itemShelving e intenta reservar en otra ubicación * * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector */ DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -28,7 +31,7 @@ BEGIN WHERE id = vItemShelvingFk AND itemFk = vItemFk; - INSERT INTO itemShelvingSaleReserve (saleFk) + INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) SELECT DISTINCT iss.saleFk FROM itemShelvingSale iss JOIN itemShelving ish ON ish.id = iss.itemShelvingFk diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 85f56ee68..b65c5df7f 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -2,7 +2,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`( vItemShelvingSaleFk INT(10), vQuantity DECIMAL(10,0), - vIsItemShelvingSaleEmpty BOOLEAN + vIsItemShelvingSaleEmpty BOOLEAN, + vSectorFk INT ) BEGIN /** @@ -14,6 +15,7 @@ BEGIN * @param vQuantity Cantidad real que se ha cogido de la ubicación * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha * quedado vacio tras el movimiento + * @param vSectorFk Id del sector */ DECLARE vSaleFk INT; DECLARE vItemShelvingFk INT; @@ -72,7 +74,7 @@ BEGIN SET visible = GREATEST(0, visible - vQuantity) WHERE id = vItemShelvingFk; - SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity) + SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity) INTO vRemainingQuantity, vTotalQuantity FROM itemShelvingSale WHERE saleFk = vSaleFk; @@ -96,9 +98,9 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserve (saleFk) + INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) SELECT vSaleFk; - CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk); + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/versions/11158-redRaphis/00-firstScript.sql b/db/versions/11158-redRaphis/00-firstScript.sql new file mode 100644 index 000000000..49fb852d0 --- /dev/null +++ b/db/versions/11158-redRaphis/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here + + +ALTER TABLE vn.itemShelvingSaleReserve ADD sectorFk int(11) NULL; +ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js b/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js index 90e66c066..add2aa404 100644 --- a/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js +++ b/modules/item/back/methods/item-shelving-sale/itemShelvingSaleSetQuantity.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('itemShelvingSaleSetQuantity', { - description: 'Set quanitity of a sale in itemShelvingSale', + description: 'Set quantity of a sale in itemShelvingSale', accessType: 'WRITE', accepts: [ { @@ -20,6 +20,12 @@ module.exports = Self => { type: 'boolean', required: true, description: 'True if the shelvingFk is empty ', + }, + { + arg: 'sectorFk', + type: 'number', + required: true, + description: 'Sector Id', } ], http: { @@ -28,14 +34,14 @@ module.exports = Self => { } }); - Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, options) => { + Self.itemShelvingSaleSetQuantity = async(ctx, id, quantity, isItemShelvingSaleEmpty, sectorFk, options) => { const myOptions = {userId: ctx.req.accessToken.userId}; if (typeof options == 'object') Object.assign(myOptions, options); - await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ? )`, - [id, quantity, isItemShelvingSaleEmpty], + await Self.rawSql(`CALL vn.itemShelvingSale_setQuantity(?, ?, ?, ?)`, + [id, quantity, isItemShelvingSaleEmpty, sectorFk], myOptions); }; }; From 8ff3e8acb0a3490600a76438cbef9144281da8d5 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Jul 2024 16:21:37 +0200 Subject: [PATCH 058/181] hotFix reservas refs #6861 --- db/versions/11158-redRaphis/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11158-redRaphis/00-firstScript.sql b/db/versions/11158-redRaphis/00-firstScript.sql index 49fb852d0..d82a7eb9d 100644 --- a/db/versions/11158-redRaphis/00-firstScript.sql +++ b/db/versions/11158-redRaphis/00-firstScript.sql @@ -1,5 +1,5 @@ -- Place your SQL code here -ALTER TABLE vn.itemShelvingSaleReserve ADD sectorFk int(11) NULL; -ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve ADD sectorFk int(11) NULL; +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; From a35ec4a42ca27cb20f9a75199659092e980689a4 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Jul 2024 16:48:52 +0200 Subject: [PATCH 059/181] hotFix reservas refs #6861 --- db/versions/11158-redRaphis/00-firstScript.sql | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/db/versions/11158-redRaphis/00-firstScript.sql b/db/versions/11158-redRaphis/00-firstScript.sql index d82a7eb9d..7fe41b32b 100644 --- a/db/versions/11158-redRaphis/00-firstScript.sql +++ b/db/versions/11158-redRaphis/00-firstScript.sql @@ -1,5 +1,11 @@ -- Place your SQL code here +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve +ADD IF NOT EXISTS sectorFk int(11) NULL; -ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve ADD sectorFk int(11) NULL; -ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve +DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK; + +ALTER TABLE IF EXISTS vn.itemShelvingSaleReserve +ADD CONSTRAINT itemShelvingSaleReserve_sector_FK FOREIGN KEY (id) +REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file From f7429f392769e711f91fa2ffc8a0165b89aa1406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 17 Jul 2024 18:24:27 +0200 Subject: [PATCH 060/181] Hotfix itemShelvingSale_doReserve Ticket #204044 --- db/routines/vn/procedures/itemShelvingSale_doReserve.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql index 810900434..d38a787a1 100644 --- a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql +++ b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql @@ -9,7 +9,7 @@ proc: BEGIN DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR - SELECT DISTINCT saleFk FROM tSale; + SELECT DISTINCT saleFk, sectorFk FROM tSale; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; 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 061/181] =?UTF-8?q?fix:=20refs#7748=20solicitud=20de=20dom?= =?UTF-8?q?iciliaci=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 e96fa75356caf77cbd95c9c0fa27278bc10b2f38 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 18 Jul 2024 09:22:27 +0200 Subject: [PATCH 062/181] fix: refs #7039 country order --- modules/invoiceIn/front/intrastat/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/invoiceIn/front/intrastat/index.html b/modules/invoiceIn/front/intrastat/index.html index fc0139303..b15fdf543 100644 --- a/modules/invoiceIn/front/intrastat/index.html +++ b/modules/invoiceIn/front/intrastat/index.html @@ -10,7 +10,7 @@ auto-load="true" url="Countries" data="countries" - order="country"> + order="name"> Date: Thu, 18 Jul 2024 10:13:21 +0200 Subject: [PATCH 063/181] feat: refs #6403 add address mobile --- back/methods/mrw-config/createShipment.ejs | 2 +- back/methods/mrw-config/createShipment.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/mrw-config/createShipment.ejs b/back/methods/mrw-config/createShipment.ejs index 65326112b..52ccc859c 100644 --- a/back/methods/mrw-config/createShipment.ejs +++ b/back/methods/mrw-config/createShipment.ejs @@ -25,7 +25,7 @@ <%= expeditionData.fi %> <%= expeditionData.clientName %> - <%= expeditionData.phone %> + <%= expeditionData.mobile %> <%= expeditionData.deliveryObservation %> diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 900e1fc0f..4db0d0c7d 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -47,7 +47,7 @@ module.exports = Self => { co.code countryCode, c.fi, c.name clientName, - c.phone, + a.mobile, DATE_FORMAT(t.shipped, '%d/%m/%Y') created, t.shipped, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, From c17214ce05e07f58562a0d4c3ac7e1bef8952e59 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 18 Jul 2024 11:50:01 +0200 Subject: [PATCH 064/181] feat: refs #7683 drop temporary table --- db/routines/vn/procedures/productionControl.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index 1b4a8e88a..ad1434189 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -199,6 +199,8 @@ proc: BEGIN pb.V = ti.V, pb.N = ti.N; + DROP TEMPORARY TABLE tItemPackingType; + -- Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb JOIN ticketCollection tc ON pb.ticketFk = tc.ticketFk From 15adc59ec5f006ae74a771bc0b8faa3036178f4f Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 18 Jul 2024 12:04:17 +0200 Subject: [PATCH 065/181] feat: refs #7683 drop temporary table --- db/routines/vn/procedures/productionControl.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index ad1434189..af6d929d7 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -199,8 +199,6 @@ proc: BEGIN pb.V = ti.V, pb.N = ti.N; - DROP TEMPORARY TABLE tItemPackingType; - -- Colecciones segun tipo de encajado UPDATE tmp.productionBuffer pb JOIN ticketCollection tc ON pb.ticketFk = tc.ticketFk @@ -278,6 +276,7 @@ proc: BEGIN tmp.risk, tmp.ticket_problems, tmp.ticketWithPrevia, - tItemShelvingStock; + tItemShelvingStock, + tItemPackingType; END$$ DELIMITER ; From bd1074131109cf8439a345d300794b098677dd38 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 18 Jul 2024 12:42:00 +0200 Subject: [PATCH 066/181] hotFix reservas refs #6861 --- .../vn/procedures/itemShelvingSale_reallocate.sql | 13 ++++++++----- .../vn/procedures/itemShelvingSale_setQuantity.sql | 13 +++++++++---- db/versions/11159-redIvy/00-firstScript.sql | 3 +++ 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 db/versions/11159-redIvy/00-firstScript.sql diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index 2b9f927e4..a60287caa 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -20,17 +20,20 @@ BEGIN START TRANSACTION; - SELECT id INTO vItemShelvingFk - FROM itemShelving - WHERE id = vItemShelvingFk - FOR UPDATE; - UPDATE itemShelving SET visible = 0, available = 0 WHERE id = vItemShelvingFk AND itemFk = vItemFk; + SELECT iss.id + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND iss.itemFk = vItemFk + AND NOT iss.isPicked + FOR UPDATE; + INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) SELECT DISTINCT iss.saleFk FROM itemShelvingSale iss diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index b65c5df7f..30abefec8 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -31,6 +31,12 @@ BEGIN RESIGNAL; END; + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN CALL util.throw('Reservation completed'); END IF; @@ -52,9 +58,8 @@ BEGIN AND NOT iss.isPicked; IF vQuantity > vReservedQuantity - OR (vQuantity < vReservedQuantity AND - (NOT vIsItemShelvingSaleEmpty OR vIsItemShelvingSaleEmpty IS NULL)) - OR (vIsItemShelvingSaleEmpty IS NOT NULL AND vQuantity = vReservedQuantity) THEN + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN CALL util.throw('The quantity cannot be different from the reserved'); END IF; @@ -99,7 +104,7 @@ BEGIN IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) - SELECT vSaleFk; + SELECT vSaleFk, vSectorFk; CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); END IF; END$$ diff --git a/db/versions/11159-redIvy/00-firstScript.sql b/db/versions/11159-redIvy/00-firstScript.sql new file mode 100644 index 000000000..d0b563b7a --- /dev/null +++ b/db/versions/11159-redIvy/00-firstScript.sql @@ -0,0 +1,3 @@ + + +ALTER TABLE vn.itemShelvingSale MODIFY COLUMN IF EXISTS isPicked tinyint(1) DEFAULT 1 NOT NULL; From ba5c44994d19103206d284d0900858f9dd661e6c Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Jul 2024 13:45:06 +0200 Subject: [PATCH 067/181] feat: refs #7686 Added cascade on update vn.state.alertLevel --- db/versions/11160-blueRoebelini/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11160-blueRoebelini/00-firstScript.sql diff --git a/db/versions/11160-blueRoebelini/00-firstScript.sql b/db/versions/11160-blueRoebelini/00-firstScript.sql new file mode 100644 index 000000000..235eda7fd --- /dev/null +++ b/db/versions/11160-blueRoebelini/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.state DROP FOREIGN KEY state_ibfk_1; +ALTER TABLE vn.state ADD CONSTRAINT state_ibfk_1 FOREIGN KEY (alertLevel) REFERENCES vn.alertLevel(id) ON DELETE RESTRICT ON UPDATE CASCADE; From f687994a7f297019a5870cd86a7e2ec4a0b17042 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Jul 2024 14:27:10 +0200 Subject: [PATCH 068/181] refactor: refs #7681 Requested changes --- db/routines/vn/procedures/route_updateM3.sql | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/route_updateM3.sql b/db/routines/vn/procedures/route_updateM3.sql index 1df37ec8e..98fdae5dd 100644 --- a/db/routines/vn/procedures/route_updateM3.sql +++ b/db/routines/vn/procedures/route_updateM3.sql @@ -8,16 +8,11 @@ BEGIN * * @param vSelf Id ruta */ - CREATE OR REPLACE TEMPORARY TABLE tRouteVolume - ENGINE = MEMORY - SELECT IFNULL(SUM(volume), 0) volume - FROM saleVolume - WHERE routeFk = vSelf; + DECLARE vVolume DECIMAL(10,1) + DEFAULT (SELECT SUM(volume) FROM saleVolume WHERE routeFk = vSelf); UPDATE `route` - SET m3 = (SELECT volume FROM tRouteVolume) + SET m3 = IFNULL(vVolume, 0) WHERE id = vSelf; - - DROP TEMPORARY TABLE tRouteVolume; END$$ DELIMITER ; From 03227d5e511928bab3b98b7c98b6aa7d284ec1c9 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 18 Jul 2024 14:49:40 +0200 Subject: [PATCH 069/181] refs #7393 do the translations --- print/templates/email/invoice-ticket-closure/locale/en.yml | 3 ++- print/templates/email/invoice-ticket-closure/locale/es.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/print/templates/email/invoice-ticket-closure/locale/en.yml b/print/templates/email/invoice-ticket-closure/locale/en.yml index fef73d23f..34f31c8e3 100644 --- a/print/templates/email/invoice-ticket-closure/locale/en.yml +++ b/print/templates/email/invoice-ticket-closure/locale/en.yml @@ -1,4 +1,5 @@ subject: Nightly ticket closing process report title: Nightly ticket closing process report reason: Reason -ticketId: Ticket \ No newline at end of file +ticketId: Ticket +clientId: Client \ No newline at end of file diff --git a/print/templates/email/invoice-ticket-closure/locale/es.yml b/print/templates/email/invoice-ticket-closure/locale/es.yml index 7d146b83d..a87311114 100644 --- a/print/templates/email/invoice-ticket-closure/locale/es.yml +++ b/print/templates/email/invoice-ticket-closure/locale/es.yml @@ -1,4 +1,5 @@ subject: Informe proceso de cierre de tickets nocturno title: Informe proceso de cierre de tickets nocturno reason: Motivo -ticketId: Ticket \ No newline at end of file +ticketId: Ticket +clientId: Cliente \ No newline at end of file From 684983ee424ecf8c03136548d4f8ff4b374d72a1 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 18 Jul 2024 15:14:18 +0200 Subject: [PATCH 070/181] 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 071/181] 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 a6e6f435f75a976cf517c5e11d7ef1a0a32d6ab2 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 18 Jul 2024 15:21:59 +0200 Subject: [PATCH 072/181] refs #7531 No assigned department --- db/routines/vn/procedures/zone_getAddresses.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/zone_getAddresses.sql b/db/routines/vn/procedures/zone_getAddresses.sql index 417b8c7a3..0622ece1b 100644 --- a/db/routines/vn/procedures/zone_getAddresses.sql +++ b/db/routines/vn/procedures/zone_getAddresses.sql @@ -50,7 +50,7 @@ BEGIN AND c.isActive AND ct.code = 'normal' AND bt.code <> 'worker' - AND d.id = vDepartmentFk + AND (d.id = vDepartmentFk OR NOT vDepartmentFk) GROUP BY c.id; DROP TEMPORARY TABLE tmp.zoneNodes; 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 073/181] =?UTF-8?q?fix:=20refs#7748=20solicitud=20de=20dom?= =?UTF-8?q?iciliaci=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 074/181] =?UTF-8?q?fix:=20refs=20#7748=20solicitud=20de=20?= =?UTF-8?q?domiciliaci=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 075/181] =?UTF-8?q?fix:=20refs=20#7748=20solicitud=20de=20?= =?UTF-8?q?domiciliaci=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 fd2bac713d2228a20d2311b6f7ba37016f7981f2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 07:16:24 +0200 Subject: [PATCH 076/181] fix: #6184 Deleted unused params --- modules/ticket/back/methods/ticket/saveSign.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index a751bd93a..bc0da686c 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -51,23 +51,23 @@ module.exports = Self => { fields: ['id'] }); - async function setLocation(ticketId) { + async function setLocation() { await models.Delivery.create({ - ticketFk: ticketId, + ticketFk: ticket.id, longitude: location.Longitude, latitude: location.Latitude, dated: signedTime || new Date() }, myOptions); } - async function hasSignDms(ticketId) { + async function hasSignDms() { const hasTicketDms = await Self.rawSql(` SELECT d.id FROM ticketDms td JOIN dms d ON d.id = td.dmsFk WHERE td.ticketFk = ? AND d.dmsTypeFk = ? - `, [ticketId, dmsTypeTicket.id], myOptions); + `, [ticket.id, dmsTypeTicket.id], myOptions); if (hasTicketDms.length) return true; } @@ -133,9 +133,9 @@ module.exports = Self => { if (await ticket.isSigned) throw new UserError('Ticket is already signed'); - if (location) await setLocation(ticketId); - if (!await hasSignDms(ticketId) && !isSignUploaded) - await createGestDoc(ticketId); + if (location) await setLocation(); + if (!await hasSignDms() && !isSignUploaded) + await createGestDoc(); if (isSignUploaded) await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); await ticket.updateAttribute('isSigned', true, myOptions); From 3449aeb673214356a0bfd4fe5bf50c58cba71e6a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 07:45:17 +0200 Subject: [PATCH 077/181] refactor: refs #7511 Minor change --- back/methods/edi/updateData.js | 6 +++--- db/versions/11146-maroonCordyline/00-firstScript.sql | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js index c9789d2d8..d8395cbc4 100644 --- a/back/methods/edi/updateData.js +++ b/back/methods/edi/updateData.js @@ -85,9 +85,9 @@ module.exports = Self => { for (const file of updatableFiles) { console.log(`Updating file ${file.name} checksum...`); await Self.rawSql(` - UPDATE edi.fileConfig - SET checksum = ? - WHERE name = ?`, + UPDATE edi.fileMultiConfig + SET checksum = ? + WHERE name = ?`, [file.checksum, file.name], options); } diff --git a/db/versions/11146-maroonCordyline/00-firstScript.sql b/db/versions/11146-maroonCordyline/00-firstScript.sql index 16093311e..1b41422f0 100644 --- a/db/versions/11146-maroonCordyline/00-firstScript.sql +++ b/db/versions/11146-maroonCordyline/00-firstScript.sql @@ -7,3 +7,5 @@ RENAME TABLE edi.tableConfig TO edi.tableMultiConfig; RENAME TABLE vn.invoiceOutTaxConfig TO vn.invoiceOutTaxMultiConfig; RENAME TABLE vn.userConfig TO vn.userMultiConfig; RENAME TABLE vn.conveyorConfig TO vn.conveyorMultiConfig; + +GRANT SELECT ON TABLE hedera.shelfMultiConfig TO employee; From f19f10797167a4ba0bb5309714a97045ece0d569 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 19 Jul 2024 08:27:22 +0200 Subject: [PATCH 078/181] feat checkExpeditionPrintOut refs #7751 --- back/models/expedition_PrintOut.json | 3 +++ db/versions/11161-limeOak/00-firstScript.sql | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 db/versions/11161-limeOak/00-firstScript.sql diff --git a/back/models/expedition_PrintOut.json b/back/models/expedition_PrintOut.json index 23a2fdbc4..dd49b0234 100644 --- a/back/models/expedition_PrintOut.json +++ b/back/models/expedition_PrintOut.json @@ -14,6 +14,9 @@ }, "itemFk": { "type": "number" + }, + "isChecked": { + "type": "boolean" } } } \ No newline at end of file diff --git a/db/versions/11161-limeOak/00-firstScript.sql b/db/versions/11161-limeOak/00-firstScript.sql new file mode 100644 index 000000000..aab05fa49 --- /dev/null +++ b/db/versions/11161-limeOak/00-firstScript.sql @@ -0,0 +1,8 @@ + +ALTER TABLE dipole.expedition_PrintOut ADD isChecked BOOL DEFAULT FALSE NOT NULL COMMENT 'Indica si la expedición ha sido revisada por un revisor'; + +DELETE FROM salix.ACL + WHERE model = 'Expedition_PrintOut'; + +INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) +VALUES( 'Expedition_PrintOut', '*', '*', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file From 69a8b8ef4943ab2fc20f4d237850b8a24ddc8b87 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 08:34:25 +0200 Subject: [PATCH 079/181] fix: refs #7511 Minor change --- back/models/default-view-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/models/default-view-config.json b/back/models/default-view-config.json index 88164692d..e7d856c17 100644 --- a/back/models/default-view-config.json +++ b/back/models/default-view-config.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "salix.defaultViewConfig" + "table": "salix.defaultViewMultiConfig" } }, "properties": { From 5f29384389c741e2e0d79cde820eb992a026a75d Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 10:49:45 +0200 Subject: [PATCH 080/181] feat: #6453 Rollback always split by itemPackingType --- .../procedures/order_confirmWithUser.sql | 190 +++++------------- 1 file changed, 55 insertions(+), 135 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index c48b74dd7..86489b080 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -47,17 +47,6 @@ BEGIN AND r.amount GROUP BY r.warehouseFk; - DECLARE vDistinctItemPackingType CURSOR FOR - SELECT DISTINCT i.itemPackingTypeFk - FROM `order` o - JOIN orderRow r ON r.orderFk = o.id - JOIN vn.item i ON i.id = r.itemFk - WHERE o.id = vSelf - AND r.warehouseFk = vWarehouseFk - AND r.amount - ORDER BY i.itemPackingTypeFk DESC; - -- El último siempre NULL, es imprescindible para la lógica !!! - DECLARE vRows CURSOR FOR SELECT r.id, r.itemFk, @@ -140,126 +129,65 @@ BEGIN LEAVE lDates; END IF; - CREATE OR REPLACE TEMPORARY TABLE tTicketByItemPackingType( - itemPackingTypeFk VARCHAR(1), - ticketFk INT, - PRIMARY KEY(itemPackingTypeFk, ticketFk) - ) ENGINE = MEMORY; - -- Busca un ticket existente que coincida con los parametros - OPEN vDistinctItemPackingType; - lDistinctItemPackingType: LOOP - SET vItemPackingTypeFk = NULL; - SET vDone = FALSE; - FETCH vDistinctItemPackingType INTO vItemPackingTypeFk; + WITH tPrevia AS ( + SELECT DISTINCT s.ticketFk + FROM vn.sale s + JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN vn.ticket t ON t.id = s.ticketFk + WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) + ) + SELECT t.id INTO vTicketFk + FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' + LEFT JOIN tPrevia tp ON tp.ticketFk = t.id + LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id + JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.warehouseFk = vWarehouseFk + AND o.date_send = t.landed + AND DATE(t.shipped) = vShipment + WHERE o.id = vSelf + AND t.refFk IS NULL + AND tp.ticketFk IS NULL + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) + LIMIT 1; - IF vDone THEN - LEAVE lDistinctItemPackingType; - END IF; + -- Crea el ticket en el caso de no existir uno adecuado + IF vTicketFk IS NULL THEN + SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); + CALL vn.ticket_add( + vClientFk, + vShipment, + vWarehouseFk, + vCompanyFk, + vAddressFk, + vAgencyModeFk, + NULL, + vLanded, + vUserFk, + TRUE, + vTicketFk + ); + ELSE + INSERT INTO vn.ticketTracking + SET ticketFk = vTicketFk, + userFk = vUserFk, + stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); + END IF; - IF vItemPackingTypeFk IS NULL THEN - SELECT COUNT(*) INTO vCountDistinctItemPackingTypeFk - FROM tTicketByItemPackingType; + INSERT IGNORE INTO vn.orderTicket + SET orderFk = vSelf, + ticketFk = vTicketFk; - CASE - WHEN NOT vCountDistinctItemPackingTypeFk THEN - -- Code - WHEN vCountDistinctItemPackingTypeFk = 1 THEN - INSERT INTO tTicketByItemPackingType - SET itemPackingTypeFk = vItemPackingTypeFk, - ticketFk = (SELECT ticketFk FROM tTicketByItemPackingType); - LEAVE lDistinctItemPackingType; - WHEN vCountDistinctItemPackingTypeFk > 1 THEN - INSERT INTO tTicketByItemPackingType - SET itemPackingTypeFk = vItemPackingTypeFk, - ticketFk = ( - SELECT ticketFk - FROM tTicketByItemPackingType - WHERE itemPackingTypeFk = 'H' - ); - LEAVE lDistinctItemPackingType; - END CASE; - END IF; - - WITH tPrevia AS ( - SELECT DISTINCT s.ticketFk - FROM vn.sale s - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ), - tTicketSameItemPackingType AS ( - SELECT t.id, COUNT(*) = SUM(IF( - vItemPackingTypeFk IS NOT NULL, - i.itemPackingTypeFk = vItemPackingTypeFk, - i.itemPackingTypeFk IS NULL - )) hasSameItemPackingType - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.shipped = vShipment - AND t.warehouseFk= vWarehouseFk - GROUP BY t.id - HAVING hasSameItemPackingType - ) - SELECT t.id INTO vTicketFk - FROM vn.ticket t - JOIN vn.alertLevel al ON al.code = 'FREE' - LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - JOIN hedera.`order` o ON o.address_id = t.addressFk - AND t.warehouseFk = vWarehouseFk - AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment - JOIN tTicketSameItemPackingType tt ON tt.id = t.id - WHERE o.id = vSelf - AND t.refFk IS NULL - AND tp.ticketFk IS NULL - AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) - LIMIT 1; - - -- Crea el ticket en el caso de no existir uno adecuado - IF vTicketFk IS NULL THEN - SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); - CALL vn.ticket_add( - vClientFk, - vShipment, - vWarehouseFk, - vCompanyFk, - vAddressFk, - vAgencyModeFk, - NULL, - vLanded, - vUserFk, - TRUE, - vTicketFk - ); - ELSE - INSERT INTO vn.ticketTracking - SET ticketFk = vTicketFk, - userFk = vUserFk, - stateFk = (SELECT id FROM vn.state WHERE code = 'FREE'); - END IF; - - INSERT IGNORE INTO vn.orderTicket - SET orderFk = vSelf, - ticketFk = vTicketFk; - - -- Añade las notas - IF vNotes IS NOT NULL AND vNotes <> '' THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicketFk, - observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), - `description` = vNotes - ON DUPLICATE KEY UPDATE - `description` = CONCAT(VALUES(`description`),'. ', `description`); - END IF; - - INSERT INTO tTicketByItemPackingType - SET itemPackingTypeFk = vItemPackingTypeFk, - ticketFk = vTicketFk; - END LOOP; - CLOSE vDistinctItemPackingType; + -- Añade las notas + IF vNotes IS NOT NULL AND vNotes <> '' THEN + INSERT INTO vn.ticketObservation SET + ticketFk = vTicketFk, + observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), + `description` = vNotes + ON DUPLICATE KEY UPDATE + `description` = CONCAT(VALUES(`description`),'. ', `description`); + END IF; -- Añade los movimientos y sus componentes OPEN vRows; @@ -279,12 +207,6 @@ BEGIN LEAVE lRows; END IF; - SELECT ticketFk INTO vTicketFk - FROM tTicketByItemPackingType - WHERE IF(vItemPackingTypeFk IS NOT NULL, - itemPackingTypeFk = vItemPackingTypeFk, - itemPackingTypeFk IS NULL) - SELECT s.id INTO vSaleFk FROM vn.sale s WHERE ticketFk = vTicketFk @@ -382,7 +304,5 @@ BEGIN WHERE id = vSelf; COMMIT; - - DROP TEMPORARY TABLE tTicketByItemPackingType; END$$ DELIMITER ; From 578de51f7e689b7ddc9ab03d5bf8015eb2c181f5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 10:54:40 +0200 Subject: [PATCH 081/181] feat: #6453 Refactor --- db/routines/hedera/procedures/order_confirmWithUser.sql | 7 ------- 1 file changed, 7 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 86489b080..841a69390 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -22,21 +22,16 @@ BEGIN DECLARE vAmount INT; DECLARE vPrice DECIMAL(10,2); DECLARE vSaleFk INT; - DECLARE vRate INT; DECLARE vRowFk INT; DECLARE vPriceFixed DECIMAL(10,2); DECLARE vLanded DATE; DECLARE vAddressFk INT; - DECLARE vIsConfirmed BOOL; DECLARE vClientFk INT; DECLARE vCompanyFk INT; DECLARE vAgencyModeFk INT; DECLARE vCalcFk INT; DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; - DECLARE vAvailable INT; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vCountDistinctItemPackingTypeFk INT; DECLARE vDates CURSOR FOR SELECT zgs.shipped, r.warehouseFk @@ -53,7 +48,6 @@ BEGIN i.name, r.amount, r.price, - r.rate, i.itemPackingTypeFk, i.isFloramondo FROM orderRow r @@ -199,7 +193,6 @@ BEGIN vConcept, vAmount, vPrice, - vRate, vItemPackingTypeFk, vIsLogifloraItem; 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 082/181] =?UTF-8?q?fix:=20refs=20#7748=20solicitud=20de=20?= =?UTF-8?q?domiciliaci=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 083/181] 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 b2a8326170594eca7aff3f5127516ee97cfa399a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 19 Jul 2024 12:44:45 +0200 Subject: [PATCH 084/181] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buyUltimateFromInterval.sql | 2 +- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- db/routines/vn/procedures/buy_getUltimateFromInterval.sql | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/buyUltimateFromInterval.sql b/db/routines/vn/procedures/buyUltimateFromInterval.sql index 9709f2edc..acb6282de 100644 --- a/db/routines/vn/procedures/buyUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buyUltimateFromInterval.sql @@ -6,7 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimateFromInte ) BEGIN /** - * DEPRECATED usar buy_getUltimateFromInterval + * @deprecated Usar buy_getUltimateFromInterval * Calcula las últimas compras realizadas * desde un rango de fechas. * diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index d16f89295..164fb3266 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -13,7 +13,7 @@ BEGIN * @param vDated Compras hasta fecha * @return tmp.buyUltimate */ - CALL cache.last_buy_refresh (FALSE); + CALL cache.last_buy_refresh(FALSE); DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; CREATE TEMPORARY TABLE tmp.buyUltimate diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql index 45d1122ae..df0d6a20e 100644 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -25,8 +25,8 @@ BEGIN END IF; -- Item - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; - CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval + + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimateFromInterval (PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) ENGINE = MEMORY @@ -97,7 +97,8 @@ BEGIN LIMIT 10000000000000000000) sub GROUP BY itemFk, warehouseFk; - -- ItemOriginal + -- ItemOriginal + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) SELECT itemFk, warehouseFk, From 6aab5fa9efdb55182ca46ca145ae6509ab967413 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 12:47:05 +0200 Subject: [PATCH 085/181] fix: refs #7546 Deleted insert util.binlogQueue --- db/dump/fixtures.after.sql | 3 --- 1 file changed, 3 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 84ce0d940..59730d592 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -10,9 +10,6 @@ SET foreign_key_checks = 0; INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); -INSERT INTO util.binlogQueue (code,logName, `position`) - VALUES ('mylogger', 'bin.000001', 4); - /* #5483 INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk) VALUES(1, NULL, 1, 300, 1); From 05598b33719fffd7c16e47b60acc3890cf69ca16 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 14:29:20 +0200 Subject: [PATCH 086/181] fix: refs #7126 Slow update --- .../00-firstScript.sql | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql index 5a0b23bc9..d3a3f0c00 100644 --- a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql +++ b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql @@ -1,8 +1,21 @@ ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL; +CREATE OR REPLACE TEMPORARY TABLE tBuyers + ENGINE = MEMORY + WITH tDistinctBuyers AS ( + SELECT DISTINCT buyer + FROM bs.waste w + ) + SELECT buyer, u.id + FROM tDistinctBuyers tdb + JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci + + UPDATE bs.waste w - JOIN account.`user` u ON u.name = w.buyer COLLATE utf8mb3_unicode_ci - SET w.buyerFk = u.id; + JOIN tBuyers tb ON tb.buyer = w.buyer + SET w.buyerFk = tb.id; + +DROP TEMPORARY TABLE tBuyers; ALTER TABLE bs.waste DROP PRIMARY KEY, From fe363fd4dbde010097353700b06e378b7b62e352 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 15:00:13 +0200 Subject: [PATCH 087/181] fix: refs #7126 Primary key no unique data --- .../00-firstScript.sql | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql index d3a3f0c00..4910a441f 100644 --- a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql +++ b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql @@ -32,4 +32,23 @@ ALTER TABLE bs.waste CHANGE saleWaste saleInternalWaste decimal(10,2) DEFAULT NU ALTER TABLE bs.waste ADD saleExternalWaste decimal(10,2) DEFAULT NULL NULL; ALTER TABLE bs.waste CHANGE saleQuantity saleQuantity decimal(10,2) DEFAULT NULL NULL AFTER itemTypeFk; ALTER TABLE bs.waste CHANGE itemFk itemFk int(11) DEFAULT 0 NOT NULL AFTER itemTypeFk; -ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk); \ No newline at end of file + +CREATE OR REPLACE TEMPORARY TABLE tWasteUnique + SELECT * + FROM bs.waste + GROUP BY `year`, `week`, buyerFk, itemTypeFk, itemFk + HAVING COUNT(*) > 1; + +DELETE w.* FROM bs.waste w + JOIN tWasteUnique twu ON twu.`year` = w.`year` + AND twu.`week` = w.`week` + AND twu.`buyerFk` = w.`buyerFk` + AND twu.`itemTypeFk` = w.`itemTypeFk` + AND twu.`itemFk` = w.`itemFk`; + +INSERT INTO bs.waste + SELECT * FROM tWasteUnique; + +ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk); + +DROP TEMPORARY TABLE tBuyers, tWasteUnique; From 55ea761af4e9f0419712a01c841f0313d466338a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 19 Jul 2024 15:11:14 +0200 Subject: [PATCH 088/181] eat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buy_getUltimate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 164fb3266..66e92c50e 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -6,7 +6,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getUltimate`( ) BEGIN /** - * Calcula las últimas compras realizadas hasta una fecha + * Calcula las últimas compras realizadas hasta una fecha. * * @param vItemFk Id del artículo * @param vWarehouseFk Id del almacén From 5567359d73d4020ae899d9cd22296304f452e21a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 19 Jul 2024 15:34:32 +0200 Subject: [PATCH 089/181] feat: refactor buyUltimate refs #7736 --- db/versions/11042-turquoiseAspidistra/00-firstScript.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql index 4910a441f..43038ab6d 100644 --- a/db/versions/11042-turquoiseAspidistra/00-firstScript.sql +++ b/db/versions/11042-turquoiseAspidistra/00-firstScript.sql @@ -1,5 +1,5 @@ ALTER TABLE bs.waste ADD buyerFk int(10) unsigned NOT NULL; - +USE vn; CREATE OR REPLACE TEMPORARY TABLE tBuyers ENGINE = MEMORY WITH tDistinctBuyers AS ( @@ -8,8 +8,7 @@ CREATE OR REPLACE TEMPORARY TABLE tBuyers ) SELECT buyer, u.id FROM tDistinctBuyers tdb - JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci - + JOIN account.`user` u ON u.name = tdb.buyer COLLATE utf8mb3_unicode_ci; UPDATE bs.waste w JOIN tBuyers tb ON tb.buyer = w.buyer @@ -51,4 +50,4 @@ INSERT INTO bs.waste ALTER TABLE bs.waste ADD CONSTRAINT waste_pk PRIMARY KEY (`year`, `week`, buyerFk, itemTypeFk, itemFk); -DROP TEMPORARY TABLE tBuyers, tWasteUnique; +DROP TEMPORARY TABLE tWasteUnique; From ae18a52a89604054445e2c188ca19bcd13060855 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 06:41:02 +0200 Subject: [PATCH 090/181] fix: refs #7129 fix filter --- modules/route/back/methods/route/filter.js | 78 +++++++++++----------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 5b13a9004..89cee84c0 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -91,25 +91,23 @@ module.exports = Self => { let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': - return {'r.id': value}; + return {'id': value}; case 'from': - return {'r.created': {gte: value}}; + return {'created': {gte: value}}; case 'to': - return {'r.created': {lte: value}}; + return {'created': {lte: value}}; case 'm3': - return {'r.m3': value}; + return {'m3': value}; case 'description': - return {'r.description': {like: `%${value}%`}}; + return {'description': {like: `%${value}%`}}; case 'warehouseFk': - param = `v.${param}`; + param = `${param}`; return {[param]: value}; - case 'workerFk': - case 'vehicleFk': case 'agencyModeFk': - param = `r.${param}`; + param = `${param}`; return {[param]: value}; case 'isOk': - return {'r.isOk': value}; + return {'isOk': value}; } }); @@ -119,34 +117,38 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL( - `SELECT - r.id, - r.workerFk, - r.created, - r.vehicleFk, - r.agencyModeFk, - r.time, - r.isOk, - r.kmStart, - r.kmEnd, - r.started, - r.finished, - r.gestdocFk, - r.cost, - r.m3, - r.description, - am.name agencyName, - u.name AS workerUserName, - v.numberPlate AS vehiclePlateNumber, - Date_format(r.time, '%H:%i') hour, - eu.email - FROM route r - LEFT JOIN agencyMode am ON am.id = r.agencyModeFk - LEFT JOIN agency a ON a.id = am.agencyFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN worker w ON w.id = r.workerFk - LEFT JOIN account.user u ON u.id = w.id - LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk` + `SELECT * + FROM( + SELECT + r.id, + r.workerFk, + r.created, + r.vehicleFk, + r.agencyModeFk, + r.time, + r.isOk, + r.kmStart, + r.kmEnd, + r.started, + r.finished, + r.gestdocFk, + r.cost, + r.m3, + r.description, + am.name agencyName, + u.name workerUserName, + v.numberPlate vehiclePlateNumber, + Date_format(r.time, '%H:%i') hour, + eu.email, + v.warehouseFk + FROM route r + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency a ON a.id = am.agencyFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN worker w ON w.id = r.workerFk + LEFT JOIN account.user u ON u.id = w.id + LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk + ) sub` ); stmt.merge(conn.makeSuffix(filter)); From ccc02d57b769763d916088dafdee04a5a99b71a2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 07:59:15 +0200 Subject: [PATCH 091/181] feat: refs #7589 Added vItemTypeFk & vItemCategoryFk (item_valuateInventory) --- .../vn/procedures/item_valuateInventory.sql | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql index 18aefdf7b..e6a7fdd08 100644 --- a/db/routines/vn/procedures/item_valuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -1,6 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_valuateInventory`( - vDated DATE + vDated DATE, + vItemTypeFk INT, + vItemCategoryFk INT ) BEGIN DECLARE vInventoried DATE; @@ -61,11 +63,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseInFk WHERE tr.landed = vDateDayEnd AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) GROUP BY tr.warehouseInFk, b.itemFk; ELSE INSERT INTO tInventory(warehouseFk, itemFk, quantity, warehouseInventory) @@ -78,11 +83,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseInFk WHERE tr.landed = vInventoried AND e.supplierFk = vInventorySupplierFk AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) GROUP BY tr.warehouseInFk, b.itemFk; END IF; @@ -97,6 +105,7 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseInFk WHERE tr.landed BETWEEN vInventoried AND vDateDayEnd AND IF(tr.landed = util.VN_CURDATE(), tr.isReceived, TRUE) @@ -104,6 +113,8 @@ BEGIN AND w.valuatedInventory AND t.isInventory AND e.supplierFk <> vInventorySupplierFk + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory, -1, 1)); -- Descontamos las salidas @@ -117,11 +128,14 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse w ON w.id = tr.warehouseOutFk WHERE tr.shipped BETWEEN vInventoried AND vDateDayEnd AND NOT e.isRaid AND w.valuatedInventory AND t.isInventory + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity * IF(vHasNotInventory,1,-1)); -- Descontamos las lineas de venta @@ -135,10 +149,13 @@ BEGIN JOIN `client` c ON c.id = t.clientFk JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.shipped BETWEEN vInventoried AND vDateDayEnd AND w.valuatedInventory AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 1, -1); -- Volver a poner lo que esta aun en las estanterias @@ -153,11 +170,14 @@ BEGIN JOIN `client` c ON c.id = t.clientFk JOIN item i ON i.id = s.itemFk JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk JOIN warehouse w ON w.id = t.warehouseFk WHERE t.shipped BETWEEN vDated AND vDateDayEnd AND NOT (s.isPicked OR t.isLabeled) AND w.valuatedInventory AND it.isInventory + AND (it.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + s.quantity * IF(vHasNotInventory, 0, 1); END IF; @@ -172,6 +192,7 @@ BEGIN JOIN `entry` e ON e.id = b.entryFk JOIN travel tr ON tr.id = e.travelFk JOIN itemType t ON t.id = i.typeFk + JOIN itemCategory ic ON ic.id = t.categoryFk JOIN warehouse wIn ON wIn.id = tr.warehouseInFk JOIN warehouse wOut ON wOut.id = tr.warehouseOutFk WHERE vDated >= tr.shipped AND vDated < tr.landed @@ -179,6 +200,8 @@ BEGIN AND wIn.valuatedInventory AND t.isInventory AND e.isConfirmed + AND (t.id = vItemTypeFk OR vItemTypeFk IS NULL) + AND (ic.id = vItemCategoryFk OR vItemCategoryFk IS NULL) ON DUPLICATE KEY UPDATE tInventory.quantity = tInventory.quantity + (b.quantity); CALL buyUltimate(NULL, vDateDayEnd); From a2799e1e612822e022b1900419fe57fd6c572a19 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 08:01:23 +0200 Subject: [PATCH 092/181] feat: refs #7589 Added display (item_valuateInventory) --- db/routines/vn/procedures/item_valuateInventory.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_valuateInventory.sql b/db/routines/vn/procedures/item_valuateInventory.sql index e6a7fdd08..d1d0573a3 100644 --- a/db/routines/vn/procedures/item_valuateInventory.sql +++ b/db/routines/vn/procedures/item_valuateInventory.sql @@ -227,7 +227,8 @@ BEGIN ic.name itemCategoryName, ti.cost, ti.total, - ti.warehouseInventory + ti.warehouseInventory, + ic.display FROM tInventory ti JOIN warehouse w ON w.id = warehouseFk JOIN item i ON i.id = ti.itemFk From ce59a2bbbf22e12fe4ecd225c3b845a08d57fca7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 08:40:12 +0200 Subject: [PATCH 093/181] fix: refs #6769 Item diary redirection to Lilium --- modules/item/front/diary/index.html | 123 +------------------------ modules/item/front/diary/index.js | 96 +------------------ modules/item/front/diary/index.spec.js | 99 -------------------- modules/item/front/diary/locale/es.yml | 5 - modules/item/front/diary/style.scss | 33 ------- 5 files changed, 7 insertions(+), 349 deletions(-) delete mode 100644 modules/item/front/diary/index.spec.js delete mode 100644 modules/item/front/diary/locale/es.yml delete mode 100644 modules/item/front/diary/style.scss diff --git a/modules/item/front/diary/index.html b/modules/item/front/diary/index.html index 481cec51a..7fb3b870e 100644 --- a/modules/item/front/diary/index.html +++ b/modules/item/front/diary/index.html @@ -1,121 +1,2 @@ - - - - - - - - - - - - - - - - - - - - Date - Id - State - Reference - Client - In - Out - Balance - - - - - - - - - - - - - {{::sale.shipped | date:'dd/MM/yyyy' }} - - - - - {{::sale.origin | dashIfEmpty}} - - - {{::sale.stateName | dashIfEmpty}} - {{::sale.reference | dashIfEmpty}} - - - - {{::sale.name | dashIfEmpty}} - - - {{::sale.name | dashIfEmpty}} - - - - {{::sale.invalue | dashIfEmpty}} - {{::sale.out | dashIfEmpty}} - - - {{::sale.balance | dashIfEmpty}} - - - - - - - - - - - - - - - + + diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index 1d2e34a66..3d86b0b60 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -1,107 +1,21 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -import './style.scss'; class Controller extends Section { - constructor($element, $scope, $anchorScroll, $location) { - super($element, $scope); - this.$anchorScroll = $anchorScroll; - this.$location = $location; - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - this.today = today.toJSON(); + constructor($element, $) { + super($element, $); } - get item() { - return this._item; - } - - set item(value) { - this._item = value; - - this.filter = { - where: {itemFk: this.$params.id} - }; - - this.$.$applyAsync(() => { - if (this.$params.warehouseFk) - this.warehouseFk = this.$params.warehouseFk; - else if (value) - this.warehouseFk = this.vnConfig.warehouseFk; - - if (this.$params.lineFk) - this.lineFk = this.$params.lineFk; - }); - } - - set warehouseFk(value) { - if (value && value != this._warehouseFk) { - this._warehouseFk = value; - this.card.warehouseFk = value; - this.filter.where.warehouseFk = this.warehouseFk; - - this.$.model.refresh(); - } - } - - get warehouseFk() { - return this._warehouseFk; - } - - set date(value) { - this._date = value; - this.filter.where.date = value; - this.filter.where.warehouseFk = this.warehouseFk; - - this.$.model.refresh(); - } - - get date() { - return this._date; - } - - set showOld(value) { - this._showOld = value; - if (!this._showOld) this.date = null; - else this.date = new Date(); - } - - get showOld() { - return this._showOld; - } - - scrollToLine(lineFk) { - this.$.$applyAsync(() => { - const hashFk = this.lineFk || lineFk; - const hash = `vnItemDiary-${hashFk}`; - this.$location.hash(hash); - this.$anchorScroll(); - }); - } - - showDescriptor(event, sale) { - let descriptor = 'entryDescriptor'; - if (sale.isTicket) - descriptor = 'ticketDescriptor'; - - this.$[descriptor].show(event.target, sale.origin); - } - - $onDestroy() { - if (this.$state.getCurrentPath()[2].state.name === 'item') - this.card.reload(); + async $onInit() { + this.$state.go('item.card.summary', {id: this.$params.id}); + window.location.href = await this.vnApp.getUrl(`item/${this.$params.id}/diary`); } } -Controller.$inject = ['$element', '$scope', '$anchorScroll', '$location']; - ngModule.vnComponent('vnItemDiary', { template: require('./index.html'), controller: Controller, bindings: { item: '<' - }, - require: { - card: '?^vnItemCard' } }); diff --git a/modules/item/front/diary/index.spec.js b/modules/item/front/diary/index.spec.js deleted file mode 100644 index a6302346d..000000000 --- a/modules/item/front/diary/index.spec.js +++ /dev/null @@ -1,99 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Item', () => { - describe('Component vnItemDiary', () => { - let $scope; - let controller; - - beforeEach(ngModule('item')); - - beforeEach(inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnItemDiary', {$element, $scope}); - controller.$.model = crudModel; - controller.$params = {id: 1}; - controller.card = {}; - })); - - describe('set item()', () => { - it('should set warehouseFk property based on itemType warehouseFk', () => { - jest.spyOn(controller.$, '$applyAsync'); - controller.vnConfig = {warehouseFk: 1}; - controller.item = {id: 1}; - - expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); - $scope.$apply(); - - expect(controller.warehouseFk).toEqual(1); - expect(controller.item.id).toEqual(1); - }); - - it(`should set warehouseFk property based on url query warehouseFk`, () => { - jest.spyOn(controller.$, '$applyAsync'); - controller.$params.warehouseFk = 4; - controller.item = {id: 1, itemType: {warehouseFk: 1}}; - - expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); - $scope.$apply(); - - expect(controller.warehouseFk).toEqual(4); - expect(controller.item.id).toEqual(1); - }); - }); - - describe('scrollToLine ()', () => { - it('should assign $location then call anchorScroll using controller value', () => { - jest.spyOn(controller, '$anchorScroll'); - controller.lineFk = 1; - controller.scrollToLine('invalidValue'); - - $scope.$apply(); - - expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`); - expect(controller.$anchorScroll).toHaveBeenCalledWith(); - }); - - it('should assign $location then call anchorScroll using received value', () => { - jest.spyOn(controller, '$anchorScroll'); - controller.lineFk = undefined; - controller.scrollToLine(1); - - $scope.$apply(); - - expect(controller.$location.hash()).toEqual(`vnItemDiary-${1}`); - expect(controller.$anchorScroll).toHaveBeenCalledWith(); - }); - }); - - describe('showDescriptor ()', () => { - it('should call to the entryDescriptor show() method', () => { - controller.$.entryDescriptor = {}; - controller.$.entryDescriptor.show = jest.fn(); - - const $event = new Event('click'); - const target = document.createElement('div'); - target.dispatchEvent($event); - const data = {id: 1, origin: 1}; - controller.showDescriptor($event, data); - - expect(controller.$.entryDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); - }); - - it('should call to the ticketDescriptor show() method', () => { - controller.$.ticketDescriptor = {}; - controller.$.ticketDescriptor.show = jest.fn(); - - const $event = new Event('click'); - const target = document.createElement('div'); - target.dispatchEvent($event); - const data = {id: 1, origin: 1, isTicket: true}; - controller.showDescriptor($event, data); - - expect(controller.$.ticketDescriptor.show).toHaveBeenCalledWith($event.target, data.origin); - }); - }); - }); -}); - diff --git a/modules/item/front/diary/locale/es.yml b/modules/item/front/diary/locale/es.yml deleted file mode 100644 index a312da774..000000000 --- a/modules/item/front/diary/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -In: Entrada -Out: Salida -Visible quantity: Cantidad visible -Ticket/Entry: Ticket/Entrada -Show what's before the inventory: Mostrar lo anterior al inventario diff --git a/modules/item/front/diary/style.scss b/modules/item/front/diary/style.scss deleted file mode 100644 index 0a6cafcb9..000000000 --- a/modules/item/front/diary/style.scss +++ /dev/null @@ -1,33 +0,0 @@ -@import "variables"; - -vn-item-diary { - & > vn-vertical { - display: block; - } - vn-horizontal { - justify-content: center; - } - vn-autocomplete > div { - width: 400px; - } - .balanceNegative .balance { - color: $color-alert; - } - .isIn .in { - color: $color-success; - font-weight: bold; - } - .isToday .date { - color: white; - background-color: $color-main; - } - .truncate { - max-width: 250px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - .table-check{ - justify-content: center; - } -} From c3d3a21b23d900ce8ceff3db21c878185844334f Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 09:12:24 +0200 Subject: [PATCH 094/181] feat: refs #7129 add fields --- modules/route/back/methods/route/cmrs.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/route/back/methods/route/cmrs.js b/modules/route/back/methods/route/cmrs.js index 0c25cbca5..6f271a4cf 100644 --- a/modules/route/back/methods/route/cmrs.js +++ b/modules/route/back/methods/route/cmrs.js @@ -91,11 +91,13 @@ module.exports = Self => { SELECT t.cmrFk, t.id ticketFk, t.routeFk, - co.name country, + co.id countryFk, + co.name countryName, t.clientFk, IF(sub.id, TRUE, FALSE) hasCmrDms, DATE(t.shipped) shipped, - t.warehouseFk + t.warehouseFk, + w.name warehouseName FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id JOIN state s ON s.id = ts.stateFk From c18765f22f658d7f4f1216076db6dd5ac2d01061 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 09:18:37 +0200 Subject: [PATCH 095/181] fix: refs #7129 fix return --- modules/route/back/methods/route/filter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 89cee84c0..8f90fc532 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -101,10 +101,8 @@ module.exports = Self => { case 'description': return {'description': {like: `%${value}%`}}; case 'warehouseFk': - param = `${param}`; return {[param]: value}; case 'agencyModeFk': - param = `${param}`; return {[param]: value}; case 'isOk': return {'isOk': value}; From 2ba4ca088d79265bf14ddce799fdb4922877b717 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 09:46:20 +0200 Subject: [PATCH 096/181] 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 097/181] 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 098/181] 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 099/181] 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; From ab45b988c82029a033a1471ea95243c1d78fbf7f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 10:27:24 +0200 Subject: [PATCH 100/181] feat: refs #7704 Added itemMinimumQuantity_check --- .../procedures/itemMinimumQuantity_check.sql | 28 +++++++++++++++++++ .../itemMinimumQuantity_beforeInsert.sql | 1 + .../itemMinimumQuantity_beforeUpdate.sql | 1 + .../models/specs/itemMinimumQuantity.spec.js | 15 +++++----- 4 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 db/routines/vn/procedures/itemMinimumQuantity_check.sql diff --git a/db/routines/vn/procedures/itemMinimumQuantity_check.sql b/db/routines/vn/procedures/itemMinimumQuantity_check.sql new file mode 100644 index 000000000..fef7cdbdb --- /dev/null +++ b/db/routines/vn/procedures/itemMinimumQuantity_check.sql @@ -0,0 +1,28 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemMinimumQuantity_check`( + vSelf INT, + vItemFk INT, + vStarted DATE, + vEnded DATE, + vWarehouseFk INT +) +BEGIN + DECLARE vHasCollision BOOL; + + IF vStarted IS NULL THEN + CALL util.throw('The field "started" cannot be null'); + END IF; + + SELECT COUNT(*) INTO vHasCollision + FROM itemMinimumQuantity + WHERE vItemFk = itemFk + AND ((vStarted <= ended OR ended IS NULL) + AND (vStarted >= `started` OR vEnded IS NULL)) + AND (vWarehouseFk <=> warehouseFk) + AND vSelf <> id; + + IF vHasCollision THEN + CALL util.throw('A line with the same configuration already exists'); + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql b/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql index 8833ac968..3ee6c0b1a 100644 --- a/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql +++ b/db/routines/vn/triggers/itemMinimumQuantity_beforeInsert.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemMinimumQuantity_b FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql b/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql index ef030f9f9..6f082551c 100644 --- a/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemMinimumQuantity_beforeUpdate.sql @@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemMinimumQuantity_b FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); END$$ DELIMITER ; diff --git a/modules/item/back/models/specs/itemMinimumQuantity.spec.js b/modules/item/back/models/specs/itemMinimumQuantity.spec.js index 072a80f94..7d1e19def 100644 --- a/modules/item/back/models/specs/itemMinimumQuantity.spec.js +++ b/modules/item/back/models/specs/itemMinimumQuantity.spec.js @@ -2,9 +2,10 @@ const {models} = require('vn-loopback/server/server'); describe('itemMinimumQuantity model', () => { const itemFk = 5; + const quantity = 100; const warehouseFk = 60; - beforeAll(async() => { + beforeEach(async() => { await models.ItemMinimumQuantity.destroyAll({where: {itemFk: itemFk}}); }); @@ -12,7 +13,7 @@ describe('itemMinimumQuantity model', () => { it('should create a new itemMinimumQuantity record', async() => { const newRecord = { itemFk: itemFk, - quantity: 100, + quantity: quantity, started: Date.vnNew(), ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 1)), warehouseFk: warehouseFk @@ -27,7 +28,7 @@ describe('itemMinimumQuantity model', () => { it('should read an existing itemMinimumQuantity record', async() => { const newRecord = { itemFk: itemFk, - quantity: 100, + quantity: quantity, started: Date.vnNew(), ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 2)), warehouseFk: warehouseFk @@ -44,7 +45,7 @@ describe('itemMinimumQuantity model', () => { it('should update an existing itemMinimumQuantity record', async() => { const newRecord = { itemFk: itemFk, - quantity: 100, + quantity: quantity, started: Date.vnNew(), ended: new Date(Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 3)), warehouseFk: warehouseFk @@ -67,7 +68,7 @@ describe('itemMinimumQuantity model', () => { it('should enforce unique constraint on itemFk, started, ended, and warehouseFk', async() => { const newRecord = { itemFk: itemFk, - quantity: 100, + quantity: quantity, started: Date.vnNew(), ended: Date.vnNew().setFullYear(Date.vnNew().getFullYear() + 5), warehouseFk: warehouseFk @@ -78,14 +79,14 @@ describe('itemMinimumQuantity model', () => { await models.ItemMinimumQuantity.create(newRecord); } catch (e) { expect(e).toBeDefined(); - expect(e.code).toContain('ER_DUP_ENTRY'); + expect(e.code).toContain('ER_SIGNAL_EXCEPTION'); } }); it('should allow null values for ended and warehouseFk', async() => { const newRecord = { itemFk: itemFk, - quantity: 100, + quantity: quantity, started: Date.vnNew(), ended: null, warehouseFk: null From d7b9a3ffd02a0571d7f3a014a33425e1c0827082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Jul 2024 11:58:51 +0200 Subject: [PATCH 101/181] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buy_getUltimate.sql | 3 +-- .../vn/procedures/buy_getUltimateFromInterval.sql | 2 +- db/routines/vn/procedures/buy_updateGrouping.sql | 10 +++++++--- db/routines/vn/procedures/catalog_calculate.sql | 2 +- db/routines/vn/procedures/item_getInfo.sql | 15 +++++++++------ modules/entry/back/methods/entry/addFromBuy.js | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/db/routines/vn/procedures/buy_getUltimate.sql b/db/routines/vn/procedures/buy_getUltimate.sql index 66e92c50e..023e81774 100644 --- a/db/routines/vn/procedures/buy_getUltimate.sql +++ b/db/routines/vn/procedures/buy_getUltimate.sql @@ -15,8 +15,7 @@ BEGIN */ CALL cache.last_buy_refresh(FALSE); - DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimate; - CREATE TEMPORARY TABLE tmp.buyUltimate + CREATE OR REPLACE TEMPORARY TABLE tmp.buyUltimate (PRIMARY KEY (itemFk, warehouseFk), INDEX(itemFk)) ENGINE = MEMORY diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql index df0d6a20e..c340686ba 100644 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -21,7 +21,7 @@ BEGIN END IF; IF vEnded < vStarted THEN - SET vStarted = TIMESTAMPADD(MONTH, -1, vEnded); + SET vStarted = vEnded - INTERVAL 1 MONTH; END IF; -- Item diff --git a/db/routines/vn/procedures/buy_updateGrouping.sql b/db/routines/vn/procedures/buy_updateGrouping.sql index 45a619262..0d97fd8bf 100644 --- a/db/routines/vn/procedures/buy_updateGrouping.sql +++ b/db/routines/vn/procedures/buy_updateGrouping.sql @@ -1,5 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`(vWarehouseFk INT, vItemFk INT, vGrouping INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_updateGrouping`( + vWarehouseFk INT, + vItemFk INT, + vGrouping INT +) BEGIN /** * Actualiza el grouping de las últimas compras de un artículo @@ -8,9 +12,9 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL vn.buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); - UPDATE vn.buy b + UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk SET b.`grouping` = vGrouping WHERE bu.warehouseFk = vWarehouseFk diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 887492b35..6c4affa9d 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -74,7 +74,7 @@ BEGIN CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); - CALL vn.buy_getUltimate(NULL, vWarehouseFk, vShipped); + CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) SELECT vWarehouseFk, diff --git a/db/routines/vn/procedures/item_getInfo.sql b/db/routines/vn/procedures/item_getInfo.sql index f569d235b..5cd4fb31e 100644 --- a/db/routines/vn/procedures/item_getInfo.sql +++ b/db/routines/vn/procedures/item_getInfo.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`(IN `vBarcode` VARCHAR(22), IN `vWarehouseFk` INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getInfo`( + `vBarcode` VARCHAR(22), + `vWarehouseFk` INT +) BEGIN /** * Devuelve información relativa al item correspondiente del vBarcode pasado @@ -11,13 +14,13 @@ BEGIN DECLARE vCacheAvailableFk INT; DECLARE vVisibleItemShelving INT; DECLARE vItemFk INT; + DECLARE vDated DATE; + + SELECT barcodeToItem(vBarcode), util.VN_CURDATE() INTO vItemFk, vDated; CALL cache.visible_refresh(vCacheVisibleFk, FALSE, vWarehouseFk); - CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, util.VN_CURDATE()); - - SELECT barcodeToItem(vBarcode) INTO vItemFk; - - CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); + CALL cache.available_refresh(vCacheAvailableFk, FALSE, vWarehouseFk, vDated); + CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated); SELECT SUM(visible) INTO vVisibleItemShelving FROM itemShelvingStock diff --git a/modules/entry/back/methods/entry/addFromBuy.js b/modules/entry/back/methods/entry/addFromBuy.js index 212aed7ea..c75c1935a 100644 --- a/modules/entry/back/methods/entry/addFromBuy.js +++ b/modules/entry/back/methods/entry/addFromBuy.js @@ -52,7 +52,7 @@ module.exports = Self => { else { const userConfig = await models.UserConfig.findById(userId, {fields: ['warehouseFk']}, myOptions); await Self.rawSql( - 'CALL vn.buy_getUltimate(?,?,?)', + 'CALL buy_getUltimate(?, ?, ?)', [args.item, userConfig.warehouseFk, null], myOptions ); From 24c85608eb5bf83162f0b00d02f5fde941d40d28 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 12:09:24 +0200 Subject: [PATCH 102/181] feat: refs #7740 Ticket before update added restriction --- db/routines/vn/triggers/ticket_beforeUpdate.sql | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/triggers/ticket_beforeUpdate.sql b/db/routines/vn/triggers/ticket_beforeUpdate.sql index 72831bc3d..34b6711ff 100644 --- a/db/routines/vn/triggers/ticket_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticket_beforeUpdate.sql @@ -8,13 +8,16 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); IF NOT (NEW.routeFk <=> OLD.routeFk) THEN - INSERT IGNORE INTO `vn`.`routeRecalc` (`routeFk`) - SELECT r.id - FROM vn.route r - WHERE r.isOk = FALSE - AND r.id IN (OLD.routeFk,NEW.routeFk) - AND r.created >= util.VN_CURDATE() - GROUP BY r.id; + IF NEW.isSigned THEN + CALL util.throw('A signed ticket cannot be rerouted'); + END IF; + INSERT IGNORE INTO routeRecalc(routeFk) + SELECT id + FROM `route` + WHERE NOT isOk + AND id IN (OLD.routeFk, NEW.routeFk) + AND created >= util.VN_CURDATE() + GROUP BY id; END IF; IF NOT (DATE(NEW.shipped) <=> DATE(OLD.shipped)) THEN From b9c57c2f0ed2b5a4a837e2f9d5cc116da5f106c0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 12:45:57 +0200 Subject: [PATCH 103/181] Fix --- modules/ticket/back/methods/expedition/deleteExpeditions.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 707a60611..24058d0f6 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -40,8 +40,6 @@ module.exports = Self => { }); const {code} = expedition.agencyMode(); - const expedition = await models.Expedition.findOne(filter); - const {code} = expedition.agencyMode(); let isDeleted = true; if (code?.toLowerCase()?.includes('mrw') && expedition.externalId) { From 513b4583b329d22e3e5d07cb58f63253a7628c05 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 12:49:50 +0200 Subject: [PATCH 104/181] =?UTF-8?q?fix(deletExpeditions):=20merge=20test?= =?UTF-8?q?=20=E2=86=92=20dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/methods/expedition/deleteExpeditions.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 24058d0f6..75993a485 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -40,8 +40,6 @@ module.exports = Self => { }); const {code} = expedition.agencyMode(); - let isDeleted = true; - if (code?.toLowerCase()?.includes('mrw') && expedition.externalId) { const result = await models.MrwConfig.cancelShipment(expeditionId); if (!result) throw new Error('not deleted'); @@ -52,14 +50,9 @@ module.exports = Self => { if (result !== 'true') throw new Error('not deleted'); } - if (!isDeleted) - notDeletedExpeditions.push(expeditionId); - else { - const deletedExpedition = await models.Expedition.destroyById(expeditionId); - deletedExpeditions.push(deletedExpedition); - } + const deletedExpedition = await models.Expedition.destroyById(expeditionId); + deletedExpeditions.push(deletedExpedition); } catch (e) { - console.log('e: ', e); notDeletedExpeditions.push(expeditionId); } } From b73eceb1c8341ad2f93b945ace10f74bca7de099 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 22 Jul 2024 13:33:51 +0200 Subject: [PATCH 105/181] fix: refs #7129 fix backFilters --- modules/route/back/methods/route/filter.js | 9 ++++----- modules/route/back/methods/route/getByWorker.js | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 8f90fc532..925927cc8 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -96,16 +96,15 @@ module.exports = Self => { return {'created': {gte: value}}; case 'to': return {'created': {lte: value}}; - case 'm3': - return {'m3': value}; case 'description': return {'description': {like: `%${value}%`}}; + case 'isOk': + case 'm3': case 'warehouseFk': - return {[param]: value}; + case 'workerFk': + case 'vehicleFk': case 'agencyModeFk': return {[param]: value}; - case 'isOk': - return {'isOk': value}; } }); diff --git a/modules/route/back/methods/route/getByWorker.js b/modules/route/back/methods/route/getByWorker.js index 9243cfbfb..5d1881c20 100644 --- a/modules/route/back/methods/route/getByWorker.js +++ b/modules/route/back/methods/route/getByWorker.js @@ -28,11 +28,11 @@ module.exports = Self => { if (canViewAll) { const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); filterGrant = { - where: {'a.warehouseFk': userConfig.warehouseFk} + where: {'warehouseFk': userConfig.warehouseFk} }; } else { filterGrant = { - where: {'r.workerFk': userId} + where: {'workerFk': userId} }; } @@ -46,16 +46,16 @@ module.exports = Self => { and: [ { or: [ - {'r.created': currentDate}, - {'r.created': nextDay} + {'created': currentDate}, + {'created': nextDay} ] } ] }, order: [ - 'r.created ASC', - 'r.time ASC', - 'am.name ASC' + 'created ASC', + 'time ASC', + 'agencyName ASC' ] }; From b086cc7658772b58c4ffd6fea4d6a7935c3a92c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Jul 2024 13:34:04 +0200 Subject: [PATCH 106/181] feat: refactor buyUltimate refs #7736 --- .../buy_getUltimateFromInterval.sql | 12 ++++---- .../vn/procedures/catalog_calculate.sql | 30 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql index c340686ba..2115beb95 100644 --- a/db/routines/vn/procedures/buy_getUltimateFromInterval.sql +++ b/db/routines/vn/procedures/buy_getUltimateFromInterval.sql @@ -115,12 +115,12 @@ BEGIN JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND (b.itemFk = vItemFk OR vItemFk IS NULL) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND (b.itemFk = vItemFk OR vItemFk IS NULL) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk ORDER BY t.landed DESC, b.id DESC LIMIT 10000000000000000000) sub GROUP BY itemFk, warehouseFk; diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 6c4affa9d..8432e8dea 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -29,7 +29,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - CALL vn.zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); + CALL zone_getShipped (vLanded, vAddressFk, vAgencyModeFk, vShowExpiredZones); DROP TEMPORARY TABLE IF EXISTS tmp.ticketLot; CREATE TEMPORARY TABLE tmp.ticketLot( @@ -86,17 +86,17 @@ BEGIN LEFT JOIN cache.availableNoRaids anr ON anr.item_id = a.item_id AND anr.calc_id = vAvailableNoRaidsCalc JOIN tmp.item i ON i.itemFk = a.item_id - JOIN vn.item it ON it.id = i.itemFk - JOIN vn.`zone` z ON z.id = vZoneFk + JOIN item it ON it.id = i.itemFk + JOIN `zone` z ON z.id = vZoneFk LEFT JOIN tmp.buyUltimate bu ON bu.itemFk = a.item_id LEFT JOIN edi.supplyResponse sr ON sr.ID = it.supplyResponseFk LEFT JOIN edi.VMPSettings v ON v.VMPID = sr.vmpID LEFT JOIN edi.marketPlace mp ON mp.id = sr.MarketPlaceID LEFT JOIN (SELECT isVNHSupplier, isEarlyBird, TRUE AS itemAllowed - FROM vn.addressFilter af + FROM addressFilter af JOIN (SELECT ad.provinceFk, p.countryFk, ad.isLogifloraAllowed - FROM vn.address ad - JOIN vn.province p ON p.id = ad.provinceFk + FROM address ad + JOIN province p ON p.id = ad.provinceFk WHERE ad.id = vAddressFk ) sub2 ON sub2.provinceFk <=> IFNULL(af.provinceFk, sub2.provinceFk) AND sub2.countryFk <=> IFNULL(af.countryFk, sub2.countryFk) @@ -108,18 +108,18 @@ BEGIN OR ISNULL(af.afterDated)) ) sub ON sub.isVNHSupplier = v.isVNHSupplier AND (sub.isEarlyBird = mp.isEarlyBird OR ISNULL(sub.isEarlyBird)) - JOIN vn.agencyMode am ON am.id = vAgencyModeFk - JOIN vn.agency ag ON ag.id = am.agencyFk - JOIN vn.itemType itt ON itt.id = it.typeFk - JOIN vn.itemCategory itc on itc.id = itt.categoryFk - JOIN vn.address ad ON ad.id = vAddressFk - LEFT JOIN vn.clientItemType cit + JOIN agencyMode am ON am.id = vAgencyModeFk + JOIN agency ag ON ag.id = am.agencyFk + JOIN itemType itt ON itt.id = it.typeFk + JOIN itemCategory itc on itc.id = itt.categoryFk + JOIN address ad ON ad.id = vAddressFk + LEFT JOIN clientItemType cit ON cit.clientFk = ad.clientFk AND cit.itemTypeFk = itt.id - LEFT JOIN vn.zoneItemType zit + LEFT JOIN zoneItemType zit ON zit.zoneFk = vZoneFk AND zit.itemTypeFk = itt.id - LEFT JOIN vn.agencyModeItemType ait + LEFT JOIN agencyModeItemType ait ON ait.agencyModeFk = vAgencyModeFk AND ait.itemTypeFk = itt.id WHERE a.calc_id = vAvailableCalc @@ -133,7 +133,7 @@ BEGIN DROP TEMPORARY TABLE tmp.buyUltimate; - CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); + CALL catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); INSERT INTO tmp.ticketCalculateItem( itemFk, From 33a71867bda9cd58ce2297d7a73fe051391949ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 22 Jul 2024 13:39:48 +0200 Subject: [PATCH 107/181] feat: refactor buyUltimate refs #7736 --- db/routines/vn/procedures/buyUltimate.sql | 4 ++-- db/routines/vn/procedures/buy_updateGrouping.sql | 2 +- db/routines/vn/procedures/catalog_calculate.sql | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/buyUltimate.sql b/db/routines/vn/procedures/buyUltimate.sql index 7026c8c82..e743b8c90 100644 --- a/db/routines/vn/procedures/buyUltimate.sql +++ b/db/routines/vn/procedures/buyUltimate.sql @@ -5,8 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buyUltimate`( ) BEGIN /** - * DEPRECATED usar buy_getUltimate - * Calcula las últimas compras realizadas hasta una fecha + * @deprecated Usar buy_getUltimate + * Calcula las últimas compras realizadas hasta una fecha. * * @param vItemFk Id del artículo * @param vWarehouseFk Id del almacén diff --git a/db/routines/vn/procedures/buy_updateGrouping.sql b/db/routines/vn/procedures/buy_updateGrouping.sql index 0d97fd8bf..e589fbd2a 100644 --- a/db/routines/vn/procedures/buy_updateGrouping.sql +++ b/db/routines/vn/procedures/buy_updateGrouping.sql @@ -12,7 +12,7 @@ BEGIN * @param vItemFk Id del Artículo * @param vGrouping Cantidad de grouping */ - CALL buy_getUltimate (vItemFk, vWarehouseFk, util.VN_CURDATE()); + CALL buy_getUltimate(vItemFk, vWarehouseFk, util.VN_CURDATE()); UPDATE buy b JOIN tmp.buyUltimate bu ON b.id = bu.buyFk diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 8432e8dea..2a0157881 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -72,8 +72,8 @@ BEGIN LEAVE l; END IF; - CALL `cache`.available_refresh (vAvailableCalc, FALSE, vWarehouseFk, vShipped); - CALL `cache`.availableNoRaids_refresh (vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); + CALL `cache`.available_refresh(vAvailableCalc, FALSE, vWarehouseFk, vShipped); + CALL `cache`.availableNoRaids_refresh(vAvailableNoRaidsCalc, FALSE, vWarehouseFk, vShipped); CALL buy_getUltimate(NULL, vWarehouseFk, vShipped); INSERT INTO tmp.ticketLot (warehouseFk, itemFk, available, buyFk, zoneFk) From afbce80303782ec1474b310741d418d01fb8c4a6 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 22 Jul 2024 13:42:42 +0200 Subject: [PATCH 108/181] hotFix solve isPicked refs #6861 --- db/routines/vn/procedures/itemShelvingSale_addBySale.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 96c49b788..757f880f9 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -98,11 +98,12 @@ proc: BEGIN itemShelvingFk, saleFk, quantity, - userFk) + isPicked) SELECT vItemShelvingFk, vSaleFk, vReservedQuantity, - vUserFk; + vUserFk, + FALSE; UPDATE itemShelving SET available = available - vReservedQuantity From bfd2b5aebbca9d98bf02b868df0ea7ef4e5a0a91 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 09:22:18 +0200 Subject: [PATCH 109/181] fix: refs #7382 invoiceIn_booking change --- db/routines/vn/procedures/invoiceIn_booking.sql | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index c194a774d..20da0545d 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -13,26 +13,12 @@ BEGIN * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo */ DECLARE vFiscalYear INT; - DECLARE vDistinctTransactions INT; DECLARE vHasRepeatedTransactions BOOL; - SELECT COUNT(DISTINCT iit.transactionTypeSageFk) INTO vDistinctTransactions - FROM invoiceIn ii - JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN invoiceInSerial iis ON iis.code = ii.serial - WHERE iit.invoiceInFk = vSelf - AND iis.taxAreaFk = 'CEE' - AND iit.transactionTypeSageFk; - - IF vDistinctTransactions > 1 THEN - CALL util.throw ('This invoice does not allow different types of transactions'); - END IF; - SELECT TRUE INTO vHasRepeatedTransactions FROM invoiceInTax WHERE invoiceInFk = vSelf - GROUP BY transactionTypeSageFk - HAVING COUNT(transactionTypeSageFk) > 1 + HAVING COUNT(DISTINCT transactionTypeSageFk) > 1 LIMIT 1; IF vHasRepeatedTransactions THEN From 04ff3e0cc79b00272d1ebbde7196292eab651c1d Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 09:23:42 +0200 Subject: [PATCH 110/181] fix: refs #7382 throw --- db/routines/vn/procedures/invoiceIn_booking.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 20da0545d..c728085b8 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -22,7 +22,7 @@ BEGIN LIMIT 1; IF vHasRepeatedTransactions THEN - CALL util.throw ('This invoice contains repeated types of transactions'); + CALL util.throw ('This invoice contains different types of transactions'); END IF; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn From fa10376beabf4941529e7b08c88065048507a6e3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 10:21:09 +0200 Subject: [PATCH 111/181] fix: refs #7662 assign --- back/methods/collection/assign.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/back/methods/collection/assign.js b/back/methods/collection/assign.js index 0484eb5a8..9abeb46f5 100644 --- a/back/methods/collection/assign.js +++ b/back/methods/collection/assign.js @@ -20,9 +20,13 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const [, , [{collectionFk}]] = - await Self.rawSql('CALL vn.collection_assign(?, @vCollectionFk); SELECT @vCollectionFk collectionFk', - [userId], myOptions); + const result = await Self.rawSql(` + CALL vn.collection_assign(?, @vCollectionFk); + SELECT @vCollectionFk collectionFk + `, [userId], myOptions); + + // Por si entra en el SELECT FOR UPDATE y retorna un array más + const collectionFk = result[2][0]?.collectionFk || result[3][0]?.collectionFk; if (!collectionFk) throw new UserError('There are not picking tickets'); await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions); From 71cd805b7e1176b0a10814254263c324c14aae90 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 10:23:28 +0200 Subject: [PATCH 112/181] build: dump db --- db/dump/.dump/data.sql | 224 ++-- db/dump/.dump/privileges.sql | 42 +- db/dump/.dump/structure.sql | 2236 +++++++++++++++++++++------------- db/dump/.dump/triggers.sql | 266 +++- 4 files changed, 1758 insertions(+), 1010 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 43f686022..711524e4c 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -3,7 +3,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11117','5558e69e648c3819d4a1edf86f8df4b94d36e71a','2024-07-09 07:39:39','11141'); +INSERT INTO `version` VALUES ('vn-database','11154','04ff3e0cc79b00272d1ebbde7196292eab651c1d','2024-07-23 09:24:55','11163'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -764,6 +764,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10955','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','10956','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10957','00-aclTicketClone.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-04 07:34:58',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10959','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-18 13:32:25',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10960','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:12',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10962','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-03-25 08:27:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10964','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10967','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-04-18 07:40:52',NULL,NULL); @@ -779,6 +780,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','10977','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','10978','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-06-11 08:32:33',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10983','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:37',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10984','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','10986','00-addSummaryId.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:12',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10988','00-pbx_prefix.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-04-11 17:00:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10990','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-05-07 07:31:59',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10991','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-05-14 07:45:26',NULL,NULL); @@ -877,8 +879,31 @@ INSERT INTO `versionLog` VALUES ('vn-database','11111','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11114','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-06-25 08:39:49',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11116','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11117','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 07:39:38',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11118','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-19 12:28:49',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11119','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:13',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11120','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11121','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11126','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11128','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11129','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11130','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11131','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:15',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11134','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-05 11:02:07',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11135','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11136','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:22:16',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11137','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:33',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11138','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11139','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-08 10:58:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11140','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:34',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11145','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-09 13:55:46',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11149','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11150','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11152','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 09:06:11',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11154','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-23 08:23:35',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11157','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-16 13:11:00',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11158','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-17 17:06:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11159','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-07-18 17:23:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11160','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-07-18 13:46:16',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1248,6 +1273,7 @@ INSERT INTO `roleInherit` VALUES (370,72,130,10578); INSERT INTO `roleInherit` VALUES (371,36,35,NULL); INSERT INTO `roleInherit` VALUES (372,126,13,19295); INSERT INTO `roleInherit` VALUES (373,131,2,19295); +INSERT INTO `roleInherit` VALUES (375,120,131,1437); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); @@ -1461,7 +1487,7 @@ INSERT INTO `ACL` VALUES (260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','emp INSERT INTO `ACL` VALUES (261,'SupplierAccount','*','*','ALLOW','ROLE','administrative'); INSERT INTO `ACL` VALUES (262,'Entry','*','*','ALLOW','ROLE','administrative'); INSERT INTO `ACL` VALUES (263,'InvoiceIn','*','READ','ALLOW','ROLE','administrative'); -INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','$authenticated'); INSERT INTO `ACL` VALUES (265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss'); INSERT INTO `ACL` VALUES (266,'ZoneLog','*','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (267,'Genus','*','WRITE','ALLOW','ROLE','logisticBoss'); @@ -1906,12 +1932,12 @@ INSERT INTO `ACL` VALUES (772,'Route','getExpeditionSummary','READ','ALLOW','ROL INSERT INTO `ACL` VALUES (773,'WorkerTimeControl','login','READ','ALLOW','ROLE','timeControl'); INSERT INTO `ACL` VALUES (774,'WorkerTimeControl','getClockIn','READ','ALLOW','ROLE','timeControl'); INSERT INTO `ACL` VALUES (775,'WorkerTimeControl','clockIn','WRITE','ALLOW','ROLE','timeControl'); -INSERT INTO `ACL` VALUES (776,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','teamBoss'); -INSERT INTO `ACL` VALUES (777,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','teamBoss'); -INSERT INTO `ACL` VALUES (778,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','teamBoss'); +INSERT INTO `ACL` VALUES (776,'WorkerTimeControl','addTimeEntry','WRITE','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (777,'WorkerTimeControl','deleteTimeEntry','WRITE','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (778,'WorkerTimeControl','updateTimeEntry','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (779,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','developer'); INSERT INTO `ACL` VALUES (780,'WorkerTimeControl','updateMailState','WRITE','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (781,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','teamBoss'); +INSERT INTO `ACL` VALUES (781,'WorkerTimeControl','weeklyHourRecordEmail','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (782,'WorkerTimeControl','getMailStates','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (783,'WorkerTimeControl','resendWeeklyHourEmail','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (784,'VnRole','*','READ','ALLOW','ROLE','employee'); @@ -2020,6 +2046,13 @@ INSERT INTO `ACL` VALUES (892,'WorkerIncome','*','*','ALLOW','ROLE','hr'); INSERT INTO `ACL` VALUES (893,'PayrollComponent','*','*','ALLOW','ROLE','hr'); INSERT INTO `ACL` VALUES (894,'Worker','__get__incomes','*','ALLOW','ROLE','hr'); INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (896,'Expedition_PrintOut','*','READ','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (897,'WorkerLog','*','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system'); +INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier'); +INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier'); +INSERT INTO `ACL` VALUES (904,'Entry','buyLabel','READ','ALLOW','ROLE','supplier'); +INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production'); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2120,9 +2153,9 @@ USE `vn`; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; INSERT INTO `alertLevel` VALUES ('FREE',0,1); -INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',1,1); -INSERT INTO `alertLevel` VALUES ('PACKED',2,0); -INSERT INTO `alertLevel` VALUES ('DELIVERED',3,0); +INSERT INTO `alertLevel` VALUES ('ON_PREPARATION',2,1); +INSERT INTO `alertLevel` VALUES ('PACKED',3,0); +INSERT INTO `alertLevel` VALUES ('DELIVERED',4,0); INSERT INTO `bookingPlanner` VALUES (5,'2017-07-01 00:00:00','4770000002','WORLD',7,4,1); INSERT INTO `bookingPlanner` VALUES (6,'2017-07-01 00:00:00','4770000010','NATIONAL',3,1,1); @@ -2321,18 +2354,18 @@ INSERT INTO `component` VALUES (47,'promocion Italia',4,NULL,NULL,1,'italianOffe INSERT INTO `component` VALUES (48,'fusión de lineas',4,NULL,NULL,1,'lineFusion',0); INSERT INTO `component` VALUES (49,'sustitución',4,NULL,NULL,1,'substitution',0); -INSERT INTO `componentType` VALUES (1,'coste',1,0,'COST'); -INSERT INTO `componentType` VALUES (2,'com ventas',1,1,NULL); -INSERT INTO `componentType` VALUES (3,'com compras',1,1,NULL); -INSERT INTO `componentType` VALUES (4,'empresa',1,1,'MARGIN'); -INSERT INTO `componentType` VALUES (5,'cliente',0,0,NULL); -INSERT INTO `componentType` VALUES (6,'agencia',0,0,'FREIGHT'); -INSERT INTO `componentType` VALUES (7,'cartera_comercial',0,0,'MANA'); -INSERT INTO `componentType` VALUES (8,'cartera_producto',0,1,NULL); -INSERT INTO `componentType` VALUES (9,'maniobra',1,0,NULL); -INSERT INTO `componentType` VALUES (10,'cartera_comprador',0,1,NULL); -INSERT INTO `componentType` VALUES (11,'errores',0,1,NULL); -INSERT INTO `componentType` VALUES (12,'otros',0,1,NULL); +INSERT INTO `componentType` VALUES (1,'cost','coste',1,0); +INSERT INTO `componentType` VALUES (2,NULL,'com ventas',1,1); +INSERT INTO `componentType` VALUES (3,NULL,'com compras',1,1); +INSERT INTO `componentType` VALUES (4,'margin','empresa',1,1); +INSERT INTO `componentType` VALUES (5,NULL,'cliente',0,0); +INSERT INTO `componentType` VALUES (6,'freight','agencia',0,0); +INSERT INTO `componentType` VALUES (7,'mana','cartera_comercial',0,0); +INSERT INTO `componentType` VALUES (8,NULL,'cartera_producto',0,1); +INSERT INTO `componentType` VALUES (9,NULL,'maniobra',1,0); +INSERT INTO `componentType` VALUES (10,NULL,'cartera_comprador',0,1); +INSERT INTO `componentType` VALUES (11,NULL,'errores',0,1); +INSERT INTO `componentType` VALUES (12,'other','otros',0,1); INSERT INTO `continent` VALUES (1,'Asia','AS'); INSERT INTO `continent` VALUES (2,'América','AM'); @@ -2340,61 +2373,62 @@ INSERT INTO `continent` VALUES (3,'África','AF'); INSERT INTO `continent` VALUES (4,'Europa','EU'); INSERT INTO `continent` VALUES (5,'Oceanía','OC'); -INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,110,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,3,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (23,'CMA','CAMARA',13,14,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (31,'it','INFORMATICA',4,5,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',6,7,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (35,'finance','FINANZAS',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (36,'labor','LABORAL',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',12,35,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (38,'picking','SACADO',15,16,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (39,'packing','ENCAJADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',36,37,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (43,'VT','VENTAS',38,69,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (44,'management','GERENCIA',70,71,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (46,'delivery','REPARTO',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',76,77,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',39,40,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',19,20,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); -INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',21,22,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); -INSERT INTO `department` VALUES (58,'CMP','CAMPOS',84,87,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (61,NULL,'VNH',90,93,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',23,24,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',96,97,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',43,44,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); -INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (89,NULL,'COORDINACION',100,101,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (90,NULL,'TRAILER',91,92,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',25,26,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',45,46,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',47,48,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); -INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',49,50,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',1,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); -INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',51,52,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',53,54,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',55,56,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',57,58,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',1,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); -INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',27,28,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',29,30,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (130,NULL,'REVISION',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',85,86,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',59,60,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',61,62,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); -INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',63,64,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); -INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',104,105,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (137,'sorter','SORTER',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',65,66,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); -INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',67,68,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (141,NULL,'PREVIA',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,112,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (43,'VT','VENTAS',40,71,NULL,0,0,0,1,15,1,'/1/',NULL,1,'',1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (44,'management','GERENCIA',72,73,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',74,75,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (46,'delivery','REPARTO',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',78,79,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',82,83,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',21,22,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); +INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',23,24,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); +INSERT INTO `department` VALUES (58,'CMP','CAMPOS',86,89,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,1,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (61,NULL,'VNH',92,95,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',96,97,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',25,26,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',98,99,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); +INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (89,NULL,'COORDINACION',102,103,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (90,NULL,'TRAILER',93,94,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',27,28,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',47,48,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); +INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',1,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); +INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',53,54,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',55,56,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',57,58,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',104,105,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,1,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',1,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); +INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (130,NULL,'REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',87,88,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',63,64,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); +INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); +INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',106,107,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',108,109,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (137,'sorter','SORTER',110,111,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); +INSERT INTO `department` VALUES (140,'hollandTeam','EQUIPO HOLANDA',69,70,NULL,0,0,0,2,0,43,'/1/43/','nl_equipo',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL); INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL); @@ -2656,38 +2690,38 @@ INSERT INTO `state` VALUES (1,'Arreglar',2,0,'FIXING',NULL,1,0,0,0,0,0,0,4,1,'al INSERT INTO `state` VALUES (2,'Libre',2,0,'FREE',NULL,2,0,0,0,0,0,0,4,1,'notice'); INSERT INTO `state` VALUES (3,'OK',3,0,'OK',3,28,1,0,0,0,1,1,3,0,'success'); INSERT INTO `state` VALUES (4,'Impreso',4,0,'PRINTED',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (5,'Preparación',6,1,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (6,'En Revisión',7,1,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'); +INSERT INTO `state` VALUES (5,'Preparación',6,2,'ON_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (6,'En Revisión',7,2,'ON_CHECKING',NULL,6,0,1,0,3,0,0,1,0,'warning'); INSERT INTO `state` VALUES (7,'Sin Acabar',1,0,'NOT_READY',NULL,7,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (8,'Revisado',8,1,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'); -INSERT INTO `state` VALUES (9,'Encajando',9,2,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL); -INSERT INTO `state` VALUES (10,'Encajado',10,2,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (11,'Facturado',0,3,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (8,'Revisado',8,2,'CHECKED',NULL,8,0,1,0,3,0,0,1,0,'warning'); +INSERT INTO `state` VALUES (9,'Encajando',9,3,'PACKING',NULL,9,0,1,0,0,0,0,1,0,NULL); +INSERT INTO `state` VALUES (10,'Encajado',10,3,'PACKED',NULL,10,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (11,'Facturado',0,4,'INVOICED',NULL,11,0,1,0,0,0,0,0,0,NULL); INSERT INTO `state` VALUES (12,'Bloqueado',0,0,'BLOCKED',NULL,12,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (13,'En Reparto',11,3,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (14,'Preparado',6,1,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'); -INSERT INTO `state` VALUES (15,'Pte Recogida',12,3,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (16,'Entregado',13,3,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (13,'En Reparto',11,4,'ON_DELIVERY',NULL,13,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (14,'Preparado',6,2,'PREPARED',NULL,14,0,1,0,2,0,0,1,0,'warning'); +INSERT INTO `state` VALUES (15,'Pte Recogida',12,4,'WAITING_FOR_PICKUP',NULL,15,0,1,0,0,0,0,0,0,NULL); +INSERT INTO `state` VALUES (16,'Entregado',13,4,'DELIVERED',NULL,16,0,1,0,0,0,0,0,0,NULL); INSERT INTO `state` VALUES (20,'Asignado',4,0,'PICKER_DESIGNED',NULL,20,1,0,0,0,0,0,2,0,'success'); -INSERT INTO `state` VALUES (21,'Retornado',4,1,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'); +INSERT INTO `state` VALUES (21,'Retornado',4,2,'PRINTED_BACK',6,21,0,0,0,0,0,0,2,0,'success'); INSERT INTO `state` VALUES (22,'Pte. Ampliar',2,0,'EXPANDABLE',NULL,22,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (23,'URGENTE',5,1,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'); +INSERT INTO `state` VALUES (23,'URGENTE',5,2,'LAST_CALL',NULL,23,1,0,1,0,0,0,4,1,'success'); INSERT INTO `state` VALUES (24,'Encadenado',4,0,'CHAINED',4,24,0,0,0,0,0,0,3,1,'success'); INSERT INTO `state` VALUES (25,'Embarcando',3,0,'BOARDING',5,25,1,0,0,0,0,0,3,0,'alert'); INSERT INTO `state` VALUES (26,'Prep Previa',5,0,'PREVIOUS_PREPARATION',1,28,1,0,0,1,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (27,'Prep Asistida',5,1,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'); +INSERT INTO `state` VALUES (27,'Prep Asistida',5,2,'ASSISTED_PREPARATION',7,27,0,0,0,0,0,0,2,0,'success'); INSERT INTO `state` VALUES (28,'Previa OK',3,0,'OK PREVIOUS',3,28,1,0,1,1,1,1,3,0,'warning'); INSERT INTO `state` VALUES (29,'Previa Impreso',4,0,'PRINTED PREVIOUS',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (30,'Embarcado',4,1,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'); -INSERT INTO `state` VALUES (31,'Polizon Impreso',4,1,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (32,'Polizon OK',3,1,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'); +INSERT INTO `state` VALUES (30,'Embarcado',4,2,'BOARD',5,30,0,0,0,2,0,0,3,0,'success'); +INSERT INTO `state` VALUES (31,'Polizon Impreso',4,2,'PRINTED STOWAWAY',2,29,1,0,1,0,0,1,2,0,'success'); +INSERT INTO `state` VALUES (32,'Polizon OK',3,2,'OK STOWAWAY',3,31,1,0,0,1,1,1,3,0,'warning'); INSERT INTO `state` VALUES (33,'Auto_Impreso',4,0,'PRINTED_AUTO',2,29,1,0,1,0,0,1,2,0,'success'); INSERT INTO `state` VALUES (34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',NULL,34,0,0,0,0,0,0,4,1,'alert'); -INSERT INTO `state` VALUES (35,'Semi-Encajado',9,2,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL); +INSERT INTO `state` VALUES (35,'Semi-Encajado',9,3,'HALF_PACKED',NULL,10,0,1,0,0,0,0,1,0,NULL); INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',2,37,1,0,0,4,0,1,2,0,'warning'); INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',2,29,1,0,1,0,0,1,2,0,'warning'); -INSERT INTO `state` VALUES (38,'Prep Cámara',6,1,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (41,'Prep Parcial',6,1,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); +INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',7,14,0,0,0,2,0,0,2,0,'warning'); INSERT INTO `ticketUpdateAction` VALUES (1,'Cambiar los precios en el ticket','renewPrices'); INSERT INTO `ticketUpdateAction` VALUES (2,'Convertir en maná','mana'); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index c063df7ae..dc0549de4 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -464,6 +464,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','productionAssi','Reservas INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','cmr','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','employee','Rutas','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','address','alexm@%','0000-00-00 00:00:00','Insert',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','pbx','grafana','queue','root@localhost','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','address','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','accountingType','guillermo@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','itemShelvingStock_byWarehouse','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -738,7 +739,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','mrw','guille INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','mrwService','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','ppePlan','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hrBoss','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','buy','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','buy','carlosap@10.5.1.8','0000-00-00 00:00:00','Select,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','buy','alexm@%','0000-00-00 00:00:00','Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','saleGoal','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','packingSiteLog','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); @@ -777,6 +778,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleState INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','vehicleEvent','alexm@%','0000-00-00 00:00:00','Select,Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','cooler','Tintas','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','itemBotanical','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','productionConfigLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','account','developer','signInLog','juan@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketTracking','alexm@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','deviceProductionState','alexm@%','0000-00-00 00:00:00','Select',''); @@ -787,6 +789,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','printServerQueue__ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','artificialBoss','buy','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','hr','Movimientos','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','buy','alexm@%','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemMinimumQuantity','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','receipt','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerBoss','producer','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','administrative','link','alexm@%','0000-00-00 00:00:00','Select',''); @@ -1003,7 +1006,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','calendar','juan@db- INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','campaign','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketService','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','report','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buyer','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','buyer','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','defaulter','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','componentType','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientManaCache','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1274,7 +1277,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','workerProductivityC INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','antenna','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','cmr','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','accounting','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditClassification','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','creditClassification','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketLog','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','grafana','moving','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','claimDevelopment','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1389,9 +1392,9 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','buyer','waste','alexm@db-prox INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientObservation','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','hedera','grafana','visit','root@localhost','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','workerActivity','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicy','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyDetail','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicy','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyDetail','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','bankPolicyReview','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','roadmapStop','guillermo@10.5.1.3','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','production','roadmapStop','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','agencyWorkCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1431,6 +1434,19 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryBoss','albaran_st INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNote','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNoteDms','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryBoss','deliveryNoteState','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','buy','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionBoss','claimDestination','juan@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','entryLog','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','dipole','grafana','expedition_PrintOut','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','ticketObservation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','recovery','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','observationType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientInforma','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','accountingType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicyDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicyReview','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','bankPolicy','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; @@ -1902,6 +1918,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','invoiceoutboo INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','ticket_gettax','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','productionAssi','midnight','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','dipole','employee','expedition_add','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_transfer','PROCEDURE','alexm@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','coolerBoss','itempacking','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesPerson','ticket_clone','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','cache','employee','available_refresh','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); @@ -2031,6 +2048,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','account','developer','user_hasrouti INSERT IGNORE INTO `procs_priv` VALUES ('','account','grafana','user_hasRole','FUNCTION','jgallego@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','guest','time_generate','PROCEDURE','jenkins@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addbyclaim','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_addByCollection','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_addlist','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelving_selfconsumption','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','item_getsimilar','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2156,6 +2174,17 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','claimManager','buy_recalcPrice INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_recalcPricesByBuy','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_nextTx','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','hr','ledger_docompensation','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_setQuantity','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_unpicked','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_getAssigned','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','collection_addWithReservation','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_addBySectorCollection','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorCollection_hasSalesReserved','FUNCTION','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_reallocate','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemShelvingSale_setPicked','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','sectorCollection_getMyPartial','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana-write','item_ValuateInventory','PROCEDURE','guillermo@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','guest','ticketCalculatePurge','PROCEDURE','jenkins@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); /*!40000 ALTER TABLE `procs_priv` ENABLE KEYS */; /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; @@ -2196,6 +2225,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','financial','{\"access\": 0, \"vers INSERT IGNORE INTO `global_priv` VALUES ('','financialBoss','{\"access\": 0, \"version_id\": 101106, \"is_role\": true}'); INSERT IGNORE INTO `global_priv` VALUES ('','floranet','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','grafana','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','grafana-write','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','greenhouseBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','guest','{\"access\": 0, \"max_questions\": 40000, \"max_updates\": 1000, \"max_connections\": 150000, \"max_user_connections\": 200, \"max_statement_time\": 0.000000, \"is_role\": true, \"version_id\": 101106}'); INSERT IGNORE INTO `global_priv` VALUES ('','handmadeBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index 9b5e9e4a7..174471895 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -89,6 +89,7 @@ CREATE TABLE `accountLog` ( `host` varchar(255) NOT NULL, `rhost` varchar(255) NOT NULL, `time` varchar(255) NOT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -156,11 +157,14 @@ CREATE TABLE `mailAliasAccount` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mailAlias` int(10) unsigned NOT NULL, `account` int(10) unsigned NOT NULL, + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `mailAlias` (`mailAlias`,`account`), KEY `account` (`account`), + KEY `mailAliasAccount_editorFk` (`editorFk`), CONSTRAINT `account` FOREIGN KEY (`account`) REFERENCES `account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `mailAlias` FOREIGN KEY (`mailAlias`) REFERENCES `mailAlias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `mailAlias` FOREIGN KEY (`mailAlias`) REFERENCES `mailAlias` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `mailAliasAccount_editorFk` FOREIGN KEY (`editorFk`) REFERENCES `user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Mail alias that is assigned to each account'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -361,6 +365,7 @@ CREATE TABLE `roleLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `roleLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -420,6 +425,7 @@ CREATE TABLE `signInLog` ( `userName` varchar(30) NOT NULL, `ip` varchar(100) NOT NULL, `owner` tinyint(1) DEFAULT 1, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), CONSTRAINT `signInLog_ibfk_1` FOREIGN KEY (`userFk`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE @@ -503,6 +509,7 @@ CREATE TABLE `userLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `userLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -3732,7 +3739,7 @@ BEGIN JOIN vn.saleComponent sc ON sc.saleFk = s.id JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' AND r.created BETWEEN vDatedFrom AND vDatedTo GROUP BY r.id ) sub ON sub.routeFk = r.Id_Ruta @@ -7194,7 +7201,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, tItemRange; + DROP TEMPORARY TABLE tmp.itemCalc, tItemRange, tmp.itemList; CALL cache_calc_end (vCalc); END ;; DELIMITER ; @@ -7369,7 +7376,7 @@ proc: BEGIN )sub GROUP BY sub.itemFk; - DROP TEMPORARY TABLE tmp.itemCalc, itemRange; + DROP TEMPORARY TABLE tmp.itemCalc, itemRange, tmp.itemList; CALL cache_calc_end (vCalc); END ;; DELIMITER ; @@ -7862,14 +7869,14 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `visible_refresh`(OUT v_calc INT, v_refresh BOOL, v_warehouse INT) -proc: BEGIN +proc:BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN CALL cache_calc_unlock (v_calc); RESIGNAL; END; - CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse); + CALL cache_calc_start (v_calc, v_refresh, 'visible', v_warehouse); IF !v_refresh THEN LEAVE proc; @@ -7877,22 +7884,23 @@ proc: BEGIN -- Calculamos el stock hasta ayer - CALL `cache`.stock_refresh(false); + CALL cache.stock_refresh(false); CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible (PRIMARY KEY (item_id)) ENGINE = MEMORY - SELECT item_id, amount stock, amount visible FROM `cache`.stock + SELECT item_id, amount stock, amount visible + FROM cache.stock WHERE warehouse_id = v_warehouse; -- Calculamos los movimientos confirmados de hoy - CALL vn.item_GetVisible(v_warehouse, NULL); + CALL vn.item_calcVisible(NULL, v_warehouse); DELETE FROM visible WHERE calc_id = v_calc; INSERT INTO visible (calc_id, item_id,visible) SELECT v_calc, item_id, visible FROM tmp.itemVisible; - CALL cache_calc_end (v_calc); + CALL cache_calc_end (v_calc); DROP TEMPORARY TABLE tmp.itemVisible; END ;; @@ -8456,7 +8464,6 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `ektRecent` AS SELECT 1 AS `id`, - 1 AS `barcode`, 1 AS `entryYear`, 1 AS `batchNumber`, 1 AS `deliveryNumber`, @@ -9831,7 +9838,6 @@ BEGIN */ DECLARE vRewriteKop INT DEFAULT NULL; DECLARE vTruncatePutOrder INT DEFAULT NULL; - DECLARE vBarcode CHAR(15) DEFAULT NULL; DECLARE vKop INT; DECLARE vPutOrderFk BIGINT; @@ -9840,17 +9846,6 @@ BEGIN FROM ekt WHERE id = vSelf; - -- Generates the barcode - - SELECT CONCAT( - LPAD(IFNULL(auction,0), 3, 0), - LPAD(IFNULL(klo, 99), 2, 0), - LPAD(DAYOFYEAR(fec), 3, 0), - COALESCE(agj, RIGHT(batchNumber,7), id)) - INTO vBarcode - FROM ekt - WHERE id = vSelf; - -- Rewrites the kop parameter IF vKop IS NULL THEN @@ -9870,10 +9865,9 @@ BEGIN -- Refresh EKT - UPDATE ekt SET - barcode = vBarcode - ,kop = vKop - ,putOrderFk = vTruncatePutOrder + UPDATE ekt + SET kop = vKop, + putOrderFk = vTruncatePutOrder WHERE id = vSelf; END ;; DELIMITER ; @@ -12872,12 +12866,8 @@ BEGIN JOIN vn.warehouse w ON w.id = p.warehouseFk ORDER BY warehouseFk, `grouping`; - DROP TEMPORARY TABLE - tmp.ticketCalculateItem, - tmp.ticketComponentPrice, - tmp.ticketComponent, - tmp.ticketLot, - tmp.zoneGetShipped; + CALL vn.ticketCalculatePurge(); + DROP TEMPORARY TABLE tmp.item; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -13942,11 +13932,23 @@ BEGIN CALL util.throw ('ORDER_ROW_UNAVAILABLE'); END IF; - SELECT IFNULL(minQuantity, 0) INTO vMinQuantity - FROM vn.item - WHERE id = vItem; + WITH itemMinQuantityPriority AS ( + SELECT quantity, + ROW_NUMBER() OVER ( + PARTITION BY itemFk + ORDER BY warehouseFk IS NULL + ) priority + FROM vn.itemMinimumQuantity + WHERE itemFk = vItem + AND `started` <= vShipment + AND (`ended` >= vShipment OR `ended` IS NULL) + AND (warehouseFk = vWarehouse OR warehouseFk IS NULL) + ) + SELECT quantity INTO vMinQuantity + FROM itemMinQuantityPriority + WHERE priority = 1; - IF vAmount < LEAST(vMinQuantity, vAvailable) THEN + IF vAmount < LEAST(IFNULL(vMinQuantity, 0), vAvailable) THEN CALL util.throw ('quantityLessThanMin'); END IF; @@ -26427,14 +26429,15 @@ CREATE TABLE `addressObservation` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `addressShortage` +-- Table structure for table `addressWaste` -- -DROP TABLE IF EXISTS `addressShortage`; +DROP TABLE IF EXISTS `addressWaste`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `addressShortage` ( +CREATE TABLE `addressWaste` ( `addressFk` int(11) NOT NULL, + `type` enum('internal','external') NOT NULL, PRIMARY KEY (`addressFk`), CONSTRAINT `addressShortage_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -26488,6 +26491,19 @@ CREATE TABLE `agencyExtraCharge` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `agencyIncoming` +-- + +DROP TABLE IF EXISTS `agencyIncoming`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `agencyIncoming` ( + `agencyModeFk` int(11) NOT NULL, + PRIMARY KEY (`agencyModeFk`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Agencias de entrada de mercancias'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `agencyLog` -- @@ -27641,6 +27657,7 @@ CREATE TABLE `calendar` ( `businessFk` int(11) NOT NULL, `dayOffTypeFk` int(11) NOT NULL, `dated` date NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `calendar_UN` (`businessFk`,`dated`), @@ -27902,6 +27919,7 @@ CREATE TABLE `claimDestination` ( `id` tinyint(3) unsigned NOT NULL AUTO_INCREMENT, `description` varchar(15) NOT NULL, `addressFk` int(10) DEFAULT NULL COMMENT 'Indica el consignatario para el ticket que regulariza el inventario', + `code` varchar(45) DEFAULT NULL, PRIMARY KEY (`id`), KEY `clSolAddressFk_idx` (`addressFk`), CONSTRAINT `clSolAddressFk` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON DELETE SET NULL ON UPDATE CASCADE @@ -28012,6 +28030,7 @@ CREATE TABLE `claimLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `claimLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -28226,6 +28245,7 @@ CREATE TABLE `client` ( `rating` int(10) unsigned DEFAULT NULL COMMENT 'información proporcionada por Informa', `recommendedCredit` int(10) unsigned DEFAULT NULL COMMENT 'información proporcionada por Informa', `editorFk` int(10) unsigned DEFAULT NULL, + `hasDailyInvoice` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indica si el cliente requiere facturación diaria por defecto se copiará lo que tenga country.hasDailyInvoice', PRIMARY KEY (`id`), UNIQUE KEY `IF` (`fi`), KEY `Id_Trabajador` (`salesPersonFk`), @@ -28454,6 +28474,7 @@ CREATE TABLE `clientLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `clientLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -29164,12 +29185,12 @@ DROP TABLE IF EXISTS `componentType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `componentType` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `type` varchar(45) NOT NULL, + `code` varchar(20) DEFAULT NULL, + `name` varchar(45) NOT NULL, `isBase` tinyint(4) NOT NULL DEFAULT 0 COMMENT 'Marca aquellas series que se utilizan para calcular el precio base de las ventas, a efectos estadisticos', `isMargin` tinyint(4) NOT NULL DEFAULT 0, - `code` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `Serie_UNIQUE` (`type`) + UNIQUE KEY `Serie_UNIQUE` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Permite organizar de forma ordenada los distintos componentes'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -29983,6 +30004,7 @@ CREATE TABLE `deviceProductionLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `deviceProductionLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -30571,6 +30593,7 @@ CREATE TABLE `entryLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `entryLog_ibfk_2` (`userFk`), KEY `entryLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -31109,13 +31132,15 @@ CREATE TABLE `expeditionState` ( `created` timestamp NOT NULL DEFAULT current_timestamp(), `expeditionFk` int(11) NOT NULL, `typeFk` int(11) NOT NULL, - `userFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, `isScanned` tinyint(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), KEY `expeditionState_FK` (`expeditionFk`), KEY `expeditionState_FK_1` (`typeFk`), + KEY `expeditionState_userFk` (`userFk`), CONSTRAINT `expeditionState_FK` FOREIGN KEY (`expeditionFk`) REFERENCES `expedition` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `expeditionState_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `expeditionStateType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `expeditionState_FK_1` FOREIGN KEY (`typeFk`) REFERENCES `expeditionStateType` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `expeditionState_userFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Historico de estados de las expediciones'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -31611,7 +31636,7 @@ DROP TABLE IF EXISTS `greuge`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `greuge` ( - `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `clientFk` int(11) NOT NULL, `description` varchar(45) NOT NULL, `amount` decimal(10,2) NOT NULL, @@ -31621,7 +31646,7 @@ CREATE TABLE `greuge` ( `ticketFk` int(11) DEFAULT NULL, `userFk` int(10) unsigned DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`Id`), + PRIMARY KEY (`id`), KEY `greuges_type_fk_idx` (`greugeTypeFk`), KEY `Id_Ticket_Greuge_Ticket_idx` (`ticketFk`), KEY `Greuges_cliente_idx` (`clientFk`), @@ -32163,6 +32188,7 @@ CREATE TABLE `invoiceInLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `invoiceInLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -32505,7 +32531,7 @@ CREATE TABLE `item` ( `editorFk` int(10) unsigned DEFAULT NULL, `recycledPlastic` decimal(10,2) DEFAULT NULL, `nonRecycledPlastic` decimal(10,2) DEFAULT NULL, - `minQuantity` int(10) unsigned DEFAULT NULL COMMENT 'Cantidad mínima para una línea de venta', + `minQuantity__` int(10) unsigned DEFAULT NULL COMMENT '@deprecated 2024-07-11 refs #7704 Cantidad mínima para una línea de venta', `isBoxPickingMode` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'FALSE: using item.packingOut TRUE: boxPicking using itemShelving.packing', `photoMotivation` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), @@ -32846,11 +32872,12 @@ CREATE TABLE `itemLog` ( `action` set('insert','update','delete') NOT NULL, `creationDate` timestamp NULL DEFAULT current_timestamp(), `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `changedModel` enum('Item','ItemBarcode','ItemBotanical','ItemNiche','ItemTag','ItemTaxCountry') NOT NULL DEFAULT 'Item', + `changedModel` enum('Item','ItemBarcode','ItemBotanical','ItemNiche','ItemTag','ItemTaxCountry','ItemMinimumQuantity') NOT NULL DEFAULT 'Item', `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `itemLogUserFk_idx` (`userFk`), KEY `itemLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -32876,6 +32903,37 @@ CREATE TABLE `itemMatchProperties` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Propiedades para encontrar articulos equivalentes en verdnatura'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `itemMinimumQuantity` +-- + +DROP TABLE IF EXISTS `itemMinimumQuantity`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `itemMinimumQuantity` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `itemFk` int(10) NOT NULL, + `quantity` int(10) NOT NULL, + `started` date NOT NULL, + `ended` date DEFAULT NULL, + `warehouseFk` smallint(5) unsigned DEFAULT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `itemMinimumQuantity_UNIQUE` (`itemFk`,`started`,`ended`,`warehouseFk`), + KEY `itemFk` (`itemFk`), + KEY `started` (`started`), + KEY `ended` (`ended`), + KEY `warehouseFk` (`warehouseFk`), + KEY `editorFk` (`editorFk`), + CONSTRAINT `itemMinimumQuantity_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `itemMinimumQuantity_ibfk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `itemMinimumQuantity_ibfk_3` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), + CONSTRAINT `itemMinimumQuantity_check_1` CHECK (`started` <= `ended`), + CONSTRAINT `itemMinimumQuantity_check` CHECK (`quantity` > 0) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `itemPackingType` -- @@ -33012,6 +33070,7 @@ CREATE TABLE `itemShelving` ( `buyFk` int(11) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, `available` int(11) DEFAULT NULL, + `isSplit` tinyint(1) DEFAULT NULL COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda', PRIMARY KEY (`id`), KEY `itemShelving_fk1_idx` (`itemFk`), KEY `itemShelving_fk2_idx` (`shelvingFk`), @@ -33170,7 +33229,7 @@ CREATE TABLE `itemShelvingSale` ( `quantity` decimal(10,0) NOT NULL DEFAULT 0, `created` timestamp NOT NULL DEFAULT current_timestamp(), `userFk` int(11) unsigned NOT NULL, - `isPicked` tinyint(1) NOT NULL DEFAULT 0, + `isPicked` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), KEY `itemShelvingSale_fk1_idx` (`itemShelvingFk`), KEY `itemShelvingSale_fk2_idx` (`saleFk`), @@ -33191,8 +33250,10 @@ DROP TABLE IF EXISTS `itemShelvingSaleReserve`; CREATE TABLE `itemShelvingSaleReserve` ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, + `sectorFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `itemShelvingSaleReserve_ibfk_1` (`saleFk`) + KEY `itemShelvingSaleReserve_ibfk_1` (`saleFk`), + CONSTRAINT `itemShelvingSaleReserve_sector_FK` FOREIGN KEY (`id`) REFERENCES `sector` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue of changed itemShelvingSale to reserve'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33408,11 +33469,11 @@ CREATE TABLE `itemType` ( `making` int(10) unsigned DEFAULT NULL COMMENT 'Son productos de confección propia', `location__` varchar(10) DEFAULT NULL, `life` smallint(5) unsigned DEFAULT NULL, - `maneuver` double NOT NULL DEFAULT 0.21, - `target` double NOT NULL DEFAULT 0.15, - `topMargin` double NOT NULL DEFAULT 0.3, - `profit` double NOT NULL DEFAULT 0.02, - `density` double NOT NULL DEFAULT 167 COMMENT 'Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', + `maneuver__` double NOT NULL DEFAULT 0.21 COMMENT '@deprecated 2024-07-01 refs #7418', + `target__` double NOT NULL DEFAULT 0.15 COMMENT '@deprecated 2024-07-01 refs #7418', + `topMargin__` double NOT NULL DEFAULT 0.3 COMMENT '@deprecated 2024-07-01 refs #7418', + `profit__` double NOT NULL DEFAULT 0.02 COMMENT '@deprecated 2024-07-01 refs #7418', + `density__` double NOT NULL DEFAULT 167 COMMENT '@deprecated 2024-07-01 refs #7418 Almacena el valor por defecto de la densidad en kg/m3 para el calculo de los portes aereos, en articulos se guarda la correcta', `promo` double NOT NULL DEFAULT 0, `isPackaging` tinyint(1) NOT NULL DEFAULT 0, `hasComponents__` tinyint(1) NOT NULL DEFAULT 1, @@ -34752,6 +34813,7 @@ CREATE TABLE `packingSiteDeviceLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `packingSiteDeviceLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -34860,6 +34922,7 @@ CREATE TABLE `parkingLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logParkinguserFk` (`userFk`), KEY `parkingLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -35063,7 +35126,7 @@ CREATE TABLE `payrollWorker` ( `companyFkA3` int(10) NOT NULL COMMENT 'Columna que hace referencia a A3.', `codcontrato__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', `FAntiguedad__` date NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', - `grupotarifa__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', + `grupotarifa` int(10) NOT NULL, `codcategoria__` int(10) NOT NULL COMMENT '@Deprecated refs #6738 15/03/2024', `ContratoTemporal__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@Deprecated refs #6738 15/03/2024', `workerFk` int(11) unsigned DEFAULT NULL, @@ -35641,21 +35704,51 @@ CREATE TABLE `productionConfig` ( `sectorFromCode` varchar(15) DEFAULT NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear', `sectorToCode` varchar(15) DEFAULT NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear', `orderMode` enum('Location','Age') NOT NULL DEFAULT 'Location', + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `productionConfig_FK` (`shortageAddressFk`), KEY `productionConfig_FK_1` (`clientSelfConsumptionFk`), KEY `productionConfig_FK_2` (`addressSelfConsumptionFk`), KEY `productionConfig_sector_FK` (`sectorFromCode`), KEY `productionConfig_sector_FK_1` (`sectorToCode`), + KEY `productionConfig_user_FK` (`editorFk`), CONSTRAINT `productionConfig_FK` FOREIGN KEY (`shortageAddressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `productionConfig_FK_1` FOREIGN KEY (`clientSelfConsumptionFk`) REFERENCES `client` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `productionConfig_FK_2` FOREIGN KEY (`addressSelfConsumptionFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `productionConfig_sector_FK` FOREIGN KEY (`sectorFromCode`) REFERENCES `sector` (`code`) ON UPDATE CASCADE, CONSTRAINT `productionConfig_sector_FK_1` FOREIGN KEY (`sectorToCode`) REFERENCES `sector` (`code`) ON UPDATE CASCADE, + CONSTRAINT `productionConfig_user_FK` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), CONSTRAINT `productionConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Recoge los parámetros que condicionan la producción'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `productionConfigLog` +-- + +DROP TABLE IF EXISTS `productionConfigLog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `productionConfigLog` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `originFk` int(11) DEFAULT NULL, + `userFk` int(10) unsigned DEFAULT NULL, + `action` set('insert','update','delete','select') NOT NULL, + `creationDate` timestamp NULL DEFAULT current_timestamp(), + `description` text CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, + `changedModel` enum('ProductionConfig') NOT NULL DEFAULT 'ProductionConfig', + `oldInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`oldInstance`)), + `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), + `changedModelId` int(11) NOT NULL, + `changedModelValue` varchar(45) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `productionConfigLog_userFk` (`userFk`), + KEY `productionConfigLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), + KEY `productionConfigLog_originFk` (`originFk`,`creationDate`), + CONSTRAINT `productionConfigUserFk` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `productionError` -- @@ -36073,6 +36166,7 @@ CREATE TABLE `rateLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logRateuserFk` (`userFk`), KEY `rateLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -36622,6 +36716,7 @@ CREATE TABLE `routeLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `routeLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -37390,11 +37485,10 @@ CREATE TABLE `sectorCollectionSaleGroup` ( `sectorCollectionFk` int(11) NOT NULL, `saleGroupFk` int(11) NOT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `saleGroupFk` (`saleGroupFk`), - KEY `sectorCollectionFk` (`sectorCollectionFk`), + UNIQUE KEY `sectorCollectionSaleGroup_unique` (`sectorCollectionFk`,`saleGroupFk`), + KEY `sectorCollectionSaleGroup_saleGroup_FK` (`saleGroupFk`), CONSTRAINT `sectorCollectionSaleGroup_ibfk_1` FOREIGN KEY (`sectorCollectionFk`) REFERENCES `sectorCollection` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `sectorCollectionSaleGroup_ibfk_2` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `sectorCollectionSaleGroup_ibfk_3` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `sectorCollectionSaleGroup_saleGroup_FK` FOREIGN KEY (`saleGroupFk`) REFERENCES `saleGroup` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Relaciona las lineas de venta con la coleccion del sector'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -37596,6 +37690,7 @@ CREATE TABLE `shelvingLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `shelvingLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -38023,10 +38118,10 @@ CREATE TABLE `state` ( PRIMARY KEY (`id`), UNIQUE KEY `code_UNIQUE` (`code`), KEY `state_id3` (`semaphore`), - KEY `alertLevel` (`alertLevel`), KEY `state_FK` (`nextStateFk`), + KEY `state_ibfk_1` (`alertLevel`), CONSTRAINT `state_FK` FOREIGN KEY (`nextStateFk`) REFERENCES `state` (`id`) ON UPDATE CASCADE, - CONSTRAINT `state_ibfk_1` FOREIGN KEY (`alertLevel`) REFERENCES `alertLevel` (`id`) + CONSTRAINT `state_ibfk_1` FOREIGN KEY (`alertLevel`) REFERENCES `alertLevel` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -38376,6 +38471,7 @@ CREATE TABLE `supplierLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `supplierLog_ibfk_2` (`userFk`), KEY `supplierLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -38857,7 +38953,7 @@ DROP TABLE IF EXISTS `ticketLastState`; CREATE TABLE `ticketLastState` ( `ticketFk` int(11) NOT NULL DEFAULT 0, `ticketTrackingFk` int(11) NOT NULL, - `name` varchar(15) NOT NULL, + `name` varchar(20) NOT NULL, PRIMARY KEY (`ticketFk`), KEY `double_foreign` (`ticketFk`,`ticketTrackingFk`), CONSTRAINT `Id_Ticket` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -38910,6 +39006,7 @@ CREATE TABLE `ticketLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `logTicketuserFk` (`userFk`), KEY `ticketLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -39211,7 +39308,7 @@ CREATE TABLE `ticketSms__` ( `ticketFk` int(11) DEFAULT NULL, PRIMARY KEY (`smsFk`), KEY `ticketSms_FK_1` (`ticketFk`), - CONSTRAINT `ticketSms_FK` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ticketSms_FK` FOREIGN KEY (`smsFk`) REFERENCES `sms` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `ticketSms_FK_1` FOREIGN KEY (`ticketFk`) REFERENCES `ticket` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -39676,6 +39773,7 @@ CREATE TABLE `travel` ( KEY `travel_FK` (`agencyModeFk`), KEY `travel_fk_editor` (`editorFk`), KEY `travel_FK_1` (`awbFk`), + KEY `travel_landed_IDX` (`landed` DESC,`warehouseInFk`,`warehouseOutFk`) USING BTREE, CONSTRAINT `travel_FK` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON UPDATE CASCADE, CONSTRAINT `travel_FK_1` FOREIGN KEY (`awbFk`) REFERENCES `awb` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `travel_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), @@ -39784,6 +39882,7 @@ CREATE TABLE `travelLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `travelLog_changedModel` (`changedModel`,`changedModelId`,`originFk`), @@ -39899,6 +39998,7 @@ CREATE TABLE `userLog` ( `newInstance` text DEFAULT NULL, `changedModelId` int(11) DEFAULT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `originFk` (`originFk`), KEY `userFk` (`userFk`), @@ -39980,14 +40080,14 @@ CREATE TABLE `vehicle` ( KEY `vehicle_supplierFk` (`supplierFk`), KEY `vehicle_supplierCoolerFk` (`supplierCoolerFk`), KEY `vehicle_bankPolicyFk` (`bankPolicyFk`), - CONSTRAINT `provinceFk` FOREIGN KEY (`warehouseFk`) REFERENCES `province` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `vehicleCompany_Fk` FOREIGN KEY (`companyFk`) REFERENCES `company` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_FK` FOREIGN KEY (`fuelTypeFk`) REFERENCES `fuelType` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `vehicle_FK_1` FOREIGN KEY (`ppeFk`) REFERENCES `ppe` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `vehicle_bankPolicyFk` FOREIGN KEY (`bankPolicyFk`) REFERENCES `bankPolicy` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_deliveryPointFk` FOREIGN KEY (`deliveryPointFk`) REFERENCES `deliveryPoint` (`id`) ON UPDATE CASCADE, CONSTRAINT `vehicle_supplierCoolerFk` FOREIGN KEY (`supplierCoolerFk`) REFERENCES `supplier` (`id`) ON UPDATE CASCADE, - CONSTRAINT `vehicle_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`) + CONSTRAINT `vehicle_supplierFk` FOREIGN KEY (`supplierFk`) REFERENCES `supplier` (`id`), + CONSTRAINT `vehicle_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40869,6 +40969,7 @@ CREATE TABLE `workerLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk_idx` (`userFk`), KEY `workerLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -41646,6 +41747,7 @@ CREATE TABLE `zoneLog` ( `newInstance` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`newInstance`)), `changedModelId` int(11) NOT NULL, `changedModelValue` varchar(45) DEFAULT NULL, + `summaryId` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), KEY `userFk` (`userFk`), KEY `zoneLog_changedModel` (`changedModel`,`changedModelId`,`creationDate`), @@ -41680,7 +41782,39 @@ CREATE TABLE `zoneWarehouse` ( -- Dumping events for database 'vn' -- /*!50106 SET @save_time_zone= @@TIME_ZONE */ ; -/*!50106 DROP EVENT IF EXISTS `client_unassignSalesPerson` */; +/*!50106 DROP EVENT IF EXISTS `claim_changeState` */; +DELIMITER ;; +/*!50003 SET @saved_cs_client = @@character_set_client */ ;; +/*!50003 SET @saved_cs_results = @@character_set_results */ ;; +/*!50003 SET @saved_col_connection = @@collation_connection */ ;; +/*!50003 SET character_set_client = utf8mb4 */ ;; +/*!50003 SET character_set_results = utf8mb4 */ ;; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ;; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ;; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;; +/*!50003 SET @saved_time_zone = @@time_zone */ ;; +/*!50003 SET time_zone = 'SYSTEM' */ ;; +/*!50106 CREATE*/ /*!50117 DEFINER=`root`@`localhost`*/ /*!50106 EVENT `claim_changeState` ON SCHEDULE EVERY 1 DAY STARTS '2024-06-06 07:52:46' ON COMPLETION PRESERVE ENABLE DO BEGIN + + DECLARE vClaimState INT; + + SELECT id INTO vClaimState + FROM claimState cs + WHERE cs.code = 'canceled'; + + UPDATE claim c + JOIN claimState cs ON cs.id = c.claimStateFk + SET c.claimStateFk = vClaimState + WHERE c.created < util.VN_CURDATE() - INTERVAL 2 MONTH + AND cs.code IN('incomplete','coming','waiting','out'); + +END */ ;; +/*!50003 SET time_zone = @saved_time_zone */ ;; +/*!50003 SET sql_mode = @saved_sql_mode */ ;; +/*!50003 SET character_set_client = @saved_cs_client */ ;; +/*!50003 SET character_set_results = @saved_cs_results */ ;; +/*!50003 SET collation_connection = @saved_col_connection */ ;; +/*!50106 DROP EVENT IF EXISTS `client_unassignSalesPerson` */;; DELIMITER ;; /*!50003 SET @saved_cs_client = @@character_set_client */ ;; /*!50003 SET @saved_cs_results = @@character_set_results */ ;; @@ -45891,6 +46025,44 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `ticket_isProblemCalcNeeded` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` FUNCTION `ticket_isProblemCalcNeeded`(vSelf INT +) RETURNS tinyint(1) + DETERMINISTIC +BEGIN +/** + * Check if the ticket requires to update column vn.ticket.problem + * + * @param vSelf Id ticket + * @return BOOL + */ + DECLARE vIsProblemCalcNeeded BOOL; + + SELECT COUNT(*) INTO vIsProblemCalcNeeded + FROM ticket t + JOIN client c ON c.id = t.clientFk + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + WHERE t.id = vSelf + AND dm.code IN ('AGENCY','DELIVERY','PICKUP') + AND c.typeFk = 'normal'; + + RETURN vIsProblemCalcNeeded; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `ticket_isTooLittle` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -46850,6 +47022,44 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `address_updateCoordinates` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `address_updateCoordinates`( + vTicketFk INT, + vLongitude INT, + vLatitude INT) +BEGIN +/** + * Actualiza las coordenadas de una dirección. + * + * @param vTicketFk Id del ticket + * @param vLongitude Longitud de la dirección + * @param vLatitude Latitud de la dirección + */ + DECLARE vAddressFK INT; + + SELECT addressFK INTO vAddressFK + FROM ticket + WHERE id = vTicketFk; + + UPDATE address + SET longitude = vLongitude, + latitude = vLatitude + WHERE id = vAddressFK; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `agencyHourGetFirstShipped` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -47902,7 +48112,10 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`(vWarehouseFk SMALLINT, vDated DATE) +CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimate`( + vWarehouseFk SMALLINT, + vDated DATE +) BEGIN /** * Calcula las últimas compras realizadas hasta una fecha @@ -47922,22 +48135,23 @@ BEGIN FROM cache.last_buy WHERE warehouse_id = vWarehouseFk OR vWarehouseFk IS NULL; - CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); + IF vDated >= util.VN_CURDATE() THEN + CALL buyUltimateFromInterval(vWarehouseFk, util.VN_CURDATE(), vDated); - REPLACE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed <= vDated - AND NOT isIgnored; - - INSERT IGNORE INTO tmp.buyUltimate - SELECT itemFk, buyFk, warehouseFk, landed landing - FROM tmp.buyUltimateFromInterval - WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) - AND landed > vDated - ORDER BY isIgnored = FALSE DESC; + REPLACE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND landed <= vDated + AND NOT isIgnored; + INSERT IGNORE INTO tmp.buyUltimate + SELECT itemFk, buyFk, warehouseFk, landed landing + FROM tmp.buyUltimateFromInterval + WHERE (warehouseFk = vWarehouseFk OR vWarehouseFk IS NULL) + AND landed > vDated + ORDER BY isIgnored = FALSE DESC; + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -47954,7 +48168,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimateFromInterval`(vWarehouseFk SMALLINT, vStarted DATE, vEnded DATE) +CREATE DEFINER=`root`@`localhost` PROCEDURE `buyUltimateFromInterval`( + vWarehouseFk SMALLINT, + vStarted DATE, + vEnded DATE +) BEGIN /** * Calcula las últimas compras realizadas @@ -47976,12 +48194,13 @@ BEGIN -- Item DROP TEMPORARY TABLE IF EXISTS tmp.buyUltimateFromInterval; CREATE TEMPORARY TABLE tmp.buyUltimateFromInterval - (PRIMARY KEY (itemFk, warehouseFk), INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) + (PRIMARY KEY (itemFk, warehouseFk), + INDEX(buyFk), INDEX(landed), INDEX(warehouseFk), INDEX(itemFk)) ENGINE = MEMORY SELECT itemFk, warehouseFk, buyFk, - MAX(landed) landed, + landed, isIgnored FROM (SELECT b.itemFk, t.warehouseInFk warehouseFk, @@ -48000,94 +48219,118 @@ BEGIN INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - GROUP BY itemFk, warehouseInFk; + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND b.price2 > 0 + AND NOT b.isIgnored + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - GROUP BY itemFk, warehouseInFk; + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND b.quantity = 0 + ORDER BY NOT b.isIgnored DESC, t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; -- ItemOriginal INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) SELECT itemFk, - warehouseFk, - buyFk, - MAX(landed) landed, - isIgnored - FROM (SELECT b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - itemOriginalFk, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND b.quantity > 0 - AND itemOriginalFk - ORDER BY t.landed DESC, b.id DESC - LIMIT 10000000000000000000) sub - GROUP BY itemOriginalFk, warehouseFk; + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + itemOriginalFk, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND b.price2 > 0 + AND NOT b.isIgnored + AND b.quantity > 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; + INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed > vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND b.price2 > 0 + AND NOT b.isIgnored + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed > vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.price2 > 0 - AND NOT b.isIgnored - AND itemOriginalFk - GROUP BY itemOriginalFk, warehouseInFk; - - INSERT IGNORE INTO tmp.buyUltimateFromInterval(itemFk, warehouseFk, buyFk, landed, isIgnored) - SELECT - b.itemFk, - t.warehouseInFk warehouseFk, - b.id buyFk, - t.landed, - b.isIgnored - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vStarted AND vEnded - AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND b.quantity = 0 - AND itemOriginalFk - GROUP BY itemOriginalFk, warehouseInFk; + SELECT itemFk, + warehouseFk, + buyFk, + landed, + isIgnored + FROM + (SELECT b.itemFk, + t.warehouseInFk warehouseFk, + b.id buyFk, + t.landed, + b.isIgnored + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE t.landed BETWEEN vStarted AND vEnded + AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) + AND b.quantity = 0 + AND itemOriginalFk + ORDER BY t.landed DESC, b.id DESC + LIMIT 10000000000000000000) sub + GROUP BY itemFk, warehouseFk; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -48955,8 +49198,7 @@ BEGIN CALL catalog_componentPrepare(); - DROP TEMPORARY TABLE IF EXISTS tmp.ticketCalculateItem; - CREATE TEMPORARY TABLE tmp.ticketCalculateItem( + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketCalculateItem( itemFk INT(11) NOT NULL, available INT(11), producer VARCHAR(50), @@ -48970,11 +49212,11 @@ BEGIN price DECIMAL(10,2), priceKg DECIMAL(10,2), `grouping` INT(10) UNSIGNED, + minQuantity INT(10) UNSIGNED, PRIMARY KEY `itemFk` (`itemFk`) ) ENGINE = MEMORY DEFAULT CHARSET=utf8; OPEN cTravelTree; - l: LOOP SET vDone = FALSE; FETCH cTravelTree INTO vZoneFk, vWarehouseFk, vShipped; @@ -49046,7 +49288,7 @@ BEGIN CALL vn.catalog_componentCalculate(vZoneFk, vAddressFk, vShipped, vWarehouseFk); - INSERT INTO tmp.ticketCalculateItem ( + INSERT INTO tmp.ticketCalculateItem( itemFk, available, producer, @@ -49059,9 +49301,9 @@ BEGIN origin, price, priceKg, - `grouping`) - SELECT - tl.itemFk, + `grouping`, + minQuantity) + SELECT tl.itemFk, SUM(tl.available) available, p.name producer, i.name item, @@ -49073,7 +49315,8 @@ BEGIN o.code origin, bl.price, bl.priceKg, - bl.`grouping` + bl.`grouping`, + mq.quantity FROM tmp.ticketLot tl JOIN item i ON tl.itemFk = i.id LEFT JOIN producer p ON p.id = i.producerFk AND p.isVisible @@ -49089,12 +49332,28 @@ BEGIN ) sub GROUP BY itemFk ) bl ON bl.itemFk = tl.itemFk - WHERE tl.zoneFk = vZoneFk AND tl.warehouseFk = vWarehouseFk + LEFT JOIN ( + WITH itemMinQuantityPriority AS ( + SELECT itemFk, + quantity, + ROW_NUMBER() OVER ( + PARTITION BY itemFk + ORDER BY warehouseFk IS NULL + ) priority + FROM vn.itemMinimumQuantity + WHERE `started` <= vShipped + AND (`ended` >= vShipped OR `ended` IS NULL) + AND (warehouseFk = vWarehouseFk OR warehouseFk IS NULL) + ) + SELECT itemFk, quantity + FROM itemMinQuantityPriority + WHERE priority = 1 + ) mq ON mq.itemFk = tl.itemFk + WHERE tl.zoneFk = vZoneFk + AND tl.warehouseFk = vWarehouseFk GROUP BY tl.itemFk ON DUPLICATE KEY UPDATE available = available + VALUES(available); - END LOOP; - CLOSE cTravelTree; END ;; DELIMITER ; @@ -49727,6 +49986,10 @@ BEGIN DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE FROM entryLog WHERE creationDate < v2Months; DELETE IGNORE FROM expedition WHERE created < v26Months; + DELETE cs + FROM sms s + JOIN clientSms cs ON cs.smsFk = s.id + WHERE s.created < v18Months; DELETE FROM sms WHERE created < v18Months; DELETE FROM saleTracking WHERE created < v1Years; DELETE FROM productionError WHERE dated < v1Years; @@ -50679,14 +50942,14 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `client_create` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `client_create`( vFirstname VARCHAR(50), @@ -50723,20 +50986,25 @@ BEGIN DECLARE vIsTaxDataChecked TINYINT(1); DECLARE vHasCoreVnl BOOLEAN; DECLARE vMandateTypeFk INT; + DECLARE vHasDailyInvoice BOOLEAN; - SELECT defaultPayMethodFk, - defaultDueDay, - defaultCredit, - defaultIsTaxDataChecked, - defaultHasCoreVnl, - defaultMandateTypeFk + SELECT cc.defaultPayMethodFk, + cc.defaultDueDay, + cc.defaultCredit, + cc.defaultIsTaxDataChecked, + cc.defaultHasCoreVnl, + cc.defaultMandateTypeFk, + c.hasDailyInvoice INTO vPayMethodFk, vDueDay, vDefaultCredit, vIsTaxDataChecked, vHasCoreVnl, - vMandateTypeFk - FROM clientConfig; + vMandateTypeFk, + vHasDailyInvoice + FROM clientConfig cc + LEFT JOIN province p ON p.id = vProvinceFk + LEFT JOIN country c ON c.id = p.countryFk; INSERT INTO `client` SET id = vUserFk, @@ -50754,7 +51022,8 @@ BEGIN credit = vDefaultCredit, isTaxDataChecked = vIsTaxDataChecked, hasCoreVnl = vHasCoreVnl, - isEqualizated = FALSE + isEqualizated = FALSE, + hasDailyInvoice = vHasDailyInvoice ON duplicate KEY UPDATE payMethodFk = vPayMethodFk, dueDay = vDueDay, @@ -51455,7 +51724,8 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_addWithReservation`( vItemFk INT, vQuantity INT, vTicketFk INT, - vSaleGroupFk INT + vSaleGroupFk INT, + vSectorFk INT ) BEGIN /** @@ -51519,7 +51789,7 @@ BEGIN SELECT LAST_INSERT_ID() INTO vSaleFk; CALL sale_calculateComponent(vSaleFk, NULL); - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN SET vHasThrow = TRUE; @@ -51580,16 +51850,16 @@ BEGIN vErrorNumber = MYSQL_ERRNO, vErrorMsg = MESSAGE_TEXT; + CALL util.debugAdd('collection_assign', JSON_OBJECT( + 'errorNumber', vErrorNumber, + 'errorMsg', vErrorMsg, + 'lockName', vLockName, + 'userFk', vUserFk + )); -- Tmp + IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); - CALL util.debugAdd('collection_assign', JSON_OBJECT( - 'errorNumber', vErrorNumber, - 'errorMsg', vErrorMsg, - 'lockName', vLockName, - 'userFk', vUserFk - )); -- Tmp END IF; - RESIGNAL; END; @@ -52123,17 +52393,17 @@ BEGIN vErrorNumber = MYSQL_ERRNO, vErrorMsg = MESSAGE_TEXT; + CALL util.debugAdd('collection_new', JSON_OBJECT( + 'errorNumber', vErrorNumber, + 'errorMsg', vErrorMsg, + 'lockName', vLockName, + 'userFk', vUserFk, + 'ticketFk', vTicketFk + )); -- Tmp + IF vLockName IS NOT NULL THEN DO RELEASE_LOCK(vLockName); - CALL util.debugAdd('collection_new', JSON_OBJECT( - 'errorNumber', vErrorNumber, - 'errorMsg', vErrorMsg, - 'lockName', vLockName, - 'userFk', vUserFk, - 'ticketFk', vTicketFk - )); -- Tmp END IF; - RESIGNAL; END; @@ -52487,18 +52757,21 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_setParking`(IN `vCollectionFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE DEFINER=`root`@`localhost` PROCEDURE `collection_setParking`( + vSelf INT, + vParkingFk INT +) +BEGIN /** * Aparca una colección en un parking. * - * @param vCollectionFk Id de la colección - * @param vParkingFk Id del parking + * @param vSelf Id colección + * @param vParkingFk Id parking */ - REPLACE vn.ticketParking(ticketFk, parkingFk) + REPLACE ticketParking(ticketFk, parkingFk) SELECT tc.ticketFk, vParkingFk - FROM vn.ticketCollection tc - WHERE tc.collectionFk = vCollectionFk; + FROM ticketCollection tc + WHERE tc.collectionFk = vSelf; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53095,9 +53368,9 @@ BEGIN SET @order = 0; - DROP TEMPORARY TABLE IF EXISTS tmp.newSaleList; + DROP TEMPORARY TABLE IF EXISTS tNewSaleList; - CREATE TEMPORARY TABLE tmp.newSaleList + CREATE TEMPORARY TABLE tNewSaleList SELECT id as saleFk, @order := @order + 1 as orden FROM vn.sale WHERE ticketFk = vTargetTicketFk @@ -53107,8 +53380,9 @@ BEGIN SELECT ns.saleFk, sc.componentFk, sc.value FROM vn.saleComponent sc JOIN tmp.saleList s ON s.saleFk = sc.saleFk - JOIN tmp.newSaleList ns ON ns.orden = s.orden; + JOIN tNewSaleList ns ON ns.orden = s.orden; + DROP TEMPORARY TABLE tNewSaleList; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -53978,7 +54252,7 @@ BEGIN AND (NOT e.isBooked OR NOT e.isConfirmed) ), notBookedEntries AS ( - SELECT e.id + SELECT entryFk FROM vn.duaEntry WHERE duaFk = vDuaFk AND NOT customsValue @@ -55078,7 +55352,7 @@ BEGIN AND e.id = vSelf; IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN - CALL util.throw('Entry is not editable'); + CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); END IF; END ;; DELIMITER ; @@ -55414,60 +55688,45 @@ BEGIN DECLARE vBuyStickers INT; DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE cur CURSOR FOR + DECLARE cur CURSOR FOR SELECT bb.id buyFk, FLOOR(ish.visible / ish.packing) ishStickers, bb.stickers buyStickers - FROM vn.itemShelving ish + FROM itemShelving ish JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b - WHERE b.entryFk = vFromEntryFk - ORDER BY b.stickers DESC - LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - AND bb.stickers >= FLOOR(ish.visible / ish.packing) - WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci - GROUP BY ish.id; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - -- Cantidades de la matrícula que exceden la de las entradas - SELECT ish.itemFk, - i.longName, - FLOOR(ish.visible / ish.packing) AS etiEnMatricula, - bb.stickers etiEnEntrada - FROM vn.itemShelving ish - JOIN vn.item i ON i.id = ish.itemFk - LEFT JOIN (SELECT b.id, b.itemFk, b.stickers - FROM vn.buy b + FROM buy b WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci - AND IFNULL(bb.stickers,0) < FLOOR(ish.visible / ish.packing) + AND bb.stickers >= FLOOR(ish.visible / ish.packing) + WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_general_ci + AND NOT ish.isSplit GROUP BY ish.id; - + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + OPEN cur; read_loop: LOOP SET vDone = FALSE; FETCH cur INTO vBuyFk, vIshStickers, vBuyStickers; - + IF vDone THEN LEAVE read_loop; END IF; - + IF vIshStickers = vBuyStickers THEN - UPDATE vn.buy + UPDATE buy SET entryFk = vToEntryFk WHERE id = vBuyFk; ELSE - UPDATE vn.buy + UPDATE buy SET stickers = stickers - vIshStickers, quantity = stickers * packing WHERE id = vBuyFk; - - INSERT INTO vn.buy(entryFk, + + INSERT INTO buy(entryFk, itemFk, quantity, buyingValue, @@ -55518,13 +55777,16 @@ BEGIN weight, deliveryFk, itemOriginalFk - FROM vn.buy + FROM buy WHERE id = vBuyFk; UPDATE buy SET printedStickers = vIshStickers WHERE id = LAST_INSERT_ID(); END IF; - END LOOP; + UPDATE itemShelving + SET isSplit = TRUE + WHERE shelvingFk = vShelvingFk; + END LOOP; CLOSE cur; END ;; DELIMITER ; @@ -55724,7 +55986,12 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_build`(IN vExpeditions JSON, IN vArcId INT, IN vWorkerFk INT, OUT vPalletFk INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `expeditionPallet_build`( + vExpeditions JSON, + vArcId INT, + vWorkerFk INT, + OUT vPalletFk INT +) BEGIN /** Construye un pallet de expediciones. * @@ -55732,28 +55999,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 vExpeditionStateTypeFk 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); @@ -55764,53 +56025,58 @@ 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) - VALUES(vTruckFk); + INSERT INTO expeditionPallet SET truckFk = 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 vExpeditionStateTypeFk + FROM expeditionStateType + WHERE code = 'PALLETIZED'; - CALL vn.report_print( + INSERT INTO expeditionState(expeditionFk, typeFk) + SELECT expeditionFk, vExpeditionStateTypeFk FROM tExpedition; + + SELECT printerFk INTO vPrinterFk FROM arcRead WHERE id = vArcId; + + CALL report_print( 'LabelPalletExpedition', vPrinterFk, account.myUser_getId(), @@ -55818,7 +56084,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 ;; @@ -57769,18 +58035,16 @@ BEGIN * @param vBookEntry Id de asiento, si es NULL se genera uno nuevo */ DECLARE vFiscalYear INT; - DECLARE vHasDistinctTransactions INT; + DECLARE vHasRepeatedTransactions BOOL; - SELECT COUNT(DISTINCT transactionTypeSageFk) INTO vHasDistinctTransactions - FROM invoiceIn ii - JOIN invoiceInTax iit ON iit.invoiceInFk = ii.id - JOIN invoiceInSerial iis ON iis.code = ii.serial - WHERE ii.id = vSelf - AND iis.taxAreaFk = 'CEE' - AND transactionTypeSageFk; + SELECT TRUE INTO vHasRepeatedTransactions + FROM invoiceInTax + WHERE invoiceInFk = vSelf + HAVING COUNT(DISTINCT transactionTypeSageFk) > 1 + LIMIT 1; - IF vHasDistinctTransactions > 1 THEN - CALL util.throw ('This invoice does not allow different types of transactions'); + IF vHasRepeatedTransactions THEN + CALL util.throw ('This invoice contains different types of transactions'); END IF; CREATE OR REPLACE TEMPORARY TABLE tInvoiceIn @@ -59193,6 +59457,47 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `itemMinimumQuantity_check` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemMinimumQuantity_check`( + vSelf INT, + vItemFk INT, + vStarted DATE, + vEnded DATE, + vWarehouseFk INT +) +BEGIN + DECLARE vHasCollision BOOL; + + IF vStarted IS NULL THEN + CALL util.throw('The field "started" cannot be null'); + END IF; + + SELECT COUNT(*) INTO vHasCollision + FROM itemMinimumQuantity + WHERE vItemFk = itemFk + AND ((vStarted <= ended OR ended IS NULL) + AND (vStarted >= `started` OR vEnded IS NULL)) + AND (vWarehouseFk <=> warehouseFk) + AND vSelf <> id; + + IF vHasCollision THEN + CALL util.throw('A line with the same configuration already exists'); + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemPlacementFromTicket` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -60237,7 +60542,7 @@ BEGIN LEAVE l; END IF; - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, NULL); END LOOP; CLOSE vSales; END ;; @@ -60256,105 +60561,121 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_addBySale`( - vSaleFk INT +CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_addBySale`( + vSaleFk INT, + vSectorFk INT ) -proc: BEGIN -/** - * Reserva una línea de venta en la ubicación más óptima - * - * @param vSaleFk Id de sale - * @param vItemShelvingSaleFk Id de reserva - */ - DECLARE vLastPickingOrder INT; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vItemShelvingFk INT; - DECLARE vAvailable INT; - DECLARE vReservedQuantity INT; - DECLARE vOutStanding INT; - DECLARE vUserFk INT; - - DECLARE vItemShelvingAvailable CURSOR FOR - SELECT ish.id itemShelvingFk, - ish.available - FROM sale s - JOIN itemShelving ish ON ish.itemFk = s.itemFk - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector sc ON sc.id = p.sectorFk - JOIN productionConfig pc - WHERE s.id = vSaleFk - AND NOT sc.isHideForPickers - ORDER BY s.id, - p.pickingOrder >= vLastPickingOrder, - sh.priority DESC, - ish.available >= s.quantity DESC, - s.quantity MOD ish.grouping = 0 DESC, - ish.grouping DESC, - IF(pc.orderMode = 'Location', p.pickingOrder, ish.created); - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)) - INTO vLastPickingOrder, vOutStanding - FROM sale s - LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id - LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN shelving sh ON sh.code = ish.shelvingFk - LEFT JOIN parking p ON p.id = sh.parkingFk - WHERE s.id = vSaleFk; - - IF vOutStanding <= 0 THEN - LEAVE proc; - END IF; - - SELECT getUser() INTO vUserFk; - - OPEN vItemShelvingAvailable; - l: LOOP - SET vDone = FALSE; - FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable; - - IF vOutStanding <= 0 OR vDone THEN - LEAVE l; - END IF; - - START TRANSACTION; - - SELECT id INTO vItemShelvingFk - FROM itemShelving - WHERE id = vItemShelvingFk - FOR UPDATE; - - SELECT LEAST(vOutStanding, vAvailable) INTO vReservedQuantity; - SET vOutStanding = vOutStanding - vReservedQuantity; - - IF vReservedQuantity > 0 THEN - - INSERT INTO itemShelvingSale( - itemShelvingFk, - saleFk, - quantity, - userFk) - SELECT vItemShelvingFk, - vSaleFk, - vReservedQuantity, - vUserFk; - - UPDATE itemShelving - SET available = available - vReservedQuantity - WHERE id = vItemShelvingFk; - - END IF; - - COMMIT; - END LOOP; - CLOSE vItemShelvingAvailable; +proc: BEGIN +/** + * Reserva una línea de venta en la ubicación más óptima + * + * @param vSaleFk Id de sale + * @param vItemShelvingSaleFk Id de reserva + * @param vSectorFk Id del sector del operator + */ + DECLARE vLastPickingOrder INT; + DECLARE vDone INT DEFAULT FALSE; + DECLARE vItemShelvingFk INT; + DECLARE vAvailable INT; + DECLARE vReservedQuantity INT; + DECLARE vOutStanding INT; + DECLARE vUserFk INT; + DECLARE vTotalReservedQuantity INT; + DECLARE vSaleQuantity INT; + + DECLARE vItemShelvingAvailable CURSOR FOR + SELECT ish.id itemShelvingFk, + ish.available + FROM sale s + JOIN itemShelving ish ON ish.itemFk = s.itemFk + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector sc ON sc.id = p.sectorFk + JOIN productionConfig pc + WHERE s.id = vSaleFk + AND NOT sc.isHideForPickers + AND (sc.id = vSectorFk OR vSectorFk IS NULL) + ORDER BY s.id, + p.pickingOrder >= vLastPickingOrder, + sh.priority DESC, + ish.available >= s.quantity DESC, + s.quantity MOD ish.grouping = 0 DESC, + ish.grouping DESC, + IF(pc.orderMode = 'Location', p.pickingOrder, ish.created); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)), s.quantity + INTO vLastPickingOrder, vOutStanding, vSaleQuantity + FROM sale s + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN parking p ON p.id = sh.parkingFk + WHERE s.id = vSaleFk; + + IF vOutStanding <= 0 THEN + LEAVE proc; + END IF; + + SELECT getUser() INTO vUserFk; + + OPEN vItemShelvingAvailable; + l: LOOP + SET vDone = FALSE; + FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable; + + IF vOutStanding <= 0 OR vDone THEN + SELECT SUM(IFNULL(quantity, 0)) + INTO vTotalReservedQuantity + FROM itemShelvingSale + WHERE saleFk = vSaleFk; + + IF vTotalReservedQuantity <> vSaleQuantity THEN + UPDATE sale + SET quantity = vTotalReservedQuantity + WHERE id = vSaleFk; + END IF; + LEAVE l; + END IF; + + START TRANSACTION; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + FOR UPDATE; + + SELECT LEAST(vOutStanding, vAvailable) INTO vReservedQuantity; + SET vOutStanding = vOutStanding - vReservedQuantity; + + IF vReservedQuantity > 0 THEN + + INSERT INTO itemShelvingSale( + itemShelvingFk, + saleFk, + quantity, + isPicked) + SELECT vItemShelvingFk, + vSaleFk, + vReservedQuantity, + vUserFk, + FALSE; + + UPDATE itemShelving + SET available = available - vReservedQuantity + WHERE id = vItemShelvingFk; + + END IF; + + COMMIT; + END LOOP; + CLOSE vItemShelvingAvailable; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -60381,6 +60702,7 @@ BEGIN */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vSaleFk INT; + DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR SELECT s.id FROM sectorCollectionSaleGroup sc @@ -60396,6 +60718,10 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + OPEN vSales; l: LOOP SET vDone = FALSE; @@ -60405,7 +60731,7 @@ BEGIN LEAVE l; END IF; - CALL itemShelvingSale_addBySale(vSaleFk); + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); END LOOP; CLOSE vSales; END ;; @@ -60431,9 +60757,10 @@ proc: BEGIN */ DECLARE vDone BOOL; DECLARE vSaleFk INT; + DECLARE vSectorFk INT; DECLARE vSales CURSOR FOR - SELECT DISTINCT saleFk FROM tSale; + SELECT DISTINCT saleFk, sectorFk FROM tSale; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -60451,24 +60778,25 @@ proc: BEGIN CREATE OR REPLACE TEMPORARY TABLE tSale ENGINE = MEMORY - SELECT id, saleFk FROM itemShelvingSaleReserve; + SELECT id, saleFk, sectorFk FROM itemShelvingSaleReserve; OPEN vSales; myLoop: LOOP SET vDone = FALSE; - FETCH vSales INTO vSaleFk; + FETCH vSales INTO vSaleFk, vSectorFk; IF vDone THEN LEAVE myLoop; END IF; - CALL itemShelvingSale_addBySale (vSaleFk); + CALL itemShelvingSale_addBySale (vSaleFk, vSectorFk); END LOOP; CLOSE vSales; - DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id; + DELETE iss FROM itemShelvingSaleReserve iss + JOIN tSale s ON s.id = iss.id AND s.sectorFk = iss.sectorFk; DROP TEMPORARY TABLE tSale; @@ -60491,13 +60819,16 @@ DELIMITER ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_reallocate`( vItemShelvingFk INT(10), - vItemFk INT(10) + vItemFk INT(10), + vSectorFk INT ) BEGIN /** * Elimina reservas de un itemShelving e intenta reservar en otra ubicación * * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector */ DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -60507,18 +60838,21 @@ BEGIN START TRANSACTION; - SELECT id INTO vItemShelvingFk - FROM itemShelving - WHERE id = vItemShelvingFk - FOR UPDATE; - UPDATE itemShelving SET visible = 0, available = 0 WHERE id = vItemShelvingFk AND itemFk = vItemFk; - INSERT INTO itemShelvingSaleReserve (saleFk) + SELECT iss.id + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND iss.itemFk = vItemFk + AND NOT iss.isPicked + FOR UPDATE; + + INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) SELECT DISTINCT iss.saleFk FROM itemShelvingSale iss JOIN itemShelving ish ON ish.id = iss.itemShelvingFk @@ -60601,7 +60935,8 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `itemShelvingSale_setQuantity`( vItemShelvingSaleFk INT(10), vQuantity DECIMAL(10,0), - vIsItemShelvingSaleEmpty BOOLEAN + vIsItemShelvingSaleEmpty BOOLEAN, + vSectorFk INT ) BEGIN /** @@ -60613,6 +60948,7 @@ BEGIN * @param vQuantity Cantidad real que se ha cogido de la ubicación * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha * quedado vacio tras el movimiento + * @param vSectorFk Id del sector */ DECLARE vSaleFk INT; DECLARE vItemShelvingFk INT; @@ -60620,6 +60956,7 @@ BEGIN DECLARE vRemainingQuantity INT; DECLARE vItemFk INT; DECLARE vTotalQuantity INT; + DECLARE vStateCode VARCHAR(45); DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -60627,21 +60964,35 @@ BEGIN RESIGNAL; END; + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN + CALL util.throw('The quantity cannot be different from the reserved'); + END IF; + IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN CALL util.throw('Reservation completed'); END IF; - SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk, SUM(IFNULL(iss.quantity,0)) - INTO vItemFk, vSaleFk, vItemShelvingFk, vReservedQuantity + SELECT s.itemFk, + iss.saleFk, + iss.itemShelvingFk, + SUM(IFNULL(iss.quantity,0)), + IF(sgd.id, 'PREVIOUS_PREPARATION', 'PREPARED') + INTO vItemFk, + vSaleFk, + vItemShelvingFk, + vReservedQuantity, + vStateCode FROM itemShelvingSale iss JOIN sale s ON s.id = iss.saleFk + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = iss.saleFk WHERE iss.id = vItemShelvingSaleFk AND NOT iss.isPicked; IF vQuantity > vReservedQuantity - OR (vQuantity < vReservedQuantity AND - (NOT vIsItemShelvingSaleEmpty OR vIsItemShelvingSaleEmpty IS NULL)) - OR (vIsItemShelvingSaleEmpty IS NOT NULL AND vQuantity = vReservedQuantity) THEN + OR (vQuantity < vReservedQuantity AND NOT vIsItemShelvingSaleEmpty) + OR (vQuantity = vReservedQuantity AND vIsItemShelvingSaleEmpty) THEN CALL util.throw('The quantity cannot be different from the reserved'); END IF; @@ -60661,7 +61012,7 @@ BEGIN SET visible = GREATEST(0, visible - vQuantity) WHERE id = vItemShelvingFk; - SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity) + SELECT SUM(IF(isPicked OR id = vItemShelvingSaleFk, 0, quantity)), SUM(quantity) INTO vRemainingQuantity, vTotalQuantity FROM itemShelvingSale WHERE saleFk = vSaleFk; @@ -60673,7 +61024,7 @@ BEGIN vTotalQuantity, `account`.`myUser_getId`(), NULL, - 'PREPARED', + vStateCode, TRUE); UPDATE sale s @@ -60685,9 +61036,9 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserve (saleFk) - SELECT vSaleFk; - CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk); + INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) + SELECT vSaleFk, vSectorFk; + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); END IF; END ;; DELIMITER ; @@ -61484,6 +61835,8 @@ BEGIN WHERE p.pickingOrder BETWEEN vPickingOrderFrom AND vPickingOrderTo AND p.sectorFk = vSectorFk ORDER BY p.pickingOrder; + + DROP TEMPORARY TABLE tmp.stockMisfit; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -62006,6 +62359,75 @@ SET tag8 = t.name, value8 = it.value WHERE it.priority = 4 AND (vItem IS NULL OR vItem = it.itemFk); +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP PROCEDURE IF EXISTS `item_calcVisible` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `item_calcVisible`( + vSelf INT, + vWarehouseFk INT +) +BEGIN +/** + * Calcula el visible de un artículo o de todos. + * + * @param vWarehouse Warehouse id + * @param vSelf Item id + * @param tmp.itemVisible(item_id, stock, visible) + */ + DECLARE vDated DATE DEFAULT util.VN_CURDATE(); + DECLARE vTomorrow DATETIME DEFAULT util.tomorrow(); + + INSERT INTO tmp.itemVisible(item_id, visible) + SELECT itemFk, SUM(quantity) + FROM ( + SELECT i.itemFk, i.quantity + FROM itemTicketOut i + LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk + JOIN `state` s ON s.id = ts.stateFk + LEFT JOIN ( + SELECT DISTINCT st.saleFk + FROM saleTracking st + JOIN state s ON s.id = st.stateFk + WHERE st.created > vDated + AND (s.isPicked OR st.isChecked) + ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk + WHERE IFNULL(vWarehouseFk, i.warehouseFk) = i.warehouseFk + AND (vSelf IS NULL OR i.itemFk = vSelf) + AND (s.isPicked OR i.reserved OR stPrevious.saleFk) + AND i.shipped >= vDated AND i.shipped < vTomorrow + UNION ALL + SELECT itemFk, quantity + FROM itemEntryIn + WHERE isReceived + AND landed >= vDated AND landed < vTomorrow + AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk + AND (vSelf IS NULL OR itemFk = vSelf) + AND NOT isVirtualStock + UNION ALL + SELECT itemFk, quantity + FROM itemEntryOut + WHERE isDelivered + AND shipped >= vDated + AND shipped < vTomorrow + AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk + AND (vSelf IS NULL OR itemFk = vSelf) + ) t + GROUP BY itemFk + ON DUPLICATE KEY UPDATE + visible = IFNULL(stock, 0) + VALUES(visible); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63073,94 +63495,84 @@ DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `item_getBalance`( vItemFk INT, vWarehouseFk INT, - vDate DATETIME + vDated DATETIME ) BEGIN /** - * @vItemFk item a buscar - * @vWarehouseFk almacen donde buscar - * @vDate Si la fecha es null, muestra el histórico desde el inventario. - * Si la fecha no es null, muestra histórico desde la fecha de vDate. + * Calcula el balance de un artículo. + * + * @vItemFk Id de artículo + * @vWarehouseFk Id de almacén + * @vDated Fecha a calcular, si es NULL muestra el histórico desde el inventario */ - DECLARE vDateInventory DATETIME; + DECLARE vDateInventory DATETIME + DEFAULT ( + SELECT IF(vDated, uc.mockUtcTime, c.inventoried) + FROM config c + JOIN util.config uc + ); + DECLARE vSupplierInventoryFk INT + DEFAULT (SELECT supplierFk FROM inventoryConfig); - IF vDate IS NULL THEN - SELECT inventoried INTO vDateInventory - FROM config; - ELSE - SELECT mockUtcTime INTO vDateInventory - FROM util.config; + IF NOT vSupplierInventoryFk OR NOT vDateInventory THEN + CALL util.throw('Config variables are not set'); END IF; - CREATE OR REPLACE TEMPORARY TABLE tItemDiary( - shipped DATE, - `in` INT(11), - `out` INT(11), - alertLevel INT(11), - stateName VARCHAR(20), - `name` VARCHAR(50), - reference VARCHAR(50), - origin INT(11), - clientFk INT(11), - isPicked INT(11), - isTicket TINYINT(1), - lineFk INT(11), - `order` TINYINT(3) UNSIGNED, - clientType VARCHAR(20), - claimFk INT(10) UNSIGNED, - inventorySupplierFk INT(10) - ); - - INSERT INTO tItemDiary + CREATE OR REPLACE TEMPORARY TABLE tItemDiary + ENGINE = MEMORY WITH entriesIn AS ( - SELECT tr.landed shipped, + SELECT 'entry' originType, + e.id originId, + tr.landed shipped, b.quantity `in`, NULL `out`, st.alertLevel , st.name stateName, - s.name `name`, e.invoiceNumber reference, - e.id origin, - s.id clientFk, + 'supplier' entityType, + s.id entityId, + s.name entityName, IF(st.`code` = 'DELIVERED', TRUE, FALSE) isPicked, FALSE isTicket, b.id lineFk, NULL `order`, NULL clientType, NULL claimFk, - ec.inventorySupplierFk + vSupplierInventoryFk inventorySupplierFk FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk JOIN vn.supplier s ON s.id = e.supplierFk - JOIN vn.state st ON st.`code` = IF( tr.landed < util.VN_CURDATE() + JOIN vn.state st ON st.`code` = IF(tr.landed < util.VN_CURDATE() OR (util.VN_CURDATE() AND tr.isReceived), 'DELIVERED', 'FREE') - JOIN vn.entryConfig ec WHERE tr.landed >= vDateInventory - AND vWarehouseFk = tr.warehouseInFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND tr.warehouseInFk = vWarehouseFk + AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT e.isRaid - ), entriesOut AS ( - SELECT tr.shipped, + ), + entriesOut AS ( + SELECT 'entry', + e.id originType, + tr.shipped, NULL, b.quantity, st.alertLevel, st.name stateName, - s.name , e.invoiceNumber, - e.id entryFk, - s.id supplierFk, + 'supplier' entityType, + s.id entityId, + s.name, IF(st.`code` = 'DELIVERED' , TRUE, FALSE), FALSE isTicket, b.id, NULL `order`, NULL clientType, NULL claimFk, - ec.inventorySupplierFk + vSupplierInventoryFk FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel tr ON tr.id = e.travelFk @@ -63170,86 +63582,108 @@ BEGIN OR (tr.shipped = util.VN_CURDATE() AND tr.isReceived), 'DELIVERED', 'FREE') - JOIN vn.entryConfig ec WHERE tr.shipped >= vDateInventory - AND vWarehouseFk = tr.warehouseOutFk - AND (s.id <> ec.inventorySupplierFk OR vDate IS NULL) + AND tr.warehouseOutFk = vWarehouseFk + AND (s.id <> vSupplierInventoryFk OR vDated IS NULL) AND b.itemFk = vItemFk AND NOT e.isExcludedFromAvailable AND NOT w.isFeedStock AND NOT e.isRaid - ), sales AS ( - SELECT DATE(t.shipped) shipped, - s.quantity, - st2.alertLevel, - st2.name, - t.nickname, - t.refFk, - t.id ticketFk, - t.clientFk, - s.id saleFk, - st.`order`, - c.typeFk, - cb.claimFk - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id - LEFT JOIN vn.state st ON st.`code` = ts.`code` - JOIN vn.client c ON c.id = t.clientFk - JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), - 'DELIVERED', - IF (t.shipped > util.dayEnd(util.VN_CURDATE()), - 'FREE', - IFNULL(ts.code, 'FREE'))) - LEFT JOIN vn.claimBeginning cb ON s.id = cb.saleFk - WHERE t.shipped >= vDateInventory - AND s.itemFk = vItemFk - AND vWarehouseFk = t.warehouseFk - ),sale AS ( - SELECT s.shipped, + ), + sales AS ( + WITH itemSales AS ( + SELECT DATE(t.shipped) shipped, + s.quantity, + st2.alertLevel, + st2.name, + t.refFk, + t.id ticketFk, + 'client' entityType, + t.clientFk entityId, + t.nickname, + s.id saleFk, + st.`order`, + c.typeFk, + cb.claimFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + LEFT JOIN vn.state st ON st.code = ts.code + JOIN vn.client c ON c.id = t.clientFk + JOIN vn.state st2 ON st2.`code` = IF(t.shipped < util.VN_CURDATE(), + 'DELIVERED', + IF (t.shipped > util.dayEnd(util.VN_CURDATE()), + 'FREE', + IFNULL(st.code, 'FREE'))) + LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id + WHERE t.shipped >= vDateInventory + AND s.itemFk = vItemFk + AND t.warehouseFk = vWarehouseFk + ) + SELECT 'ticket', + s.ticketFk, + s.shipped, NULL `in`, s.quantity, s.alertLevel, s.name, - s.nickname, s.refFk, - s.ticketFk, - s.clientFk, - IF(stk.saleFk, TRUE, NULL), + s.entityType, + s.entityId, + s.nickname, + IF(stk.saleFk, TRUE, FALSE), TRUE, s.saleFk, s.`order`, s.typeFk, s.claimFk, NULL - FROM sales s + FROM itemSales s LEFT JOIN vn.state stPrep ON stPrep.`code` = 'PREPARED' LEFT JOIN vn.saleTracking stk ON stk.saleFk = s.saleFk AND stk.stateFk = stPrep.id GROUP BY s.saleFk - ) SELECT shipped, - `in`, - `out`, - alertLevel, - stateName, - `name`, - reference, - origin, - clientFk, - isPicked, - isTicket, - lineFk, - `order`, - clientType, - claimFk, - inventorySupplierFk - FROM entriesIn + ), + orders AS ( + SELECT 'order' originType, + o.id originId, + r.shipment, + NULL 'in', + r.amount, + NULL alertLevel, + NULL stateName, + NULL invoiceNumber, + 'client' entityType, + c.id, + c.name, + FALSE, + FALSE isTicket, + NULL buyFk, + NULL 'order', + c.typeFk, + NULL claimFk, + NULL + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN vn.client c ON c.id = o.customer_id + WHERE r.shipment >= vDateInventory + AND r.warehouseFk = vWarehouseFk + AND r.created >= ( + SELECT SUBTIME(util.VN_NOW(), reserveTime) + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND r.itemFk = vItemFk + ) + SELECT * FROM entriesIn UNION ALL SELECT * FROM entriesOut UNION ALL - SELECT * FROM sale + SELECT * FROM sales + UNION ALL + SELECT * FROM orders ORDER BY shipped, - (inventorySupplierFk = clientFk) DESC, + (inventorySupplierFk = entityId) DESC, alertLevel DESC, isTicket, `order` DESC, @@ -63257,19 +63691,20 @@ BEGIN `in` DESC, `out` DESC; - IF vDate IS NULL THEN - + IF vDated IS NULL THEN SET @a := 0; SET @currentLineFk := 0; SET @shipped := ''; - SELECT DATE(@shipped:= t.shipped) shipped, + SELECT t.originType, + t.originId, + DATE(@shipped:= t.shipped) shipped, t.alertLevel, t.stateName, - t.origin, t.reference, - t.clientFk, - t.name, + t.entityType, + t.entityId, + t.entityName, t.`in` invalue, t.`out`, @a := @a + IFNULL(t.`in`, 0) - IFNULL(t.`out`, 0) balance, @@ -63285,37 +63720,41 @@ BEGIN t.`order` FROM tItemDiary t LEFT JOIN alertLevel a ON a.id = t.alertLevel; - ELSE SELECT IFNULL(SUM(IFNULL(`in`, 0)) - SUM(IFNULL(`out`, 0)), 0) INTO @a FROM tItemDiary - WHERE shipped < vDate; + WHERE shipped < vDated; - SELECT vDate shipped, - 0 alertLevel, - 0 stateName, - 0 origin, - '' reference, - 0 clientFk, + SELECT NULL originType, + NULL originId, + vDated shipped, + NULL alertLevel, + NULL stateName, + NULL reference, + NULL entityType, + NULL entityId, 'Inventario calculado', @a invalue, NULL `out`, @a balance, - 0 lastPreparedLineFk, - 0 isTicket, - 0 lineFk, - 0 isPicked, - 0 clientType, - 0 claimFk, + NULL lastPreparedLineFk, + NULL isTicket, + NULL lineFk, + NULL isPicked, + NULL clientType, + NULL claimFk, NULL `order` UNION ALL - SELECT shipped, + SELECT originType, + originId, + shipped, alertlevel, stateName, - origin, - reference, - clientFk, - name, `in`, + reference, + entityType, + entityId, + entityName, + `in`, `out`, @a := @a + IFNULL(`in`, 0) - IFNULL(`out`, 0), 0, @@ -63326,7 +63765,7 @@ BEGIN claimFk, `order` FROM tItemDiary - WHERE shipped >= vDate; + WHERE shipped >= vDated; END IF; DROP TEMPORARY TABLE tItemDiary; @@ -63578,6 +64017,8 @@ BEGIN i.quantity amount FROM tmp.itemAtp i HAVING amount != 0; + + DROP TEMPORARY TABLE tmp.itemAtp; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -63695,7 +64136,7 @@ BEGIN WHEN b.groupingMode = 'grouping' THEN b.grouping WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 - END AS minQuantity, + END minQuantity, v.visible located, b.price2 FROM vn.item i @@ -63820,62 +64261,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `item_GetVisible` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `item_GetVisible`(vWarehouse SMALLINT, vItem INT) -BEGIN - DECLARE vTomorrow DATETIME DEFAULT TIMESTAMPADD(DAY, 1, util.VN_CURDATE()); - - INSERT INTO tmp.itemVisible (item_id, visible) - SELECT item_id, SUM(amount) amount - FROM ( - SELECT i.itemFk AS item_id, quantity AS amount - FROM itemTicketOut i - LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk - JOIN state s ON s.id = ts.stateFk - LEFT JOIN (SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.created > util.VN_CURDATE() - AND (s.isPicked OR st.isChecked) - ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk - WHERE i.warehouseFk = vWarehouse - AND (vItem IS NULL OR i.itemFk = vItem) - AND (s.isPicked OR i.reserved OR stPrevious.saleFk ) - AND i.shipped >= util.VN_CURDATE() AND i.shipped < vTomorrow - UNION ALL - SELECT iei.itemFk, quantity - FROM itemEntryIn iei - WHERE (iei.isReceived != FALSE /*OR ip.modificationDate > util.VN_CURDATE()*/) - AND iei.landed >= util.VN_CURDATE() AND iei.landed < vTomorrow - AND iei.warehouseInFk = vWarehouse - AND (vItem IS NULL OR iei.itemFk = vItem) - AND iei.isVirtualStock is FALSE - UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE isDelivered != FALSE - AND shipped >= util.VN_CURDATE() AND shipped < vTomorrow - AND warehouseOutFk = vWarehouse - AND (vItem IS NULL OR itemFk = vItem) - ) t - GROUP BY item_id - ON DUPLICATE KEY UPDATE - visible = IFNULL(stock,0) + VALUES(visible); -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `item_multipleBuy` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -64211,7 +64596,8 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `item_setVisibleDiscard`( vAddressFk INT) BEGIN /** - * Procedimiento para dar dar de baja/alta un item, si vAddressFk es NULL se entiende que se da de alta y se toma el addressFk de la configuración + * Procedimiento para dar dar de baja/alta un item, si vAdressFk es NULL + * se entiende que se da de alta y se toma el addressFk de la configuración * * @param vItemFk Identificador del ítem * @param vWarehouseFk id del warehouse @@ -65228,6 +65614,7 @@ proc: BEGIN DECLARE vDateTo DATETIME; DECLARE vDateToTomorrow DATETIME; DECLARE vDefaultDayRange INT; + DECLARE vCalcFk INT; IF vDate < util.VN_CURDATE() THEN LEAVE proc; @@ -65300,50 +65687,18 @@ proc: BEGIN ai.sd = iic.quantity; -- Cálculo del visible - CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc - (PRIMARY KEY (itemFk)) - ENGINE = MEMORY - SELECT itemFk, SUM(quantity) visible - FROM ( - SELECT s.itemFk, s.quantity - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN warehouse w ON w.id = t.warehouseFk - WHERE t.shipped >= vDate - AND t.shipped < vDateTomorrow - AND (NOT isPicked AND NOT t.isLabeled AND t.refFk IS NULL) - AND IFNULL(vWarehouseFk, t.warehouseFk) = t.warehouseFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, - b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - WHERE t.landed = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseInFk) = t.warehouseInFk - AND w.isComparative - UNION ALL - SELECT b.itemFk, b.quantity - FROM buy b - JOIN entry e ON e.id = b.entryFk - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseOutFk - WHERE t.shipped = vDate - AND NOT t.isReceived - AND NOT e.isExcludedFromAvailable - AND NOT e.isRaid - AND IFNULL(vWarehouseFk, t.warehouseOutFk) = t.warehouseOutFk - AND w.isComparative - ) sub2 - GROUP BY itemFk; + CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - UPDATE tmp.itemInventory ai - JOIN tItemVisibleCalc ivc ON ivc.itemFk = ai.id - SET ai.visible = ai.visible + ivc.visible; + CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc + (PRIMARY KEY (item_id)) + ENGINE = MEMORY + SELECT item_id, visible + FROM cache.visible + WHERE calc_id = vCalcFk; + + UPDATE tmp.itemInventory it + JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + SET it.visible = it.visible + ivc.visible; -- Calculo del disponible CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc @@ -65414,9 +65769,9 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.itemTravel, tmp.itemCalc, + tmp.itemAtp, tItemInventoryCalc, - tItemVisibleCalc, - tmp.itemAtp; + tItemVisibleCalc; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -66964,6 +67319,7 @@ BEGIN ) sub; DROP TEMPORARY TABLE tmp.whiteTicket; DROP TEMPORARY TABLE tmp.sectorTypeTicket; + DROP TEMPORARY TABLE tmp.productionBuffer; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -68078,20 +68434,28 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_setParking`(IN `vSaleGroupFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE DEFINER=`root`@`localhost` PROCEDURE `saleGroup_setParking`( + vSaleGroupFk VARCHAR(8), + vParkingFk INT +) +BEGIN /** - * Aparca una preparación previa en un parking + * Aparca una preparación previa en un parking. * * @param vSaleGroupFk id de la preparación previa * @param vParkingFk id del parking */ - UPDATE vn.saleGroup sg + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + + UPDATE saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vSaleGroupFk - AND sg.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK; - CALL vn.ticket_setNextState(vn.ticket_get(vSaleGroupFk)); + CALL ticket_setNextState(ticket_get(vSaleGroupFk)); END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -68919,21 +69283,20 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.sale (saleFk INT PRIMARY KEY) - SELECT - s.ticketFk, - s.id saleFk, - s.itemFk, - s.concept, - s.quantity, - MAKETIME(pb.HH,pb.mm,0) etd, - pb.routeFk, - FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers, - IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, - b.packagingFk + SELECT s.ticketFk, + s.id saleFk, + s.itemFk, + s.concept, + s.quantity, + MAKETIME(pb.HH,pb.mm,0) etd, + pb.routeFk, + FLOOR(s.quantity / IF(i.isBoxPickingMode, ish.packing, i.packingOut)) stickers, + IF(i.isBoxPickingMode, ish.packing, i.packingOut) packing, + IF(pa.isPackageReturnable, pc.defaultBigPackageFk, b.packagingFk) packagingFk FROM sale s JOIN item i ON i.id = s.itemFk JOIN itemShelving ish ON ish.itemFk = s.itemFk - LEFT JOIN ( SELECT iss.itemShelvingFk, + LEFT JOIN ( SELECT iss.itemShelvingFk, s.itemFk, SUM(iss.quantity) reserve FROM itemShelvingSale iss @@ -68952,6 +69315,8 @@ BEGIN LEFT JOIN ticketState ts ON ts.ticketFk = s.ticketFk LEFT JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk LEFT JOIN buy b ON b.id = lb.buy_id + LEFT JOIN packaging pa ON pa.id = b.packagingFk + JOIN packagingConfig pc WHERE IF(i.isBoxPickingMode, ish.packing, i.packingOut) <= LEAST(s.quantity, ish.visible - IFNULL(tISS.reserve,0)) AND NOT pb.problem @@ -69490,7 +69855,7 @@ BEGIN JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk WHERE s.ticketFk = vTicketFk - AND ct.`type` = 'otros'; + AND ct.code = 'other'; UPDATE vn.sale s JOIN ( @@ -69795,15 +70160,33 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `sale_setProblem`( BEGIN /** * Update column sale.problem with a problem code + * * @param vProblemCode Code to set or unset - * @table tmp.sale(saleFk, hasProblem) + * @table tmp.sale(saleFk, hasProblem, isProblemCalcNeeded) */ - UPDATE sale s - JOIN tmp.sale ts ON ts.saleFk = s.id - SET s.problem = CONCAT( - IF(ts.hasProblem, - CONCAT(s.problem, ',', vProblemCode), - REPLACE(s.problem, vProblemCode , ''))); + DECLARE vSaleFk INT; + DECLARE vHasProblem INT; + DECLARE vDone BOOL; + DECLARE vSaleList CURSOR FOR SELECT saleFk, hasProblem FROM tmp.sale; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vSaleList; + l: LOOP + SET vDone = FALSE; + FETCH vSaleList INTO vSaleFk, vHasProblem; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE sale + SET problem = CONCAT( + IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))) + WHERE id = vSaleFk; + END LOOP; + CLOSE vSaleList; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -69831,9 +70214,13 @@ BEGIN * @param vSelf Id del sale */ CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) + (INDEX(saleFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem; + SELECT vSelf saleFk, + sale_hasComponentLack(vSelf) hasProblem, + ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + FROM sale + WHERE id = vSelf; CALL sale_setProblem('hasComponentLack'); @@ -69865,11 +70252,13 @@ BEGIN * @param vComponentFk Id component */ CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) + (INDEX(saleFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem + SELECT saleFk, + sale_hasComponentLack(saleFk) hasProblem, + ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded FROM ( - SELECT s.id saleFk + SELECT s.id saleFk, s.ticketFk FROM ticket t JOIN sale s ON s.ticketFk = t.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id @@ -69908,9 +70297,10 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vShipped DATE; DECLARE vQuantity INT; + DECLARE vIsProblemCalcNeeded BOOL; - SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity - INTO vItemFk, vWarehouseFk, vShipped, vQuantity + SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity, ticket_isProblemCalcNeeded(t.id) + INTO vItemFk, vWarehouseFk, vShipped, vQuantity, vIsProblemCalcNeeded FROM sale s JOIN ticket t ON t.id = s.ticketFk WHERE s.id = vSelf; @@ -69918,7 +70308,9 @@ BEGIN CALL buyUltimate(vWarehouseFk, vShipped); CREATE OR REPLACE TEMPORARY TABLE tmp.sale - SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem + SELECT vSelf saleFk, + MOD(vQuantity, b.`grouping`) hasProblem, + vIsProblemCalcNeeded isProblemCalcNeeded FROM tmp.buyUltimate bu JOIN buy b ON b.id = bu.buyFk WHERE bu.itemFk = vItemFk; @@ -70275,8 +70667,11 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `setParking`(IN `vParam` VARCHAR(8), IN `vParkingCode` VARCHAR(8)) -proc: BEGIN +CREATE DEFINER=`root`@`localhost` PROCEDURE `setParking`( + vParam VARCHAR(8), + vParkingCode VARCHAR(8) +) +BEGIN /** * Aparca una colección, un ticket, un saleGroup o un shelving en un parking * @@ -70284,57 +70679,42 @@ proc: BEGIN * @param vParkingCode código del parking */ DECLARE vParkingFk INT; - DECLARE vIsSaleGroup BOOL; - DECLARE vIsTicket BOOL; - DECLARE vIsCollection BOOL; + DECLARE vLastWeek DATE; - SET vParkingCode = replace(vParkingCode,' ',''); + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SET vParkingCode = REPLACE(vParkingCode, ' ', ''); SELECT id INTO vParkingFk - FROM vn.parking + FROM parking WHERE code = vParkingCode COLLATE utf8_unicode_ci; IF vParkingFk IS NULL THEN CALL util.throw('parkingNotExist'); - LEAVE proc; END IF; - - IF vParam REGEXP '^[0-9]+$' THEN - -- Se comprueba si es una preparación previa - SELECT COUNT(*) INTO vIsSaleGroup - FROM vn.saleGroup sg - WHERE sg.id = vParam; - IF vIsSaleGroup THEN - CALL vn.saleGroup_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; + START TRANSACTION; - -- Se comprueba si es un ticket - SELECT COUNT(*) INTO vIsTicket - FROM vn.ticket t - WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK; - IF vIsTicket THEN - CALL vn.ticket_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Se comprueba si es una coleccion de tickets - SELECT COUNT(*) INTO vIsCollection - FROM vn.collection c - WHERE c.id = vParam - AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsCollection THEN - CALL vn.collection_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; + -- Comprobamos si es una prep. previa, ticket, colección o shelving + IF (SELECT TRUE FROM saleGroup WHERE id = vParam) THEN + CALL saleGroup_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM ticket WHERE id = vParam AND shipped >= vLastWeek) THEN + CALL ticket_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM `collection` WHERE id = vParam AND created >= vLastWeek) THEN + CALL collection_setParking(vParam, vParkingFk); + ELSEIF (SELECT TRUE FROM shelving WHERE code = vParam COLLATE utf8_unicode_ci) THEN + CALL shelving_setParking(vParam, vParkingFk); ELSE - -- Por descarte, se considera una matrícula - CALL vn.shelving_setParking(vParam, vParkingFk); + CALL util.throw('paramNotExist'); END IF; + + COMMIT; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -72760,14 +73140,14 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_add` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_add`( vClientId INT @@ -72835,6 +73215,8 @@ BEGIN IF (vZoneFk IS NULL OR vZoneFk = 0) AND vIsRequiredZone THEN CALL util.throw ('NOT_ZONE_WITH_THIS_PARAMETERS'); END IF; + + DROP TEMPORARY TABLE tmp.zoneGetShipped; END IF; INSERT INTO ticket ( @@ -73236,14 +73618,14 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_checkNoComponents` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_checkNoComponents`(vShippedFrom DATETIME, vShippedTo DATETIME) BEGIN @@ -73266,7 +73648,8 @@ BEGIN JOIN itemCategory ic ON ic.id = tp.categoryFk JOIN saleComponent sc ON sc.saleFk = s.id JOIN component c ON c.id = sc.componentFk - JOIN componentType ct ON ct.id = c.typeFk AND ct.id = 1 + JOIN componentType ct ON ct.id = c.typeFk + AND ct.code = 'cost' WHERE t.shipped BETWEEN vShippedFrom AND vShippedTo AND ic.merchandise; @@ -73664,7 +74047,7 @@ BEGIN END; END LOOP; CLOSE rsTicket; - DROP TEMPORARY TABLE IF EXISTS tmp.time; + DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -73726,14 +74109,14 @@ BEGIN t.shipped, IFNULL(a.hasDailyInvoice, co.hasDailyInvoice), w.isManaged, - c.hasToInvoice + c.hasToInvoice INTO vClientFk, vIsTaxDataChecked, vCompanyFk, vShipped, vHasDailyInvoice, vWithPackage, - vHasToInvoice + vHasToInvoice FROM ticket t JOIN `client` c ON c.id = t.clientFk JOIN province p ON p.id = c.provinceFk @@ -73746,8 +74129,12 @@ BEGIN (SELECT vCurTicketFk, p.id, COUNT(*) FROM expedition e JOIN packaging p ON p.id = e.packagingFk + JOIN ticket t ON t.id = e.ticketFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable AND vWithPackage + AND NOT dm.`code`= 'PICKUP' GROUP BY p.itemFk); -- No retornables o no catalogados @@ -74066,14 +74453,14 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_DelayTruck`(vWarehouserFk IN BEGIN DECLARE done INT DEFAULT FALSE; DECLARE vTicketFk INT; - DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tmp.ticket; + DECLARE cur1 CURSOR FOR SELECT ticketFk FROM tTicket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; CALL vn.productionControl(vWarehouserFk,0) ; - DROP TEMPORARY TABLE IF EXISTS tmp.ticket; - CREATE TEMPORARY TABLE tmp.ticket + DROP TEMPORARY TABLE IF EXISTS tTicket; + CREATE TEMPORARY TABLE tTicket SELECT ticketFk FROM tmp.productionBuffer JOIN alertLevel al ON al.code = 'FREE' @@ -74094,6 +74481,7 @@ BEGIN END LOOP; CLOSE cur1; + DROP TEMPORARY TABLE tTicket, tmp.productionBuffer; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -74344,7 +74732,7 @@ BEGIN JOIN vn.componentType ct ON ct.id = c.typeFk JOIN vn.sale s ON s.id = sc.saleFk JOIN tmp.ticket t ON t.ticketFk = s.ticketFk - WHERE ct.code = 'FREIGHT' + WHERE ct.code = 'freight' GROUP BY t.ticketFk) sb ON sb.ticketFk = tf.ticketFk SET tf.freight = sb.freight; @@ -74366,7 +74754,7 @@ BEGIN -- Margin UPDATE tmp.ticketFloramondo tf - JOIN (SELECT SUM(IF(ct.code = 'COST',sc.value, 0)) cost, + JOIN (SELECT SUM(IF(ct.code = 'cost',sc.value, 0)) cost, SUM(IF(ct.isMargin, sc.value, 0)) margin, t.ticketFk FROM vn.saleComponent sc @@ -75228,25 +75616,32 @@ DELIMITER ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `ticket_setNextState` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setNextState`(vSelf INT) +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setNextState`( + vSelf INT +) BEGIN /** - * Cambia el estado del ticket al siguiente estado según la tabla state + * Cambia el estado del ticket al siguiente estado según la tabla state. * - * @param vSelf id dle ticket + * @param vSelf Id ticket */ DECLARE vStateFk INT; DECLARE vNewStateFk INT; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + SELECT stateFk INTO vStateFk FROM ticketState WHERE ticketFk = vSelf; @@ -75255,6 +75650,10 @@ BEGIN FROM state WHERE id = vStateFk; + IF vNewStateFk IS NULL THEN + CALL util.throw('The ticket not have next state'); + END IF; + INSERT INTO ticketTracking(stateFk, ticketFk, userFk) VALUES (vNewStateFk, vSelf, account.myUser_getId()); END ;; @@ -75273,13 +75672,16 @@ DELIMITER ; /*!50003 SET character_set_results = utf8mb4 */ ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; -CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setParking`(IN `vTicketFk` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setParking`( + vSelf INT, + vParkingFk INT +) +BEGIN /** - * Aparca un ticket en un parking + * Aparca un ticket en un parking. * - * @param vTicketFk id del ticket - * @param vParkingFk id del parking + * @param vSelf Id ticket + * @param vParkingFk Id parking */ DECLARE vDone INT DEFAULT FALSE; DECLARE vCollectionTicketFk INT; @@ -75288,16 +75690,21 @@ proc: BEGIN FROM ticket t LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk - WHERE t.id = vTicketFk; + WHERE t.id = vSelf; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + RESIGNAL; + END; + INSERT INTO vn.ticketParking(ticketFk, parkingFk) SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk FROM ticket t LEFT JOIN ticketCollection tc1 ON tc1.ticketFk = t.id LEFT JOIN ticketCollection tc2 ON tc2.collectionFk = tc1.collectionFk - WHERE t.id = vTicketFk + WHERE t.id = vSelf ON DUPLICATE KEY UPDATE parkingFk = vParkingFk; OPEN vCursor; @@ -75378,17 +75785,35 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_setProblem`( ) BEGIN /** - * Update column ticket.problem with a problem code + * Update column ticket.problem with a problem code and SET NULL when + * the problem is not requiered * * @param vProblemCode Code to set or unset - * @table tmp.ticket(ticketFk, hasProblem) + * @table tmp.ticket(ticketFk, hasProblem, isProblemCalcNeeded) */ - UPDATE ticket t - JOIN tmp.ticket tt ON tt.ticketFk = t.id - SET t.problem = CONCAT( - IF(tt.hasProblem, - CONCAT(problem, ',', vProblemCode), - REPLACE(problem, vProblemCode , ''))); + DECLARE vTicketFk INT; + DECLARE vHasProblem INT; + DECLARE vDone BOOL; + DECLARE vTicketList CURSOR FOR SELECT ticketFk, hasProblem FROM tmp.ticket; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTicketList; + l: LOOP + SET vDone = FALSE; + FETCH vTicketList INTO vTicketFk, vHasProblem; + + IF vDone THEN + LEAVE l; + END IF; + + UPDATE ticket + SET problem = CONCAT( + IF(vHasProblem, + CONCAT(problem, ',', vProblemCode), + REPLACE(problem, vProblemCode , ''))) + WHERE id = vTicketFk; + END LOOP; + CLOSE vTicketList; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75415,9 +75840,11 @@ BEGIN * @param vClientFk Id Cliente, if NULL all clients */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem + SELECT t.id ticketFk, + FALSE hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM ticket t WHERE t.shipped >= util.VN_CURDATE() AND (vClientFk IS NULL OR t.clientFk = vClientFk); @@ -75427,7 +75854,7 @@ BEGIN JOIN client c ON c.id = ti.clientFk SET t.hasProblem = TRUE WHERE c.isFreezed; - + CALL ticket_setProblem('isFreezed'); DROP TEMPORARY TABLE tmp.ticket; @@ -75457,9 +75884,11 @@ BEGIN * @param vSelf Id ticket, if NULL ALL tickets */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem + SELECT t.id ticketFk, + FALSE hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM ticket t WHERE t.shipped >= util.VN_CURDATE() AND (vSelf IS NULL OR t.id = vSelf); @@ -75499,21 +75928,30 @@ BEGIN */ DECLARE vHasRisk BOOL; DECLARE vHasHighRisk BOOL; + DECLARE vIsProblemCalcNeeded BOOL; - SELECT t.risk > (c.credit + 10), ((t.risk - cc.riskTolerance) > (c.credit + 10)) - INTO vHasRisk, vHasHighRisk + SELECT t.risk > (c.credit + 10), + (t.risk - cc.riskTolerance) > (c.credit + 10), + ticket_isProblemCalcNeeded(t.id) + INTO vHasRisk, vHasHighRisk, vIsProblemCalcNeeded FROM client c JOIN ticket t ON t.clientFk = c.id JOIN clientConfig cc WHERE t.id = vSelf; CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf ticketFk, vHasRisk hasProblem; + ENGINE = MEMORY + SELECT vSelf ticketFk, + vHasRisk hasProblem, + vIsProblemCalcNeeded isProblemCalcNeeded; CALL ticket_setProblem('hasRisk'); CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf ticketFk, vHasHighRisk hasProblem; + ENGINE = MEMORY + SELECT vSelf ticketFk, + vHasHighRisk hasProblem, + vIsProblemCalcNeeded isProblemCalcNeeded; CALL ticket_setProblem('hasHighRisk'); @@ -75553,8 +75991,11 @@ BEGIN CALL buyUltimate(vWarehouseFk, vDated); - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk, isProblemCalcNeeded)) + SELECT s.id saleFk , + MOD(s.quantity, b.`grouping`) hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM ticket t JOIN sale s ON s.ticketFk = t.id JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk @@ -75590,9 +76031,11 @@ BEGIN * @param vClientFk Id cliente, if NULL all clients */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem + SELECT t.id ticketFk, + IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM ticket t JOIN client c ON c.id = t.clientFk WHERE t.shipped >= util.VN_CURDATE() @@ -75626,14 +76069,18 @@ BEGIN * * @param vSelf Id del ticket */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - SELECT vSelf ticketFk, ticket_isTooLittle(vSelf) hasProblem; + SELECT vSelf ticketFk, + ticket_isTooLittle(vSelf) hasProblem, + ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded; CALL ticket_setProblem('isTooLittle'); DROP TEMPORARY TABLE tmp.ticket; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -75661,7 +76108,7 @@ BEGIN * @param vItemFk Id del item, NULL ALL items */ CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) + (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY WITH tickets AS( SELECT t.id ticketFk @@ -75670,7 +76117,9 @@ BEGIN WHERE t.shipped >= util.VN_CURDATE() AND (s.itemFk = vItemFk OR vItemFk IS NULL) GROUP BY t.id - )SELECT ticketFk, ticket_isTooLittle(ticketFk) hasProblem + )SELECT ticketFk, + ticket_isTooLittle(ticketFk) hasProblem, + ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded FROM tickets; CALL ticket_setProblem('isTooLittle'); @@ -75701,6 +76150,7 @@ BEGIN * @param vClientFk Id cliente */ DECLARE vHasDebt BOOL; + DECLARE vStarted DATETIME; SELECT COUNT(*) INTO vHasDebt FROM `client` @@ -75709,22 +76159,24 @@ BEGIN IF vHasDebt THEN + SELECT util.VN_CURDATE() - INTERVAL riskScope MONTH INTO vStarted + FROM clientConfig; + CREATE OR REPLACE TEMPORARY TABLE tTicketRisk (KEY (ticketFk)) ENGINE = MEMORY WITH ticket AS( - SELECT id ticketFk, companyFk, DATE(shipped) dated - FROM vn.ticket t + SELECT id ticketFk, + companyFk, + DATE(shipped) dated, + totalWithVat, + ticket_isProblemCalcNeeded(id) isProblemCalcNeeded + FROM vn.ticket WHERE clientFk = vClientFk AND refFk IS NULL AND NOT isDeleted - AND totalWithoutVat <> 0 - ), dated AS( - SELECT t.companyFk, MIN(DATE(t.dated) - INTERVAL cc.riskScope MONTH) started, - MAX(DATE(t.dated)) ended - FROM ticket t - JOIN vn.clientConfig cc - GROUP BY t.companyFk + AND IFNULL(totalWithVat, 0) <> 0 + AND shipped > vStarted ), balance AS( SELECT SUM(amount)amount, companyFk FROM ( @@ -75742,15 +76194,11 @@ BEGIN WHERE companyFk GROUP BY companyFk ), uninvoiced AS( - SELECT t.companyFk, DATE(t.shipped) dated, SUM(IFNULL(t.totalWithVat, 0)) amount - FROM vn.ticket t - JOIN dated d - WHERE t.clientFk = vClientFk - AND t.refFk IS NULL - AND t.shipped BETWEEN d.started AND d.ended - GROUP BY t.companyFk, DATE(t.shipped) + SELECT companyFk, dated, SUM(totalWithVat) amount + FROM ticket + GROUP BY companyFk, dated ), receipt AS( - SELECT companyFk,DATE(payed) dated, SUM(amountPaid) amount + SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount FROM vn.receipt WHERE clientFk = vClientFk AND payed > util.VN_CURDATE() @@ -75766,13 +76214,21 @@ BEGIN LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk GROUP BY b.companyFk, ui.dated ) - SELECT ti.ticketFk, r.amount + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded FROM ticket ti JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk; UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = tr.amount; + SET t.risk = tr.amount + WHERE tr.isProblemCalcNeeded + ORDER BY t.id; + + UPDATE ticket t + JOIN tTicketRisk tr ON tr.ticketFk = t.id + SET t.risk = NULL + WHERE tr.isProblemCalcNeeded + ORDER BY t.id; DROP TEMPORARY TABLE tTicketRisk; END IF; @@ -75951,60 +76407,80 @@ DELIMITER ; /*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; DELIMITER ;; CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_splitItemPackingType`( - vTicketFk INT, - vOriginalItemPackingTypeFk VARCHAR(1) + vSelf INT, + vItemPackingTypeFk VARCHAR(1) ) BEGIN /** * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. * Respeta el id inicial para el tipo propuesto. * - * @param vTicketFk Identificador de vn.ticket - * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original + * @param vSelf Id ticket + * @param vItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; DECLARE vPackingTypesToSplit INT; DECLARE vDone INT DEFAULT FALSE; + DECLARE vErrorNumber INT; + DECLARE vErrorMsg TEXT; - DECLARE cur1 CURSOR FOR + DECLARE vSaleGroup CURSOR FOR SELECT itemPackingTypeFk - FROM tmp.saleGroup + FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; + ORDER BY (itemPackingTypeFk = vItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN + GET DIAGNOSTICS CONDITION 1 + vErrorNumber = MYSQL_ERRNO, + vErrorMsg = MESSAGE_TEXT; + + CALL util.debugAdd('ticket_splitItemPackingType', JSON_OBJECT( + 'errorNumber', vErrorNumber, + 'errorMsg', vErrorMsg, + 'ticketFk', vSelf + )); -- Tmp + ROLLBACK; RESIGNAL; END; - DELETE FROM vn.sale - WHERE quantity = 0 - AND ticketFk = vTicketFk; + START TRANSACTION; - CREATE OR REPLACE TEMPORARY TABLE tmp.sale + SELECT id + FROM sale + WHERE ticketFk = vSelf + AND NOT quantity + FOR UPDATE; + + DELETE FROM sale + WHERE NOT quantity + AND ticketFk = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tSale (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT s.id, i.itemPackingTypeFk , IFNULL(sv.litros, 0) litros - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN vn.saleVolume sv ON sv.saleFk = s.id - WHERE s.ticketFk = vTicketFk; + SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros + FROM sale s + JOIN item i ON i.id = s.itemFk + LEFT JOIN saleVolume sv ON sv.saleFk = s.id + WHERE s.ticketFk = vSelf; - CREATE OR REPLACE TEMPORARY TABLE tmp.saleGroup + CREATE OR REPLACE TEMPORARY TABLE tSaleGroup ENGINE = MEMORY SELECT itemPackingTypeFk, SUM(litros) totalLitros - FROM tmp.sale + FROM tSale GROUP BY itemPackingTypeFk; SELECT COUNT(*) INTO vPackingTypesToSplit - FROM tmp.saleGroup + FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT ( + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( ticketFk INT, itemPackingTypeFk VARCHAR(1) ) ENGINE = MEMORY; @@ -76012,56 +76488,64 @@ BEGIN CASE vPackingTypesToSplit WHEN 0 THEN INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vTicketFk, vItemPackingTypeFk); + VALUES(vSelf, vItemPackingTypeFk); WHEN 1 THEN INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - SELECT vTicketFk, itemPackingTypeFk - FROM tmp.saleGroup + SELECT vSelf, itemPackingTypeFk + FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL; ELSE - OPEN cur1; - - FETCH cur1 INTO vItemPackingTypeFk; + OPEN vSaleGroup; + FETCH vSaleGroup INTO vItemPackingTypeFk; INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vTicketFk, vItemPackingTypeFk); + VALUES(vSelf, vItemPackingTypeFk); - read_loop: LOOP - FETCH cur1 INTO vItemPackingTypeFk; + l: LOOP + SET vDone = FALSE; + FETCH vSaleGroup INTO vItemPackingTypeFk; IF vDone THEN - LEAVE read_loop; + LEAVE l; END IF; - CALL vn.ticket_Clone(vTicketFk, vNewTicketFk); + CALL ticket_Clone(vSelf, vNewTicketFk); INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) VALUES(vNewTicketFk, vItemPackingTypeFk); END LOOP; - CLOSE cur1; + CLOSE vSaleGroup; - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id + SELECT s.id + FROM sale s + JOIN tSale ts ON ts.id = s.id + JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk + FOR UPDATE; + + UPDATE sale s + JOIN tSale ts ON ts.id = s.id JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk SET s.ticketFk = t.ticketFk; SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tmp.saleGroup sg + FROM tSaleGroup sg WHERE sg.itemPackingTypeFk IS NOT NULL ORDER BY sg.itemPackingTypeFk LIMIT 1; - UPDATE vn.sale s - JOIN tmp.sale ts ON ts.id = s.id + UPDATE sale s + JOIN tSale ts ON ts.id = s.id JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk SET s.ticketFk = t.ticketFk WHERE ts.itemPackingTypeFk IS NULL; END CASE; + COMMIT; + DROP TEMPORARY TABLE - tmp.sale, - tmp.saleGroup; + tSale, + tSaleGroup; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -79671,6 +80155,8 @@ BEGIN */ DECLARE vLastIn DATETIME ; DECLARE vIsMiddleOdd BOOLEAN ; + DECLARE vMailTo VARCHAR(50) DEFAULT NULL; + DECLARE vUserName VARCHAR(50) DEFAULT NULL; IF (vTimed IS NULL) THEN SET vTimed = util.VN_NOW(); @@ -79719,6 +80205,19 @@ BEGIN VALUES('in', NULL); END IF; + IF (SELECT option1 IS NULL AND option2 IS NULL FROM tmp.workerTimeControlDirection) THEN + SELECT CONCAT(u.name, '@verdnatura.es'), CONCAT(w.firstName, ' ', w.lastName) + INTO vMailTo, vUserName + FROM account.user u + JOIN worker w ON w.bossFk = u.id + WHERE w.id = vWorkerFk; + + CALL mail_insert( + vMailTo, + vMailTo, + 'Error al fichar', + CONCAT(vUserName, ' tiene problemas para fichar')); + END IF; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -80670,19 +81169,6 @@ BEGIN * identificando y notificando los asientos descuadrados * y ajustando los saldos en caso necesario. */ - INSERT INTO mail (receiver, subject, body) - SELECT 'cau@verdnatura.es', - 'Asientos descuadrados', - GROUP_CONCAT(CONCAT(' Asiento: ', ASIEN, ' - Importe:', recon) SEPARATOR ' | \n') - FROM ( - SELECT ASIEN, - SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0)) recon - FROM XDiario - WHERE NOT enlazado - GROUP BY ASIEN - HAVING ABS(SUM(IFNULL(ROUND(Eurodebe, 2), 0)) - SUM(IFNULL(ROUND(EUROHABER, 2), 0))) > 0.01 - ) sub - HAVING COUNT(*); UPDATE XDiario xd JOIN ( @@ -81462,7 +81948,8 @@ BEGIN DROP TEMPORARY TABLE geoCollision, tmp.zone, - tmp.zoneNodes; + tmp.zoneNodes, + tmp.zoneOption; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -83166,16 +83653,11 @@ SET character_set_client = utf8; 1 AS `Id_Trabajador`, 1 AS `life`, 1 AS `isPackaging`, - 1 AS `density`, 1 AS `inventory`, 1 AS `odbc_date`, 1 AS `confeccion`, 1 AS `Temperatura`, - 1 AS `promo`, - 1 AS `maneuver`, - 1 AS `target`, - 1 AS `top_margin`, - 1 AS `profit` */; + 1 AS `promo` */; SET character_set_client = @saved_cs_client; -- @@ -83654,8 +84136,7 @@ SET character_set_client = utf8; 1 AS `packingOut`, 1 AS `itemOriginalFk`, 1 AS `itemOriginalName`, - 1 AS `gramsMax`, - 1 AS `minQuantity` */; + 1 AS `gramsMax` */; SET character_set_client = @saved_cs_client; -- @@ -83668,7 +84149,6 @@ SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE VIEW `buy_edi` AS SELECT 1 AS `id`, - 1 AS `barcode`, 1 AS `entry_year`, 1 AS `delivery_number`, 1 AS `fec`, @@ -85241,7 +85721,7 @@ USE `bi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `tarifa_componentes_series` AS select `ct`.`id` AS `tarifa_componentes_series_id`,`ct`.`type` AS `Serie`,`ct`.`isBase` AS `base`,`ct`.`isMargin` AS `margen` from `vn`.`componentType` `ct` */; +/*!50001 VIEW `tarifa_componentes_series` AS select `ct`.`id` AS `tarifa_componentes_series_id`,`ct`.`name` AS `Serie`,`ct`.`isBase` AS `base`,`ct`.`isMargin` AS `margen` from `vn`.`componentType` `ct` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -85373,7 +85853,7 @@ USE `edi`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ektRecent` AS select `e`.`id` AS `id`,`e`.`barcode` AS `barcode`,`e`.`entryYear` AS `entryYear`,`e`.`batchNumber` AS `batchNumber`,`e`.`deliveryNumber` AS `deliveryNumber`,`e`.`vendorOrderNumber` AS `vendorOrderNumber`,`e`.`fec` AS `fec`,`e`.`hor` AS `hor`,`e`.`now` AS `now`,`e`.`ptj` AS `ptj`,`e`.`ref` AS `ref`,`e`.`item` AS `item`,`e`.`pac` AS `pac`,`e`.`qty` AS `qty`,`e`.`ori` AS `ori`,`e`.`cat` AS `cat`,`e`.`agj` AS `agj`,`e`.`kop` AS `kop`,`e`.`ptd` AS `ptd`,`e`.`sub` AS `sub`,`e`.`pro` AS `pro`,`e`.`pri` AS `pri`,`e`.`package` AS `package`,`e`.`auction` AS `auction`,`e`.`klo` AS `klo`,`e`.`k1` AS `k1`,`e`.`k2` AS `k2`,`e`.`k3` AS `k3`,`e`.`k4` AS `k4`,`e`.`s1` AS `s1`,`e`.`s2` AS `s2`,`e`.`s3` AS `s3`,`e`.`s4` AS `s4`,`e`.`s5` AS `s5`,`e`.`s6` AS `s6`,`e`.`ok` AS `ok`,`e`.`trolleyFk` AS `trolleyFk`,`e`.`putOrderFk` AS `putOrderFk`,`e`.`scanned` AS `scanned`,`e`.`cps` AS `cps`,`e`.`dp` AS `dp`,`e`.`sender` AS `sender`,`ec`.`usefulAuctionLeftSegmentLength` AS `usefulAuctionLeftSegmentLength`,`ec`.`standardBarcodeLength` AS `standardBarcodeLength`,`ec`.`floridayBarcodeLength` AS `floridayBarcodeLength`,`ec`.`floramondoBarcodeLength` AS `floramondoBarcodeLength`,`ec`.`defaultKlo` AS `defaultKlo`,`ec`.`ektRecentScopeDays` AS `ektRecentScopeDays` from (`ekt` `e` join `ektConfig` `ec`) where `e`.`entryYear` = year(`util`.`VN_CURDATE`()) and `e`.`fec` >= `util`.`VN_CURDATE`() + interval -`ec`.`ektRecentScopeDays` day */; +/*!50001 VIEW `ektRecent` AS select `e`.`id` AS `id`,`e`.`entryYear` AS `entryYear`,`e`.`batchNumber` AS `batchNumber`,`e`.`deliveryNumber` AS `deliveryNumber`,`e`.`vendorOrderNumber` AS `vendorOrderNumber`,`e`.`fec` AS `fec`,`e`.`hor` AS `hor`,`e`.`now` AS `now`,`e`.`ptj` AS `ptj`,`e`.`ref` AS `ref`,`e`.`item` AS `item`,`e`.`pac` AS `pac`,`e`.`qty` AS `qty`,`e`.`ori` AS `ori`,`e`.`cat` AS `cat`,`e`.`agj` AS `agj`,`e`.`kop` AS `kop`,`e`.`ptd` AS `ptd`,`e`.`sub` AS `sub`,`e`.`pro` AS `pro`,`e`.`pri` AS `pri`,`e`.`package` AS `package`,`e`.`auction` AS `auction`,`e`.`klo` AS `klo`,`e`.`k1` AS `k1`,`e`.`k2` AS `k2`,`e`.`k3` AS `k3`,`e`.`k4` AS `k4`,`e`.`s1` AS `s1`,`e`.`s2` AS `s2`,`e`.`s3` AS `s3`,`e`.`s4` AS `s4`,`e`.`s5` AS `s5`,`e`.`s6` AS `s6`,`e`.`ok` AS `ok`,`e`.`trolleyFk` AS `trolleyFk`,`e`.`putOrderFk` AS `putOrderFk`,`e`.`scanned` AS `scanned`,`e`.`cps` AS `cps`,`e`.`dp` AS `dp`,`e`.`sender` AS `sender`,`ec`.`usefulAuctionLeftSegmentLength` AS `usefulAuctionLeftSegmentLength`,`ec`.`standardBarcodeLength` AS `standardBarcodeLength`,`ec`.`floridayBarcodeLength` AS `floridayBarcodeLength`,`ec`.`floramondoBarcodeLength` AS `floramondoBarcodeLength`,`ec`.`defaultKlo` AS `defaultKlo`,`ec`.`ektRecentScopeDays` AS `ektRecentScopeDays` from (`ekt` `e` join `ektConfig` `ec`) where `e`.`entryYear` = year(`util`.`VN_CURDATE`()) and `e`.`fec` >= `util`.`VN_CURDATE`() + interval -`ec`.`ektRecentScopeDays` day */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87533,7 +88013,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `saleCost` AS select `s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`discount` AS `discount`,`s`.`price` AS `price`,`c`.`name` AS `component`,`sc`.`value` AS `coste` from (((`sale` `s` join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk`)) where `ct`.`type` = 'coste' */; +/*!50001 VIEW `saleCost` AS select `s`.`itemFk` AS `itemFk`,`s`.`ticketFk` AS `ticketFk`,`s`.`concept` AS `concept`,`s`.`quantity` AS `quantity`,`s`.`discount` AS `discount`,`s`.`price` AS `price`,`c`.`name` AS `component`,`sc`.`value` AS `coste` from (((`sale` `s` join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk`)) where `ct`.`code` = 'cost' */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87659,7 +88139,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,`sc`.`value` * `s`.`quantity` AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on(`t`.`id` = `s`.`ticketFk`)) join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk` and `ct`.`type` = 'agencia')) */; +/*!50001 VIEW `sale_freightComponent` AS select `t`.`id` AS `ticketFk`,`sc`.`value` * `s`.`quantity` AS `amount`,`t`.`shipped` AS `shipped` from ((((`ticket` `t` straight_join `sale` `s` on(`t`.`id` = `s`.`ticketFk`)) join `saleComponent` `sc` on(`sc`.`saleFk` = `s`.`id`)) join `component` `c` on(`c`.`id` = `sc`.`componentFk`)) join `componentType` `ct` on(`ct`.`id` = `c`.`typeFk` and `ct`.`code` = 'freight')) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -88835,7 +89315,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `Tipos` AS select `it`.`id` AS `tipo_id`,`it`.`code` AS `Id_Tipo`,`it`.`name` AS `Tipo`,`it`.`order` AS `Orden`,`it`.`categoryFk` AS `reino_id`,`it`.`workerFk` AS `Id_Trabajador`,`it`.`life` AS `life`,`it`.`isPackaging` AS `isPackaging`,`it`.`density` AS `density`,`it`.`isInventory` AS `inventory`,`it`.`created` AS `odbc_date`,`it`.`making` AS `confeccion`,`it`.`temperatureFk` AS `Temperatura`,`it`.`promo` AS `promo`,`it`.`maneuver` AS `maneuver`,`it`.`target` AS `target`,`it`.`topMargin` AS `top_margin`,`it`.`profit` AS `profit` from `vn`.`itemType` `it` */; +/*!50001 VIEW `Tipos` AS select `it`.`id` AS `tipo_id`,`it`.`code` AS `Id_Tipo`,`it`.`name` AS `Tipo`,`it`.`order` AS `Orden`,`it`.`categoryFk` AS `reino_id`,`it`.`workerFk` AS `Id_Trabajador`,`it`.`life` AS `life`,`it`.`isPackaging` AS `isPackaging`,`it`.`isInventory` AS `inventory`,`it`.`created` AS `odbc_date`,`it`.`making` AS `confeccion`,`it`.`temperatureFk` AS `Temperatura`,`it`.`promo` AS `promo` from `vn`.`itemType` `it` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89267,7 +89747,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `buySource` AS select `b`.`entryFk` AS `Id_Entrada`,`b`.`isPickedOff` AS `isPickedOff`,NULL AS `tarifa0`,`e`.`kop` AS `kop`,`b`.`id` AS `Id_Compra`,`i`.`typeFk` AS `tipo_id`,`b`.`itemFk` AS `Id_Article`,`i`.`size` AS `Medida`,`i`.`stems` AS `Tallos`,`b`.`stickers` AS `Etiquetas`,`b`.`packagingFk` AS `Id_Cubo`,`b`.`buyingValue` AS `Costefijo`,`b`.`packing` AS `Packing`,`b`.`grouping` AS `Grouping`,`b`.`quantity` AS `Cantidad`,`b`.`price2` AS `Tarifa2`,`b`.`price3` AS `Tarifa3`,`b`.`isChecked` AS `Punteo`,`b`.`groupingMode` AS `Caja`,`i`.`isToPrint` AS `Imprimir`,`i`.`name` AS `Article`,`vn`.`ink`.`picture` AS `Tinta`,`i`.`originFk` AS `id_origen`,`i`.`minPrice` AS `PVP`,NULL AS `Id_Accion`,`s`.`company_name` AS `pro`,`i`.`hasMinPrice` AS `Min`,`b`.`isIgnored` AS `Novincular`,`b`.`freightValue` AS `Portefijo`,round(`b`.`buyingValue` * `b`.`quantity`,2) AS `Importe`,`b`.`printedStickers` AS `Vida`,`i`.`comment` AS `reference`,`b`.`workerFk` AS `Id_Trabajador`,`e`.`s1` AS `S1`,`e`.`s2` AS `S2`,`e`.`s3` AS `S3`,`e`.`s4` AS `S4`,`e`.`s5` AS `S5`,`e`.`s6` AS `S6`,0 AS `price_fixed`,`i`.`producerFk` AS `producer_id`,`i`.`subName` AS `tag1`,`i`.`value5` AS `tag2`,`i`.`value6` AS `tag3`,`i`.`value7` AS `tag4`,`i`.`value8` AS `tag5`,`i`.`value9` AS `tag6`,`i`.`value10` AS `tag7`,`s`.`company_name` AS `company_name`,`b`.`weight` AS `weightPacking`,`i`.`packingOut` AS `packingOut`,`b`.`itemOriginalFk` AS `itemOriginalFk`,`io`.`longName` AS `itemOriginalName`,`it`.`gramsMax` AS `gramsMax`,`i`.`minQuantity` AS `minQuantity` from ((((((`vn`.`item` `i` join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) left join `vn`.`ink` on(`vn`.`ink`.`id` = `i`.`inkFk`)) left join `vn`.`buy` `b` on(`b`.`itemFk` = `i`.`id`)) left join `vn`.`item` `io` on(`io`.`id` = `b`.`itemOriginalFk`)) left join `edi`.`ekt` `e` on(`e`.`id` = `b`.`ektFk`)) left join `edi`.`supplier` `s` on(`e`.`pro` = `s`.`supplier_id`)) */; +/*!50001 VIEW `buySource` AS select `b`.`entryFk` AS `Id_Entrada`,`b`.`isPickedOff` AS `isPickedOff`,NULL AS `tarifa0`,`e`.`kop` AS `kop`,`b`.`id` AS `Id_Compra`,`i`.`typeFk` AS `tipo_id`,`b`.`itemFk` AS `Id_Article`,`i`.`size` AS `Medida`,`i`.`stems` AS `Tallos`,`b`.`stickers` AS `Etiquetas`,`b`.`packagingFk` AS `Id_Cubo`,`b`.`buyingValue` AS `Costefijo`,`b`.`packing` AS `Packing`,`b`.`grouping` AS `Grouping`,`b`.`quantity` AS `Cantidad`,`b`.`price2` AS `Tarifa2`,`b`.`price3` AS `Tarifa3`,`b`.`isChecked` AS `Punteo`,`b`.`groupingMode` AS `Caja`,`i`.`isToPrint` AS `Imprimir`,`i`.`name` AS `Article`,`vn`.`ink`.`picture` AS `Tinta`,`i`.`originFk` AS `id_origen`,`i`.`minPrice` AS `PVP`,NULL AS `Id_Accion`,`s`.`company_name` AS `pro`,`i`.`hasMinPrice` AS `Min`,`b`.`isIgnored` AS `Novincular`,`b`.`freightValue` AS `Portefijo`,round(`b`.`buyingValue` * `b`.`quantity`,2) AS `Importe`,`b`.`printedStickers` AS `Vida`,`i`.`comment` AS `reference`,`b`.`workerFk` AS `Id_Trabajador`,`e`.`s1` AS `S1`,`e`.`s2` AS `S2`,`e`.`s3` AS `S3`,`e`.`s4` AS `S4`,`e`.`s5` AS `S5`,`e`.`s6` AS `S6`,0 AS `price_fixed`,`i`.`producerFk` AS `producer_id`,`i`.`subName` AS `tag1`,`i`.`value5` AS `tag2`,`i`.`value6` AS `tag3`,`i`.`value7` AS `tag4`,`i`.`value8` AS `tag5`,`i`.`value9` AS `tag6`,`i`.`value10` AS `tag7`,`s`.`company_name` AS `company_name`,`b`.`weight` AS `weightPacking`,`i`.`packingOut` AS `packingOut`,`b`.`itemOriginalFk` AS `itemOriginalFk`,`io`.`longName` AS `itemOriginalName`,`it`.`gramsMax` AS `gramsMax` from ((((((`vn`.`item` `i` join `vn`.`itemType` `it` on(`it`.`id` = `i`.`typeFk`)) left join `vn`.`ink` on(`vn`.`ink`.`id` = `i`.`inkFk`)) left join `vn`.`buy` `b` on(`b`.`itemFk` = `i`.`id`)) left join `vn`.`item` `io` on(`io`.`id` = `b`.`itemOriginalFk`)) left join `edi`.`ekt` `e` on(`e`.`id` = `b`.`ektFk`)) left join `edi`.`supplier` `s` on(`e`.`pro` = `s`.`supplier_id`)) */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89285,7 +89765,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `buy_edi` AS select `t`.`id` AS `id`,`t`.`barcode` AS `barcode`,`t`.`entryYear` AS `entry_year`,`t`.`deliveryNumber` AS `delivery_number`,`t`.`fec` AS `fec`,`t`.`hor` AS `hor`,`t`.`now` AS `now`,`t`.`ptj` AS `ptj`,`t`.`ref` AS `ref`,`t`.`item` AS `item`,`t`.`pac` AS `pac`,`t`.`qty` AS `qty`,`t`.`ori` AS `ori`,`t`.`cat` AS `cat`,`t`.`agj` AS `agj`,`t`.`kop` AS `kop`,`t`.`ptd` AS `ptd`,`t`.`sub` AS `sub`,`t`.`pro` AS `pro`,`t`.`pri` AS `pri`,`t`.`package` AS `package`,`t`.`auction` AS `auction`,`t`.`klo` AS `klo`,`t`.`k1` AS `k01`,`t`.`k2` AS `k02`,`t`.`k3` AS `k03`,`t`.`k4` AS `k04`,`t`.`s1` AS `s1`,`t`.`s2` AS `s2`,`t`.`s3` AS `s3`,`t`.`s4` AS `s4`,`t`.`s5` AS `s5`,`t`.`s6` AS `s6`,`t`.`ok` AS `ok`,`t`.`trolleyFk` AS `trolley_id`,`t`.`putOrderFk` AS `putOrderFk`,`t`.`scanned` AS `scanned` from `edi`.`ekt` `t` */; +/*!50001 VIEW `buy_edi` AS select `t`.`id` AS `id`,`t`.`entryYear` AS `entry_year`,`t`.`deliveryNumber` AS `delivery_number`,`t`.`fec` AS `fec`,`t`.`hor` AS `hor`,`t`.`now` AS `now`,`t`.`ptj` AS `ptj`,`t`.`ref` AS `ref`,`t`.`item` AS `item`,`t`.`pac` AS `pac`,`t`.`qty` AS `qty`,`t`.`ori` AS `ori`,`t`.`cat` AS `cat`,`t`.`agj` AS `agj`,`t`.`kop` AS `kop`,`t`.`ptd` AS `ptd`,`t`.`sub` AS `sub`,`t`.`pro` AS `pro`,`t`.`pri` AS `pri`,`t`.`package` AS `package`,`t`.`auction` AS `auction`,`t`.`klo` AS `klo`,`t`.`k1` AS `k01`,`t`.`k2` AS `k02`,`t`.`k3` AS `k03`,`t`.`k4` AS `k04`,`t`.`s1` AS `s1`,`t`.`s2` AS `s2`,`t`.`s3` AS `s3`,`t`.`s4` AS `s4`,`t`.`s5` AS `s5`,`t`.`s6` AS `s6`,`t`.`ok` AS `ok`,`t`.`trolleyFk` AS `trolley_id`,`t`.`putOrderFk` AS `putOrderFk`,`t`.`scanned` AS `scanned` from `edi`.`ekt` `t` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -90559,4 +91039,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-07-09 5:48:04 +-- Dump completed on 2024-07-23 8:19:18 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 41525b2eb..1b92f0d43 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -175,6 +175,70 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAliasAccount_beforeInsert` + BEFORE INSERT ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAliasAccount_beforeUpdate` + BEFORE UPDATE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailAliasAccount_afterDelete` + AFTER DELETE ON `mailAliasAccount` + FOR EACH ROW +BEGIN + INSERT INTO userLog + SET `action` = 'delete', + `changedModel` = 'MailAliasAccount', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `account`.`mailForward_beforeInsert` BEFORE INSERT ON `mailForward` FOR EACH ROW @@ -4084,29 +4148,22 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeInsert` BEFORE INSERT ON `delivery` FOR EACH ROW BEGIN - - IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -4116,29 +4173,22 @@ DELIMITER ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb3 */ ; -/*!50003 SET character_set_results = utf8mb3 */ ; -/*!50003 SET collation_connection = utf8mb3_general_ci */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`delivery_beforeUpdate` BEFORE UPDATE ON `delivery` FOR EACH ROW BEGIN - -IF (NEW.longitude IS NOT NULL AND NEW.latitude IS NOT NULL AND NEW.ticketFK IS NOT NULL) + IF (NEW.longitude IS NOT NULL + AND NEW.latitude IS NOT NULL + AND NEW.ticketFK IS NOT NULL) THEN - UPDATE address - SET longitude = NEW.longitude, - latitude = NEW.latitude - WHERE id IN ( - SELECT addressFK - FROM ticket - WHERE id = NEW.ticketFk - ); + CALL address_updateCoordinates(NEW.ticketFk, NEW.longitude, NEW.latitude); END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6176,6 +6226,72 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_beforeInsert` + BEFORE INSERT ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_beforeUpdate` + BEFORE UPDATE ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); + CALL itemMinimumQuantity_check(NEW.id, NEW.itemFk, NEW.started, NEW.ended, NEW.warehouseFk); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemMinimumQuantity_afterDelete` + AFTER DELETE ON `itemMinimumQuantity` + FOR EACH ROW +BEGIN + INSERT INTO itemLog + SET `action` = 'delete', + `changedModel` = 'ItemMinimumQuantity', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeInsert` BEFORE INSERT ON `itemShelving` FOR EACH ROW @@ -6309,6 +6425,30 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterDelete` + AFTER DELETE ON `itemShelving` + FOR EACH ROW +BEGIN + INSERT INTO shelvingLog + SET `action` = 'delete', + `changedModel` = 'itemShelving', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelvingSale_afterInsert` AFTER INSERT ON `itemShelvingSale` FOR EACH ROW @@ -7162,6 +7302,70 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`productionConfig_beforeInsert` + BEFORE INSERT ON `productionConfig` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`productionConfig_beforeUpdate` + BEFORE UPDATE ON `productionConfig` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`productionConfig_afterDelete` + AFTER DELETE ON `productionConfig` + FOR EACH ROW +BEGIN + INSERT INTO productionConfig + SET `action` = 'delete', + `changedModel` = 'ProductionConfig', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); +END */;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `vn`.`projectNotes_beforeInsert` BEFORE INSERT ON `projectNotes` FOR EACH ROW @@ -10939,4 +11143,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-07-09 5:48:24 +-- Dump completed on 2024-07-23 8:19:41 From eb413af275e73df25ede6787d0719b9c630b0be5 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 10:48:12 +0200 Subject: [PATCH 113/181] hotFix: collection assign --- back/methods/collection/assign.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/collection/assign.js b/back/methods/collection/assign.js index 9abeb46f5..718cd48c5 100644 --- a/back/methods/collection/assign.js +++ b/back/methods/collection/assign.js @@ -26,7 +26,7 @@ module.exports = Self => { `, [userId], myOptions); // Por si entra en el SELECT FOR UPDATE y retorna un array más - const collectionFk = result[2][0]?.collectionFk || result[3][0]?.collectionFk; + const collectionFk = result[2]?.[0]?.collectionFk || result[3]?.[0]?.collectionFk; if (!collectionFk) throw new UserError('There are not picking tickets'); await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions); From e35ded5e354024b40e7e7da801239317d43da57a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 11:01:57 +0200 Subject: [PATCH 114/181] hotFix: add summaryId to productionConfigLog & agencyLog --- db/versions/11164-turquoiseRoebelini/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11164-turquoiseRoebelini/00-firstScript.sql diff --git a/db/versions/11164-turquoiseRoebelini/00-firstScript.sql b/db/versions/11164-turquoiseRoebelini/00-firstScript.sql new file mode 100644 index 000000000..be45d9e95 --- /dev/null +++ b/db/versions/11164-turquoiseRoebelini/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.productionConfigLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); +ALTER TABLE vn.agencyLog ADD COLUMN IF NOT EXISTS summaryId varchar(30); From bfc2d6f73422069c16d746db10fc4d6165d99209 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 23 Jul 2024 11:38:05 +0200 Subject: [PATCH 115/181] feat: refs #7716 travel_setDelivered --- db/routines/vn/events/travel_setDelivered.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/routines/vn/events/travel_setDelivered.sql diff --git a/db/routines/vn/events/travel_setDelivered.sql b/db/routines/vn/events/travel_setDelivered.sql new file mode 100644 index 000000000..769ee9d24 --- /dev/null +++ b/db/routines/vn/events/travel_setDelivered.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`travel_setDelivered` + ON SCHEDULE EVERY 1 DAY + STARTS '2024-07-12 00:10:00.000' + ON COMPLETION PRESERVE + ENABLE +DO BEGIN + UPDATE travel t + SET t.isDelivered = TRUE + WHERE t.shipped < util.VN_CURDATE(); +END$$ +DELIMITER ; From 80b338228ebc85d65719d726ac208a25320c55a9 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 23 Jul 2024 12:29:08 +0200 Subject: [PATCH 116/181] fix: refs #6403 take observation from ticket --- back/methods/mrw-config/createShipment.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 4db0d0c7d..8a0eb58b3 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -53,7 +53,7 @@ module.exports = Self => { CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, LPAD(IF(mw.serviceType IS NULL, ms.serviceType, mw.serviceType), mc.serviceTypeWidth, '0') serviceType, IF(mw.weekdays, 'S', 'N') weekDays, - oa.description deliveryObservation + ta.description deliveryObservation FROM expedition e JOIN ticket t ON e.ticketFk = t.id JOIN agencyMode am ON am.id = t.agencyModeFk @@ -62,8 +62,8 @@ module.exports = Self => { AND mw.weekDays & (1 << WEEKDAY(t.landed)) JOIN client c ON t.clientFk = c.id JOIN address a ON t.addressFk = a.id - LEFT JOIN addressObservation oa ON oa.addressFk = a.id - AND oa.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery') + LEFT JOIN ticketObservation ta ON ta.ticketFk = t.id + AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery') JOIN province p ON a.provinceFk = p.id JOIN country co ON co.id = p.countryFk JOIN mrwConfig mc From 88724d6d8c4810ea9b798b030466e53df3984ad5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 13:08:49 +0200 Subject: [PATCH 117/181] fix: refs #7505 visible_refresh support warehouse null --- db/routines/cache/procedures/visible_refresh.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/cache/procedures/visible_refresh.sql b/db/routines/cache/procedures/visible_refresh.sql index 78d23dbfb..e1b40ec10 100644 --- a/db/routines/cache/procedures/visible_refresh.sql +++ b/db/routines/cache/procedures/visible_refresh.sql @@ -22,7 +22,7 @@ proc:BEGIN ENGINE = MEMORY SELECT item_id, amount stock, amount visible FROM cache.stock - WHERE warehouse_id = v_warehouse; + WHERE (warehouse_id IS NULL OR warehouse_id = v_warehouse); -- Calculamos los movimientos confirmados de hoy CALL vn.item_calcVisible(NULL, v_warehouse); From bdfaf02c959bfaa95ee4d31994e8f08fc729bf13 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 23 Jul 2024 13:36:52 +0200 Subject: [PATCH 118/181] fix: refs #6403 fix delivery observation --- back/methods/mrw-config/createShipment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 8a0eb58b3..3b91f4486 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -63,7 +63,7 @@ module.exports = Self => { JOIN client c ON t.clientFk = c.id JOIN address a ON t.addressFk = a.id LEFT JOIN ticketObservation ta ON ta.ticketFk = t.id - AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'delivery') + AND ta.observationTypeFk IN (SELECT id FROM observationType ot WHERE ot.code = 'agency') JOIN province p ON a.provinceFk = p.id JOIN country co ON co.id = p.countryFk JOIN mrwConfig mc From eb18bd2400ccd0e27d721b41c297803b84dfebd3 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 13:57:14 +0200 Subject: [PATCH 119/181] fix: without path --- front/salix/routes.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/front/salix/routes.js b/front/salix/routes.js index ee3a9cd10..37247d93f 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -5,6 +5,8 @@ config.$inject = ['$stateProvider', '$urlRouterProvider']; function config($stateProvider, $urlRouterProvider) { $urlRouterProvider .otherwise(async($injector, {$location}) => { + if (!$location.$$path) return window.location.href = '/#!/'; + const url = $location.$$absUrl .replace('5000', '9000') .replace('salix', 'lilium') From 5d2e9c6210bf511990848b98637e7272ffaf2d7b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 13:59:36 +0200 Subject: [PATCH 120/181] fix: refs #7505 visible_refresh support warehouse null and added isComparative --- .../cache/procedures/visible_refresh.sql | 5 +-- .../vn/procedures/item_calcVisible.sql | 36 +++++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/db/routines/cache/procedures/visible_refresh.sql b/db/routines/cache/procedures/visible_refresh.sql index e1b40ec10..053da1d14 100644 --- a/db/routines/cache/procedures/visible_refresh.sql +++ b/db/routines/cache/procedures/visible_refresh.sql @@ -20,9 +20,10 @@ proc:BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible (PRIMARY KEY (item_id)) ENGINE = MEMORY - SELECT item_id, amount stock, amount visible + SELECT item_id, SUM(amount) stock, SUM(amount) visible FROM cache.stock - WHERE (warehouse_id IS NULL OR warehouse_id = v_warehouse); + WHERE (v_warehouse IS NULL OR warehouse_id = v_warehouse) + GROUP BY item_id; -- Calculamos los movimientos confirmados de hoy CALL vn.item_calcVisible(NULL, v_warehouse); diff --git a/db/routines/vn/procedures/item_calcVisible.sql b/db/routines/vn/procedures/item_calcVisible.sql index 820e73a7e..2ce663d80 100644 --- a/db/routines/vn/procedures/item_calcVisible.sql +++ b/db/routines/vn/procedures/item_calcVisible.sql @@ -21,6 +21,8 @@ BEGIN FROM itemTicketOut i LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk JOIN `state` s ON s.id = ts.stateFk + JOIN warehouse w ON w.id = i.warehouseFk + AND w.isComparative LEFT JOIN ( SELECT DISTINCT st.saleFk FROM saleTracking st @@ -28,26 +30,30 @@ BEGIN WHERE st.created > vDated AND (s.isPicked OR st.isChecked) ) stPrevious ON `stPrevious`.`saleFk` = i.saleFk - WHERE IFNULL(vWarehouseFk, i.warehouseFk) = i.warehouseFk + WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk) AND (vSelf IS NULL OR i.itemFk = vSelf) AND (s.isPicked OR i.reserved OR stPrevious.saleFk) AND i.shipped >= vDated AND i.shipped < vTomorrow UNION ALL - SELECT itemFk, quantity - FROM itemEntryIn - WHERE isReceived - AND landed >= vDated AND landed < vTomorrow - AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk - AND (vSelf IS NULL OR itemFk = vSelf) - AND NOT isVirtualStock + SELECT iei.itemFk, iei.quantity + FROM itemEntryIn iei + JOIN warehouse w ON w.id = iei.warehouseInFk + AND w.isComparative + WHERE iei.isReceived + AND iei.landed >= vDated AND iei.landed < vTomorrow + AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk) + AND (vSelf IS NULL OR iei.itemFk = vSelf) + AND NOT iei.isVirtualStock UNION ALL - SELECT itemFk, quantity - FROM itemEntryOut - WHERE isDelivered - AND shipped >= vDated - AND shipped < vTomorrow - AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk - AND (vSelf IS NULL OR itemFk = vSelf) + SELECT ieo.itemFk, ieo.quantity + FROM itemEntryOut ieo + JOIN warehouse w ON w.id = ieo.warehouseOutFk + AND w.isComparative + WHERE ieo.isDelivered + AND ieo.shipped >= vDated + AND ieo.shipped < vTomorrow + AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk) + AND (vSelf IS NULL OR ieo.itemFk = vSelf) ) t GROUP BY itemFk ON DUPLICATE KEY UPDATE From a9aa47fef1aa194145cbe93260a2618ec365702b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 14:17:01 +0200 Subject: [PATCH 121/181] fix: refs #7505 visible_refresh support warehouse null and added isComparative --- db/routines/cache/procedures/visible_refresh.sql | 10 ++++++---- db/routines/vn/procedures/item_calcVisible.sql | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/db/routines/cache/procedures/visible_refresh.sql b/db/routines/cache/procedures/visible_refresh.sql index 053da1d14..d7c5c3738 100644 --- a/db/routines/cache/procedures/visible_refresh.sql +++ b/db/routines/cache/procedures/visible_refresh.sql @@ -20,10 +20,12 @@ proc:BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible (PRIMARY KEY (item_id)) ENGINE = MEMORY - SELECT item_id, SUM(amount) stock, SUM(amount) visible - FROM cache.stock - WHERE (v_warehouse IS NULL OR warehouse_id = v_warehouse) - GROUP BY item_id; + SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible + FROM cache.stock s + JOIN warehouse w ON w.id = s.warehouse_id + WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse) + AND w.isComparative + GROUP BY s.item_id; -- Calculamos los movimientos confirmados de hoy CALL vn.item_calcVisible(NULL, v_warehouse); diff --git a/db/routines/vn/procedures/item_calcVisible.sql b/db/routines/vn/procedures/item_calcVisible.sql index 2ce663d80..32adfdfa3 100644 --- a/db/routines/vn/procedures/item_calcVisible.sql +++ b/db/routines/vn/procedures/item_calcVisible.sql @@ -22,7 +22,6 @@ BEGIN LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk JOIN `state` s ON s.id = ts.stateFk JOIN warehouse w ON w.id = i.warehouseFk - AND w.isComparative LEFT JOIN ( SELECT DISTINCT st.saleFk FROM saleTracking st @@ -34,26 +33,27 @@ BEGIN AND (vSelf IS NULL OR i.itemFk = vSelf) AND (s.isPicked OR i.reserved OR stPrevious.saleFk) AND i.shipped >= vDated AND i.shipped < vTomorrow + AND w.isComparative UNION ALL SELECT iei.itemFk, iei.quantity FROM itemEntryIn iei JOIN warehouse w ON w.id = iei.warehouseInFk - AND w.isComparative WHERE iei.isReceived AND iei.landed >= vDated AND iei.landed < vTomorrow AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk) AND (vSelf IS NULL OR iei.itemFk = vSelf) AND NOT iei.isVirtualStock + AND w.isComparative UNION ALL SELECT ieo.itemFk, ieo.quantity FROM itemEntryOut ieo JOIN warehouse w ON w.id = ieo.warehouseOutFk - AND w.isComparative WHERE ieo.isDelivered AND ieo.shipped >= vDated AND ieo.shipped < vTomorrow AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk) AND (vSelf IS NULL OR ieo.itemFk = vSelf) + AND w.isComparative ) t GROUP BY itemFk ON DUPLICATE KEY UPDATE From abfbf13440deec47bfb63e6e3eec84454099cf2a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 23 Jul 2024 14:18:52 +0200 Subject: [PATCH 122/181] fix: refs #7505 fix --- db/routines/cache/procedures/visible_refresh.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/cache/procedures/visible_refresh.sql b/db/routines/cache/procedures/visible_refresh.sql index d7c5c3738..a673969d2 100644 --- a/db/routines/cache/procedures/visible_refresh.sql +++ b/db/routines/cache/procedures/visible_refresh.sql @@ -21,8 +21,8 @@ proc:BEGIN (PRIMARY KEY (item_id)) ENGINE = MEMORY SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible - FROM cache.stock s - JOIN warehouse w ON w.id = s.warehouse_id + FROM stock s + JOIN vn.warehouse w ON w.id = s.warehouse_id WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse) AND w.isComparative GROUP BY s.item_id; From 4f321340017a13f0fdbd0325b656c31aa532d808 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 14:19:20 +0200 Subject: [PATCH 123/181] add prefix --- front/salix/routes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/front/salix/routes.js b/front/salix/routes.js index 37247d93f..2c6f1b848 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -5,12 +5,13 @@ config.$inject = ['$stateProvider', '$urlRouterProvider']; function config($stateProvider, $urlRouterProvider) { $urlRouterProvider .otherwise(async($injector, {$location}) => { - if (!$location.$$path) return window.location.href = '/#!/'; + const prefix = '#!'; + if (!$location.$$path) return window.location.href = `/${prefix}/`; const url = $location.$$absUrl .replace('5000', '9000') .replace('salix', 'lilium') - .replace('#!', '#') + .replace(prefix, '#') .replace('client', 'customer'); window.location.href = url; }); From 1a3ed42bcde938b670e273f4779ecef36ce9e27b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 14:37:34 +0200 Subject: [PATCH 124/181] fix: defaulter filter correct sql --- modules/client/back/methods/defaulter/filter.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 0bfa7659b..40756b236 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -85,6 +85,7 @@ module.exports = Self => { LEFT JOIN ( SELECT MAX(started), clientFk, finished FROM recovery + GROUP BY clientFk ) r ON r.clientFk = c.id LEFT JOIN workerDepartment wd ON wd.workerFk = u.id JOIN department dp ON dp.id = wd.departmentFk From 2086746eb058780714ade871828392edf39e6c16 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Jul 2024 07:34:52 +0200 Subject: [PATCH 125/181] fix: refs #7505 Visible COM --- db/routines/vn/procedures/multipleInventory.sql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index 6cd584c6e..dc34f040e 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -75,13 +75,6 @@ proc: BEGIN ) sub GROUP BY itemFk; - UPDATE tmp.itemInventory ai - JOIN tItemInventoryCalc iic ON iic.itemFk = ai.id - SET ai.inventory = iic.quantity, - ai.visible = iic.quantity, - ai.avalaible = iic.quantity, - ai.sd = iic.quantity; - -- Cálculo del visible CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); @@ -93,8 +86,12 @@ proc: BEGIN WHERE calc_id = vCalcFk; UPDATE tmp.itemInventory it + JOIN tItemInventoryCalc iic ON iic.itemFk = it.id JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id - SET it.visible = it.visible + ivc.visible; + SET it.inventory = iic.quantity, + it.visible = ivc.visible, + it.avalaible = iic.quantity, + it.sd = iic.quantity; -- Calculo del disponible CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc From 0c51a97a17ae13d98804824e7635c1d80b7aa28c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Jul 2024 09:13:47 +0200 Subject: [PATCH 126/181] refactor: refs #7640 Multipleinventory available --- .../vn/procedures/multipleInventory.sql | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index dc34f040e..582baf4dd 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -139,31 +139,35 @@ proc: BEGIN CALL item_getAtp(vDate); CALL travel_upcomingArrivals(vWarehouseFk, vDate); - UPDATE tmp.itemInventory ai - JOIN ( - SELECT it.itemFk, - SUM(it.quantity) quantity, - im.quantity minQuantity - FROM tmp.itemCalc it - JOIN tmp.itemAtp im ON im.itemFk = it.itemFk - JOIN item i ON i.id = it.itemFk - LEFT JOIN origin o ON o.id = i.originFk - LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk - WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, - t.landing, - vDateToTomorrow) - GROUP BY it.itemFk - ) sub ON sub.itemFk = ai.id - SET ai.avalaible = IF(sub.minQuantity > 0, - ai.avalaible, - ai.avalaible + sub.minQuantity), - ai.sd = ai.inventory + sub.quantity; + CREATE OR REPLACE TEMPORARY TABLE tItemAvailableCalc + (PRIMARY KEY (itemFk)) + ENGINE = MEMORY + SELECT it.itemFk, + SUM(it.quantity) quantity, + im.quantity minQuantity + FROM tmp.itemCalc it + JOIN tmp.itemAtp im ON im.itemFk = it.itemFk + JOIN item i ON i.id = it.itemFk + LEFT JOIN origin o ON o.id = i.originFk + LEFT JOIN tmp.itemTravel t ON t.wh = o.warehouseFk + WHERE it.dated < IF(vMaxDays < 0 AND t.landing IS NOT NULL, + t.landing, + vDateToTomorrow) + GROUP BY it.itemFk; + + UPDATE tmp.itemInventory it + JOIN tItemAvailableCalc iac ON iac.itemFk = it.id + SET it.avalaible = IF(iac.minQuantity > 0, + it.avalaible, + it.avalaible + iac.minQuantity), + it.sd = it.inventory + iac.quantity; DROP TEMPORARY TABLE tmp.itemTravel, tmp.itemCalc, tmp.itemAtp, tItemInventoryCalc, - tItemVisibleCalc; + tItemVisibleCalc, + tItemAvailableCalc; END$$ DELIMITER ; From db31ac3b60660e557186b65f38364c82eba14dfd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Jul 2024 09:39:33 +0200 Subject: [PATCH 127/181] fix: refs #7662 ticket_splitItemPackingType --- db/routines/vn/procedures/ticket_splitItemPackingType.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index c2ec50fd9..5ae9fb9bc 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_splitItemPackingType`( vSelf INT, - vItemPackingTypeFk VARCHAR(1) + vOriginalItemPackingTypeFk VARCHAR(1) ) BEGIN /** @@ -9,7 +9,7 @@ BEGIN * Respeta el id inicial para el tipo propuesto. * * @param vSelf Id ticket - * @param vItemPackingTypeFk Tipo para el que se reserva el número de ticket original + * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; @@ -23,7 +23,7 @@ BEGIN SELECT itemPackingTypeFk FROM tSaleGroup WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vItemPackingTypeFk) DESC; + ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; From c0664fd1af1abcd29a3df04bd5fd6d2abd388ecf Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Jul 2024 10:05:29 +0200 Subject: [PATCH 128/181] hotFix_liliumRedirection --- front/salix/routes.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/front/salix/routes.js b/front/salix/routes.js index be210b749..2c6f1b848 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -4,7 +4,17 @@ import getMainRoute from 'core/lib/get-main-route'; config.$inject = ['$stateProvider', '$urlRouterProvider']; function config($stateProvider, $urlRouterProvider) { $urlRouterProvider - .otherwise('/'); + .otherwise(async($injector, {$location}) => { + const prefix = '#!'; + if (!$location.$$path) return window.location.href = `/${prefix}/`; + + const url = $location.$$absUrl + .replace('5000', '9000') + .replace('salix', 'lilium') + .replace(prefix, '#') + .replace('client', 'customer'); + window.location.href = url; + }); $stateProvider .state('layout', { From e3f4cd293f9c643afd42fc8158e164a878715e31 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Jul 2024 10:07:44 +0200 Subject: [PATCH 129/181] hotFix: liliumRedirection --- front/salix/routes.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/front/salix/routes.js b/front/salix/routes.js index be210b749..2c6f1b848 100644 --- a/front/salix/routes.js +++ b/front/salix/routes.js @@ -4,7 +4,17 @@ import getMainRoute from 'core/lib/get-main-route'; config.$inject = ['$stateProvider', '$urlRouterProvider']; function config($stateProvider, $urlRouterProvider) { $urlRouterProvider - .otherwise('/'); + .otherwise(async($injector, {$location}) => { + const prefix = '#!'; + if (!$location.$$path) return window.location.href = `/${prefix}/`; + + const url = $location.$$absUrl + .replace('5000', '9000') + .replace('salix', 'lilium') + .replace(prefix, '#') + .replace('client', 'customer'); + window.location.href = url; + }); $stateProvider .state('layout', { From ebac41603448d2af178184563f4f34835b6b4b66 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Jul 2024 12:03:47 +0200 Subject: [PATCH 130/181] remove console.log --- back/methods/mrw-config/cancelShipment.js | 1 - 1 file changed, 1 deletion(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 0efd00874..56d206529 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -37,7 +37,6 @@ module.exports = Self => { }); const xmlString = response.data; - console.log('xmlString: ', xmlString); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; From 808c09643f6fa1fae611a131fc16c38c44700e32 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Jul 2024 12:05:26 +0200 Subject: [PATCH 131/181] remove console.log --- back/methods/mrw-config/cancelShipment.js | 1 - 1 file changed, 1 deletion(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 0efd00874..56d206529 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -37,7 +37,6 @@ module.exports = Self => { }); const xmlString = response.data; - console.log('xmlString: ', xmlString); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; From de7b4dc9d607764bd66879204f390607be44122e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 24 Jul 2024 10:08:01 +0000 Subject: [PATCH 132/181] fix: missing fields --- modules/entry/back/methods/entry/getBuys.js | 32 +++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 3a4d5cc47..bd9c5db7a 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -50,6 +50,7 @@ module.exports = Self => { 'stickers', 'packing', 'grouping', + 'packing', 'groupingMode', 'quantity', 'packagingFk', @@ -79,7 +80,9 @@ module.exports = Self => { fields: [ 'id', 'typeFk', + 'stems', 'name', + 'category', 'subName', 'size', 'minPrice', @@ -95,14 +98,31 @@ module.exports = Self => { 'value9', 'tag10', 'value10', - 'groupingMode' + 'groupingMode', + 'inkFk', + 'originFk', + 'producerFk' ], - include: { - relation: 'itemType', - scope: { - fields: ['code', 'description'] + include: [ + { + relation: 'itemType', + scope: { + fields: ['code', 'description'] + } + }, + { + relation: 'origin', + scope: { + fields: ['code'] + } + }, + { + relation: 'producer', + scope: { + fields: ['name'] + } } - } + ] } }] }; From bc9fe220d5fa306af7f75fe93d016154e2058f95 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 24 Jul 2024 12:38:27 +0200 Subject: [PATCH 133/181] fix: refs #6403 remove console log --- modules/ticket/back/methods/expedition/deleteExpeditions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index d7a090b00..75993a485 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -53,7 +53,6 @@ module.exports = Self => { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); } catch (e) { - console.log('e: ', e); notDeletedExpeditions.push(expeditionId); } } From 983d66a681e7d0918ac8d12f30be907ebac57647 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Jul 2024 14:24:06 +0200 Subject: [PATCH 134/181] feat: refs #7728 Added throw due date --- db/routines/vn/procedures/duaInvoiceInBooking.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 10c0714e5..80166db62 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -12,6 +12,7 @@ BEGIN DECLARE vInvoiceFk INT; DECLARE vBookEntry INT; DECLARE vFiscalYear INT; + DECLARE vIncorrectInvoiceInDueDay INT; DECLARE vInvoicesIn CURSOR FOR SELECT DISTINCT e.invoiceInFk @@ -24,6 +25,19 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + SELECT GROUP_CONCAT(ii.id) INTO vIncorrectInvoiceInDueDay + FROM invoiceInDueDay iidd + JOIN invoiceIn ii ON iidd.invoiceInFk = ii.id + JOIN `entry` e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN invoiceInConfig iic + WHERE de.duaFk = vDuaFk + AND iidd.dueDated <= util.VN_CURDATE() + INTERVAL iic.dueDateMarginDays DAY; + + IF vIncorrectInvoiceInDueDay THEN + CALL util.throw(CONCAT('Incorrect due date, invoice: ', vIncorrectInvoiceInDueDay)); + END IF; + UPDATE invoiceIn ii JOIN entry e ON e.invoiceInFk = ii.id JOIN duaEntry de ON de.entryFk = e.id From 1639f7155e5cb841a57e50bd15435ebe0dcc2a6f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 25 Jul 2024 07:21:01 +0200 Subject: [PATCH 135/181] fix: refs #7640 multipleInventory --- db/routines/vn/procedures/multipleInventory.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/multipleInventory.sql b/db/routines/vn/procedures/multipleInventory.sql index dc34f040e..6c5320399 100644 --- a/db/routines/vn/procedures/multipleInventory.sql +++ b/db/routines/vn/procedures/multipleInventory.sql @@ -86,8 +86,8 @@ proc: BEGIN WHERE calc_id = vCalcFk; UPDATE tmp.itemInventory it - JOIN tItemInventoryCalc iic ON iic.itemFk = it.id - JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id + LEFT JOIN tItemInventoryCalc iic ON iic.itemFk = it.id + LEFT JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id SET it.inventory = iic.quantity, it.visible = ivc.visible, it.avalaible = iic.quantity, From 2374711a882aa21907d528857d5a4bd36cae09a1 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 25 Jul 2024 08:36:14 +0200 Subject: [PATCH 136/181] hotFix itemShelvingSale_addBySale refs #6861 --- db/routines/vn/procedures/itemShelvingSale_addBySale.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 757f880f9..454ea877f 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -98,6 +98,7 @@ proc: BEGIN itemShelvingFk, saleFk, quantity, + userFk, isPicked) SELECT vItemShelvingFk, vSaleFk, From af62c2e8071f31a12ade906b3a2e98bc5eb8aa94 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 25 Jul 2024 08:57:18 +0200 Subject: [PATCH 137/181] fix: refs #7664 No insert editorFk --- db/versions/11168-redFern/00-firstScript.sql | 2 ++ modules/worker/back/models/calendar.json | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 db/versions/11168-redFern/00-firstScript.sql diff --git a/db/versions/11168-redFern/00-firstScript.sql b/db/versions/11168-redFern/00-firstScript.sql new file mode 100644 index 000000000..f91780e37 --- /dev/null +++ b/db/versions/11168-redFern/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.calendar + ADD CONSTRAINT calendar_user_FK FOREIGN KEY (editorFk) REFERENCES account.`user`(id); diff --git a/modules/worker/back/models/calendar.json b/modules/worker/back/models/calendar.json index 40d29c519..4c68c7793 100644 --- a/modules/worker/back/models/calendar.json +++ b/modules/worker/back/models/calendar.json @@ -1,9 +1,8 @@ { "name": "Calendar", "base": "VnModel", - "log": { - "model": "WorkerLog", - "relation": "labour" + "mixins": { + "Loggable": true }, "options": { "mysql": { From 81120df4e4c080f2e02a5844d014fefdf72da292 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 25 Jul 2024 09:57:56 +0200 Subject: [PATCH 138/181] feat: refs #6403 default mobile --- back/methods/mrw-config/createShipment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/mrw-config/createShipment.js b/back/methods/mrw-config/createShipment.js index 3b91f4486..2ebb80774 100644 --- a/back/methods/mrw-config/createShipment.js +++ b/back/methods/mrw-config/createShipment.js @@ -47,7 +47,7 @@ module.exports = Self => { co.code countryCode, c.fi, c.name clientName, - a.mobile, + IFNULL(a.mobile, c.mobile) mobile, DATE_FORMAT(t.shipped, '%d/%m/%Y') created, t.shipped, CONCAT( e.ticketFk, LPAD(e.counter, mc.counterWidth, '0')) reference, From 6661cb4c2ae6b137936360cdf058f98e1272c8dc Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 25 Jul 2024 12:30:18 +0200 Subject: [PATCH 139/181] fix: refs #7654 itemShelving --- db/versions/11169-azureCyca/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11169-azureCyca/00-firstScript.sql diff --git a/db/versions/11169-azureCyca/00-firstScript.sql b/db/versions/11169-azureCyca/00-firstScript.sql new file mode 100644 index 000000000..49adcfc05 --- /dev/null +++ b/db/versions/11169-azureCyca/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE IF EXISTS vn.itemShelving +MODIFY COLUMN IF EXISTS isSplit tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Este valor cambia al splitar un carro que se ha quedado en holanda'; From 7254abea40b0f5f2ddd9c98ac926acc2e47310cf Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 25 Jul 2024 12:49:23 +0200 Subject: [PATCH 140/181] feat(salix): #7648 Add args to filter shipped value --- modules/entry/back/methods/entry/filter.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index 5963e9c72..dcb1e3158 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -95,6 +95,16 @@ module.exports = Self => { type: 'date', description: `The to date filter` }, + { + arg: 'fromShipped', + type: 'date', + description: `The from shipped date filter` + }, + { + arg: 'toShipped', + type: 'date', + description: `The to shipped date filter` + }, { arg: 'days', type: 'number', @@ -133,8 +143,12 @@ module.exports = Self => { return {'e.created': {gte: value}}; case 'from': return {'t.landed': {gte: value}}; + case 'fromShipped': + return {'t.shipped': {gte: value}}; case 'to': return {'t.landed': {lte: value}}; + case 'toShipped': + return {'t.shipped': {lte: value}}; case 'id': case 'isBooked': case 'isConfirmed': From 9e18a208b27bb389ae765b8f5dad71e41db53aa1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 25 Jul 2024 13:26:45 +0200 Subject: [PATCH 141/181] fix: refs #7662 get value for proc with select for updates --- back/methods/collection/assign.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/back/methods/collection/assign.js b/back/methods/collection/assign.js index 718cd48c5..f246043b8 100644 --- a/back/methods/collection/assign.js +++ b/back/methods/collection/assign.js @@ -20,13 +20,14 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + const randStr = Math.random().toString(36).substring(3); const result = await Self.rawSql(` CALL vn.collection_assign(?, @vCollectionFk); - SELECT @vCollectionFk collectionFk - `, [userId], myOptions); + SELECT @vCollectionFk ? + `, [userId, randStr], myOptions); - // Por si entra en el SELECT FOR UPDATE y retorna un array más - const collectionFk = result[2]?.[0]?.collectionFk || result[3]?.[0]?.collectionFk; + // Por si entra en SELECT FOR UPDATE una o varias veces + const collectionFk = result.find(item => item[0]?.[randStr] !== undefined)?.[0]?.[randStr]; if (!collectionFk) throw new UserError('There are not picking tickets'); await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions); From cf84ce1337aab940e74599faf80f55c287421d2f Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 26 Jul 2024 09:38:49 +0200 Subject: [PATCH 142/181] feat: refs #7401 redirect lilium --- e2e/paths/08-route/01_summary.spec.js | 62 ---- e2e/paths/08-route/02_basic_data.spec.js | 42 --- .../08-route/03_create_and_clone.spec.js | 91 ------ e2e/paths/08-route/04_tickets.spec.js | 59 ---- .../front/agency-term-search-panel/index.html | 52 ---- .../front/agency-term-search-panel/index.js | 17 -- .../agency-term-search-panel/locale/es.yml | 2 - .../agency-term/createInvoiceIn/index.html | 108 ------- .../agency-term/createInvoiceIn/index.js | 120 -------- .../agency-term/createInvoiceIn/index.spec.js | 107 ------- .../agency-term/createInvoiceIn/style.scss | 7 - .../route/front/agency-term/index/index.html | 152 ---------- .../route/front/agency-term/index/index.js | 121 -------- .../front/agency-term/index/index.spec.js | 94 ------ modules/route/front/agency-term/locale/es.yml | 5 - modules/route/front/basic-data/index.html | 96 ------ modules/route/front/basic-data/index.js | 28 -- modules/route/front/basic-data/locale/es.yml | 8 - modules/route/front/card/index.html | 5 - modules/route/front/card/index.js | 71 ----- modules/route/front/create/index.html | 52 ---- modules/route/front/create/index.js | 20 -- modules/route/front/index.js | 13 - modules/route/front/index/index.html | 228 -------------- modules/route/front/index/index.js | 151 ---------- modules/route/front/index/index.spec.js | 156 ---------- modules/route/front/index/locale/es.yml | 13 - modules/route/front/locale/en.yml | 1 - modules/route/front/locale/es.yml | 5 - modules/route/front/log/index.html | 1 - modules/route/front/log/index.js | 7 - modules/route/front/main/index.html | 20 -- modules/route/front/main/index.js | 34 +-- modules/route/front/main/index.spec.js | 49 ---- .../route/front/roadmap/basic-data/index.html | 98 ------- .../route/front/roadmap/basic-data/index.js | 16 - modules/route/front/roadmap/card/index.html | 5 - modules/route/front/roadmap/card/index.js | 19 -- modules/route/front/roadmap/create/index.html | 37 --- modules/route/front/roadmap/create/index.js | 23 -- modules/route/front/roadmap/create/style.scss | 6 - .../route/front/roadmap/descriptor/index.html | 39 --- .../route/front/roadmap/descriptor/index.js | 26 -- .../front/roadmap/descriptor/locale/es.yml | 3 - modules/route/front/roadmap/index.js | 9 - modules/route/front/roadmap/index/index.html | 112 ------- modules/route/front/roadmap/index/index.js | 60 ---- .../route/front/roadmap/index/locale/es.yml | 3 - modules/route/front/roadmap/locale/es.yml | 14 - modules/route/front/roadmap/main/index.html | 20 -- modules/route/front/roadmap/main/index.js | 61 ---- .../route/front/roadmap/main/locale/es.yml | 1 - .../front/roadmap/search-panel/index.html | 74 ----- .../route/front/roadmap/search-panel/index.js | 7 - modules/route/front/roadmap/stops/index.html | 71 ----- modules/route/front/roadmap/stops/index.js | 39 --- .../route/front/roadmap/stops/locale/es.yml | 4 - .../route/front/roadmap/summary/index.html | 116 -------- modules/route/front/roadmap/summary/index.js | 68 ----- .../route/front/roadmap/summary/locale/es.yml | 3 - .../route/front/roadmap/summary/style.scss | 9 - modules/route/front/routes.json | 115 +------- modules/route/front/search-panel/index.html | 96 ------ modules/route/front/search-panel/index.js | 43 --- .../route/front/search-panel/index.spec.js | 48 --- modules/route/front/sms/index.html | 36 --- modules/route/front/sms/index.js | 47 --- modules/route/front/sms/index.spec.js | 71 ----- modules/route/front/sms/locale/es.yml | 9 - modules/route/front/sms/style.scss | 5 - modules/route/front/ticket-popup/index.html | 84 ------ modules/route/front/ticket-popup/index.js | 80 ----- .../route/front/ticket-popup/index.spec.js | 82 ------ modules/route/front/ticket-popup/style.scss | 5 - .../tickets/__snapshots__/index.spec.js.snap | 18 -- modules/route/front/tickets/index.html | 203 ------------- modules/route/front/tickets/index.js | 201 ------------- modules/route/front/tickets/index.spec.js | 277 ------------------ modules/route/front/tickets/locale/es.yml | 18 -- modules/route/front/tickets/style.scss | 16 - 80 files changed, 6 insertions(+), 4388 deletions(-) delete mode 100644 e2e/paths/08-route/01_summary.spec.js delete mode 100644 e2e/paths/08-route/02_basic_data.spec.js delete mode 100644 e2e/paths/08-route/03_create_and_clone.spec.js delete mode 100644 e2e/paths/08-route/04_tickets.spec.js delete mode 100644 modules/route/front/agency-term-search-panel/index.html delete mode 100644 modules/route/front/agency-term-search-panel/index.js delete mode 100644 modules/route/front/agency-term-search-panel/locale/es.yml delete mode 100644 modules/route/front/agency-term/createInvoiceIn/index.html delete mode 100644 modules/route/front/agency-term/createInvoiceIn/index.js delete mode 100644 modules/route/front/agency-term/createInvoiceIn/index.spec.js delete mode 100644 modules/route/front/agency-term/createInvoiceIn/style.scss delete mode 100644 modules/route/front/agency-term/index/index.html delete mode 100644 modules/route/front/agency-term/index/index.js delete mode 100644 modules/route/front/agency-term/index/index.spec.js delete mode 100644 modules/route/front/agency-term/locale/es.yml delete mode 100644 modules/route/front/basic-data/index.html delete mode 100644 modules/route/front/basic-data/index.js delete mode 100644 modules/route/front/basic-data/locale/es.yml delete mode 100644 modules/route/front/card/index.html delete mode 100644 modules/route/front/card/index.js delete mode 100644 modules/route/front/create/index.html delete mode 100644 modules/route/front/create/index.js delete mode 100644 modules/route/front/index/index.html delete mode 100644 modules/route/front/index/index.js delete mode 100644 modules/route/front/index/index.spec.js delete mode 100644 modules/route/front/index/locale/es.yml delete mode 100644 modules/route/front/locale/en.yml delete mode 100644 modules/route/front/locale/es.yml delete mode 100644 modules/route/front/log/index.html delete mode 100644 modules/route/front/log/index.js delete mode 100644 modules/route/front/main/index.spec.js delete mode 100644 modules/route/front/roadmap/basic-data/index.html delete mode 100644 modules/route/front/roadmap/basic-data/index.js delete mode 100644 modules/route/front/roadmap/card/index.html delete mode 100644 modules/route/front/roadmap/card/index.js delete mode 100644 modules/route/front/roadmap/create/index.html delete mode 100644 modules/route/front/roadmap/create/index.js delete mode 100644 modules/route/front/roadmap/create/style.scss delete mode 100644 modules/route/front/roadmap/descriptor/index.html delete mode 100644 modules/route/front/roadmap/descriptor/index.js delete mode 100644 modules/route/front/roadmap/descriptor/locale/es.yml delete mode 100644 modules/route/front/roadmap/index.js delete mode 100644 modules/route/front/roadmap/index/index.html delete mode 100644 modules/route/front/roadmap/index/index.js delete mode 100644 modules/route/front/roadmap/index/locale/es.yml delete mode 100644 modules/route/front/roadmap/locale/es.yml delete mode 100644 modules/route/front/roadmap/main/index.html delete mode 100644 modules/route/front/roadmap/main/index.js delete mode 100644 modules/route/front/roadmap/main/locale/es.yml delete mode 100644 modules/route/front/roadmap/search-panel/index.html delete mode 100644 modules/route/front/roadmap/search-panel/index.js delete mode 100644 modules/route/front/roadmap/stops/index.html delete mode 100644 modules/route/front/roadmap/stops/index.js delete mode 100644 modules/route/front/roadmap/stops/locale/es.yml delete mode 100644 modules/route/front/roadmap/summary/index.html delete mode 100644 modules/route/front/roadmap/summary/index.js delete mode 100644 modules/route/front/roadmap/summary/locale/es.yml delete mode 100644 modules/route/front/roadmap/summary/style.scss delete mode 100644 modules/route/front/search-panel/index.html delete mode 100644 modules/route/front/search-panel/index.js delete mode 100644 modules/route/front/search-panel/index.spec.js delete mode 100644 modules/route/front/sms/index.html delete mode 100644 modules/route/front/sms/index.js delete mode 100644 modules/route/front/sms/index.spec.js delete mode 100644 modules/route/front/sms/locale/es.yml delete mode 100644 modules/route/front/sms/style.scss delete mode 100644 modules/route/front/ticket-popup/index.html delete mode 100644 modules/route/front/ticket-popup/index.js delete mode 100644 modules/route/front/ticket-popup/index.spec.js delete mode 100644 modules/route/front/ticket-popup/style.scss delete mode 100644 modules/route/front/tickets/__snapshots__/index.spec.js.snap delete mode 100644 modules/route/front/tickets/index.html delete mode 100644 modules/route/front/tickets/index.js delete mode 100644 modules/route/front/tickets/index.spec.js delete mode 100644 modules/route/front/tickets/locale/es.yml delete mode 100644 modules/route/front/tickets/style.scss diff --git a/e2e/paths/08-route/01_summary.spec.js b/e2e/paths/08-route/01_summary.spec.js deleted file mode 100644 index 44f66ba2d..000000000 --- a/e2e/paths/08-route/01_summary.spec.js +++ /dev/null @@ -1,62 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Route summary path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'route'); - await page.waitToClick(selectors.routeIndex.previewButton); - await page.waitToClick(selectors.routeSummary.goToRouteSummaryButton); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the first route summary section', async() => { - await page.waitForState('route.card.summary'); - }); - - it(`should display details from the route on the header`, async() => { - await page.waitForTextInElement(selectors.routeSummary.header, 'first route'); - const result = await page.waitToGetProperty(selectors.routeSummary.header, 'innerText'); - - expect(result).toContain('first route'); - }); - - it('should display some route details like the cost', async() => { - const result = await page.waitToGetProperty(selectors.routeSummary.cost, 'innerText'); - - expect(result).toContain('€10.00'); - }); - - it('should click on the first ticket ID making the descriptor popover visible', async() => { - await page.waitForState('route.card.summary'); - await page.waitForTimeout(250); - await page.waitToClick(selectors.routeSummary.firstTicketID); - await page.waitForSelector(selectors.routeSummary.firstTicketDescriptor); - const visible = await page.isVisible(selectors.routeSummary.firstTicketDescriptor); - - expect(visible).toBe(true); - }); - - it('should close the ticket descriptor', async() => { - await page.closePopup(); - }); - - it('should click on the first alias making the client descriptor popover visible', async() => { - await page.waitToClick(selectors.routeSummary.firstAlias); - await page.waitForSelector(selectors.routeSummary.firstClientDescriptor); - const visible = await page.isVisible(selectors.routeSummary.firstClientDescriptor); - - expect(visible).toBe(true); - }); - - it('should close the client descriptor', async() => { - await page.closePopup(); - }); -}); diff --git a/e2e/paths/08-route/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js deleted file mode 100644 index 7ab7dda42..000000000 --- a/e2e/paths/08-route/02_basic_data.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -describe('Route basic Data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('delivery', 'route'); - await page.accessToSearchResult('1'); - await page.accessToSection('route.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the route basic data and confirm the route was edited', async() => { - const nextMonth = Date.vnNew(); - nextMonth.setMonth(nextMonth.getMonth() + 1); - nextMonth.setUTCHours(0, 0, 0, 0); - - const form = 'vn-route-basic-data form'; - const values = { - worker: 'adminBossNick', - vehicle: '1111-IMK', - created: nextMonth, - kmStart: 1, - kmEnd: 2, - started: '08:00', - finished: '12:30', - }; - - const message = await page.sendForm(form, values); - await page.reloadSection('route.card.basicData'); - const formValues = await page.fetchForm(form, Object.keys(values)); - - expect(message.isSuccess).toBeTrue(); - expect(formValues).toEqual(values); - }); -}); diff --git a/e2e/paths/08-route/03_create_and_clone.spec.js b/e2e/paths/08-route/03_create_and_clone.spec.js deleted file mode 100644 index 31c0cfc18..000000000 --- a/e2e/paths/08-route/03_create_and_clone.spec.js +++ /dev/null @@ -1,91 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Route create path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('employee', 'route'); - }); - - afterAll(async() => { - await browser.close(); - }); - - describe('as employee', () => { - it('should click on the add new route button and open the creation form', async() => { - await page.waitToClick(selectors.routeIndex.addNewRouteButton); - await page.waitForState('route.create'); - }); - - it(`should attempt to create a new route but fail since employee has no access rights`, async() => { - await page.write(selectors.createRouteView.description, 'faster faster!!'); - await page.waitToClick(selectors.createRouteView.submitButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Access Denied'); - }); - }); - - describe('as delivery', () => { - beforeAll(async() => { - await page.login('delivery'); - await page.selectModule('route'); - }); - - it('should again click on the add new route button and open the creation form', async() => { - await page.waitToClick(selectors.routeIndex.addNewRouteButton); - await page.waitForState('route.create'); - }); - - it(`should create a new route`, async() => { - await page.autocompleteSearch(selectors.createRouteView.worker, 'teamManagerNick'); - await page.pickDate(selectors.createRouteView.createdDatePicker); - await page.autocompleteSearch(selectors.createRouteView.vehicleAuto, '4444-IMK'); - await page.autocompleteSearch(selectors.createRouteView.agency, 'Teleportation device'); - await page.write(selectors.createRouteView.description, 'faster faster!!'); - await page.waitToClick(selectors.createRouteView.submitButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should confirm the redirection to the created route summary`, async() => { - await page.waitForState('route.card.summary'); - }); - - it(`should navigate back to the route index`, async() => { - await page.waitToClick(selectors.globalItems.returnToModuleIndexButton); - await page.waitForState('route.index'); - }); - - let count; - it(`should count the amount of routes before clonation`, async() => { - await page.waitForFunction(selector => { - return document.querySelectorAll(selector).length > 6; - }, {}, selectors.routeIndex.anyResult); - count = await page.countElement(selectors.routeIndex.anyResult); - - expect(count).toBeGreaterThanOrEqual(7); - }); - - it(`should clone the first route`, async() => { - await page.waitToClick(selectors.routeIndex.firstRouteCheckbox); - await page.waitToClick(selectors.routeIndex.cloneButton); - await page.waitToClick(selectors.routeIndex.submitClonationButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it(`should reload the section and count the amount of routes after clonation`, async() => { - await page.waitForNumberOfElements(selectors.routeIndex.anyResult, count + 1); - const result = await page.countElement(selectors.routeIndex.anyResult); - - expect(result).toEqual(count + 1); - }); - }); -}); diff --git a/e2e/paths/08-route/04_tickets.spec.js b/e2e/paths/08-route/04_tickets.spec.js deleted file mode 100644 index c890162a1..000000000 --- a/e2e/paths/08-route/04_tickets.spec.js +++ /dev/null @@ -1,59 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Route tickets path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('delivery', 'route'); - await page.accessToSearchResult('2'); - await page.accessToSection('route.card.tickets'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should modify the first ticket priority', async() => { - await page.writeOnEditableTD(selectors.routeTickets.firstTicketPriority, '9'); - await page.keyboard.press('Enter'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should confirm the buscaman button is disabled', async() => { - await page.waitForSelector(`${selectors.routeTickets.buscamanButton}.disabled`); - }); - - it('should check the first ticket checkbox and confirm the buscamanButton button is no longer disabled', async() => { - await page.waitForSelector(`${selectors.routeTickets.buscamanButton}.disabled`, {visible: false}); - }); - - it('should check the route volume on the descriptor', async() => { - const result = await page.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText'); - - expect(result).toEqual('0.2 / 50 m³'); - }); - - it('should count how many tickets are in route', async() => { - const result = await page.countElement(selectors.routeTickets.anyTicket); - - expect(result).toEqual(1); - }); - - it('should delete the first ticket in route', async() => { - await page.waitToClick(selectors.routeTickets.firstTicketDeleteButton); - await page.waitToClick(selectors.routeTickets.confirmButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Ticket removed from route'); - }); - - it('should now count how many tickets are in route to find one less', async() => { - await page.waitForNumberOfElements(selectors.routeTickets.anyTicket, 0); - }); -}); diff --git a/modules/route/front/agency-term-search-panel/index.html b/modules/route/front/agency-term-search-panel/index.html deleted file mode 100644 index fdd6b649b..000000000 --- a/modules/route/front/agency-term-search-panel/index.html +++ /dev/null @@ -1,52 +0,0 @@ -
- - -
- - - - - - - - - - -
- - - - - - -
- - - -
-
diff --git a/modules/route/front/agency-term-search-panel/index.js b/modules/route/front/agency-term-search-panel/index.js deleted file mode 100644 index d5d8ea7a6..000000000 --- a/modules/route/front/agency-term-search-panel/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - get filter() { - return this.$.filter; - } - - set filter(value = {}) { - this.$.filter = value; - } -} - -ngModule.vnComponent('vnAgencyTermSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/agency-term-search-panel/locale/es.yml b/modules/route/front/agency-term-search-panel/locale/es.yml deleted file mode 100644 index 74336a03b..000000000 --- a/modules/route/front/agency-term-search-panel/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -Search by invoiceIn id or autonomous name: Buscar por id de recibida o por nombre de autónomo -Search autonomous: Buscar autónomos \ No newline at end of file diff --git a/modules/route/front/agency-term/createInvoiceIn/index.html b/modules/route/front/agency-term/createInvoiceIn/index.html deleted file mode 100644 index 8f270378f..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/index.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
diff --git a/modules/route/front/agency-term/createInvoiceIn/index.js b/modules/route/front/agency-term/createInvoiceIn/index.js deleted file mode 100644 index 0198ab80f..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/index.js +++ /dev/null @@ -1,120 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.dms = { - files: [], - hasFile: false, - hasFileAttached: false - }; - } - - get route() { - return this._route; - } - - set route(value) { - this._route = value; - - this.setDefaultParams(); - this.getAllowedContentTypes(); - } - - $onChanges() { - if (this.$params && this.$params.q) - this.params = JSON.parse(this.$params.q); - } - - getAllowedContentTypes() { - this.$http.get('DmsContainers/allowedContentTypes').then(res => { - const contentTypes = res.data.join(', '); - this.allowedContentTypes = contentTypes; - }); - } - - get contentTypesInfo() { - return this.$t('ContentTypesInfo', { - allowedContentTypes: this.allowedContentTypes - }); - } - - setDefaultParams() { - const params = {filter: { - where: {code: 'invoiceIn'} - }}; - this.$http.get('DmsTypes/findOne', {params}).then(res => { - const dmsType = res.data && res.data; - const companyId = this.vnConfig.companyFk; - const warehouseId = this.vnConfig.warehouseFk; - const defaultParams = { - warehouseId: warehouseId, - companyId: companyId, - dmsTypeId: dmsType.id, - description: this.params.supplierName - }; - - this.dms = Object.assign(this.dms, defaultParams); - }); - } - - onSubmit() { - if (this.dms.files.length > 1) throw new UserError('You cannot attach more than one document'); - const query = `dms/uploadFile`; - const options = { - method: 'POST', - url: query, - params: this.dms, - headers: { - 'Content-Type': undefined - }, - transformRequest: files => { - const formData = new FormData(); - formData.append(files[0].name, files[0]); - return formData; - }, - data: this.dms.files - }; - this.$http(options).then(res => { - if (res) { - const addedDms = res.data; - this.$.watcher.updateOriginalData(); - - const params = { - rows: this.params.rows, - dms: addedDms - }; - - this.$http.post('AgencyTerms/createInvoiceIn', params) - .then(() => { - this.$state.go('route.agencyTerm.index'); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - }); - } - - onFileChange(files) { - let hasFileAttached = false; - - if (files.length > 0) - hasFileAttached = true; - - this.$.$applyAsync(() => { - this.dms.hasFileAttached = hasFileAttached; - }); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnAgencyTermCreateInvoiceIn', { - template: require('./index.html'), - controller: Controller, - bindings: { - route: '<' - } -}); diff --git a/modules/route/front/agency-term/createInvoiceIn/index.spec.js b/modules/route/front/agency-term/createInvoiceIn/index.spec.js deleted file mode 100644 index d6d9883a7..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/index.spec.js +++ /dev/null @@ -1,107 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher.js'; - -describe('AgencyTerm', () => { - describe('Component vnAgencyTermCreateInvoiceIn', () => { - let controller; - let $scope; - let $httpBackend; - let $httpParamSerializer; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $scope = $rootScope.$new(); - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - const $element = angular.element(''); - controller = $componentController('vnAgencyTermCreateInvoiceIn', {$element}); - controller._route = { - id: 1 - }; - })); - - describe('$onChanges()', () => { - it('should update the params data when $params.q is defined', () => { - controller.$params = {q: '{"supplierName": "Plants SL","rows": null}'}; - - const params = {q: '{"supplierName": "Plants SL", "rows": null}'}; - const json = JSON.parse(params.q); - - controller.$onChanges(); - - expect(controller.params).toEqual(json); - }); - }); - - describe('route() setter', () => { - it('should set the ticket data and then call setDefaultParams() and getAllowedContentTypes()', () => { - jest.spyOn(controller, 'setDefaultParams'); - jest.spyOn(controller, 'getAllowedContentTypes'); - controller.route = { - id: 1 - }; - - expect(controller.route).toBeDefined(); - expect(controller.setDefaultParams).toHaveBeenCalledWith(); - expect(controller.getAllowedContentTypes).toHaveBeenCalledWith(); - }); - }); - - describe('getAllowedContentTypes()', () => { - it('should make an HTTP GET request to get the allowed content types', () => { - const expectedResponse = ['image/png', 'image/jpg']; - $httpBackend.expect('GET', `DmsContainers/allowedContentTypes`).respond(expectedResponse); - controller.getAllowedContentTypes(); - $httpBackend.flush(); - - expect(controller.allowedContentTypes).toBeDefined(); - expect(controller.allowedContentTypes).toEqual('image/png, image/jpg'); - }); - }); - - describe('setDefaultParams()', () => { - it('should perform a GET query and define the dms property on controller', () => { - const params = {filter: { - where: {code: 'invoiceIn'} - }}; - const serializedParams = $httpParamSerializer(params); - $httpBackend.expect('GET', `DmsTypes/findOne?${serializedParams}`).respond({id: 1, code: 'invoiceIn'}); - controller.params = {supplierName: 'Plants SL'}; - controller.setDefaultParams(); - $httpBackend.flush(); - - expect(controller.dms).toBeDefined(); - expect(controller.dms.dmsTypeId).toEqual(1); - }); - }); - - describe('onSubmit()', () => { - it('should make an HTTP POST request to save the form data', () => { - controller.$.watcher = watcher; - - jest.spyOn(controller.$.watcher, 'updateOriginalData'); - const files = [{id: 1, name: 'MyFile'}]; - controller.dms = {files}; - const serializedParams = $httpParamSerializer(controller.dms); - const query = `dms/uploadFile?${serializedParams}`; - controller.params = {rows: null}; - - $httpBackend.expect('POST', query).respond({}); - $httpBackend.expect('POST', 'AgencyTerms/createInvoiceIn').respond({}); - controller.onSubmit(); - $httpBackend.flush(); - }); - }); - - describe('onFileChange()', () => { - it('should set dms hasFileAttached property to true if has any files', () => { - const files = [{id: 1, name: 'MyFile'}]; - controller.onFileChange(files); - $scope.$apply(); - - expect(controller.dms.hasFileAttached).toBeTruthy(); - }); - }); - }); -}); diff --git a/modules/route/front/agency-term/createInvoiceIn/style.scss b/modules/route/front/agency-term/createInvoiceIn/style.scss deleted file mode 100644 index 73f136fc1..000000000 --- a/modules/route/front/agency-term/createInvoiceIn/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} - diff --git a/modules/route/front/agency-term/index/index.html b/modules/route/front/agency-term/index/index.html deleted file mode 100644 index 0d8ea40e7..000000000 --- a/modules/route/front/agency-term/index/index.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - -
-
-
Total
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - Id - - Date - - Agency route - - Agency Agreement - - Packages - - M3 - - Km - - Price - - Received - - Autonomous -
- - - - - {{::agencyTerm.routeFk}} - - {{::agencyTerm.created | date:'dd/MM/yyyy'}}{{::agencyTerm.agencyModeName | dashIfEmpty}}{{::agencyTerm.agencyAgreement | dashIfEmpty}}{{::agencyTerm.packages | dashIfEmpty}}{{::agencyTerm.m3 | dashIfEmpty}}{{::agencyTerm.kmTotal | dashIfEmpty}}{{::agencyTerm.price | dashIfEmpty}} - - {{::agencyTerm.invoiceInFk}} - - - - {{::agencyTerm.supplierName}} - - - - -
-
-
-
- - - - - - - - - - - - - -
- - - - -
diff --git a/modules/route/front/agency-term/index/index.js b/modules/route/front/agency-term/index/index.js deleted file mode 100644 index 6c3bafc9a..000000000 --- a/modules/route/front/agency-term/index/index.js +++ /dev/null @@ -1,121 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.smartTableOptions = { - activeButtons: { - search: true - }, - columns: [ - { - field: 'agencyModeFk', - autocomplete: { - url: 'AgencyModes', - showField: 'name', - valueField: 'id' - } - }, - { - field: 'agencyFk', - autocomplete: { - url: 'Agencies', - showField: 'name', - valueField: 'id' - } - }, - { - field: 'supplierFk', - autocomplete: { - url: 'Suppliers', - showField: 'name', - valueField: 'name', - } - } - ] - }; - } - - exprBuilder(param, value) { - switch (param) { - case 'agencyModeFk': - return {'a.agencyModeFk': value}; - case 'supplierFk': - return {'a.supplierName': value}; - case 'routeFk': - return {'a.routeFk': value}; - case 'created': - case 'agencyFk': - case 'packages': - case 'm3': - case 'kmTotal': - case 'price': - case 'invoiceInFk': - return {[`a.${param}`]: value}; - } - } - - get checked() { - const agencyTerms = this.$.model.data || []; - const checkedAgencyTerms = []; - for (let agencyTerm of agencyTerms) { - if (agencyTerm.checked) - checkedAgencyTerms.push(agencyTerm); - } - - return checkedAgencyTerms; - } - - get totalChecked() { - return this.checked.length; - } - - get totalPrice() { - let totalPrice = 0; - - if (this.checked.length > 0) { - for (let agencyTerm of this.checked) - totalPrice += agencyTerm.price; - - return totalPrice; - } - - return totalPrice; - } - - preview(route) { - this.routeSelected = route; - this.$.summary.show(); - } - - createInvoiceIn() { - const rowsToCreateInvoiceIn = []; - const supplierFk = this.checked[0].supplierFk; - - for (let agencyTerm of this.checked) { - let hasSameSupplier = supplierFk == agencyTerm.supplierFk; - if (hasSameSupplier) { - rowsToCreateInvoiceIn.push({ - routeFk: agencyTerm.routeFk, - supplierFk: agencyTerm.supplierFk, - created: agencyTerm.created, - totalPrice: this.totalPrice}); - } else { - this.vnApp.showError(this.$t('Two autonomous cannot be counted at the same time')); - return false; - } - } - const params = JSON.stringify({ - supplierName: this.checked[0].supplierName, - rows: rowsToCreateInvoiceIn - }); - this.$state.go('route.agencyTerm.createInvoiceIn', {q: params}); - } -} - -ngModule.vnComponent('vnAgencyTermIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/agency-term/index/index.spec.js b/modules/route/front/agency-term/index/index.spec.js deleted file mode 100644 index 55c40daa5..000000000 --- a/modules/route/front/agency-term/index/index.spec.js +++ /dev/null @@ -1,94 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('AgencyTerm', () => { - describe('Component vnAgencyTermIndex', () => { - let controller; - let $window; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, _$window_) => { - $window = _$window_; - const $element = angular.element(''); - controller = $componentController('vnAgencyTermIndex', {$element}); - controller.$.model = crudModel; - controller.$.model.data = [ - {supplierFk: 1, totalPrice: null}, - {supplierFk: 1}, - {supplierFk: 2} - ]; - })); - - describe('checked() getter', () => { - it('should return the checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.checked; - - const firstCheckedRow = checkedRows[0]; - - expect(firstCheckedRow.supplierFk).toEqual(1); - }); - }); - - describe('totalCheked() getter', () => { - it('should return the total checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.totalChecked; - - expect(checkedRows).toEqual(1); - }); - }); - - describe('preview()', () => { - it('should show the summary dialog', () => { - controller.$.summary = {show: () => {}}; - jest.spyOn(controller.$.summary, 'show'); - - let event = new MouseEvent('click', { - view: $window, - bubbles: true, - cancelable: true - }); - const route = {id: 1}; - - controller.preview(event, route); - - expect(controller.$.summary.show).toHaveBeenCalledWith(); - }); - }); - - describe('createInvoiceIn()', () => { - it('should throw an error if more than one autonomous are checked', () => { - jest.spyOn(controller.vnApp, 'showError'); - const data = controller.$.model.data; - data[0].checked = true; - data[2].checked = true; - - controller.createInvoiceIn(); - - expect(controller.vnApp.showError).toHaveBeenCalled(); - }); - - it('should call the function go() on $state to go to the file management', () => { - jest.spyOn(controller.$state, 'go'); - const data = controller.$.model.data; - data[0].checked = true; - - controller.createInvoiceIn(); - - delete data[0].checked; - const params = JSON.stringify({ - supplierName: data[0].supplierName, - rows: [data[0]] - }); - - expect(controller.$state.go).toHaveBeenCalledWith('route.agencyTerm.createInvoiceIn', {q: params}); - }); - }); - }); -}); diff --git a/modules/route/front/agency-term/locale/es.yml b/modules/route/front/agency-term/locale/es.yml deleted file mode 100644 index 0f6797188..000000000 --- a/modules/route/front/agency-term/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Agency route: Agencia ruta -Agency Agreement: Acuerdo agencia -Autonomous: Autónomos -Two autonomous cannot be counted at the same time: Dos autonónomos no pueden ser contabilizados al mismo tiempo -You cannot attach more than one document: No puedes adjuntar más de un documento \ No newline at end of file diff --git a/modules/route/front/basic-data/index.html b/modules/route/front/basic-data/index.html deleted file mode 100644 index 7f9aef0d0..000000000 --- a/modules/route/front/basic-data/index.html +++ /dev/null @@ -1,96 +0,0 @@ - - - -
- - - - - - {{::numberPlate}} - {{::name}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/basic-data/index.js b/modules/route/front/basic-data/index.js deleted file mode 100644 index f051e23c5..000000000 --- a/modules/route/front/basic-data/index.js +++ /dev/null @@ -1,28 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - $onInit() { - this.$http.post(`Vehicles/sorted`, {warehouseFk: this.vnConfig.warehouseFk}) - .then(res => { - this.vehicles = res.data; - }); - } - - onSubmit() { - this.$.watcher.submit().then(() => - this.card.reload() - ); - } -} - -ngModule.vnComponent('vnRouteBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - route: '<' - }, - require: { - card: '^vnRouteCard' - } -}); diff --git a/modules/route/front/basic-data/locale/es.yml b/modules/route/front/basic-data/locale/es.yml deleted file mode 100644 index 9dcacbe9a..000000000 --- a/modules/route/front/basic-data/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -Date finished: Fecha fin -Date started: Fecha inicio -Km start: Km de inicio -Km end: Km de fin -Description: Descripción -Hour started: Hora inicio -Hour finished: Hora fin -Is served: Se ha servido diff --git a/modules/route/front/card/index.html b/modules/route/front/card/index.html deleted file mode 100644 index 9e0ae4e8c..000000000 --- a/modules/route/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/route/front/card/index.js b/modules/route/front/card/index.js deleted file mode 100644 index 07b5a547c..000000000 --- a/modules/route/front/card/index.js +++ /dev/null @@ -1,71 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - fields: [ - 'id', - 'workerFk', - 'agencyModeFk', - 'created', - 'm3', - 'warehouseFk', - 'description', - 'vehicleFk', - 'kmStart', - 'kmEnd', - 'started', - 'finished', - 'cost', - 'zoneFk', - 'isOk' - ], - include: [ - { - relation: 'agencyMode', - scope: { - fields: ['id', 'name'] - } - }, { - relation: 'vehicle', - scope: { - fields: ['id', 'm3'] - } - }, { - relation: 'zone', - scope: { - fields: ['id', 'name'] - } - }, - { - relation: 'worker', - scope: { - fields: ['id'], - include: { - relation: 'user', - scope: { - fields: ['id'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - } - } - } - ] - }; - - this.$http.get(`Routes/${this.$params.id}`, {filter}) - .then(res => this.route = res.data); - } -} - -ngModule.vnComponent('vnRouteCard', { - template: require('./index.html'), - controller: Controller -}); - diff --git a/modules/route/front/create/index.html b/modules/route/front/create/index.html deleted file mode 100644 index de341220e..000000000 --- a/modules/route/front/create/index.html +++ /dev/null @@ -1,52 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/create/index.js b/modules/route/front/create/index.js deleted file mode 100644 index c81394c10..000000000 --- a/modules/route/front/create/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - this.$.watcher.submit().then( - res => { - this.$http.post(`Routes/${res.data.id}/updateWorkCenter`, null) - .then(() => { - this.$state.go('route.card.summary', {id: res.data.id}); - }); - } - ); - } -} - -ngModule.vnComponent('vnRouteCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/index.js b/modules/route/front/index.js index 803fc1045..0f2208862 100644 --- a/modules/route/front/index.js +++ b/modules/route/front/index.js @@ -1,19 +1,6 @@ export * from './module'; import './main'; -import './index/'; -import './search-panel'; import './descriptor'; import './descriptor-popover'; import './summary'; -import './card'; -import './create'; -import './basic-data'; -import './log'; -import './tickets'; -import './agency-term/index'; -import './agency-term/createInvoiceIn'; -import './agency-term-search-panel'; -import './ticket-popup'; -import './sms'; -import './roadmap'; diff --git a/modules/route/front/index/index.html b/modules/route/front/index/index.html deleted file mode 100644 index 9384af6be..000000000 --- a/modules/route/front/index/index.html +++ /dev/null @@ -1,228 +0,0 @@ - - - - - - - - -
- - - -
- - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - Id - - Worker - - Agency - - Vehicle - - Date - - - - Description - - Hour started - - Hour finished -
- - - {{::route.id | dashIfEmpty}} - - -
{{name}} - {{nickname}}
-
-
-
- - - - - - - - - {{::route.m3 | dashIfEmpty}} - - - - - - - - - - - - - -
-
-
-
-
- - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js deleted file mode 100644 index bb32e1f13..000000000 --- a/modules/route/front/index/index.js +++ /dev/null @@ -1,151 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - constructor($element, $, vnReport) { - super($element, $); - this.vnReport = vnReport; - this.droppableElement = 'a.vn-tr'; - } - - preview(route) { - this.routeSelected = route; - this.$.summary.show(); - } - - showTicketPopup(route) { - this.routeSelected = route; - this.$.ticketPopup.show(); - } - - get checked() { - const rows = this.$.model.data || []; - const checkedRows = []; - for (let row of rows) { - if (row.checked) - checkedRows.push(row); - } - - return checkedRows; - } - - get totalChecked() { - return this.checked.length; - } - - showRouteReport() { - const routesIds = []; - const access_token = this.vnToken.tokenMultimedia; - - for (let route of this.checked) - routesIds.push(route.id); - const stringRoutesIds = routesIds.join(','); - - if (this.checked.length <= 1) { - const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${access_token}`; - window.open(url, '_blank'); - } else { - const serializedParams = this.$httpParamSerializer({ - access_token, - id: stringRoutesIds - }); - const url = `api/Routes/downloadZip?${serializedParams}`; - window.open(url, '_blank'); - } - } - - openClonationDialog() { - this.$.clonationDialog.show(); - this.createdDate = Date.vnNew(); - } - - cloneSelectedRoutes() { - try { - if (!this.createdDate) - throw new Error(`The date can't be empty`); - - const routesIds = []; - for (let route of this.checked) - routesIds.push(route.id); - - return this.$http.post('Routes/clone', {ids: routesIds, created: this.createdDate}).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } - - onDrop($event) { - const target = $event.target; - const droppable = target.closest(this.droppableElement); - const ticketId = $event.dataTransfer.getData('Text'); - const routeId = droppable.id; - - if (isNaN(ticketId)) { - const regexp = new RegExp(/\/ticket\/([0-9]+)\//i); - const matches = ticketId.match(regexp); - - if (matches && matches.length) - this.insert(routeId, matches[1]); - else - this.vnApp.showError(this.$t('Ticket not found')); - } - - if (!isNaN(ticketId)) - this.insert(routeId, ticketId); - } - - insert(routeId, ticketId) { - routeId = parseInt(routeId); - ticketId = parseInt(ticketId); - - const query = `Routes/${routeId}/insertTicket`; - return this.$http.patch(query, {ticketId}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - }).catch(error => { - if (error.status == 404) - return this.vnApp.showError(this.$t('Ticket not found')); - throw error; - }); - } - - updateAttributes(route) { - if (route.started == null || route.finished == null) - return this.vnApp.showError(this.$t('You must select a valid time')); - if (route.created == null) - return this.vnApp.showError(this.$t('You must select a valid date')); - const params = { - workerFk: route.workerFk, - agencyModeFk: route.agencyModeFk, - vehicleFk: route.vehicleFk, - created: route.created, - description: route.description, - started: route.started, - finished: route.finished - }; - const query = `Routes/${route.id}/`; - this.$http.patch(query, params).then(res => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - markAsServed() { - const routes = []; - for (let route of this.checked) - routes.push(route.id); - - const params = {isOk: true}; - for (let routeId of routes) - this.$http.patch(`Routes/${routeId}`, params); - } -} - -Controller.$inject = ['$element', '$scope', 'vnReport']; - -ngModule.vnComponent('vnRouteIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/index/index.spec.js b/modules/route/front/index/index.spec.js deleted file mode 100644 index 399ece714..000000000 --- a/modules/route/front/index/index.spec.js +++ /dev/null @@ -1,156 +0,0 @@ -import './index.js'; -import crudModel from 'core/mocks/crud-model'; - -describe('Component vnRouteIndex', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(''); - controller = $componentController('vnRouteIndex', {$element}); - controller.$.model = crudModel; - controller.$.model.data = [{id: 1, checked: true}, {id: 2}, {id: 3}]; - })); - - describe('checked() getter', () => { - it('should return the checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - data[2].checked = true; - - const checkedRows = controller.checked; - - const firstCheckedRow = checkedRows[0]; - const secondCheckedRow = checkedRows[1]; - - expect(firstCheckedRow.id).toEqual(1); - expect(secondCheckedRow.id).toEqual(3); - }); - }); - - describe('totalCheked() getter', () => { - it('should return the total checked lines', () => { - const data = controller.$.model.data; - data[0].checked = true; - - const checkedRows = controller.totalChecked; - - expect(checkedRows).toEqual(1); - }); - }); - - describe('showRouteReport()', () => { - it('should call to the vnReport show method', () => { - jest.spyOn(window, 'open').mockReturnThis(); - - const data = controller.$.model.data; - data[0].checked = true; - data[2].checked = true; - - controller.showRouteReport(); - - expect(window.open).toHaveBeenCalled(); - }); - }); - - describe('cloneSelectedRoutes()', () => { - it('should perform an http request to Routes/clone', () => { - controller.createdDate = Date.vnNew(); - - $httpBackend.expect('POST', 'Routes/clone').respond(); - controller.cloneSelectedRoutes(); - $httpBackend.flush(); - }); - }); - - describe('onDrop()', () => { - it('should call the insert method when dragging a ticket number', () => { - jest.spyOn(controller, 'insert'); - - const routeId = '1'; - const expectedTicketId = '16'; - const draggedElement = '16'; - const droppable = document.createElement('a'); - droppable.setAttribute('id', 1); - droppable.classList.add('vn-tr'); - - const $event = { - dataTransfer: { - getData: () => draggedElement - }, - target: droppable - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(routeId, expectedTicketId); - }); - - it('should call the insert method when dragging a ticket link', () => { - jest.spyOn(controller, 'insert'); - - const routeId = '1'; - const expectedTicketId = '11'; - const draggedElement = 'http://arkamcity.com/#!/ticket/11/summary'; - const droppable = document.createElement('a'); - droppable.setAttribute('id', 1); - droppable.classList.add('vn-tr'); - - const $event = { - dataTransfer: { - getData: () => draggedElement - }, - target: droppable - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(routeId, expectedTicketId); - }); - - it('should throw an error when dragging an invalid ticket link', () => { - jest.spyOn(controller.vnApp, 'showError'); - - const draggedElement = 'http://arkamcity.com/#!/item/11/summary'; - const droppable = document.createElement('a'); - droppable.setAttribute('id', 1); - droppable.classList.add('vn-tr'); - const $event = { - dataTransfer: { - getData: () => draggedElement - }, - target: droppable - }; - controller.onDrop($event); - - expect(controller.vnApp.showError).toHaveBeenCalledWith('Ticket not found'); - }); - }); - - describe('insert()', () => { - it('should perform a HTTP patch query and then call both refresh and showSuccess methods', () => { - jest.spyOn(controller.$.model, 'refresh').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - const routeId = 1; - const ticketId = 11; - const data = {ticketId}; - $httpBackend.expect('PATCH', `Routes/1/insertTicket`, data).respond(); - controller.insert(routeId, ticketId); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('markAsServed()', () => { - it('should perform a HTTP patch query', () => { - const data = {isOk: true}; - $httpBackend.expect('PATCH', `Routes/1`, data).respond(); - controller.markAsServed(); - $httpBackend.flush(); - }); - }); -}); diff --git a/modules/route/front/index/locale/es.yml b/modules/route/front/index/locale/es.yml deleted file mode 100644 index 3db84d81e..000000000 --- a/modules/route/front/index/locale/es.yml +++ /dev/null @@ -1,13 +0,0 @@ -Vehicle: Vehículo -Download selected routes as PDF: Descargar rutas seleccionadas como PDF -Clone selected routes: Clonar rutas seleccionadas -The date can't be empty: La fecha no puede estar vacía -Starting date: Fecha de inicio -Hour started: Hora inicio -Hour finished: Hora fin -Go to route: Ir a la ruta -You must select a valid time: Debe seleccionar una hora válida -You must select a valid date: Debe seleccionar una fecha válida -Mark as served: Marcar como servidas -Retrieving data from the routes: Recuperando datos de las rutas -Send SMS to all clients: Mandar sms a todos los clientes de las rutas \ No newline at end of file diff --git a/modules/route/front/locale/en.yml b/modules/route/front/locale/en.yml deleted file mode 100644 index 0e5302b14..000000000 --- a/modules/route/front/locale/en.yml +++ /dev/null @@ -1 +0,0 @@ -Unlink zone: Unlink zone {{zoneName}} from agency {{agencyName}} \ No newline at end of file diff --git a/modules/route/front/locale/es.yml b/modules/route/front/locale/es.yml deleted file mode 100644 index 74ab2cd61..000000000 --- a/modules/route/front/locale/es.yml +++ /dev/null @@ -1,5 +0,0 @@ -Routes: Rutas -Search routes by id: Buscar rutas por identificador -New route: Nueva ruta -route: ruta -Unlink zone: Desvincular zona {{zoneName}} de agencia {{agencyName}} \ No newline at end of file diff --git a/modules/route/front/log/index.html b/modules/route/front/log/index.html deleted file mode 100644 index 7df2e30ae..000000000 --- a/modules/route/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/route/front/log/index.js b/modules/route/front/log/index.js deleted file mode 100644 index c1a7052a9..000000000 --- a/modules/route/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnRouteLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/route/front/main/index.html b/modules/route/front/main/index.html index f1bed84ff..e69de29bb 100644 --- a/modules/route/front/main/index.html +++ b/modules/route/front/main/index.html @@ -1,20 +0,0 @@ - - - - - - - - - - diff --git a/modules/route/front/main/index.js b/modules/route/front/main/index.js index 8c57bbad6..a567e3072 100644 --- a/modules/route/front/main/index.js +++ b/modules/route/front/main/index.js @@ -2,36 +2,12 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Route extends ModuleMain { - $postLink() { - const to = Date.vnNew(); - to.setDate(to.getDate() + 1); - to.setHours(0, 0, 0, 0); - - const from = Date.vnNew(); - from.setDate(from.getDate()); - from.setHours(0, 0, 0, 0); - - this.filterParams = {from, to}; - this.$.model.applyFilter(null, this.filterParams); + constructor($element, $) { + super($element, $); } - - fetchParams($params) { - const hasEntries = Object.entries($params).length; - if (!hasEntries) - $params.scopeDays = 1; - - if (typeof $params.scopeDays === 'number') { - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - - const to = new Date(from.getTime()); - to.setDate(to.getDate() + $params.scopeDays); - to.setHours(23, 59, 59, 999); - - Object.assign($params, {from, to}); - } - - return $params; + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`route/`); } } diff --git a/modules/route/front/main/index.spec.js b/modules/route/front/main/index.spec.js deleted file mode 100644 index 0c16a7b1f..000000000 --- a/modules/route/front/main/index.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import './index.js'; - -describe('Route Component vnRoute', () => { - let controller; - - beforeEach(ngModule('route')); - - beforeEach(inject($componentController => { - let $element = angular.element(`
`); - controller = $componentController('vnRoute', {$element}); - })); - - describe('fetchParams()', () => { - it('should return a range of dates with passed scope days', () => { - let params = controller.fetchParams({ - scopeDays: 2 - }); - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - const to = new Date(from.getTime()); - to.setDate(to.getDate() + params.scopeDays); - to.setHours(23, 59, 59, 999); - - const expectedParams = { - from, - scopeDays: params.scopeDays, - to - }; - - expect(params).toEqual(expectedParams); - }); - - it('should return default value for scope days', () => { - let params = controller.fetchParams({ - scopeDays: 1 - }); - - expect(params.scopeDays).toEqual(1); - }); - - it('should return the given scope days', () => { - let params = controller.fetchParams({ - scopeDays: 2 - }); - - expect(params.scopeDays).toEqual(2); - }); - }); -}); diff --git a/modules/route/front/roadmap/basic-data/index.html b/modules/route/front/roadmap/basic-data/index.html deleted file mode 100644 index 28c67eb47..000000000 --- a/modules/route/front/roadmap/basic-data/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/roadmap/basic-data/index.js b/modules/route/front/roadmap/basic-data/index.js deleted file mode 100644 index d5b39b76e..000000000 --- a/modules/route/front/roadmap/basic-data/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - onSubmit() { - this.$.watcher.submit(); - } -} - -ngModule.component('vnRoadmapBasicData', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/card/index.html b/modules/route/front/roadmap/card/index.html deleted file mode 100644 index 97ca40f95..000000000 --- a/modules/route/front/roadmap/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/route/front/roadmap/card/index.js b/modules/route/front/roadmap/card/index.js deleted file mode 100644 index ff2d13616..000000000 --- a/modules/route/front/roadmap/card/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import ngModule from '../../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - const filter = { - include: [ - {relation: 'supplier'} - ] - }; - this.$http.get(`Roadmaps/${this.$params.id}`, {filter}) - .then(res => this.roadmap = res.data); - } -} - -ngModule.vnComponent('vnRoadmapCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/roadmap/create/index.html b/modules/route/front/roadmap/create/index.html deleted file mode 100644 index f5a26566e..000000000 --- a/modules/route/front/roadmap/create/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - -
- - - - - - - - - - - - - - - - -
diff --git a/modules/route/front/roadmap/create/index.js b/modules/route/front/roadmap/create/index.js deleted file mode 100644 index 7e638da94..000000000 --- a/modules/route/front/roadmap/create/index.js +++ /dev/null @@ -1,23 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $, $transclude, vnReport, vnEmail) { - super($element, $, $transclude); - this.roadmap = {etd: Date.vnNew()}; - } - - onSubmit() { - this.$.watcher.submit().then( - res => this.$state.go('route.roadmap.card.summary', {id: res.data.id}) - ); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnRoadmapCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/roadmap/create/style.scss b/modules/route/front/roadmap/create/style.scss deleted file mode 100644 index 8ee7ecb09..000000000 --- a/modules/route/front/roadmap/create/style.scss +++ /dev/null @@ -1,6 +0,0 @@ -vn-ticket-request { - .vn-textfield { - margin: 0!important; - max-width: 100px; - } -} diff --git a/modules/route/front/roadmap/descriptor/index.html b/modules/route/front/roadmap/descriptor/index.html deleted file mode 100644 index 92ae8eab1..000000000 --- a/modules/route/front/roadmap/descriptor/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - Delete roadmap - - - -
- - - - - - - {{$ctrl.roadmap.supplier.nickname}} - - -
-
-
- - - - diff --git a/modules/route/front/roadmap/descriptor/index.js b/modules/route/front/roadmap/descriptor/index.js deleted file mode 100644 index 2846b073a..000000000 --- a/modules/route/front/roadmap/descriptor/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import ngModule from '../../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get roadmap() { - return this.entity; - } - - set roadmap(value) { - this.entity = value; - } - - onDelete() { - return this.$http.delete(`Roadmaps/${this.roadmap.id}`) - .then(() => this.$state.go('route.roadmap')) - .then(() => this.vnApp.showSuccess(this.$t('Roadmap removed'))); - } -} - -ngModule.component('vnRoadmapDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/descriptor/locale/es.yml b/modules/route/front/roadmap/descriptor/locale/es.yml deleted file mode 100644 index 376209694..000000000 --- a/modules/route/front/roadmap/descriptor/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Delete roadmap: Eliminar troncal -The roadmap will be removed: La troncal será eliminada -Roadmap removed: Troncal eliminada diff --git a/modules/route/front/roadmap/index.js b/modules/route/front/roadmap/index.js deleted file mode 100644 index 91b782a9b..000000000 --- a/modules/route/front/roadmap/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import './main'; -import './index/'; -import './summary'; -import './card'; -import './descriptor'; -import './create'; -import './basic-data'; -import './search-panel'; -import './stops'; diff --git a/modules/route/front/roadmap/index/index.html b/modules/route/front/roadmap/index/index.html deleted file mode 100644 index 6f8cbecc4..000000000 --- a/modules/route/front/roadmap/index/index.html +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - Roadmap - ETD - Carrier - Plate - Price - Observations - - - - - - - - - - {{::roadmap.name}} - {{::roadmap.etd | date:'dd/MM/yyyy HH:mm'}} - - - {{::roadmap.supplier.nickname}} - - - {{::roadmap.tractorPlate | dashIfEmpty}} - {{::roadmap.price | currency: 'EUR':2 | dashIfEmpty}} - {{::roadmap.observations | dashIfEmpty}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/route/front/roadmap/index/index.js b/modules/route/front/roadmap/index/index.js deleted file mode 100644 index c5f5ef9d1..000000000 --- a/modules/route/front/roadmap/index/index.js +++ /dev/null @@ -1,60 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - get checked() { - const roadmaps = this.$.model.data || []; - const checkedRoadmap = []; - for (let roadmap of roadmaps) { - if (roadmap.checked) - checkedRoadmap.push(roadmap); - } - - return checkedRoadmap; - } - - get totalChecked() { - return this.checked.length; - } - - preview(roadmap) { - this.roadmapSelected = roadmap; - this.$.summary.show(); - } - - openClonationDialog() { - this.$.clonationDialog.show(); - this.etd = Date.vnNew(); - } - - cloneSelectedRoadmaps() { - try { - if (!this.etd) - throw new Error(`The date can't be empty`); - - const roadmapsIds = []; - for (let roadmap of this.checked) - roadmapsIds.push(roadmap.id); - - return this.$http.post('Roadmaps/clone', {ids: roadmapsIds, etd: this.etd}).then(() => { - this.$.model.refresh(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } - - deleteRoadmaps() { - for (const roadmap of this.checked) { - this.$http.delete(`Roadmaps/${roadmap.id}`) - .then(() => this.$.model.refresh()) - .then(() => this.vnApp.showSuccess(this.$t('Roadmaps removed'))); - } - } -} - -ngModule.vnComponent('vnRoadmapIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/roadmap/index/locale/es.yml b/modules/route/front/roadmap/index/locale/es.yml deleted file mode 100644 index dd93eac6e..000000000 --- a/modules/route/front/roadmap/index/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Delete roadmap(s): Eliminar troncal(es) -Selected roadmaps will be removed: Los troncales seleccionados serán eliminados -Roadmaps removed: Troncales eliminados diff --git a/modules/route/front/roadmap/locale/es.yml b/modules/route/front/roadmap/locale/es.yml deleted file mode 100644 index e136eca31..000000000 --- a/modules/route/front/roadmap/locale/es.yml +++ /dev/null @@ -1,14 +0,0 @@ -Roadmaps: Troncales -Roadmap: Troncal -Driver name: Nombre conductor -Plate: Matrícula -Price: Precio -Observations: Observaciones -Clone selected roadmaps: Clonar troncales seleccionadas -Select the estimated time of departure (ETD): Seleccione la hora estimada de salida (ETD) -Create roadmap: Crear troncal -Tractor plate: Matrícula tractor -Trailer plate: Matrícula trailer -Carrier: Transportista -ETD date: Fecha ETD -ETD hour: Hora ETD diff --git a/modules/route/front/roadmap/main/index.html b/modules/route/front/roadmap/main/index.html deleted file mode 100644 index 3a8eb2599..000000000 --- a/modules/route/front/roadmap/main/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/modules/route/front/roadmap/main/index.js b/modules/route/front/roadmap/main/index.js deleted file mode 100644 index e7b3366f2..000000000 --- a/modules/route/front/roadmap/main/index.js +++ /dev/null @@ -1,61 +0,0 @@ -import ngModule from '../../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Roadmap extends ModuleMain { - constructor($element, $) { - super($element, $); - - this.include = { - relation: 'supplier', - scope: { - fields: ['nickname'] - } - }; - } - - $postLink() { - const from = Date.vnNew(); - from.setHours(0, 0, 0, 0); - - const to = Date.vnNew(); - to.setHours(23, 59, 59, 999); - - this.filterParams = { - from: from, - to: to - }; - - this.$.model.addFilter({where: { - and: [ - {etd: {gte: from}}, - {etd: {lte: to}} - ] - }}); - } - - exprBuilder(param, value) { - switch (param) { - case 'search': - return /^\d+$/.test(value) - ? {id: value} - : {name: {like: `%${value}%`}}; - case 'from': - return {etd: {gte: value}}; - case 'to': - return {etd: {lte: value}}; - case 'supplierFk': - case 'price': - return {[param]: value}; - case 'tractorPlate': - case 'trailerPlate': - case 'phone': - case 'driverName': - return {[param]: {like: `%${value}%`}}; - } - } -} - -ngModule.vnComponent('vnRoadmap', { - controller: Roadmap, - template: require('./index.html') -}); diff --git a/modules/route/front/roadmap/main/locale/es.yml b/modules/route/front/roadmap/main/locale/es.yml deleted file mode 100644 index 78342bce8..000000000 --- a/modules/route/front/roadmap/main/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Search roadmap by id or trunk: Buscar troncales por id o troncal diff --git a/modules/route/front/roadmap/search-panel/index.html b/modules/route/front/roadmap/search-panel/index.html deleted file mode 100644 index 53fd37344..000000000 --- a/modules/route/front/roadmap/search-panel/index.html +++ /dev/null @@ -1,74 +0,0 @@ -
-
- - - - -
- - - - - - -
- - - - - - - - - - {{::id}} - {{::nickname}} - - - - - - - - - - - - - - -
-
diff --git a/modules/route/front/roadmap/search-panel/index.js b/modules/route/front/roadmap/search-panel/index.js deleted file mode 100644 index 499027d14..000000000 --- a/modules/route/front/roadmap/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.component('vnRoadmapSearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/route/front/roadmap/stops/index.html b/modules/route/front/roadmap/stops/index.html deleted file mode 100644 index 82f30c326..000000000 --- a/modules/route/front/roadmap/stops/index.html +++ /dev/null @@ -1,71 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - diff --git a/modules/route/front/roadmap/stops/index.js b/modules/route/front/roadmap/stops/index.js deleted file mode 100644 index 075a1c8a4..000000000 --- a/modules/route/front/roadmap/stops/index.js +++ /dev/null @@ -1,39 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - add() { - const filter = { - fields: ['etd'] - }; - this.$http.get(`Roadmaps/${this.$params.id}`, {filter}) - .then(res => { - this.roadmap = res.data; - - const eta = new Date(this.roadmap.etd); - eta.setDate(eta.getDate() + 1); - - this.$.model.insert({ - roadmapFk: this.$params.id, - eta: eta - }); - }); - } - - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - this.$.model.refresh(); - }); - } -} - -ngModule.component('vnRoadmapStops', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/stops/locale/es.yml b/modules/route/front/roadmap/stops/locale/es.yml deleted file mode 100644 index 1db275949..000000000 --- a/modules/route/front/roadmap/stops/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Remove stop: Eliminar parada -Add stop: Añadir parada -ETA date: Fecha ETA -ETA hour: Hora ETA diff --git a/modules/route/front/roadmap/summary/index.html b/modules/route/front/roadmap/summary/index.html deleted file mode 100644 index abf5ff90a..000000000 --- a/modules/route/front/roadmap/summary/index.html +++ /dev/null @@ -1,116 +0,0 @@ - -
- {{summary.id}} - {{summary.name}} -
- - - - - {{summary.supplier.nickname}} - - - - - - - - - - - - - - - - - - - -

- - Stops - - - -

- - - - Wharehouse - ETA - - - - - {{roadmapStop.warehouse.name}} - {{roadmapStop.eta | date:'dd/MM/yyyy HH:mm'}} - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/route/front/roadmap/summary/index.js b/modules/route/front/roadmap/summary/index.js deleted file mode 100644 index 46abe5ca2..000000000 --- a/modules/route/front/roadmap/summary/index.js +++ /dev/null @@ -1,68 +0,0 @@ -import ngModule from '../../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - set roadmap(value) { - this._roadmap = value; - this.$.summary = null; - if (!value) return; - - this.loadData(); - } - - get roadmap() { - return this._roadmap; - } - - loadData() { - const filter = { - include: [ - {relation: 'supplier'}, - {relation: 'worker'}, - {relation: 'roadmapStop', - scope: { - include: [ - {relation: 'warehouse'} - ] - }} - ] - }; - this.$http.get(`Roadmaps/${this.roadmap.id}`, {filter}) - .then(res => this.$.summary = res.data); - } - - getETD() { - const eta = new Date(this.roadmap.etd); - eta.setDate(eta.getDate() + 1); - - this.roadmapStop = {eta: eta}; - } - - onAddAccept() { - try { - const data = { - roadmapFk: this.roadmap.id, - warehouseFk: this.roadmapStop.warehouseFk, - eta: this.roadmapStop.eta, - description: this.roadmapStop.description - }; - - this.$http.post(`RoadmapStops`, data) - .then(() => { - this.loadData(); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - } - } -} - -ngModule.component('vnRoadmapSummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - roadmap: '<' - } -}); diff --git a/modules/route/front/roadmap/summary/locale/es.yml b/modules/route/front/roadmap/summary/locale/es.yml deleted file mode 100644 index f2d82438a..000000000 --- a/modules/route/front/roadmap/summary/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Stops: Paradas -Wharehouse: Almacén -You must fill all the fields: Debes rellenar todos los campos diff --git a/modules/route/front/roadmap/summary/style.scss b/modules/route/front/roadmap/summary/style.scss deleted file mode 100644 index 743500cef..000000000 --- a/modules/route/front/roadmap/summary/style.scss +++ /dev/null @@ -1,9 +0,0 @@ -@import "variables"; - -vn-roadmap-summary .summary { - a:not(vn-link-phone a) { - display: flex; - align-items: center; - height: 18.328px; - } -} diff --git a/modules/route/front/routes.json b/modules/route/front/routes.json index 3b866581d..00fedc259 100644 --- a/modules/route/front/routes.json +++ b/modules/route/front/routes.json @@ -6,18 +6,7 @@ "dependencies": ["client", "worker", "ticket", "supplier", "invoiceIn"], "menus": { "main": [ - {"state": "route.index", "icon": "icon-delivery"}, - {"state": "route.agencyTerm.index", "icon": "icon-agency-term"}, - {"state": "route.roadmap", "icon": "icon-trailer"} - ], - "card": [ - {"state": "route.card.basicData", "icon": "settings"}, - {"state": "route.card.tickets", "icon": "icon-ticket"}, - {"state": "route.card.log", "icon": "history"} - ], - "roadmap": [ - {"state": "route.roadmap.card.basicData", "icon": "settings"}, - {"state": "route.roadmap.card.stops", "icon": "icon-lines"} + {"state": "route.index", "icon": "icon-delivery"} ] }, "routes": [ @@ -33,108 +22,6 @@ "state": "route.index", "component": "vn-route-index", "description": "Routes" - }, { - "url": "/create", - "state": "route.create", - "component": "vn-route-create", - "description": "New route" - }, { - "url": "/:id", - "state": "route.card", - "abstract": true, - "component": "vn-route-card" - }, { - "url": "/agency-term?q", - "abstract": true, - "state": "route.agencyTerm", - "component": "ui-view" - }, { - "url": "/index", - "state": "route.agencyTerm.index", - "component": "vn-agency-term-index", - "description": "Autonomous", - "acl": ["administrative"] - },{ - "url": "/createInvoiceIn?q", - "state": "route.agencyTerm.createInvoiceIn", - "component": "vn-agency-term-create-invoice-in", - "description": "File management", - "params": { - "route": "$ctrl.route" - }, - "acl": ["administrative"] - }, { - "url": "/summary", - "state": "route.card.summary", - "component": "vn-route-summary", - "description": "Summary", - "params": { - "route": "$ctrl.route" - } - }, { - "url": "/basic-data", - "state": "route.card.basicData", - "component": "vn-route-basic-data", - "description": "Basic data", - "params": { - "route": "$ctrl.route" - }, - "acl": ["delivery"] - }, { - "url" : "/log", - "state": "route.card.log", - "component": "vn-route-log", - "description": "Log", - "acl": ["delivery"] - }, { - "url": "/tickets", - "state": "route.card.tickets", - "component": "vn-route-tickets", - "description": "Tickets", - "params": { - "route": "$ctrl.route" - }, - "acl": ["delivery"] - }, { - "url": "/roadmap?q", - "state": "route.roadmap", - "component": "vn-roadmap", - "description": "Roadmaps" - }, { - "url": "/create", - "state": "route.roadmap.create", - "component": "vn-roadmap-create", - "description": "Create roadmap" - },{ - "url": "/:id", - "state": "route.roadmap.card", - "component": "vn-roadmap-card", - "abstract": true, - "description": "Detail" - },{ - "url": "/summary", - "state": "route.roadmap.card.summary", - "component": "vn-roadmap-summary", - "description": "Summary", - "params": { - "roadmap": "$ctrl.roadmap" - } - },{ - "url": "/basic-data", - "state": "route.roadmap.card.basicData", - "component": "vn-roadmap-basic-data", - "description": "Basic data", - "params": { - "roadmap": "$ctrl.roadmap" - } - }, { - "url": "/stops", - "state": "route.roadmap.card.stops", - "component": "vn-roadmap-stops", - "description": "Stops", - "params": { - "route": "$ctrl.roadmap" - } } ] } diff --git a/modules/route/front/search-panel/index.html b/modules/route/front/search-panel/index.html deleted file mode 100644 index f3d392580..000000000 --- a/modules/route/front/search-panel/index.html +++ /dev/null @@ -1,96 +0,0 @@ -
- - -
- - - - - - - - - - -
- - - - - - Or - - - - - -
- - - - - - - - - - - - - - - -
-
diff --git a/modules/route/front/search-panel/index.js b/modules/route/front/search-panel/index.js deleted file mode 100644 index b5abbd94a..000000000 --- a/modules/route/front/search-panel/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -class Controller extends SearchPanel { - constructor($, $element) { - super($, $element); - this.filter = this.$.filter; - } - - get from() { - return this._from; - } - - set from(value) { - this._from = value; - this.filter.scopeDays = null; - } - - get to() { - return this._to; - } - - set to(value) { - this._to = value; - this.filter.scopeDays = null; - } - - get scopeDays() { - return this._scopeDays; - } - - set scopeDays(value) { - this._scopeDays = value; - - this.filter.from = null; - this.filter.to = null; - } -} - -ngModule.vnComponent('vnRouteSearchPanel', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/route/front/search-panel/index.spec.js b/modules/route/front/search-panel/index.spec.js deleted file mode 100644 index ae15e16e4..000000000 --- a/modules/route/front/search-panel/index.spec.js +++ /dev/null @@ -1,48 +0,0 @@ -import './index'; - -describe('Route Component vnRouteSearchPanel', () => { - let controller; - - beforeEach(ngModule('route')); - - beforeEach(inject($componentController => { - controller = $componentController('vnRouteSearchPanel', {$element: null}); - controller.$t = () => {}; - controller.filter = {}; - })); - - describe('from() setter', () => { - it('should clear the scope days when setting the from property', () => { - controller.filter.scopeDays = 1; - - controller.from = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.from).toBeDefined(); - }); - }); - - describe('to() setter', () => { - it('should clear the scope days when setting the to property', () => { - controller.filter.scopeDays = 1; - - controller.to = Date.vnNew(); - - expect(controller.filter.scopeDays).toBeNull(); - expect(controller.to).toBeDefined(); - }); - }); - - describe('scopeDays() setter', () => { - it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = Date.vnNew(); - controller.filter.to = Date.vnNew(); - - controller.scopeDays = 1; - - expect(controller.filter.from).toBeNull(); - expect(controller.filter.to).toBeNull(); - expect(controller.scopeDays).toBeDefined(); - }); - }); -}); diff --git a/modules/route/front/sms/index.html b/modules/route/front/sms/index.html deleted file mode 100644 index 0d7dd7c11..000000000 --- a/modules/route/front/sms/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - -
- - - - - - - {{'Characters remaining' | translate}}: - - {{$ctrl.charactersRemaining()}} - - - -
-
- - - - -
\ No newline at end of file diff --git a/modules/route/front/sms/index.js b/modules/route/front/sms/index.js deleted file mode 100644 index f466adea7..000000000 --- a/modules/route/front/sms/index.js +++ /dev/null @@ -1,47 +0,0 @@ -import ngModule from '../module'; -import Component from 'core/lib/component'; -import './style.scss'; - -class Controller extends Component { - open() { - this.$.SMSDialog.show(); - } - - charactersRemaining() { - const element = this.$.message; - const value = element.input.value; - - const maxLength = 160; - const textAreaLength = new Blob([value]).size; - return maxLength - textAreaLength; - } - - onResponse() { - try { - if (!this.sms.destination) - throw new Error(`The destination can't be empty`); - if (!this.sms.message) - throw new Error(`The message can't be empty`); - if (this.charactersRemaining() < 0) - throw new Error(`The message it's too long`); - - this.$http.post(`Routes/sendSms`, this.sms).then(res => { - this.vnApp.showMessage(this.$t('SMS sent')); - - if (res.data) this.emit('send', {response: res.data}); - }); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - return true; - } -} - -ngModule.vnComponent('vnRouteSms', { - template: require('./index.html'), - controller: Controller, - bindings: { - sms: '<', - } -}); diff --git a/modules/route/front/sms/index.spec.js b/modules/route/front/sms/index.spec.js deleted file mode 100644 index 8bf35e673..000000000 --- a/modules/route/front/sms/index.spec.js +++ /dev/null @@ -1,71 +0,0 @@ -import './index'; - -describe('Route', () => { - describe('Component vnRouteSms', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - let $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnRouteSms', {$element, $scope}); - controller.$.message = { - input: { - value: 'My SMS' - } - }; - })); - - describe('onResponse()', () => { - it('should perform a POST query and show a success snackbar', () => { - let params = {destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - controller.sms = {destinationFk: 1101, destination: 111111111, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showMessage'); - $httpBackend.expect('POST', `Routes/sendSms`, params).respond(200, params); - - controller.onResponse(); - $httpBackend.flush(); - - expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent'); - }); - - it('should call onResponse without the destination and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, message: 'My SMS'}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`); - }); - - it('should call onResponse without the message and show an error snackbar', () => { - controller.sms = {destinationFk: 1101, destination: 222222222}; - - jest.spyOn(controller.vnApp, 'showError'); - - controller.onResponse(); - - expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`); - }); - }); - - describe('charactersRemaining()', () => { - it('should return the characters remaining in a element', () => { - controller.$.message = { - input: { - value: 'My message 0€' - } - }; - - let result = controller.charactersRemaining(); - - expect(result).toEqual(145); - }); - }); - }); -}); diff --git a/modules/route/front/sms/locale/es.yml b/modules/route/front/sms/locale/es.yml deleted file mode 100644 index 0168a6eb6..000000000 --- a/modules/route/front/sms/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Send SMS to the selected tickets: Enviar SMS a los tickets seleccionados -Routes to notify: Rutas a notificar -Message: Mensaje -SMS sent!: ¡SMS enviado! -Characters remaining: Carácteres restantes -The destination can't be empty: El destinatario no puede estar vacio -The message can't be empty: El mensaje no puede estar vacio -The message it's too long: El mensaje es demasiado largo -Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios \ No newline at end of file diff --git a/modules/route/front/sms/style.scss b/modules/route/front/sms/style.scss deleted file mode 100644 index 84571a5f4..000000000 --- a/modules/route/front/sms/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "variables"; - -.SMSDialog { - min-width: 400px -} \ No newline at end of file diff --git a/modules/route/front/ticket-popup/index.html b/modules/route/front/ticket-popup/index.html deleted file mode 100644 index 5046d5e43..000000000 --- a/modules/route/front/ticket-popup/index.html +++ /dev/null @@ -1,84 +0,0 @@ - - - - Tickets to add -
- -
-
-
- - - - - - - - - - - - Ticket - Client - Province - - - Population - - - PC - Address - Zone - - - - - - - - - - - {{::ticket.id}} - - - - - {{::ticket.nickname}} - - - {{::ticket.address.province.name}} - {{::ticket.address.city}} - {{::ticket.address.postalCode}} - {{::ticket.address.street}} - - {{::ticket.zone.name}} - - - - - - - - - - - - - - - diff --git a/modules/route/front/ticket-popup/index.js b/modules/route/front/ticket-popup/index.js deleted file mode 100644 index 8fd7b5d71..000000000 --- a/modules/route/front/ticket-popup/index.js +++ /dev/null @@ -1,80 +0,0 @@ -import ngModule from '../module'; -import Dialog from 'core/components/dialog'; -import './style.scss'; - -class Controller extends Dialog { - constructor($element, $, $transclude) { - super($element, $, $transclude); - } - - getSelectedTickets(tickets) { - const selectedTickets = []; - - if (tickets) { - for (let i = 0; i < tickets.length; i++) { - if (tickets[i].checked) - selectedTickets.push(tickets[i]); - } - } - return selectedTickets; - } - - updateVolume() { - let url = `Routes/${this.route.id}/updateVolume`; - this.$http.post(url).then(() => { - this.$.model.refresh(); - if (this.parentReload) - this.parentReload(); - }); - } - - setTicketsRoute() { - const tickets = this.getSelectedTickets(this.possibleTickets); - if (tickets.length === 0) return; - - const updates = []; - - for (let ticket of tickets) { - delete ticket.checked; - const update = { - where: {id: ticket.id}, - data: {routeFk: this.route.id} - }; - - updates.push(update); - } - - const data = {creates: [], updates: updates, deletes: []}; - return this.$http.post(`Tickets/crud`, data) - .then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.updateVolume(); - this.hide(); - }); - } - - unlinkZone(ticket) { - const params = { - agencyModeId: this.route.agencyModeFk, - zoneId: ticket.zoneFk, - }; - - const query = `Routes/unlink`; - this.$http.post(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - this.hide(); - }); - } -} -Controller.$inject = ['$element', '$scope', '$transclude']; - -ngModule.vnComponent('vnRouteTicketPopup', { - slotTemplate: require('./index.html'), - controller: Controller, - bindings: { - route: '<', - model: ' { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - const $transclude = { - $$boundTransclude: { - $$slots: [] - } - }; - controller = $componentController('vnRouteTicketPopup', {$element, $scope, $transclude}); - controller.route = {id: 1}; - controller.$.model = { - refresh: () => {}, - remove: () => {} - }; - controller.card = {reload: () => {}}; - })); - - describe('unlink()', () => { - it('should call the route unlink endpoint with the agency and zone ids', () => { - controller.$.model = {refresh: jest.fn()}; - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller, 'hide'); - - controller.route = { - agencyModeFk: 1 - }; - - const ticket = { - zoneFk: 2, - }; - const params = { - agencyModeId: controller.route.agencyModeFk, - zoneId: ticket.zoneFk, - }; - - $httpBackend.expectPOST(`Routes/unlink`, params).respond('ok'); - controller.unlinkZone(ticket); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.hide).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('setTicketsRoute()', () => { - it('should perform a POST query to add tickets to the route', () => { - controller.$.model = {refresh: jest.fn()}; - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller, 'hide'); - - controller.route = {id: 111}; - - controller.possibleTickets = [ - {id: 2, checked: false}, - {id: 3, checked: true}, - {id: 4, checked: false}, - {id: 5, checked: true}, - ]; - - $httpBackend.whenPOST(`Routes/${controller.route.id}/updateVolume`).respond(200); - $httpBackend.expectPOST('Tickets/crud').respond(); - controller.setTicketsRoute(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.hide).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/route/front/ticket-popup/style.scss b/modules/route/front/ticket-popup/style.scss deleted file mode 100644 index 77fa48f20..000000000 --- a/modules/route/front/ticket-popup/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -@import "variables"; - -.dialog{ - padding: $float-spacing -} \ No newline at end of file diff --git a/modules/route/front/tickets/__snapshots__/index.spec.js.snap b/modules/route/front/tickets/__snapshots__/index.spec.js.snap deleted file mode 100644 index 9476a8e09..000000000 --- a/modules/route/front/tickets/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,18 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Route getSelectedItems() should return the selected items 1`] = ` -Array [ - Object { - "checked": true, - "id": 1, - }, - Object { - "checked": true, - "id": 3, - }, - Object { - "checked": true, - "id": 5, - }, -] -`; diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html deleted file mode 100644 index 7fafeb0ba..000000000 --- a/modules/route/front/tickets/index.html +++ /dev/null @@ -1,203 +0,0 @@ - - - -
- -
- - - - - - - - - - - - - - - - - - - - - Order - Street - City - PC - Client - Warehouse - Packages - - Packaging - Ticket - - - - - - - - - - - - - - - - - - {{ticket.priority}} - - - - - - - {{::ticket.street}} - - {{::ticket.city}} - - {{::ticket.postalCode}} - - - {{::ticket.nickname}} - - - {{ticket.warehouseName}} - {{::ticket.packages}} - {{::ticket.volume | number:2}} - {{::ticket.ipt}} - - - {{::ticket.id}} - - - - - - - - - - - - - - - - - -
-
-
-
- - - - - - - - - -
- - - - - - -
- - - - - - - diff --git a/modules/route/front/tickets/index.js b/modules/route/front/tickets/index.js deleted file mode 100644 index a1b97005e..000000000 --- a/modules/route/front/tickets/index.js +++ /dev/null @@ -1,201 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; -import UserError from 'core/lib/user-error'; - -class Controller extends Section { - get isChecked() { - if (this.tickets) { - for (let instance of this.tickets) - if (instance.checked) return true; - } - - return false; - } - - getHighestPriority() { - let highestPriority = Math.max(...this.$.model.data.map(tag => { - return tag.priority; - })); - return highestPriority + 1; - } - - setHighestPriority(ticket) { - const highestPriority = this.getHighestPriority(); - if (highestPriority - 1 != ticket.priority) { - const params = {priority: highestPriority}; - const query = `Tickets/${ticket.id}/`; - this.$http.patch(query, params).then(res => { - ticket.priority = res.data.priority; - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - } - - setPriority(id, priority) { - let params = {priority: priority}; - let query = `Tickets/${id}/`; - this.$http.patch(query, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - deletePriority() { - const lines = this.getSelectedItems(this.tickets); - - for (const line of lines) { - this.$http.patch(`Tickets/${line.id}/`, {priority: null}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - }); - } - } - - setOrderedPriority(lines) { - let priority = 1; - for (const line of lines) { - this.$http.patch(`Tickets/${line.id}/`, {priority: priority}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.$.model.refresh(); - }); - priority++; - } - } - - getSelectedItems(items) { - const selectedItems = []; - - if (items) { - for (let i = 0; i < items.length; i++) { - if (items[i].checked) - selectedItems.push(items[i]); - } - } - return selectedItems; - } - - goToBuscaman(ticket) { - if (!this.route.vehicleFk) - throw new UserError(`The route doesn't have a vehicle`); - - this.$http.get(`Routes/${this.route.vehicleFk}/getDeliveryPoint`).then(res => { - if (!res.data) - throw new UserError(`The route's vehicle doesn't have a delivery point`); - - let addresses = res.data; - const lines = ticket ? [ticket] : this.getSelectedItems(this.tickets); - lines.forEach((line, index) => { - const previousLine = lines[index - 1] ? lines[index - 1].street : null; - if (previousLine != line.street) - addresses = addresses + '+to:' + line.postalCode + ' ' + line.city + ' ' + line.street; - }); - - const url = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr='; - window.open(url + encodeURI(addresses), '_blank'); - }); - } - - showDeleteConfirm(id) { - this.selectedTicket = id; - this.$.confirm.show(); - } - - removeTicketFromRoute($index) { - let params = {routeFk: null}; - let query = `Tickets/${this.selectedTicket}/`; - this.$http.patch(query, params).then(() => { - this.$.model.remove($index); - this.vnApp.showSuccess(this.$t('Ticket removed from route')); - this.updateVolume(); - }); - } - - updateVolume() { - let url = `Routes/${this.$params.id}/updateVolume`; - this.$http.post(url).then(() => { - this.card.reload(); - this.$.model.refresh(); - }); - } - - guessPriority() { - let query = `Routes/${this.$params.id}/guessPriority/`; - this.$http.patch(query).then(() => { - this.vnApp.showSuccess(this.$t('Order changed')); - this.$.model.refresh(); - }); - } - - onDrop($event) { - const ticketId = $event.dataTransfer.getData('Text'); - - if (isNaN(ticketId)) { - const regexp = new RegExp(/\/ticket\/([0-9]+)\//i); - const matches = ticketId.match(regexp); - - if (matches && matches.length) - this.insert(matches[1]); - else - this.vnApp.showError(this.$t('Ticket not found')); - } - - if (!isNaN(ticketId)) - this.insert(ticketId); - } - - insert(ticketId) { - ticketId = parseInt(ticketId); - - const query = `Routes/${this.route.id}/insertTicket`; - return this.$http.patch(query, {ticketId}).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - this.updateVolume(); - }).catch(error => { - if (error.status == 404) - return this.vnApp.showError(this.$t('Ticket not found')); - throw error; - }); - } - - async sendSms() { - try { - const clientsFk = []; - const clientsName = []; - const clients = []; - - const selectedTickets = this.getSelectedItems(this.$.$ctrl.tickets); - - for (let ticket of selectedTickets) { - clientsFk.push(ticket.clientFk); - let userContact = await this.$http.get(`Clients/${ticket.clientFk}`); - clientsName.push(userContact.data.name); - clients.push(userContact.data.phone); - } - - const destinationFk = String(clientsFk); - const destination = String(clients); - - this.newSMS = Object.assign({ - destinationFk: destinationFk, - destination: destination - }); - - this.$.sms.open(); - return true; - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - } -} - -ngModule.vnComponent('vnRouteTickets', { - template: require('./index.html'), - controller: Controller, - require: { - card: '^vnRouteCard' - }, - bindings: { - route: '<' - } -}); diff --git a/modules/route/front/tickets/index.spec.js b/modules/route/front/tickets/index.spec.js deleted file mode 100644 index fef4b8331..000000000 --- a/modules/route/front/tickets/index.spec.js +++ /dev/null @@ -1,277 +0,0 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ -import './index'; - -describe('Route', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(ngModule('route')); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(''); - controller = $componentController('vnRouteTickets', {$element, $scope}); - controller.route = {id: 1}; - controller.$.model = { - refresh: () => {}, - remove: () => {} - }; - controller.card = {reload: () => {}}; - })); - - describe('route setter/getter', () => { - it('should return the route id', () => { - controller.route = 2; - - expect(controller.route).toEqual(2); - }); - }); - - describe('isChecked getter', () => { - it('should return false if none of the tickets is checked or there are no tickets', () => { - expect(controller.isChecked).toBeFalsy(); - }); - - it('should return true if any of the tickets is checked', () => { - controller.tickets = [{checked: true}]; - - expect(controller.isChecked).toBeTruthy(); - }); - }); - - describe('getHighestPriority()', () => { - it('should return the highest value found in priorities plus 1', () => { - controller.$.model = {data: [ - {priority: 99}, - {priority: 1}, - {priority: 2}, - {priority: 3}, - {priority: 4}, - {priority: 5}, - ]}; - - let result = controller.getHighestPriority(); - - expect(result).toEqual(100); - }); - }); - - describe('setHighestPriority()', () => { - it('should set a ticket highest priority', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.$.model.data = [{priority: 3}]; - const ticket = {id: 1, priority: 2}; - const res = {data: {priority: 4}}; - - $httpBackend.expectPATCH(`Tickets/${ticket.id}/`).respond(res); - controller.setHighestPriority(ticket); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('setPriority()', () => { - it('should set a ticket priority', () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - const ticketId = 1; - const priority = 999; - - $httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok'); - controller.setPriority(ticketId, priority); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - }); - }); - - describe('deletePriority()', () => { - it('should delete priority of all tickets', () => { - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.tickets = [{id: 1, checked: true}]; - - $httpBackend.expectPATCH(`Tickets/${controller.tickets[0].id}/`).respond(); - controller.deletePriority(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('setOrderedPriority()', () => { - it('should set priority of all tickets starting by 1', () => { - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.vnApp, 'showSuccess'); - const tickets = [{id: 1, checked: true}]; - - $httpBackend.expectPATCH(`Tickets/${tickets[0].id}/`).respond(); - controller.setOrderedPriority(tickets); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); - - describe('getSelectedItems()', () => { - it('should return the selected items', () => { - let items = [ - {id: 1, checked: true}, - {id: 2, checked: false}, - {id: 3, checked: true}, - {id: 4, checked: false}, - {id: 5, checked: true}, - ]; - - let selectedItems = controller.getSelectedItems(items); - - expect(selectedItems).toMatchSnapshot(); - }); - }); - - describe('goToBuscaman()', () => { - it('should open buscaman with the given arguments', () => { - jest.spyOn(window, 'open').mockReturnThis(); - const expectedUrl = 'http://gps.buscalia.com/usuario/localizar.aspx?bmi=true&addr=46460%20Av%20Espioca%20100+to:n19%20London%20my%20street'; - controller.route = {vehicleFk: 1}; - const url = `Routes/${controller.route.vehicleFk}/getDeliveryPoint`; - $httpBackend.expectGET(url).respond('46460 Av Espioca 100'); - - controller.tickets = [ - { - id: 1, - checked: true, - street: 'my street', - postalCode: 'n19', - city: 'London' - }, - ]; - - controller.goToBuscaman(); - $httpBackend.flush(); - - expect(window.open).toHaveBeenCalledWith(expectedUrl, '_blank'); - }); - }); - - describe('showDeleteConfirm()', () => { - it('should open a confirm dialog after setting the selected ticket into the controller', () => { - controller.$.confirm = {show: () => {}}; - jest.spyOn(controller.$.confirm, 'show'); - let ticketId = 1; - - controller.showDeleteConfirm(ticketId); - - expect(controller.selectedTicket).toEqual(ticketId); - expect(controller.$.confirm.show).toHaveBeenCalledWith(); - }); - }); - - describe('removeTicketFromRoute()', () => { - it('should perform a patch query then call showSuccess and updateVolume methods', () => { - controller.$params = {id: 1101}; - - jest.spyOn(controller.vnApp, 'showSuccess'); - jest.spyOn(controller.$.model, 'remove'); - - let ticketId = 1; - controller.selectedTicket = ticketId; - - $httpBackend.whenPOST(`Routes/${controller.$params.id}/updateVolume`).respond(200); - $httpBackend.expectPATCH(`Tickets/${ticketId}/`).respond('ok'); - controller.removeTicketFromRoute(); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Ticket removed from route'); - }); - }); - - describe('updateVolume()', () => { - it('should perform a POST query then call both reload and refresh methods', () => { - controller.$params = {id: 999}; - jest.spyOn(controller.$.model, 'refresh'); - jest.spyOn(controller.card, 'reload'); - - let ticketId = 1; - controller.selectedTicket = ticketId; - - const url = `Routes/${controller.$params.id}/updateVolume`; - $httpBackend.expectPOST(url).respond('ok'); - controller.updateVolume(); - $httpBackend.flush(); - - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - }); - }); - - describe('onDrop()', () => { - it('should call the insert method when dragging a ticket number', () => { - jest.spyOn(controller, 'insert'); - - const expectedTicketId = '11'; - const draggedElement = '11'; - const $event = { - dataTransfer: { - getData: () => draggedElement - } - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); - }); - - it('should call the insert method when dragging a ticket link', () => { - jest.spyOn(controller, 'insert'); - - const expectedTicketId = '11'; - const draggedElement = 'http://arkamcity.com/#!/ticket/11/summary'; - const $event = { - dataTransfer: { - getData: () => draggedElement - } - }; - controller.onDrop($event); - - expect(controller.insert).toHaveBeenCalledWith(expectedTicketId); - }); - - it('should throw an error when dragging an invalid ticket link', () => { - jest.spyOn(controller.vnApp, 'showError'); - - const draggedElement = 'http://arkamcity.com/#!/item/11/summary'; - const $event = { - dataTransfer: { - getData: () => draggedElement - } - }; - controller.onDrop($event); - - expect(controller.vnApp.showError).toHaveBeenCalledWith('Ticket not found'); - }); - }); - - describe('insert()', () => { - it('should make a HTTP patch query and then call both refresh and showSuccess methods', () => { - controller.$params = {id: 1101}; - - jest.spyOn(controller.$.model, 'refresh').mockReturnThis(); - jest.spyOn(controller.vnApp, 'showSuccess'); - - const ticketId = 11; - const data = {ticketId}; - - $httpBackend.whenPOST(`Routes/${controller.$params.id}/updateVolume`).respond(200); - $httpBackend.expect('PATCH', `Routes/1/insertTicket`, data).respond(); - controller.insert(ticketId); - $httpBackend.flush(); - - expect(controller.vnApp.showSuccess).toHaveBeenCalled(); - expect(controller.$.model.refresh).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/modules/route/front/tickets/locale/es.yml b/modules/route/front/tickets/locale/es.yml deleted file mode 100644 index e7f483d2f..000000000 --- a/modules/route/front/tickets/locale/es.yml +++ /dev/null @@ -1,18 +0,0 @@ -Remove ticket: Eliminar ticket -Open buscaman: Abrir buscaman -Ticket removed from route: Ticket quitado de la ruta -Order changed: Orden cambiado -Delete ticket from route?: ¿Quitar el ticket de la ruta? -Sort routes: Ordenar rutas -Add ticket: Añadir ticket -Tickets to add: Tickets a añadir -Ticket not found: No se ha encontrado el ticket -The selected ticket is not suitable for this route: El ticket seleccionado no es apto para esta ruta -PC: CP -The route's vehicle doesn't have a delivery point: El vehículo de la ruta no tiene un punto de entrega -The route doesn't have a vehicle: La ruta no tiene un vehículo -Population: Población -Unlink selected zone?: Desvincular zona seleccionada? -Delete priority: Borrar orden -Renumber all tickets in the order you see on the screen: Renumerar todos los tickets con el orden que ves por pantalla -Assign highest priority: Asignar máxima prioridad \ No newline at end of file diff --git a/modules/route/front/tickets/style.scss b/modules/route/front/tickets/style.scss deleted file mode 100644 index 9393a7d59..000000000 --- a/modules/route/front/tickets/style.scss +++ /dev/null @@ -1,16 +0,0 @@ -@import "variables"; - -vn-route-tickets form{ - margin: 0 auto; - max-width: $width-lg; - - .order-field { - max-width: 30px; - } -} - -.button-right{ - display: block; - padding-right: 50px; - text-align: right; -} \ No newline at end of file From 2505adf87fc5786f93d2aa7fabe74d5893d86b2f Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 26 Jul 2024 13:47:15 +0200 Subject: [PATCH 143/181] hotFix: ticketAdvanced --- modules/ticket/front/advance/index.js | 12 +++--------- modules/ticket/front/advance/index.spec.js | 18 ------------------ 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 1f47d8242..15ad303e3 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -62,8 +62,11 @@ export default class Controller extends Section { setDefaultFilter() { let today = Date.vnNew(); + today.setHours(0, 0, 0, 0); const tomorrow = new Date(today); tomorrow.setDate(tomorrow.getDate() + 1); + tomorrow.setHours(23, 59, 59, 999); + this.$http.get(`UserConfigs/getUserConfig`) .then(res => { this.filterParams = { @@ -86,15 +89,6 @@ export default class Controller extends Section { return checkedLines; } - dateRange(value) { - const minHour = new Date(value); - minHour.setHours(0, 0, 0, 0); - const maxHour = new Date(value); - maxHour.setHours(23, 59, 59, 59); - - return [minHour, maxHour]; - } - totalPriceColor(totalWithVat) { return this.isLessThan50(totalWithVat) ? 'warning' : ''; } diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js index 883993c1c..5caca742c 100644 --- a/modules/ticket/front/advance/index.spec.js +++ b/modules/ticket/front/advance/index.spec.js @@ -36,24 +36,6 @@ describe('Component vnTicketAdvance', () => { }); }); - describe('dateRange()', () => { - it('should return two dates with the hours at the start and end of the given date', () => { - const now = Date.vnNew(); - - const today = now.getDate(); - - const dateRange = controller.dateRange(now); - const start = dateRange[0].toString(); - const end = dateRange[1].toString(); - - expect(start).toContain(today); - expect(start).toContain('00:00:00'); - - expect(end).toContain(today); - expect(end).toContain('23:59:59'); - }); - }); - describe('moveTicketsAdvance()', () => { it('should make an HTTP Post query', () => { jest.spyOn(controller.$.model, 'refresh'); From b876d1c2781ef674cddb6feb69cce6343d785f89 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 26 Jul 2024 13:52:18 +0200 Subject: [PATCH 144/181] feat: refs #7644 Added item reference --- .../back/methods/client/hasCustomerRole.js | 2 +- .../reports/buy-label/assets/css/style.css | 5 +---- .../templates/reports/buy-label/buy-label.html | 18 ++++++++++++------ .../templates/reports/buy-label/locale/en.yml | 3 ++- .../templates/reports/buy-label/locale/es.yml | 3 ++- print/templates/reports/buy-label/sql/buys.sql | 3 ++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/modules/client/back/methods/client/hasCustomerRole.js b/modules/client/back/methods/client/hasCustomerRole.js index e790d6e3a..08e90077e 100644 --- a/modules/client/back/methods/client/hasCustomerRole.js +++ b/modules/client/back/methods/client/hasCustomerRole.js @@ -29,7 +29,7 @@ module.exports = Self => { SELECT COUNT(*) > 0 isCustomer FROM salix.Account A JOIN salix.Role r ON r.id = A.roleFK - WHERE r.name = 'customer' + WHERE r.name IN ('customer', 'supplier') AND A.id IN (?)`; const [result] = await Self.rawSql(query, [id], myOptions); const {isCustomer} = result; diff --git a/print/templates/reports/buy-label/assets/css/style.css b/print/templates/reports/buy-label/assets/css/style.css index 0d4a2891d..3b1f2f91e 100644 --- a/print/templates/reports/buy-label/assets/css/style.css +++ b/print/templates/reports/buy-label/assets/css/style.css @@ -33,9 +33,6 @@ span { .barcode { text-align: center; } -#variant { +.one-third { width: 314px; -} -#producer { - width: 471px; } \ No newline at end of file diff --git a/print/templates/reports/buy-label/buy-label.html b/print/templates/reports/buy-label/buy-label.html index b14e54759..4a0d7f3fc 100644 --- a/print/templates/reports/buy-label/buy-label.html +++ b/print/templates/reports/buy-label/buy-label.html @@ -4,7 +4,7 @@ -
+ @@ -63,18 +63,24 @@ - -
+ + + +
+ {{$t('control')}} + {{`${weekNum} / ${dayNum}`}} +
+ -
- {{$t('control')}} - {{`${weekNum} / ${dayNum}`}} + diff --git a/print/templates/reports/buy-label/locale/en.yml b/print/templates/reports/buy-label/locale/en.yml index d48d00771..333282759 100644 --- a/print/templates/reports/buy-label/locale/en.yml +++ b/print/templates/reports/buy-label/locale/en.yml @@ -9,4 +9,5 @@ grouping: Grouping unitSale: Un. sale producer: Producer control: Control -boxNum: Box no. \ No newline at end of file +boxNum: Box no. +reference: Reference \ No newline at end of file diff --git a/print/templates/reports/buy-label/locale/es.yml b/print/templates/reports/buy-label/locale/es.yml index 33a4a499d..af1d9aa1c 100644 --- a/print/templates/reports/buy-label/locale/es.yml +++ b/print/templates/reports/buy-label/locale/es.yml @@ -9,4 +9,5 @@ grouping: Grouping saleUnit: Sale un. producer: Productor control: Control -boxNum: Caja nº \ No newline at end of file +boxNum: Caja nº +reference: Referencia \ No newline at end of file diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql index d75366815..015a74797 100644 --- a/print/templates/reports/buy-label/sql/buys.sql +++ b/print/templates/reports/buy-label/sql/buys.sql @@ -20,7 +20,8 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, i.stems, b.id, b.itemFk, - p.name producer + p.name producer, + i.comment FROM buy b JOIN item i ON i.id = b.itemFk LEFT JOIN producer p ON p.id = i.producerFk From a4d3eec1e1bd7066323f06318d38b702c63754a0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 26 Jul 2024 14:05:22 +0200 Subject: [PATCH 145/181] fix: refs #7580 Parking deadlock --- db/routines/vn/procedures/saleGroup_setParking.sql | 9 ++------- db/routines/vn/procedures/setParking.sql | 10 ---------- db/routines/vn/procedures/shelving_setParking.sql | 6 +++--- db/routines/vn/procedures/ticket_setParking.sql | 5 ----- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/db/routines/vn/procedures/saleGroup_setParking.sql b/db/routines/vn/procedures/saleGroup_setParking.sql index 551ca6386..fffe5e154 100644 --- a/db/routines/vn/procedures/saleGroup_setParking.sql +++ b/db/routines/vn/procedures/saleGroup_setParking.sql @@ -10,15 +10,10 @@ BEGIN * @param vSaleGroupFk id de la preparación previa * @param vParkingFk id del parking */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - RESIGNAL; - END; - UPDATE saleGroup sg SET sg.parkingFk = vParkingFk - WHERE sg.id = vSaleGroupFk - AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK; + WHERE sg.id = vSaleGroupFk + AND sg.created >= util.VN_CURDATE() - INTERVAL 1 WEEK; CALL ticket_setNextState(ticket_get(vSaleGroupFk)); END$$ diff --git a/db/routines/vn/procedures/setParking.sql b/db/routines/vn/procedures/setParking.sql index 1aa4f920a..b3edf350d 100644 --- a/db/routines/vn/procedures/setParking.sql +++ b/db/routines/vn/procedures/setParking.sql @@ -13,12 +13,6 @@ BEGIN DECLARE vParkingFk INT; DECLARE vLastWeek DATE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - SET vParkingCode = REPLACE(vParkingCode, ' ', ''); SELECT id INTO vParkingFk @@ -29,8 +23,6 @@ BEGIN CALL util.throw('parkingNotExist'); END IF; - START TRANSACTION; - SET vLastWeek = util.VN_CURDATE() - INTERVAL 1 WEEK; -- Comprobamos si es una prep. previa, ticket, colección o shelving @@ -45,7 +37,5 @@ BEGIN ELSE CALL util.throw('paramNotExist'); END IF; - - COMMIT; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/shelving_setParking.sql b/db/routines/vn/procedures/shelving_setParking.sql index 0ff07ef5d..3e8717197 100644 --- a/db/routines/vn/procedures/shelving_setParking.sql +++ b/db/routines/vn/procedures/shelving_setParking.sql @@ -1,20 +1,20 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`shelving_setParking`(IN `vShelvingCode` VARCHAR(8), IN `vParkingFk` INT) -proc: BEGIN +BEGIN /** * Aparca una matrícula en un parking * * @param vShelvingCode code de la matrícula * @param vParkingFk id del parking */ - INSERT INTO vn.shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) + INSERT INTO shelvingLog (originFk, userFk, action , description,changedModel,changedModelId) SELECT s.id, account.myUser_getId(), 'update', CONCAT("Cambio parking ",vShelvingCode," de ", p.code," a ", pNew.code),'Shelving',s.id FROM parking p JOIN shelving s ON s.parkingFk = p.id JOIN parking pNew ON pNew.id = vParkingFk WHERE s.code = vShelvingCode COLLATE utf8_unicode_ci; - UPDATE vn.shelving + UPDATE shelving SET parkingFk = vParkingFk, parked = util.VN_NOW(), isPrinted = TRUE diff --git a/db/routines/vn/procedures/ticket_setParking.sql b/db/routines/vn/procedures/ticket_setParking.sql index 7935e0d60..bd2a5370a 100644 --- a/db/routines/vn/procedures/ticket_setParking.sql +++ b/db/routines/vn/procedures/ticket_setParking.sql @@ -21,11 +21,6 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - RESIGNAL; - END; - INSERT INTO vn.ticketParking(ticketFk, parkingFk) SELECT IFNULL(tc2.ticketFk, t.id), vParkingFk FROM ticket t From c713c3a5c0b5dcd94e10436cf3b01cb2137f9c10 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 09:21:35 +0200 Subject: [PATCH 146/181] fix: refs #6861 Unhandled error --- loopback/locale/es.json | 5 +++-- modules/item/back/methods/item-shelving/updateFromSale.js | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e2be5d013..acc3d69f6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -367,5 +367,6 @@ "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", "Payment method is required": "El método de pago es obligatorio", "Cannot send mail": "Não é possível enviar o email", - "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos" -} + "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", + "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo" +} \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/updateFromSale.js b/modules/item/back/methods/item-shelving/updateFromSale.js index 2b9f49cae..167509074 100644 --- a/modules/item/back/methods/item-shelving/updateFromSale.js +++ b/modules/item/back/methods/item-shelving/updateFromSale.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethod('updateFromSale', { description: 'Update the visible items', @@ -32,6 +33,9 @@ module.exports = Self => { include: {relation: 'itemShelving'} }, myOptions); + if (!itemShelvingSale?.itemShelving()) + throw new UserError('The sale not exists in the item shelving'); + const itemShelving = itemShelvingSale.itemShelving(); const quantity = itemShelving.visible + itemShelvingSale.quantity; From 5264d6c9739afe1e66524ff216075f809daba008 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 29 Jul 2024 10:35:01 +0200 Subject: [PATCH 147/181] feat(postcode_town): refs #7679 add requireds --- back/models/postcode.json | 5 +++-- back/models/town.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/back/models/postcode.json b/back/models/postcode.json index eadc2c86c..bad6be5d7 100644 --- a/back/models/postcode.json +++ b/back/models/postcode.json @@ -9,7 +9,8 @@ "properties": { "code": { "id": true, - "type": "string" + "type": "string", + "required": true } }, "relations": { @@ -47,4 +48,4 @@ } } } -} \ No newline at end of file +} diff --git a/back/models/town.json b/back/models/town.json index 4ad729791..e5d39314b 100644 --- a/back/models/town.json +++ b/back/models/town.json @@ -12,7 +12,8 @@ "type": "number" }, "name": { - "type": "string" + "type": "string", + "required": true } }, "relations": { @@ -54,4 +55,4 @@ "fields": ["id", "name", "provinceFk"] } } -} \ No newline at end of file +} From 4c602800ea9183a72ef358e29a5141286711bb5c Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 11:46:59 +0200 Subject: [PATCH 148/181] feat: refs #6453 Added new ticket search --- .../procedures/order_confirmWithUser.sql | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 841a69390..48f97c9b6 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -123,14 +123,14 @@ BEGIN LEAVE lDates; END IF; - -- Busca un ticket existente que coincida con los parametros + -- Busca un ticket libre disponible WITH tPrevia AS ( SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ) + ), SELECT t.id INTO vTicketFk FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' @@ -146,6 +146,37 @@ BEGIN AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) LIMIT 1; + -- Comprobamos si hay un ticket de previa disponible + IF vTicketFk IS NULL THEN + WITH tItemPackingTypeOrder AS ( + SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes, + o.address_id + FROM vn.item i + JOIN orderRow oro ON oro.itemFk = i.id + JOIN `order` o ON o.id = oro.orderFk + WHERE oro.orderFk = vSelf + ), + tItemPackingTypeTicket AS ( + SELECT t.id, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes + FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'ON_PREVIOUS' + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + JOIN tItemPackingTypeOrder ipto + WHERE t.refFk IS NULL + AND DATE(t.shipped) = vShipment + AND t.warehouseFk = vWarehouseFk + AND t.addressFk = ipto.address_id + GROUP BY t.id + ) + SELECT iptt.id INTO vTicketFk + FROM tItemPackingTypeTicket iptt + JOIN tItemPackingTypeOrder ipto + WHERE INSTR(iptt.distinctItemPackingTypes, ipto.distinctItemPackingTypes) + LIMIT 1 + END IF; + -- Crea el ticket en el caso de no existir uno adecuado IF vTicketFk IS NULL THEN SET vShipment = IFNULL(vShipment, util.VN_CURDATE()); From e53b12d51bc220990d3e90ea0f20a2985adec303 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 12:31:44 +0200 Subject: [PATCH 149/181] feat: refs #6453 Fixes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 48f97c9b6..cf0f9aead 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -20,6 +20,7 @@ BEGIN DECLARE vItemFk INT; DECLARE vConcept VARCHAR(30); DECLARE vAmount INT; + DECLARE vAvailable INT; DECLARE vPrice DECIMAL(10,2); DECLARE vSaleFk INT; DECLARE vRowFk INT; @@ -48,7 +49,6 @@ BEGIN i.name, r.amount, r.price, - i.itemPackingTypeFk, i.isFloramondo FROM orderRow r JOIN vn.item i ON i.id = r.itemFk @@ -130,7 +130,7 @@ BEGIN JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) - ), + ) SELECT t.id INTO vTicketFk FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' @@ -174,7 +174,7 @@ BEGIN FROM tItemPackingTypeTicket iptt JOIN tItemPackingTypeOrder ipto WHERE INSTR(iptt.distinctItemPackingTypes, ipto.distinctItemPackingTypes) - LIMIT 1 + LIMIT 1; END IF; -- Crea el ticket en el caso de no existir uno adecuado @@ -224,7 +224,6 @@ BEGIN vConcept, vAmount, vPrice, - vItemPackingTypeFk, vIsLogifloraItem; IF vDone THEN From 6ad3d5a5ebdc37873d5c6dc3791e6529fe1308bb Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 29 Jul 2024 12:36:08 +0200 Subject: [PATCH 150/181] feat: refs #6453 Minor changes --- db/routines/hedera/procedures/order_confirmWithUser.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index cf0f9aead..4fcee91f7 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -15,6 +15,7 @@ BEGIN DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; + DECLARE vShipmentDayEnd DATE; DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); DECLARE vItemFk INT; @@ -123,13 +124,15 @@ BEGIN LEAVE lDates; END IF; + SET vShipmentDayEnd = util.dayEnd(vShipment); + -- Busca un ticket libre disponible WITH tPrevia AS ( SELECT DISTINCT s.ticketFk FROM vn.sale s JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vShipment AND util.dayend(vShipment) + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd ) SELECT t.id INTO vTicketFk FROM vn.ticket t @@ -139,7 +142,7 @@ BEGIN JOIN hedera.`order` o ON o.address_id = t.addressFk AND t.warehouseFk = vWarehouseFk AND o.date_send = t.landed - AND DATE(t.shipped) = vShipment + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL @@ -165,7 +168,7 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN tItemPackingTypeOrder ipto WHERE t.refFk IS NULL - AND DATE(t.shipped) = vShipment + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd AND t.warehouseFk = vWarehouseFk AND t.addressFk = ipto.address_id GROUP BY t.id From 254cced550a5a417e840fe844ac46250ba319ecd Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 29 Jul 2024 13:40:30 +0200 Subject: [PATCH 151/181] chore: refs #6989 add config model --- back/model-config.json | 3 +++ back/models/config.json | 22 +++++++++++++++++++ db/routines/vn/procedures/item_getBalance.sql | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 back/models/config.json diff --git a/back/model-config.json b/back/model-config.json index a16fe4e8a..13c06ef54 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -28,6 +28,9 @@ "Company": { "dataSource": "vn" }, + "Config": { + "dataSource": "vn" + }, "Continent": { "dataSource": "vn" }, diff --git a/back/models/config.json b/back/models/config.json new file mode 100644 index 000000000..e5ba1f134 --- /dev/null +++ b/back/models/config.json @@ -0,0 +1,22 @@ +{ + "name": "Config", + "base": "VnModel", + "options": { + "mysql": { + "table": "config" + } + }, + "properties": { + "inventoried": { + "type": "date" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/routines/vn/procedures/item_getBalance.sql b/db/routines/vn/procedures/item_getBalance.sql index 0de59b478..3a594c81c 100644 --- a/db/routines/vn/procedures/item_getBalance.sql +++ b/db/routines/vn/procedures/item_getBalance.sql @@ -240,7 +240,7 @@ BEGIN NULL reference, NULL entityType, NULL entityId, - 'Inventario calculado', + 'Inventario calculado' entityName, @a invalue, NULL `out`, @a balance, From 434dfe4ae45740e8d60f603eeae7941231c9632e Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 29 Jul 2024 15:03:40 +0200 Subject: [PATCH 152/181] fix: refs #7679 postcode filter --- back/methods/postcode/filter.js | 36 +++++++++++++++------------------ loopback/locale/en.json | 4 +++- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index 8b0f64d97..fc7905215 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -11,13 +11,11 @@ module.exports = Self => { arg: 'filter', type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', - http: {source: 'query'} }, { arg: 'search', type: 'string', description: 'Value to filter', - http: {source: 'query'} }, ], returns: { @@ -29,13 +27,11 @@ module.exports = Self => { verb: 'GET', }, }); - Self.filter = async(ctx, filter, options) => { + Self.filter = async(filter = {}, search, options) => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); - filter = ctx?.filter ?? {}; - const conn = Self.dataSource.connector; const where = buildFilter(filter?.where, (param, value) => { switch (param) { @@ -50,27 +46,27 @@ module.exports = Self => { }; } }) ?? {}; - delete ctx.filter.where; + delete filter.where; const stmts = []; let stmt; stmt = new ParameterizedSQL(` - SELECT - pc.townFk, - t.provinceFk, - p.countryFk, - pc.code, - t.name as town, - p.name as province, - c.name country - FROM - postCode pc - JOIN town t on t.id = pc.townFk - JOIN province p on p.id = t.provinceFk - JOIN country c on c.id = p.countryFk + SELECT + pc.townFk, + t.provinceFk, + p.countryFk, + pc.code, + t.name as town, + p.name as province, + c.name country + FROM + postCode pc + JOIN town t on t.id = pc.townFk + JOIN province p on p.id = t.provinceFk + JOIN country c on c.id = p.countryFk `); - stmt.merge(conn.makeSuffix({where, ...ctx})); + stmt.merge(conn.makeSuffix({where})); const itemsIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 382a2824c..06538a524 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -233,5 +233,7 @@ "It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated", "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated", "Cannot add holidays on this day": "Cannot add holidays on this day", - "Cannot send mail": "Cannot send mail" + "Cannot send mail": "Cannot send mail", + "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`", + "This postcode already exists": "This postcode already exists" } \ No newline at end of file From 6c1de1d6bd85802bcd2ed273fc1a489831d6c1fe Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 30 Jul 2024 07:55:14 +0200 Subject: [PATCH 153/181] refs #7801 frenchGoLabel --- .../email/printer-setup/locale/fr.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 print/templates/email/printer-setup/locale/fr.yml diff --git a/print/templates/email/printer-setup/locale/fr.yml b/print/templates/email/printer-setup/locale/fr.yml new file mode 100644 index 000000000..0c9f7031a --- /dev/null +++ b/print/templates/email/printer-setup/locale/fr.yml @@ -0,0 +1,39 @@ +subject: Instalation et configuration de l'imprimante +title: "Merci pour votre confiance !" +description: + dear: Cher client + instructions: Veuillez suivre les instructions spécifiées dans cet e-mail pour procéder à l'installation de l'imprimante. + followGuide: Vous pouvez utiliser comme guide la vidéo du montage du ruban et de la bande. + https://www.youtube.com/watch?v=qhb0kgQF3o8. Vous + aurez également besoin de GoLabel, le programme pour imprimer les bandes. + downloadFrom: Vous pouvez le télécharger depuis ce lien. https://cdn.verdnatura.es/public/GoLabel.zip + downloadDriver: Vous pouvez télécharger le pilote de l'imprimante depuis ce lien. https://es.seagullscientific.com/support/downloads/drivers/godex/download/ +sections: + GoLabel: + title: Utilisation de GoLabel + description: Pour utiliser le programme d'impression des bandes, suivez ces étapes + steps: + - Ci-joint à cet e-mail, vous trouverez le fichier 'model.ezp' (le modèle de bandes de corona standard). Téléchargez-le et vous le trouverez probablement dans le dossier 'Téléchargements'. + - Ouvrez le programme GoLabel. + - Cliquez sur l'icône de la barre supérieure en forme de dossier avec une feuille. + - Sélectionnez le fichier nommé 'model.ezp' (qui se trouve probablement dans 'Téléchargements'), puis cliquez sur Ouvrir. + - Une fois le fichier ouvert, double-cliquez sur le texte. Dans la boîte qui s'ouvre, cliquez sur le texte d'exemple (dans ce cas "TUS HERMANOS") et il apparaîtra dans la même zone à gauche pour que vous puissiez l'éditer et écrire ce que vous souhaitez. + - Lorsque vous avez le texte souhaité, cliquez sur le bouton 'OK'. + - Allez dans 'Fichier' → 'Enregistrer sous' et enregistrez-le sur le bureau sous un autre nom. + - Ensuite, pour imprimer, vous devez d'abord configurer l'imprimante. + - Cliquez sur la huitième icône de la barre supérieure, qui sera ici une imprimante avec un engrenage orange. + - Une fois là, cliquez sur le menu déroulant du modèle d'imprimante et choisissez le modèle qui correspond au vôtre 'G***'. + - Cliquez sur 'Enregistrer' et notre imprimante sera configurée et prête. + - Et enfin, pour imprimer, cliquez sur la neuvième icône, qui correspond à une imprimante bleue. + help: + title: "Avez-vous besoin d'aide ?" + description: Si vous avez besoin d'aide, téléchargez notre programme de support afin que nous puissions nous connecter à distance à votre ordinateur et effectuer l'installation. Veuillez nous fournir un horaire de contact pour vous assister, et nous vous contacterons. + remoteSupport: Vous pouvez télécharger le programme depuis ce lien. http://soporte.verdnatura.es. +help: Pour toute question que vous pourriez avoir, n'hésitez pas à nous la poser. Nous sommes là pour vous aider ! +salesPersonName: Je suis votre commercial et mon nom est +salesPersonPhone: Téléphone et WhatsApp. +salesPersonEmail: Adresse e-mail. From fcd26784bfb60dae6fcbf44677beae279acad9fc Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 08:37:35 +0200 Subject: [PATCH 154/181] build: init version 2434 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9016f74a6..261b877dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.32.0", + "version": "24.34.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From dbe0f4497c880fafde27066d5ba70991b59c381f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 08:59:03 +0200 Subject: [PATCH 155/181] fix(postcode_filter): add limit --- back/methods/postcode/filter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index fc7905215..37cc0c148 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -67,10 +67,12 @@ module.exports = Self => { `); stmt.merge(conn.makeSuffix({where})); + stmt.merge(conn.makeLimit(filter)); const itemsIndex = stmts.push(stmt) - 1; const sql = ParameterizedSQL.join(stmts, ';'); const result = await conn.executeStmt(sql, myOptions); + return itemsIndex === 0 ? result : result[itemsIndex]; }; }; From 2ac8760061506f713e5e4fbde9e9f0bfb6e86560 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 10:13:32 +0200 Subject: [PATCH 156/181] test: fix postcode filter back test --- back/methods/postcode/filter.js | 7 +-- back/methods/postcode/specs/filter.spec.js | 57 ++++++++-------------- 2 files changed, 20 insertions(+), 44 deletions(-) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index 37cc0c148..f350b1ea9 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -12,11 +12,6 @@ module.exports = Self => { type: 'object', description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', }, - { - arg: 'search', - type: 'string', - description: 'Value to filter', - }, ], returns: { type: ['object'], @@ -27,7 +22,7 @@ module.exports = Self => { verb: 'GET', }, }); - Self.filter = async(filter = {}, search, options) => { + Self.filter = async(filter = {}, options) => { const myOptions = {}; if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/back/methods/postcode/specs/filter.spec.js b/back/methods/postcode/specs/filter.spec.js index 60ac24809..391b1e196 100644 --- a/back/methods/postcode/specs/filter.spec.js +++ b/back/methods/postcode/specs/filter.spec.js @@ -1,17 +1,14 @@ const {models} = require('vn-loopback/server/server'); -describe('Postcode filter()', () => { +fdescribe('Postcode filter()', () => { it('should retrieve with no filter', async() => { const tx = await models.Postcode.beginTransaction({}); const options = {transaction: tx}; try { - const ctx = { - filter: { - }, + const results = await models.Postcode.filter({ limit: 1 - }; - const results = await models.Postcode.filter(ctx, options); + }, options); expect(results.length).toEqual(1); await tx.rollback(); @@ -26,14 +23,11 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 46, - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({ + where: { + search: 46, + } + }, options); expect(results.length).toEqual(4); await tx.rollback(); @@ -48,14 +42,9 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'Alz', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({where: { + search: 'Alz', + }}, options); expect(results.length).toEqual(1); await tx.rollback(); @@ -70,14 +59,9 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'one', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({where: { + search: 'one', + }}, options); expect(results.length).toEqual(4); await tx.rollback(); @@ -92,14 +76,11 @@ describe('Postcode filter()', () => { const options = {transaction: tx}; try { - const ctx = { - filter: { - where: { - search: 'Ec', - } - }, - }; - const results = await models.Postcode.filter(ctx, options); + const results = await models.Postcode.filter({ + where: { + search: 'Ec', + } + }, options); expect(results.length).toEqual(1); await tx.rollback(); From b6abcbe0907eb78e28feab73800ac5abebb064e0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 10:14:20 +0200 Subject: [PATCH 157/181] feat: refs #6453 Requested changes --- .../procedures/order_confirmWithUser.sql | 65 +++---------------- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 4fcee91f7..17798caf8 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -11,11 +11,11 @@ BEGIN * @param vSelf The order identifier * @param vUser The user identifier */ - DECLARE vIsOk BOOL; + DECLARE vHasRows BOOL; DECLARE vDone BOOL; DECLARE vWarehouseFk INT; DECLARE vShipment DATE; - DECLARE vShipmentDayEnd DATE; + DECLARE vShipmentDayEnd DATETIME; DECLARE vTicketFk INT; DECLARE vNotes VARCHAR(255); DECLARE vItemFk INT; @@ -32,7 +32,6 @@ BEGIN DECLARE vCompanyFk INT; DECLARE vAgencyModeFk INT; DECLARE vCalcFk INT; - DECLARE vIsLogifloraItem BOOL; DECLARE vIsTaxDataChecked BOOL; DECLARE vDates CURSOR FOR @@ -49,8 +48,7 @@ BEGIN r.itemFk, i.name, r.amount, - r.price, - i.isFloramondo + r.price FROM orderRow r JOIN vn.item i ON i.id = r.itemFk WHERE r.amount @@ -104,12 +102,12 @@ BEGIN CALL order_checkEditable(vSelf); -- Check order is not empty - SELECT COUNT(*) > 0 INTO vIsOk + SELECT COUNT(*) > 0 INTO vHasRows FROM orderRow WHERE orderFk = vSelf AND amount > 0; - IF NOT vIsOk THEN + IF NOT vHasRows THEN CALL util.throw('ORDER_EMPTY'); END IF; @@ -209,8 +207,8 @@ BEGIN -- Añade las notas IF vNotes IS NOT NULL AND vNotes <> '' THEN - INSERT INTO vn.ticketObservation SET - ticketFk = vTicketFk, + INSERT INTO vn.ticketObservation + SET ticketFk = vTicketFk, observationTypeFk = (SELECT id FROM vn.observationType WHERE code = 'salesPerson'), `description` = vNotes ON DUPLICATE KEY UPDATE @@ -222,12 +220,7 @@ BEGIN lRows: LOOP SET vSaleFk = NULL; SET vDone = FALSE; - FETCH vRows INTO vRowFk, - vItemFk, - vConcept, - vAmount, - vPrice, - vIsLogifloraItem; + FETCH vRows INTO vRowFk, vItemFk, vConcept, vAmount, vPrice; IF vDone THEN LEAVE lRows; @@ -277,48 +270,6 @@ BEGIN UPDATE orderRow SET saleFk = vSaleFk WHERE id = vRowFk; - - -- Inserta en putOrder si la compra es de Floramondo - IF vIsLogifloraItem THEN - CALL cache.availableNoRaids_refresh(vCalcFk, FALSE,vWarehouseFk, vShipment); - - SELECT GREATEST(0, available) INTO vAvailable - FROM cache.availableNoRaids - WHERE calc_id = vCalcFk - AND item_id = vItemFk; - - UPDATE cache.availableNoRaids - SET available = GREATEST(0, available - vAmount) - WHERE item_id = vItemFk - AND calc_id = vCalcFk; - - INSERT INTO edi.putOrder ( - deliveryInformationID, - supplyResponseId, - quantity , - EndUserPartyId, - EndUserPartyGLN, - FHAdminNumber, - saleFk - ) - SELECT di.ID, - i.supplyResponseFk, - CEIL((vAmount - vAvailable)/ sr.NumberOfItemsPerCask), - o.address_id , - vClientFk, - IFNULL(ca.fhAdminNumber, fhc.defaultAdminNumber), - vSaleFk - FROM edi.deliveryInformation di - JOIN vn.item i ON i.supplyResponseFk = di.supplyResponseID - JOIN edi.supplyResponse sr ON sr.ID = i.supplyResponseFk - LEFT JOIN edi.clientFHAdminNumber ca ON ca.clientFk = vClientFk - JOIN edi.floraHollandConfig fhc - JOIN `order` o ON o.id = vSelf - WHERE i.id = vItemFk - AND di.LatestOrderDateTime > util.VN_NOW() - AND vAmount > vAvailable - LIMIT 1; - END IF; END LOOP; CLOSE vRows; END LOOP; From b17b5a1b21955ae12d517fb208f0ad094473a42f Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Jul 2024 10:15:09 +0200 Subject: [PATCH 158/181] test: fix postcode filter back test --- back/methods/postcode/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/postcode/specs/filter.spec.js b/back/methods/postcode/specs/filter.spec.js index 391b1e196..abf450a19 100644 --- a/back/methods/postcode/specs/filter.spec.js +++ b/back/methods/postcode/specs/filter.spec.js @@ -1,6 +1,6 @@ const {models} = require('vn-loopback/server/server'); -fdescribe('Postcode filter()', () => { +describe('Postcode filter()', () => { it('should retrieve with no filter', async() => { const tx = await models.Postcode.beginTransaction({}); const options = {transaction: tx}; From 1f80117ff749021ca6ae5070986c78f122337b99 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 10:24:50 +0200 Subject: [PATCH 159/181] fix: refs #6861 Column --- db/routines/vn/procedures/itemShelvingSale_setQuantity.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 30abefec8..9d21e6a6f 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -103,7 +103,7 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) SELECT vSaleFk, vSectorFk; CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk, vSectorFk); END IF; From 01562420d4861b6c392a7209c92cc5ab9b6d1955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 30 Jul 2024 10:14:15 +0000 Subject: [PATCH 160/181] Actualizar db/routines/vn/procedures/itemShelvingSale_reallocate.sql --- .../itemShelvingSale_reallocate.sql | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index a60287caa..0ce4440e6 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -1,55 +1,55 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( - vItemShelvingFk INT(10), - vItemFk INT(10), - vSectorFk INT -) -BEGIN -/** - * Elimina reservas de un itemShelving e intenta reservar en otra ubicación - * - * @param vItemShelvingFk Id itemShelving - * @param vItemFk Id del artículo - * @param vSectorFk Id del sector - */ - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - - UPDATE itemShelving - SET visible = 0, - available = 0 - WHERE id = vItemShelvingFk - AND itemFk = vItemFk; - - SELECT iss.id - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND iss.itemFk = vItemFk - AND NOT iss.isPicked - FOR UPDATE; - - INSERT INTO itemShelvingSaleReserve (saleFk, vSectorFk) - SELECT DISTINCT iss.saleFk - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - - DELETE iss - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - COMMIT; - - CALL itemShelvingSale_doReserve(); -END$$ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( + vItemShelvingFk INT(10), + vItemFk INT(10), + vSectorFk INT +) +BEGIN +/** + * Elimina reservas de un itemShelving e intenta reservar en otra ubicación + * + * @param vItemShelvingFk Id itemShelving + * @param vItemFk Id del artículo + * @param vSectorFk Id del sector + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE itemShelving + SET visible = 0, + available = 0 + WHERE id = vItemShelvingFk + AND itemFk = vItemFk; + + SELECT iss.id + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND iss.itemFk = vItemFk + AND NOT iss.isPicked + FOR UPDATE; + + INSERT INTO itemShelvingSaleReserve (saleFk, sectorFk) + SELECT DISTINCT iss.saleFk, vSectorFk + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + + DELETE iss + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + COMMIT; + + CALL itemShelvingSale_doReserve(); +END$$ DELIMITER ; \ No newline at end of file From 2015256f5d6a3416eb903d7e0f6b8e82af5ac5f6 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 12:38:13 +0200 Subject: [PATCH 161/181] hotFix reallocate resfs #6861 --- db/versions/11177-crimsonPaniculata/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11177-crimsonPaniculata/00-firstScript.sql diff --git a/db/versions/11177-crimsonPaniculata/00-firstScript.sql b/db/versions/11177-crimsonPaniculata/00-firstScript.sql new file mode 100644 index 000000000..79bcf1291 --- /dev/null +++ b/db/versions/11177-crimsonPaniculata/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +ALTER TABLE vn.itemShelvingSaleReserve DROP FOREIGN KEY IF EXISTS itemShelvingSaleReserve_sector_FK; + +ALTER TABLE vn.itemShelvingSaleReserve ADD CONSTRAINT itemShelvingSaleReserve_sector_FK + FOREIGN KEY IF NOT EXISTS (sectorFk) REFERENCES vn.sector(id) ON DELETE RESTRICT ON UPDATE CASCADE; \ No newline at end of file From 9e486e4affa8593546602921ef393a18caf7533e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 13:04:33 +0200 Subject: [PATCH 162/181] hotFix reallocate iss refs #6861 --- db/routines/vn/procedures/itemShelvingSale_reallocate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index 0ce4440e6..d5b89c373 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -30,7 +30,7 @@ BEGIN FROM itemShelvingSale iss JOIN itemShelving ish ON ish.id = iss.itemShelvingFk WHERE iss.itemShelvingFk = vItemShelvingFk - AND iss.itemFk = vItemFk + AND ish.itemFk = vItemFk AND NOT iss.isPicked FOR UPDATE; From 80ad1f30af043ff4e20881fae72526add266d680 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 13:50:47 +0200 Subject: [PATCH 163/181] fix: refs #7811 Variables pm2 --- back/process.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/back/process.yml b/back/process.yml index a29323240..08fee7a93 100644 --- a/back/process.yml +++ b/back/process.yml @@ -2,6 +2,5 @@ apps: - script: ./loopback/server/server.js name: salix-back instances: 1 - max_restarts: 3 - restart_delay: 15000 + max_restarts: 0 node_args: --tls-min-v1.0 --openssl-legacy-provider From 4ef57e68692bc81008343a01a9840358d1a43d9c Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 14:17:41 +0200 Subject: [PATCH 164/181] fix: refs #7821 Added orders in item_getMinacum --- db/routines/vn/procedures/item_getMinacum.sql | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index a3ebedb12..c0bdb7e7d 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -1,35 +1,38 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(IN vWarehouseFk TINYINT, IN vDatedFrom DATETIME, IN vRange INT, IN vItemFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`( + vWarehouseFk TINYINT, + vDated DATE, + vRange INT, + vItemFk INT +) BEGIN /** - * Cálculo del mínimo acumulado, para un item/almacén especificado, en caso de - * NULL para todo. + * Cálculo del mínimo acumulado, para un item/almacén + * especificado, en caso de NULL para todo. * - * @param vWarehouseFk -> warehouseFk - * @param vDatedFrom -> fecha inicio - * @param vRange -> número de días a considerar - * @param vItemFk -> Identificador de item + * @param vWarehouseFk Id warehouse + * @param vDated Fecha inicio + * @param vRange Número de días a considerar + * @param vItemFk Id de artículo * @return tmp.itemMinacum */ - DECLARE vDatedTo DATETIME; + DECLARE vDatedTo DATETIME DEFAULT util.dayEnd(vDated + INTERVAL vRange DAY); - SET vDatedFrom = TIMESTAMP(DATE(vDatedFrom), '00:00:00'); - SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, vRange, vDatedFrom), '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.itemCalc; - CREATE TEMPORARY TABLE tmp.itemCalc + CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc (INDEX (itemFk, warehouseFk)) + ENGINE = MEMORY SELECT sub.itemFk, sub.dated, CAST(SUM(sub.quantity) AS SIGNED) quantity, sub.warehouseFk - FROM (SELECT s.itemFk, + FROM ( + SELECT s.itemFk, DATE(t.shipped) dated, -s.quantity quantity, t.warehouseFk FROM sale s JOIN ticket t ON t.id = s.ticketFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + WHERE t.shipped BETWEEN vDated AND vDatedTo AND t.warehouseFk AND s.quantity != 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) @@ -42,10 +45,10 @@ BEGIN FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk - WHERE t.landed BETWEEN vDatedFrom AND vDatedTo + WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL SELECT b.itemFk, @@ -55,20 +58,35 @@ BEGIN FROM buy b JOIN entry e ON e.id = b.entryFk JOIN travel t ON t.id = e.travelFk - WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) AND !e.isExcludedFromAvailable - AND b.quantity != 0 + AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) AND !e.isRaid + UNION ALL + SELECT r.itemFk, + r.shipment, + -r.amount, + r.warehouseFk + FROM hedera.orderRow r + JOIN hedera.`order` o ON o.id = r.orderFk + JOIN vn.client c ON c.id = o.customer_id + WHERE r.shipment BETWEEN vDated AND vDatedTo + AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) + AND r.created >= ( + SELECT SUBTIME(util.VN_NOW(), reserveTime) + FROM hedera.orderConfig + ) + AND NOT o.confirmed + AND (vItemFk IS NULL OR r.itemFk = vItemFk) + AND r.amount <> 0 ) sub GROUP BY sub.itemFk, sub.warehouseFk, sub.dated; - CALL item_getAtp(vDatedFrom); - DROP TEMPORARY TABLE tmp.itemCalc; + CALL item_getAtp(vDated); - DROP TEMPORARY TABLE IF EXISTS tmp.itemMinacum; - CREATE TEMPORARY TABLE tmp.itemMinacum + CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY SELECT i.itemFk, @@ -77,6 +95,8 @@ BEGIN FROM tmp.itemAtp i HAVING amount != 0; - DROP TEMPORARY TABLE tmp.itemAtp; + DROP TEMPORARY TABLE + tmp.itemAtp, + tmp.itemCalc; END$$ DELIMITER ; From 961d05ab354944977308c5db39dc4398fce6442a Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 14:19:04 +0200 Subject: [PATCH 165/181] fix: refs #7821 Added orders in item_getMinacum --- db/routines/vn/procedures/item_getMinacum.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index c0bdb7e7d..2b51355d5 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -34,7 +34,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vDated AND vDatedTo AND t.warehouseFk - AND s.quantity != 0 + AND s.quantity <> 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) UNION ALL @@ -93,7 +93,7 @@ BEGIN i.warehouseFk, i.quantity amount FROM tmp.itemAtp i - HAVING amount != 0; + HAVING amount <> 0; DROP TEMPORARY TABLE tmp.itemAtp, From d97aba8e10127c2522d30f87d1b7294e55fdf22d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 30 Jul 2024 17:28:55 +0200 Subject: [PATCH 166/181] hotFix getTickets refs #6861 --- back/methods/collection/getTickets.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index b79dbc93a..2a2b67524 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -57,8 +57,10 @@ module.exports = Self => { ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY pickingOrder) currentItemShelving, COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) totalItemShelving, sh.code, - IFNULL(p2.code, p.code) parkingCode, - IFNULL(p2.pickingOrder, p.pickingOrder) pickingOrder, + p2.code parkingCode, + p2.pickingOrder pickingOrder, + p.code parkingCodePrevia, + p.pickingOrder pickingOrderPrevia, iss.id itemShelvingSaleFk, iss.isPicked FROM ticketCollection tc @@ -95,8 +97,10 @@ module.exports = Self => { ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder), COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) , sh.code, - IFNULL(p2.code, p.code), - IFNULL(p2.pickingOrder, p.pickingOrder), + p2.code, + p2.pickingOrder, + p.code, + p.pickingOrder, iss.id itemShelvingSaleFk, iss.isPicked FROM sectorCollection sc From 952b7a5054efff1b7ce6b34a33cbb87c3f13cda3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jul 2024 07:10:38 +0200 Subject: [PATCH 167/181] hotFix model itemShelving refs #7805 --- modules/item/back/models/item-shelving.json | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 893a1f81d..40f2a2852 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -1,9 +1,9 @@ { "name": "ItemShelving", "base": "VnModel", - "mixins": { - "Loggable": true - }, + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "itemShelving" @@ -17,27 +17,27 @@ }, "shelvingFk": { "type": "string" - }, + }, "itemFk": { "type": "number" - }, + }, "created": { "type": "date" - }, + }, "grouping": { "type": "number" - }, - "isChecked": { - "type": "boolean" + }, + "isChecked": { + "type": "number" }, "packing": { "type": "number" - }, - "visible": { - "type": "number" }, - "userFk": { - "type": "number" + "visible": { + "type": "number" + }, + "userFk": { + "type": "number" } }, "relations": { @@ -56,6 +56,6 @@ "model": "Shelving", "foreignKey": "shelvingFk", "primaryKey": "code" - } + } } -} +} \ No newline at end of file From 07b6d2aca9ae9f3f7536ecc127afcb955866c935 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 31 Jul 2024 08:59:33 +0200 Subject: [PATCH 168/181] feat: refs #7644 Added comment if has itemOriginalFk --- print/templates/reports/buy-label/buy-label.js | 3 +-- print/templates/reports/buy-label/sql/buys.sql | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/print/templates/reports/buy-label/buy-label.js b/print/templates/reports/buy-label/buy-label.js index 7d626c052..48ffe336c 100755 --- a/print/templates/reports/buy-label/buy-label.js +++ b/print/templates/reports/buy-label/buy-label.js @@ -15,7 +15,6 @@ module.exports = { }, methods: { getBarcode(id) { - const xmlSerializer = new XMLSerializer(); const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); @@ -26,7 +25,7 @@ module.exports = { width: 3.8, height: 115, }); - return xmlSerializer.serializeToString(svgNode); + return new XMLSerializer().serializeToString(svgNode); } }, props: { diff --git a/print/templates/reports/buy-label/sql/buys.sql b/print/templates/reports/buy-label/sql/buys.sql index 015a74797..44b1b4bad 100644 --- a/print/templates/reports/buy-label/sql/buys.sql +++ b/print/templates/reports/buy-label/sql/buys.sql @@ -21,12 +21,13 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, b.id, b.itemFk, p.name producer, - i.comment + IF(i2.id, i2.comment, i.comment) comment 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 + LEFT JOIN item i2 ON i2.id = b.itemOriginalFk JOIN numbers num WHERE b.entryFk = ? AND num.n <= b.stickers From cc78355aad92cdd9c446637abe17e29f43061f92 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 31 Jul 2024 09:26:55 +0200 Subject: [PATCH 169/181] fix: refs #7821 Requested changes --- db/routines/vn/procedures/item_getMinacum.sql | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index 2b51355d5..1decf881d 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -8,7 +8,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`( BEGIN /** * Cálculo del mínimo acumulado, para un item/almacén - * especificado, en caso de NULL para todo. + * especificado, en caso de NULL para todos. * * @param vWarehouseFk Id warehouse * @param vDated Fecha inicio @@ -47,7 +47,7 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND !e.isExcludedFromAvailable + AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL @@ -60,10 +60,10 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) - AND !e.isExcludedFromAvailable + AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND !e.isRaid + AND NOT e.isRaid UNION ALL SELECT r.itemFk, r.shipment, @@ -71,11 +71,11 @@ BEGIN r.warehouseFk FROM hedera.orderRow r JOIN hedera.`order` o ON o.id = r.orderFk - JOIN vn.client c ON c.id = o.customer_id + JOIN client c ON c.id = o.customer_id WHERE r.shipment BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) AND r.created >= ( - SELECT SUBTIME(util.VN_NOW(), reserveTime) + SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND FROM hedera.orderConfig ) AND NOT o.confirmed @@ -89,11 +89,11 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY - SELECT i.itemFk, - i.warehouseFk, - i.quantity amount - FROM tmp.itemAtp i - HAVING amount <> 0; + SELECT itemFk, + warehouseFk, + quantity amount + FROM tmp.itemAtp + WHERE quantity <> 0; DROP TEMPORARY TABLE tmp.itemAtp, From dca7900ab231cbb52944a77e4264b2a35adbc270 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 31 Jul 2024 11:31:02 +0200 Subject: [PATCH 170/181] fix: refs #7818 entry_splitByShelving --- db/routines/vn/procedures/entry_splitByShelving.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/entry_splitByShelving.sql b/db/routines/vn/procedures/entry_splitByShelving.sql index eb07c12b7..f46278e5a 100644 --- a/db/routines/vn/procedures/entry_splitByShelving.sql +++ b/db/routines/vn/procedures/entry_splitByShelving.sql @@ -110,7 +110,7 @@ BEGIN UPDATE itemShelving SET isSplit = TRUE - WHERE shelvingFk = vShelvingFk; + WHERE shelvingFk = vShelvingFk COLLATE utf8_general_ci; END LOOP; CLOSE cur; END$$ From 77fa4dd4979d1148cec6cb02cdeb87020685a436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 14:38:12 +0200 Subject: [PATCH 171/181] fix: refs #7213 componentLack y setRisk --- db/routines/vn/procedures/sale_setProblemComponentLack.sql | 2 +- .../vn/procedures/sale_setProblemComponentLackByComponent.sql | 4 ++-- db/routines/vn/procedures/ticket_setRisk.sql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblemComponentLack.sql b/db/routines/vn/procedures/sale_setProblemComponentLack.sql index aa5f5f1be..23eb77c2e 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLack.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLack.sql @@ -14,7 +14,7 @@ BEGIN ENGINE = MEMORY SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem, - ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded FROM sale WHERE id = vSelf; diff --git a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql index 2ee49b656..cdf28ac09 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql @@ -14,9 +14,9 @@ BEGIN ENGINE = MEMORY SELECT saleFk, sale_hasComponentLack(saleFk) hasProblem, - ticket_isProblemCalcNeeded(ticketFk) isProblemCalcNeeded + (ticket_isProblemCalcNeeded(ticketFk) AND quantity > 0) isProblemCalcNeeded FROM ( - SELECT s.id saleFk, s.ticketFk + SELECT s.id saleFk, s.ticketFk, s.quantity FROM ticket t JOIN sale s ON s.ticketFk = t.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id diff --git a/db/routines/vn/procedures/ticket_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql index bd5d1e9f9..b88e60a37 100644 --- a/db/routines/vn/procedures/ticket_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -85,7 +85,7 @@ BEGIN UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id SET t.risk = NULL - WHERE tr.isProblemCalcNeeded + WHERE NOT tr.isProblemCalcNeeded ORDER BY t.id; DROP TEMPORARY TABLE tTicketRisk; From 6c0aae04c004d97d6fe31d4faa739ae5faf2be04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 14:59:12 +0200 Subject: [PATCH 172/181] fix: refs #7213 componentLack y setRisk --- db/routines/vn/procedures/ticket_setRisk.sql | 140 ++++++++----------- 1 file changed, 62 insertions(+), 78 deletions(-) diff --git a/db/routines/vn/procedures/ticket_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql index b88e60a37..535cd0787 100644 --- a/db/routines/vn/procedures/ticket_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -1,94 +1,78 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`( - vClientFk INT) + vClientFk INT +) BEGIN /** - * Update the risk for a client with pending tickets + * Update the risk for a client with pending tickets. * * @param vClientFk Id cliente */ - DECLARE vHasDebt BOOL; - DECLARE vStarted DATETIME; - - SELECT COUNT(*) INTO vHasDebt - FROM `client` - WHERE id = vClientFk - AND typeFk = 'normal'; - - IF vHasDebt THEN - - SELECT util.VN_CURDATE() - INTERVAL riskScope MONTH INTO vStarted - FROM clientConfig; - + IF (SELECT COUNT(*) FROM client WHERE id = vClientFk AND typeFk = 'normal') THEN CREATE OR REPLACE TEMPORARY TABLE tTicketRisk - (KEY (ticketFk)) + (PRIMARY KEY (ticketFk)) ENGINE = MEMORY - WITH ticket AS( - SELECT id ticketFk, - companyFk, - DATE(shipped) dated, - totalWithVat, - ticket_isProblemCalcNeeded(id) isProblemCalcNeeded - FROM vn.ticket - WHERE clientFk = vClientFk - AND refFk IS NULL - AND NOT isDeleted - AND IFNULL(totalWithVat, 0) <> 0 - AND shipped > vStarted - ), balance AS( - SELECT SUM(amount)amount, companyFk - FROM ( - SELECT amount, companyFk - FROM vn.clientRisk - WHERE clientFk = vClientFk - UNION ALL - SELECT -(SUM(amount) / 100) amount, tm.companyFk - FROM hedera.tpvTransaction t - JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk - WHERE clientFk = vClientFk - AND receiptFk IS NULL - AND status = 'ok' - ) sub - WHERE companyFk - GROUP BY companyFk - ), uninvoiced AS( - SELECT companyFk, dated, SUM(totalWithVat) amount - FROM ticket - GROUP BY companyFk, dated - ), receipt AS( - SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount - FROM vn.receipt - WHERE clientFk = vClientFk - AND payed > util.VN_CURDATE() - GROUP BY companyFk, DATE(payed) - ), risk AS( - SELECT b.companyFk, - ui.dated, - SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated ) + - b.amount + - SUM(IFNULL(r.amount, 0)) amount - FROM balance b - JOIN uninvoiced ui ON ui.companyFk = b.companyFk - LEFT JOIN receipt r ON r.dated > ui.dated AND r.companyFk = ui.companyFk - GROUP BY b.companyFk, ui.dated - ) - SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded - FROM ticket ti - JOIN risk r ON r.dated = ti.dated AND r.companyFk = ti.companyFk; + WITH ticket AS ( + SELECT t.id ticketFk, + t.companyFk, + DATE(t.shipped) dated, + t.totalWithVat, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN vn.clientConfig cc + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND NOT t.isDeleted + AND IFNULL(t.totalWithVat, 0) <> 0 + AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) + ), balance AS ( + SELECT SUM(amount)amount, companyFk + FROM ( + SELECT amount, companyFk + FROM vn.clientRisk + WHERE clientFk = vClientFk + UNION ALL + SELECT -(SUM(amount) / 100) amount, tm.companyFk + FROM hedera.tpvTransaction t + JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk + WHERE clientFk = vClientFk + AND receiptFk IS NULL + AND `status` = 'ok' + ) sub + WHERE companyFk + GROUP BY companyFk + ), uninvoiced AS ( + SELECT companyFk, dated, SUM(totalWithVat) amount + FROM ticket + GROUP BY companyFk, dated + ), receipt AS ( + SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount + FROM vn.receipt + WHERE clientFk = vClientFk + AND payed > util.VN_CURDATE() + GROUP BY companyFk, DATE(payed) + ), risk AS ( + SELECT b.companyFk, + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + + b.amount + + SUM(IFNULL(r.amount, 0)) amount + FROM balance b + JOIN uninvoiced ui ON ui.companyFk = b.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated + AND r.companyFk = ui.companyFk + GROUP BY b.companyFk, ui.dated + ) + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded + FROM ticket ti + JOIN risk r ON r.dated = ti.dated + AND r.companyFk = ti.companyFk; UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = tr.amount - WHERE tr.isProblemCalcNeeded - ORDER BY t.id; - - UPDATE ticket t - JOIN tTicketRisk tr ON tr.ticketFk = t.id - SET t.risk = NULL - WHERE NOT tr.isProblemCalcNeeded - ORDER BY t.id; + SET t.risk = IF(tr.isProblemCalcNeeded, tr.amount, NULL); DROP TEMPORARY TABLE tTicketRisk; - END IF; + END IF; END$$ DELIMITER ; \ No newline at end of file From 65e9ed301ff370f6f0e019c44ecfda47adf526f3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jul 2024 18:11:03 +0200 Subject: [PATCH 173/181] hotFix itemShelving refs #6861 --- .../itemShelvingSale_addBySaleGroup.sql | 46 +++++++++++++++++++ .../vn/procedures/itemShelving_get.sql | 3 +- .../vn/triggers/itemShelving_beforeUpdate.sql | 4 -- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql b/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql new file mode 100644 index 000000000..285b9f93f --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addBySaleGroup.sql @@ -0,0 +1,46 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySaleGroup`( + vSaleGroupFk INT(11) +) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * a través del saleGroup + * + * @param vSaleGroupFk Identificador de saleGroup + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSectorFk INT; + DECLARE vSales CURSOR FOR + SELECT s.id + FROM saleGroupDetail sgd + JOIN sale s ON sgd.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + WHERE sgd.saleGroupFk = vSaleGroupFk + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + SELECT sectorFk INTO vSectorFk + FROM operator + WHERE workerFk = account.myUser_getId(); + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk); + END LOOP; + CLOSE vSales; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 1be762f09..d42446b06 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -16,7 +16,8 @@ BEGIN ish.id, s.priority, ish.isChecked, - ic.url + ic.url, + ish.available FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index 214c64b45..961d89f65 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -9,9 +9,5 @@ BEGIN SET NEW.userFk = account.myUser_getId(); END IF; - IF (NEW.visible <> OLD.visible) THEN - SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0); - END IF; - END$$ DELIMITER ; From 70b931553bf91c2bda7509b01023b96a34f4178f Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jul 2024 18:14:09 +0200 Subject: [PATCH 174/181] hotFix itemShelving refs #6861 --- modules/item/back/models/item-shelving.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 40f2a2852..5df3b0703 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -38,6 +38,9 @@ }, "userFk": { "type": "number" + }, + "available": { + "type": "number" } }, "relations": { From 5b0dcee62d5be611423328fe6583b11237953071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 18:41:18 +0200 Subject: [PATCH 175/181] hotfix: getBuys add field comment Ticket 207748 --- modules/entry/back/methods/entry/getBuys.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index bd9c5db7a..245dada09 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -101,7 +101,8 @@ module.exports = Self => { 'groupingMode', 'inkFk', 'originFk', - 'producerFk' + 'producerFk', + 'comment' ], include: [ { From 77f6e80066b37174020dfd76446dbbd97cf5212b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 31 Jul 2024 17:38:50 +0000 Subject: [PATCH 176/181] Actualizar db/routines/vn/procedures/ticket_setRisk.sql --- db/routines/vn/procedures/ticket_setRisk.sql | 113 ++++++++++--------- 1 file changed, 59 insertions(+), 54 deletions(-) diff --git a/db/routines/vn/procedures/ticket_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql index 535cd0787..e3cbaf231 100644 --- a/db/routines/vn/procedures/ticket_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -13,60 +13,65 @@ BEGIN (PRIMARY KEY (ticketFk)) ENGINE = MEMORY WITH ticket AS ( - SELECT t.id ticketFk, - t.companyFk, - DATE(t.shipped) dated, - t.totalWithVat, - ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded - FROM vn.ticket t - JOIN vn.clientConfig cc - WHERE t.clientFk = vClientFk - AND t.refFk IS NULL - AND NOT t.isDeleted - AND IFNULL(t.totalWithVat, 0) <> 0 - AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) - ), balance AS ( - SELECT SUM(amount)amount, companyFk - FROM ( - SELECT amount, companyFk - FROM vn.clientRisk - WHERE clientFk = vClientFk - UNION ALL - SELECT -(SUM(amount) / 100) amount, tm.companyFk - FROM hedera.tpvTransaction t - JOIN hedera.tpvMerchant tm ON t.id = t.merchantFk - WHERE clientFk = vClientFk - AND receiptFk IS NULL - AND `status` = 'ok' - ) sub - WHERE companyFk - GROUP BY companyFk - ), uninvoiced AS ( - SELECT companyFk, dated, SUM(totalWithVat) amount - FROM ticket - GROUP BY companyFk, dated - ), receipt AS ( - SELECT companyFk, DATE(payed) dated, SUM(amountPaid) amount - FROM vn.receipt - WHERE clientFk = vClientFk - AND payed > util.VN_CURDATE() - GROUP BY companyFk, DATE(payed) - ), risk AS ( - SELECT b.companyFk, - ui.dated, - SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + - b.amount + - SUM(IFNULL(r.amount, 0)) amount - FROM balance b - JOIN uninvoiced ui ON ui.companyFk = b.companyFk - LEFT JOIN receipt r ON r.dated > ui.dated - AND r.companyFk = ui.companyFk - GROUP BY b.companyFk, ui.dated - ) - SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded - FROM ticket ti - JOIN risk r ON r.dated = ti.dated - AND r.companyFk = ti.companyFk; + SELECT t.id ticketFk, + t.companyFk, + DATE(t.shipped) dated, + t.totalWithVat, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded + FROM vn.ticket t + JOIN vn.clientConfig cc + WHERE t.clientFk = vClientFk + AND t.refFk IS NULL + AND NOT t.isDeleted + AND IFNULL(t.totalWithVat, 0) <> 0 + AND t.shipped > (util.VN_CURDATE() - INTERVAL cc.riskScope MONTH) + ), uninvoiced AS ( + SELECT companyFk, dated, SUM(totalWithVat) amount + FROM ticket + GROUP BY companyFk, dated + ), companies AS ( + SELECT DISTINCT companyFk FROM uninvoiced + ), balance AS ( + SELECT SUM(IFNULL(amount, 0))amount, companyFk + FROM ( + SELECT cr.amount, c.companyFk + FROM companies c + LEFT JOIN vn.clientRisk cr ON cr.companyFk = c.companyFk + AND cr.clientFk = vClientFk + UNION ALL + SELECT -(SUM(t.amount) / 100) amount, c.companyFk + FROM companies c + LEFT JOIN hedera.tpvMerchant tm ON tm.companyFk = c.companyFk + LEFT JOIN hedera.tpvTransaction t ON t.merchantFk = tm.id + AND t.clientFk = vClientFk + AND t.receiptFk IS NULL + AND t.`status` = 'ok' + ) sub + WHERE companyFk + GROUP BY companyFk + ), receipt AS ( + SELECT r.companyFk, DATE(r.payed) dated, SUM(r.amountPaid) amount + FROM vn.receipt r + JOIN companies c ON c.companyFk = r.companyFk + WHERE r.clientFk = vClientFk + AND r.payed > util.VN_CURDATE() + GROUP BY r.companyFk, DATE(r.payed) + ), risk AS ( + SELECT b.companyFk, + ui.dated, + SUM(ui.amount) OVER (PARTITION BY b.companyFk ORDER BY ui.dated) + + b.amount + + SUM(IFNULL(r.amount, 0)) amount + FROM balance b + JOIN uninvoiced ui ON ui.companyFk = b.companyFk + LEFT JOIN receipt r ON r.dated > ui.dated + AND r.companyFk = ui.companyFk + GROUP BY b.companyFk, ui.dated + ) + SELECT ti.ticketFk, r.amount, ti.isProblemCalcNeeded + FROM ticket ti + JOIN risk r ON r.dated = ti.dated + AND r.companyFk = ti.companyFk; UPDATE ticket t JOIN tTicketRisk tr ON tr.ticketFk = t.id From b56260af365a0a2097b6068a80340ec56c27b202 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 2 Aug 2024 07:58:45 +0200 Subject: [PATCH 177/181] feat: refs #6453 Requested changes --- .../procedures/order_confirmWithUser.sql | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 17798caf8..3acdaed5a 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -136,11 +136,11 @@ BEGIN FROM vn.ticket t JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id + LEFT JOIN vn.ticketState tls ON tls.ticketFk = t.id JOIN hedera.`order` o ON o.address_id = t.addressFk + AND t.shipped BETWEEN vShipment AND vShipmentDayEnd AND t.warehouseFk = vWarehouseFk AND o.date_send = t.landed - AND t.shipped BETWEEN vShipment AND vShipmentDayEnd WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL @@ -150,7 +150,9 @@ BEGIN -- Comprobamos si hay un ticket de previa disponible IF vTicketFk IS NULL THEN WITH tItemPackingTypeOrder AS ( - SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes, + SELECT GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes, o.address_id FROM vn.item i JOIN orderRow oro ON oro.itemFk = i.id @@ -159,16 +161,20 @@ BEGIN ), tItemPackingTypeTicket AS ( SELECT t.id, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes + GROUP_CONCAT( + DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk + ) distinctItemPackingTypes FROM vn.ticket t - JOIN vn.alertLevel al ON al.code = 'ON_PREVIOUS' + JOIN vn.ticketState tls ON tls.ticketFk = t.id + JOIN vn.alertLevel al ON al.id = tls.alertLevel JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk JOIN tItemPackingTypeOrder ipto - WHERE t.refFk IS NULL - AND t.shipped BETWEEN vShipment AND vShipmentDayEnd + WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd + AND t.refFk IS NULL AND t.warehouseFk = vWarehouseFk AND t.addressFk = ipto.address_id + AND al.code = 'ON_PREVIOUS' GROUP BY t.id ) SELECT iptt.id INTO vTicketFk From d852d16ae4d19e97aafa562a8c9686b0e78c8742 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 2 Aug 2024 08:11:38 +0200 Subject: [PATCH 178/181] feat: refs #7382 Changes --- db/routines/vn/procedures/invoiceIn_booking.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index c728085b8..a5dd3a5f1 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -16,9 +16,11 @@ BEGIN DECLARE vHasRepeatedTransactions BOOL; SELECT TRUE INTO vHasRepeatedTransactions - FROM invoiceInTax - WHERE invoiceInFk = vSelf - HAVING COUNT(DISTINCT transactionTypeSageFk) > 1 + FROM invoiceInTax iit + JOIN invoiceIn ii ON ii.id = iit.invoiceInFk + WHERE ii.id = vSelf + AND ii.serial = 'E' + HAVING COUNT(DISTINCT iit.transactionTypeSageFk) > 1 LIMIT 1; IF vHasRepeatedTransactions THEN From ddd5e4ffa491ce3b98a025659475e4d16b7b8d07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 2 Aug 2024 10:28:50 +0200 Subject: [PATCH 179/181] fix: refs #7829 Error al calcular problemas de componentes --- .../vn/procedures/sale_getProblems.sql | 29 +++++++-------- .../ticket_setProblemRiskByClient.sql | 35 +++++++++++++++++++ 2 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 db/routines/vn/procedures/ticket_setProblemRiskByClient.sql diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index ba4ff5857..730d84f38 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; DECLARE vDone BOOL; - DECLARE vComponentCount INT; + DECLARE vRequiredComponent INT; DECLARE vCursor CURSOR FOR SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped)) @@ -54,7 +54,7 @@ BEGIN SELECT ticketFk, clientFk FROM tmp.sale_getProblems; - SELECT COUNT(*) INTO vComponentCount + SELECT COUNT(*) INTO vRequiredComponent FROM component WHERE isRequired; @@ -96,20 +96,17 @@ BEGIN -- Faltan componentes INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT ticketFk, (vComponentCount > nComp) hasComponentLack, saleFk - FROM ( - SELECT COUNT(s.id) nComp, tl.ticketFk, s.id saleFk - FROM tmp.ticket_list tl - JOIN sale s ON s.ticketFk = tl.ticketFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired - JOIN ticket t ON t.id = tl.ticketFk - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND s.quantity > 0 - GROUP BY s.id - ) sub + SELECT t.id, COUNT(c.id) < vRequiredComponent hasComponentLack, s.id + FROM tmp.ticket_list tl + JOIN ticket t ON t.id = tl.ticketFk + JOIN sale s ON s.ticketFk = t.id + JOIN agencyMode am ON am.id = t.agencyModeFk + JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired + WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') + AND s.quantity > 0 + GROUP BY s.id HAVING hasComponentLack; -- Cliente congelado diff --git a/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql new file mode 100644 index 000000000..d652f5269 --- /dev/null +++ b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql @@ -0,0 +1,35 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRiskByClient`( + vClientFk INT +) +BEGIN +/** + * Updates future ticket risk for a client + * + * @param vClientFk Id client + */ + DECLARE vDone INT DEFAULT FALSE; + DECLARE vTicketFk INT; + DECLARE vTickets CURSOR FOR + SELECT id + FROM ticket + WHERE clientFk = vClientFk + AND shipped >= util.VN_CURDATE(); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vTickets; + l: LOOP + SET vDone = FALSE; + FETCH vTickets INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL vn.ticket_setProblemRisk(vTicketFk); + END LOOP; + + CLOSE vTickets; +END$$ +DELIMITER ; \ No newline at end of file From 29a50caaca99ec6024f13fa9780c67130ad72e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 2 Aug 2024 11:43:30 +0200 Subject: [PATCH 180/181] fix: refs #7829 Error al calcular problemas de componentes --- db/routines/vn/procedures/sale_getProblems.sql | 3 ++- db/routines/vn/procedures/ticket_setProblemRiskByClient.sql | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 730d84f38..979978f4a 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -103,7 +103,8 @@ BEGIN JOIN agencyMode am ON am.id = t.agencyModeFk JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk AND c.isRequired + LEFT JOIN component c ON c.id = sc.componentFk + AND c.isRequired WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') AND s.quantity > 0 GROUP BY s.id diff --git a/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql index d652f5269..8479550de 100644 --- a/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql +++ b/db/routines/vn/procedures/ticket_setProblemRiskByClient.sql @@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRi ) BEGIN /** - * Updates future ticket risk for a client + * Updates future ticket risk for a client. * * @param vClientFk Id client */ @@ -14,7 +14,8 @@ BEGIN SELECT id FROM ticket WHERE clientFk = vClientFk - AND shipped >= util.VN_CURDATE(); + AND shipped >= util.VN_CURDATE() + AND refFk IS NULL; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -29,7 +30,6 @@ BEGIN CALL vn.ticket_setProblemRisk(vTicketFk); END LOOP; - CLOSE vTickets; END$$ DELIMITER ; \ No newline at end of file From abd8bc96390eca32823c33e5d8e20574ca1b0d70 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 2 Aug 2024 12:20:50 +0200 Subject: [PATCH 181/181] fix: refs #6453 order_confirmWithUser --- db/routines/hedera/procedures/order_confirmWithUser.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 3acdaed5a..2b033b704 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -155,8 +155,8 @@ BEGIN ) distinctItemPackingTypes, o.address_id FROM vn.item i - JOIN orderRow oro ON oro.itemFk = i.id - JOIN `order` o ON o.id = oro.orderFk + JOIN hedera.orderRow oro ON oro.itemFk = i.id + JOIN hedera.`order` o ON o.id = oro.orderFk WHERE oro.orderFk = vSelf ), tItemPackingTypeTicket AS (