From 1ea357a5dd5ac3ec047b14a89992fe63ac02a8bd Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 10:01:46 +0200 Subject: [PATCH 01/56] 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 -- 2.40.1 From eea04520adac7fa085296bd9426fd6f4db9a8da9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 10:05:02 +0200 Subject: [PATCH 02/56] 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 ; -- 2.40.1 From b1e136aa47cbbb585431de51eae40bfab757d673 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 11:05:20 +0200 Subject: [PATCH 03/56] 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; -- 2.40.1 From 13ed86d26d235538ed43d5e14182b2e849b15d07 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 11:06:49 +0200 Subject: [PATCH 04/56] 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}; -- 2.40.1 From 4d1031e0313cce0eb1bd06362878fdb28e8bf206 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 10 May 2024 13:20:15 +0200 Subject: [PATCH 05/56] 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 ; -- 2.40.1 From 52400ab62651a38c3180b7b2eee3850986957b5c Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 20 May 2024 15:17:41 +0200 Subject: [PATCH 06/56] 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}}


-- 2.40.1 From 624f4707aca2ac1e13f2e5d97c8d1be816c2979e Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 26 Jun 2024 10:43:02 +0200 Subject: [PATCH 07/56] 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)}}; } -- 2.40.1 From dce62245e9ffbe7cb639776b0785c8f0a262a0bb Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 4 Jul 2024 13:10:32 +0200 Subject: [PATCH 08/56] 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}; } }); -- 2.40.1 From 8469b2ac3f0fbf08cdd740c72392644eaa658a59 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 9 Jul 2024 08:24:50 +0200 Subject: [PATCH 09/56] 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 -- 2.40.1 From 2078bf58ff474db4d99f1fe66c4e67bea7c135da Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:09:00 +0200 Subject: [PATCH 10/56] 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 ; -- 2.40.1 From 042ea840558403519b68a8ff4b09d4289be124aa Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:14:55 +0200 Subject: [PATCH 11/56] 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; -- 2.40.1 From a725cd2840f4af816833b3a29277d26d3fb9721c Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:19:04 +0200 Subject: [PATCH 12/56] 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; -- 2.40.1 From 376adebe9d93a7dbe7562fc47d15a94c33baa916 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:19:18 +0200 Subject: [PATCH 13/56] 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` -- 2.40.1 From 96d2bacb3dc2317e96aa679a7f82a62e9d9fa0c2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 10:22:42 +0200 Subject: [PATCH 14/56] 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 ; -- 2.40.1 From 769ee33ab21effdc47c4a5eba644318eac773400 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 11:40:24 +0200 Subject: [PATCH 15/56] 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 -- 2.40.1 From c3051ebcfbe70dc2dc923e705d2d00daf4ca00c6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 11:43:15 +0200 Subject: [PATCH 16/56] 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) -- 2.40.1 From f4e5f0205dc28621ea5b779a0abce2e03bb1c331 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 11:56:32 +0200 Subject: [PATCH 17/56] 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 -- 2.40.1 From bb7002b7022a12d30d8deeefe18856a9c0ece812 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 9 Jul 2024 12:00:55 +0200 Subject: [PATCH 18/56] 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', -- 2.40.1 From 46e8f5b8110f1bf6d11d3e3dae15b8c66174f49f Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 07:46:18 +0200 Subject: [PATCH 19/56] 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 -- 2.40.1 From d660043df2db6ff5bd3bd6e245c8698342c3099a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 07:48:42 +0200 Subject: [PATCH 20/56] 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": { -- 2.40.1 From 889982dd82e09e038ae3a89766b50481742b4a56 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 12:00:54 +0200 Subject: [PATCH 21/56] 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 ; -- 2.40.1 From a2f2ed743d7cb516f15d47073b00378d88334aec Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Jul 2024 13:31:48 +0200 Subject: [PATCH 22/56] 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; -- 2.40.1 From 94470915daf97f387269ad9fe011344776c7ab3c Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 15 Jul 2024 08:21:54 +0200 Subject: [PATCH 23/56] 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', { -- 2.40.1 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 24/56] 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; -- 2.40.1 From ddd6c799dc2e1f949757562e3930ff6e116ec653 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Jul 2024 17:32:14 +0000 Subject: [PATCH 25/56] feat(salix): #7648 Add field for endpoint as buyLabel report --- modules/entry/back/methods/entry/getBuys.js | 35 ++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 0cb71653e..6635c8038 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -51,6 +51,7 @@ module.exports = Self => { 'stickers', 'packing', 'grouping', + 'packing', 'groupingMode', 'quantity', 'packagingFk', @@ -59,7 +60,8 @@ module.exports = Self => { 'price2', 'price3', 'printedStickers', - 'entryFk' + 'entryFk', + ], include: [{ relation: 'entry', @@ -80,7 +82,9 @@ module.exports = Self => { fields: [ 'id', 'typeFk', + 'stems', 'name', + 'category', 'subName', 'size', 'minPrice', @@ -96,14 +100,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'] + } } - } + ] } }] }; -- 2.40.1 From a0be2edc415ecda3e6101e0c7d598c6a19f70359 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Jul 2024 17:33:21 +0000 Subject: [PATCH 26/56] feat(salix): #7648 remove white line --- modules/entry/back/methods/entry/getBuys.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 6635c8038..b6809c8c5 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -60,8 +60,7 @@ module.exports = Self => { 'price2', 'price3', 'printedStickers', - 'entryFk', - + 'entryFk' ], include: [{ relation: 'entry', -- 2.40.1 From aa1db03224da1754d5a88a4e6f7e369f0d309880 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 16 Jul 2024 09:18:52 +0200 Subject: [PATCH 27/56] build: init version 24.32 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea126bce3..9016f74a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.30.0", + "version": "24.32.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", -- 2.40.1 From 99bbb55c37926581563e3d78d421aa7dd7b486f8 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Jul 2024 10:02:57 +0200 Subject: [PATCH 28/56] feat: refs #7297 add new columns --- .../vn/procedures/item_comparative.sql | 21 ++++++++++--------- .../vn/procedures/item_refreshFromTags.sql | 6 ++++++ .../11156-tealCordyline/00-firstScript.sql | 8 +++++++ 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 db/versions/11156-tealCordyline/00-firstScript.sql diff --git a/db/routines/vn/procedures/item_comparative.sql b/db/routines/vn/procedures/item_comparative.sql index d429cf009..2625a87a5 100644 --- a/db/routines/vn/procedures/item_comparative.sql +++ b/db/routines/vn/procedures/item_comparative.sql @@ -10,19 +10,20 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_comparative`( ) proc: BEGIN /** - * Genera una tabla de comparativa de artículos por itemType/comprador/fecha. - * Los datos se calculan en función de los parámetros proporcionados. + * Generates a comparison table of items by itemType/buyer/date. + * The data is calculated based on the provided parameters. * - * @param vDate La fecha para la cual se generará la comparativa. - * @param vDayRange El rango de días a considerar para la comparativa. - * @param vWarehouseFk El identificador del almacén para filtrar los artículos. - * @param vAvailableSince La fecha de disponibilidad desde la cual se consideran los artículos disponibles. - * @param vBuyerFk El identificador del comprador para filtrar los artículos. - * @param vIsFloramondo Indica si se deben incluir solo los artículos de Floramondo (opcional). - * @param vCountryFk El identificador del país. - * @param tmp.comparativeFilterType(filterFk INT ,itemTypeFk INT) + * @param vDate The date for which the comparison will be generated. + * @param vDayRange The range of days to consider for the comparison. + * @param vWarehouseFk The warehouse identifier to filter the items. + * @param vAvailableSince The availability date from which the items are considered available. + * @param vBuyerFk The buyer identifier to filter the items. + * @param vIsFloramondo Indicates whether only Floramondo items should be included (optional). + * @param vCountryFk The country identifier. + * @param tmp.comparativeFilterType(filterFk INT, itemTypeFk INT) * @return tmp.comparative */ + DECLARE vDayRangeStart DATE; DECLARE vDayRangeEnd DATE; DECLARE w1, w2, w3, w4, w5, w6, w7 INT; diff --git a/db/routines/vn/procedures/item_refreshFromTags.sql b/db/routines/vn/procedures/item_refreshFromTags.sql index 398c01d8e..35f7c74e7 100644 --- a/db/routines/vn/procedures/item_refreshFromTags.sql +++ b/db/routines/vn/procedures/item_refreshFromTags.sql @@ -46,12 +46,18 @@ BEGIN i.tag8 = JSON_VALUE(vTags, '$.8'), i.tag9 = JSON_VALUE(vTags, '$.9'), i.tag10 = JSON_VALUE(vTags, '$.10'), + i.tag11 = JSON_VALUE(vTags, '$.11'), + i.tag12 = JSON_VALUE(vTags, '$.12'), + i.tag13 = JSON_VALUE(vTags, '$.13'), i.value5 = JSON_VALUE(vValues, '$.5'), i.value6 = JSON_VALUE(vValues, '$.6'), i.value7 = JSON_VALUE(vValues, '$.7'), i.value8 = JSON_VALUE(vValues, '$.8'), i.value9 = JSON_VALUE(vValues, '$.9'), i.value10 = JSON_VALUE(vValues, '$.10'), + i.value11 = JSON_VALUE(vValues, '$.11'), + i.value12 = JSON_VALUE(vValues, '$.12'), + i.value13 = JSON_VALUE(vValues, '$.13'), i.producerFk = p.id, i.inkFk = k.id, i.originFk = IFNULL(o.id, i.originFk) diff --git a/db/versions/11156-tealCordyline/00-firstScript.sql b/db/versions/11156-tealCordyline/00-firstScript.sql new file mode 100644 index 000000000..18c004b03 --- /dev/null +++ b/db/versions/11156-tealCordyline/00-firstScript.sql @@ -0,0 +1,8 @@ +ALTER TABLE vn.item ADD IF NOT EXISTS tag11 varchar(20) DEFAULT NULL NULL; +ALTER TABLE vn.item ADD IF NOT EXISTS value11 varchar(50) DEFAULT NULL NULL; + +ALTER TABLE vn.item ADD IF NOT EXISTS tag12 varchar(20) DEFAULT NULL NULL; +ALTER TABLE vn.item ADD IF NOT EXISTS value12 varchar(50) DEFAULT NULL NULL; + +ALTER TABLE vn.item ADD IF NOT EXISTS tag13 varchar(20) DEFAULT NULL NULL; +ALTER TABLE vn.item ADD IF NOT EXISTS value13 varchar(50) DEFAULT NULL NULL; \ No newline at end of file -- 2.40.1 From b7e84f43decbff0d4c45c6a64e116b2c605ec2e3 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Jul 2024 13:26:20 +0200 Subject: [PATCH 29/56] feat: refs #6403 add delete --- back/methods/mrw-config/cancelShipment.js | 3 ++- .../methods/expedition/deleteExpeditions.js | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 10d556575..57f9a1a8a 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -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 result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; + return result.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); } -- 2.40.1 From 9e007bfb8a05fc9311bbde5440152ec3aab48144 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Jul 2024 13:43:36 +0200 Subject: [PATCH 30/56] fix: refs #6403 fix mrw cancel shipment return type --- back/methods/mrw-config/cancelShipment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 57f9a1a8a..56d206529 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: { -- 2.40.1 From 12316fb44bf246ee062becd5bf32c5f668120129 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Jul 2024 07:32:42 +0200 Subject: [PATCH 31/56] fix(client_filter): add recovery --- .../client/back/methods/defaulter/filter.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index ac9504ec2..9f2d4b340 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -60,7 +60,7 @@ module.exports = Self => { DISTINCT c.id clientFk, c.name clientName, c.salesPersonFk, - c.businessTypeFk, + c.businessTypeFk = 'worker' isWorker, u.name salesPersonName, d.amount, co.created, @@ -71,14 +71,19 @@ module.exports = Self => { d.defaulterSinced, cn.name country, c.countryFk, - pm.name payMethod - FROM vn.defaulter d - JOIN vn.client c ON c.id = d.clientFk - JOIN vn.country cn ON cn.id = c.countryFk - JOIN vn.payMethod pm ON pm.id = c.payMethodFk - LEFT JOIN vn.clientObservation co ON co.clientFk = c.id + pm.name payMethod, + r.finished IS NULL hasRecovery + FROM defaulter d + JOIN client c ON c.id = d.clientFk + JOIN country cn ON cn.id = c.countryFk + JOIN payMethod pm ON pm.id = c.payMethodFk + LEFT JOIN clientObservation co ON co.clientFk = c.id LEFT JOIN account.user u ON u.id = c.salesPersonFk LEFT JOIN account.user uw ON uw.id = co.workerFk + LEFT JOIN ( + SELECT MAX(started), clientFk, finished + FROM recovery + ) r ON r.clientFk = c.id WHERE d.created = ? AND d.amount > 0 -- 2.40.1 From e66d138091c2d9ff9de301f47525618ea735b0f2 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 18 Jul 2024 08:12:39 +0200 Subject: [PATCH 32/56] feat(defaulter_filter): add department --- modules/client/back/methods/defaulter/filter.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index 9f2d4b340..0bfa7659b 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -72,7 +72,9 @@ module.exports = Self => { cn.name country, c.countryFk, pm.name payMethod, - r.finished IS NULL hasRecovery + r.finished IS NULL hasRecovery, + dp.id departmentFk, + dp.name departmentName FROM defaulter d JOIN client c ON c.id = d.clientFk JOIN country cn ON cn.id = c.countryFk @@ -84,6 +86,8 @@ module.exports = Self => { SELECT MAX(started), clientFk, finished FROM recovery ) r ON r.clientFk = c.id + LEFT JOIN workerDepartment wd ON wd.workerFk = u.id + JOIN department dp ON dp.id = wd.departmentFk WHERE d.created = ? AND d.amount > 0 -- 2.40.1 From 150b3a276eb8f1b575ffd7b570c561e83d66f22f Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 18 Jul 2024 10:51:24 +0200 Subject: [PATCH 33/56] feat: refs #7356 new parameters in sql for Weekly tickets front --- .../ticket/back/methods/ticket-weekly/filter.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket-weekly/filter.js b/modules/ticket/back/methods/ticket-weekly/filter.js index 0bf92d542..a43b5e270 100644 --- a/modules/ticket/back/methods/ticket-weekly/filter.js +++ b/modules/ticket/back/methods/ticket-weekly/filter.js @@ -53,13 +53,22 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL( - `SELECT t.id AS ticketFk, c.id AS clientFk, c.name AS clientName, tw.weekDay, - wh.name AS warehouseName, u.id AS workerFk, u.name AS userName, u.nickName, tw.agencyModeFk + `SELECT t.id AS ticketFk, + c.id AS clientFk, + c.name AS clientName, + tw.weekDay, + wh.name AS warehouseName, + u.id AS workerFk, + u.name AS userName, + u.nickName, + tw.agencyModeFk, + am.name agencyModeName FROM ticketWeekly tw JOIN ticket t ON t.id = tw.ticketFk JOIN client c ON c.id = t.clientFk JOIN account.user u ON u.id = c.salesPersonFk - JOIN warehouse wh ON wh.id = t.warehouseFk` + JOIN warehouse wh ON wh.id = t.warehouseFk + LEFT JOIN agencyMode am ON am.id = tw.agencyModeFk` ); stmt.merge(conn.makeSuffix(filter)); -- 2.40.1 From c17214ce05e07f58562a0d4c3ac7e1bef8952e59 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 18 Jul 2024 11:50:01 +0200 Subject: [PATCH 34/56] 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 -- 2.40.1 From 15adc59ec5f006ae74a771bc0b8faa3036178f4f Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 18 Jul 2024 12:04:17 +0200 Subject: [PATCH 35/56] 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 ; -- 2.40.1 From f687994a7f297019a5870cd86a7e2ec4a0b17042 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Jul 2024 14:27:10 +0200 Subject: [PATCH 36/56] 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 ; -- 2.40.1 From 03227d5e511928bab3b98b7c98b6aa7d284ec1c9 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 18 Jul 2024 14:49:40 +0200 Subject: [PATCH 37/56] 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 -- 2.40.1 From 3449aeb673214356a0bfd4fe5bf50c58cba71e6a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 07:45:17 +0200 Subject: [PATCH 38/56] 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; -- 2.40.1 From f19f10797167a4ba0bb5309714a97045ece0d569 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 19 Jul 2024 08:27:22 +0200 Subject: [PATCH 39/56] 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 -- 2.40.1 From 69a8b8ef4943ab2fc20f4d237850b8a24ddc8b87 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 08:34:25 +0200 Subject: [PATCH 40/56] 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": { -- 2.40.1 From 6aab5fa9efdb55182ca46ca145ae6509ab967413 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 12:47:05 +0200 Subject: [PATCH 41/56] 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); -- 2.40.1 From 05598b33719fffd7c16e47b60acc3890cf69ca16 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 14:29:20 +0200 Subject: [PATCH 42/56] 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, -- 2.40.1 From fe363fd4dbde010097353700b06e378b7b62e352 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 19 Jul 2024 15:00:13 +0200 Subject: [PATCH 43/56] 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; -- 2.40.1 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 44/56] 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; -- 2.40.1 From ccc02d57b769763d916088dafdee04a5a99b71a2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 07:59:15 +0200 Subject: [PATCH 45/56] 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); -- 2.40.1 From a2799e1e612822e022b1900419fe57fd6c572a19 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 08:01:23 +0200 Subject: [PATCH 46/56] 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 -- 2.40.1 From 24c85608eb5bf83162f0b00d02f5fde941d40d28 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 12:09:24 +0200 Subject: [PATCH 47/56] 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 -- 2.40.1 From b9c57c2f0ed2b5a4a837e2f9d5cc116da5f106c0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 12:45:57 +0200 Subject: [PATCH 48/56] 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) { -- 2.40.1 From 513b4583b329d22e3e5d07cb58f63253a7628c05 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Jul 2024 12:49:50 +0200 Subject: [PATCH 49/56] =?UTF-8?q?fix(deletExpeditions):=20merge=20test=20?= =?UTF-8?q?=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); } } -- 2.40.1 From eb18bd2400ccd0e27d721b41c297803b84dfebd3 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 13:57:14 +0200 Subject: [PATCH 50/56] 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') -- 2.40.1 From 4f321340017a13f0fdbd0325b656c31aa532d808 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 14:19:20 +0200 Subject: [PATCH 51/56] 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; }); -- 2.40.1 From 1a3ed42bcde938b670e273f4779ecef36ce9e27b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Jul 2024 14:37:34 +0200 Subject: [PATCH 52/56] 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 -- 2.40.1 From 0c51a97a17ae13d98804824e7635c1d80b7aa28c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Jul 2024 09:13:47 +0200 Subject: [PATCH 53/56] 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 ; -- 2.40.1 From ebac41603448d2af178184563f4f34835b6b4b66 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 24 Jul 2024 12:03:47 +0200 Subject: [PATCH 54/56] 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; -- 2.40.1 From 983d66a681e7d0918ac8d12f30be907ebac57647 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 24 Jul 2024 14:24:06 +0200 Subject: [PATCH 55/56] 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 -- 2.40.1 From cf84ce1337aab940e74599faf80f55c287421d2f Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 26 Jul 2024 09:38:49 +0200 Subject: [PATCH 56/56] 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 -- 2.40.1