From 2a203926b967715a184dce7fc08fac389d4b024f Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 2 Jul 2024 09:02:24 +0200 Subject: [PATCH 01/48] feat: refs #7564 Added volume column --- db/versions/11124-greenBamboo/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11124-greenBamboo/00-firstScript.sql diff --git a/db/versions/11124-greenBamboo/00-firstScript.sql b/db/versions/11124-greenBamboo/00-firstScript.sql new file mode 100644 index 000000000..6f47cbc21 --- /dev/null +++ b/db/versions/11124-greenBamboo/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.ticket ADD volume decimal(10,6) DEFAULT NULL NULL COMMENT 'Unidad en m3'; From 1e5fd8002cc925b8f7f90fd768328e0e7816103b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 2 Jul 2024 09:36:23 +0200 Subject: [PATCH 02/48] feat: refs #7564 Added proc --- .../vn/procedures/ticket_setVolume.sql | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 db/routines/vn/procedures/ticket_setVolume.sql diff --git a/db/routines/vn/procedures/ticket_setVolume.sql b/db/routines/vn/procedures/ticket_setVolume.sql new file mode 100644 index 000000000..060a6fa57 --- /dev/null +++ b/db/routines/vn/procedures/ticket_setVolume.sql @@ -0,0 +1,24 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolume`( + vSelf INT +) +BEGIN +/** + * Update the volume ticket + * + * @param vSelf Ticket id + */ + DECLARE vVolume DECIMAL(10,6); + + SELECT SUM(s.quantity * ic.cm3delivery / 1000000) INTO vVolume + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + WHERE t.id = vSelf; + + UPDATE ticket + SET volume = vVolume + WHERE id = vSelf; +END$$ +DELIMITER ; From 2f8df96ba7d0e8cd4d82d50a18a131fe2a10fa98 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 3 Jul 2024 09:29:12 +0200 Subject: [PATCH 03/48] feat: refs #7564 Added ticket_setVolumeItemCost --- .../procedures/ticket_setVolumeItemCost.sql | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 db/routines/vn/procedures/ticket_setVolumeItemCost.sql diff --git a/db/routines/vn/procedures/ticket_setVolumeItemCost.sql b/db/routines/vn/procedures/ticket_setVolumeItemCost.sql new file mode 100644 index 000000000..c00fc63dc --- /dev/null +++ b/db/routines/vn/procedures/ticket_setVolumeItemCost.sql @@ -0,0 +1,32 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolumeItemCost`( + vItemFk INT +) +BEGIN +/** + * Update the volume tickets of item + * + * @param vSelf Ticket id + */ + CREATE OR REPLACE TEMPORARY TABLE tTicket + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + WHERE t.id IN ( + SELECT DISTINCT ticketFk + FROM sale + WHERE itemFk = vItemFk + ) + GROUP BY t.id; + + UPDATE ticket t + JOIN tTicket tt ON tt.id = t.id + SET t.volume = tt.volume; + + DROP TEMPORARY TABLE tTicket; +END$$ +DELIMITER ; From 18dc3873b87a6e461f0ec7d85f371488c0318679 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 09:54:43 +0200 Subject: [PATCH 04/48] feat: refs #7650 Added no transfer lines to inventory entry and fixtures --- db/dump/fixtures.before.sql | 4 ++++ db/routines/vn/triggers/buy_beforeUpdate.sql | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 60c96abb4..e3c19f6e0 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -582,6 +582,7 @@ INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif` VALUES (1, 'PLANTS SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'GOTHAM', 1, 46000, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), (2, 'FARMER KING', 'The farmer', 4000020002, 1, '87945234L', 0, util.VN_CURDATE(), 1, 'supplier address 2', 'GOTHAM', 2, 46000, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), + (4, 'INVENTARIO', 'INVENTARIO', 4000000004, NULL, NULL, 0, util.VN_CURDATE(), 1, NULL, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL, NULL), (69, 'PACKAGING', 'Packaging nick', 4100000069, 1, '94935005K', 0, util.VN_CURDATE(), 1, 'supplier address 5', 'ASGARD', 3, 46600, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), (442, 'VERDNATURA LEVANTE SL', 'Verdnatura', 5115000442, 1, '06815934E', 0, util.VN_CURDATE(), 1, 'supplier address 3', 'GOTHAM', 1, 46000, 1, 2, 15, 6, 9, 3, 18, 'complements', 1, '400664487V'), (567, 'HOLLAND', 'Holland nick', 4000020567, 1, '14364089Z', 0, util.VN_CURDATE(), 1, 'supplier address 6', 'ASGARD', 3, 46600, 1, 2, 10, 93, 2, 8, 18, 'animals', 1, '400664487V'), @@ -1516,6 +1517,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''); +INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) + VALUES (1, 4, 1); + INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleQuantity`, `saleInternalWaste`, `saleExternalWaste`) VALUES ('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'), diff --git a/db/routines/vn/triggers/buy_beforeUpdate.sql b/db/routines/vn/triggers/buy_beforeUpdate.sql index 1e2faecdc..366681f99 100644 --- a/db/routines/vn/triggers/buy_beforeUpdate.sql +++ b/db/routines/vn/triggers/buy_beforeUpdate.sql @@ -69,6 +69,10 @@ trig:BEGIN IF NOT NEW.printedStickers <=> OLD.printedStickers THEN CALL util.throw("Stickers cannot be modified if they are inventory"); END IF; + + IF OLD.entryFk <> NEW.entryFk THEN + CALL util.throw("Cannot transfer lines to inventory entry"); + END IF; END IF; IF NEW.quantity < 0 THEN From 0451e4bb2a50dca6fe5e148335cfcd168e09900e Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Jul 2024 10:20:04 +0200 Subject: [PATCH 05/48] feat: refs #7650 Fix tests --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e3c19f6e0..adb0c01ac 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1518,7 +1518,7 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) - VALUES (1, 4, 1); + VALUES (2, 4, 1); INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `saleTotal`, `saleQuantity`, `saleInternalWaste`, `saleExternalWaste`) VALUES From ea754469824eb0610f1e59243172dd1127b6ed56 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 10:32:47 +0200 Subject: [PATCH 06/48] refs #7844 Change in problems calc --- .../vn/procedures/productionControl.sql | 6 - .../vn/procedures/sale_getProblems.sql | 285 +++++++----------- .../procedures/sale_getProblemsByTicket.sql | 3 +- .../vn/procedures/ticket_getProblems.sql | 4 +- 4 files changed, 107 insertions(+), 191 deletions(-) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index af6d929d7..84717a19a 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -15,11 +15,6 @@ proc: BEGIN DECLARE vEndingDate DATETIME; DECLARE vIsTodayRelative BOOLEAN; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - RESIGNAL; - END; - SELECT util.dayEnd(util.VN_CURDATE()) + INTERVAL LEAST(vScopeDays, maxProductionScopeDays) DAY INTO vEndingDate FROM productionConfig; @@ -273,7 +268,6 @@ proc: BEGIN DROP TEMPORARY TABLE tmp.productionTicket, tmp.ticket, - tmp.risk, tmp.ticket_problems, tmp.ticketWithPrevia, tItemShelvingStock, diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index c881bcf92..20e9f4c3a 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -1,152 +1,87 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas de cada venta para un conjunto de tickets. * * @param vIsTodayRelative Indica si se calcula el disponible como si todo saliera hoy - * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Identificadores de los tickets a calcular + * @table tmp.sale_getProblems(ticketFk, clientFk, warehouseFk, shipped) Tickets a calcular * @return tmp.sale_problems */ - DECLARE vWarehouseFk INT; + DECLARE vWarehouseFk INT; DECLARE vDate DATE; - DECLARE vAvailableCache INT; + DECLARE vAvailableCache INT; DECLARE vVisibleCache INT; DECLARE vDone BOOL; - DECLARE vRequiredComponent INT; - - DECLARE vCursor CURSOR FOR - SELECT DISTINCT tt.warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(tt.shipped)) - FROM tmp.sale_getProblems tt - WHERE DATE(tt.shipped) BETWEEN util.VN_CURDATE() - AND util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY; + DECLARE vCursor CURSOR FOR + SELECT DISTINCT warehouseFk, IF(vIsTodayRelative, util.VN_CURDATE(), DATE(shipped)) + FROM tmp.sale_getProblems + WHERE shipped BETWEEN util.VN_CURDATE() + AND util.dayEnd(util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; DELETE tt.* FROM tmp.sale_getProblems tt JOIN ticketObservation tto ON tto.ticketFk = tt.ticketFk - JOIN observationType ot ON ot.id = tto.observationTypeFk - WHERE ot.code = 'administrative' + JOIN observationType ot ON ot.id = tto.observationTypeFk + WHERE ot.code = 'administrative' AND tto.description = 'Miriam'; - CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( - ticketFk INT(11), - saleFk INT(11), - isFreezed INTEGER(1) DEFAULT 0, - risk DECIMAL(10,1) DEFAULT 0, - hasHighRisk TINYINT(1) DEFAULT 0, - hasTicketRequest INTEGER(1) DEFAULT 0, - itemShortage VARCHAR(255), - isTaxDataChecked INTEGER(1) DEFAULT 1, - itemDelay VARCHAR(255), - itemLost VARCHAR(255), - hasComponentLack INTEGER(1), - hasRounding VARCHAR(255), - isTooLittle BOOL DEFAULT FALSE, - isVip BOOL DEFAULT FALSE, - PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_problems ( + ticketFk INT(11), + saleFk INT(11), + isFreezed INTEGER(1) DEFAULT 0, + risk DECIMAL(10,1) DEFAULT 0, + hasHighRisk TINYINT(1) DEFAULT 0, + hasTicketRequest INTEGER(1) DEFAULT 0, + itemShortage VARCHAR(255), + isTaxDataChecked INTEGER(1) DEFAULT 1, + itemDelay VARCHAR(255), + itemLost VARCHAR(255), + hasComponentLack INTEGER(1), + hasRounding VARCHAR(255), + isTooLittle BOOL DEFAULT FALSE, + isVip BOOL DEFAULT FALSE, + PRIMARY KEY (ticketFk, saleFk) + ) ENGINE = MEMORY; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (ticketFk)) - ENGINE = MEMORY - SELECT ticketFk, clientFk - FROM tmp.sale_getProblems; - - SELECT COUNT(*) INTO vRequiredComponent - FROM component - WHERE isRequired; - - -- Too Little - INSERT INTO tmp.sale_problems(ticketFk, isTooLittle) - SELECT tp.ticketFk, TRUE - FROM tmp.sale_getProblems tp - JOIN ticket t ON t.id = tp.ticketFk - JOIN ( - SELECT t.addressFk, - SUM(ROUND(`ic`.`cm3delivery` * `s`.`quantity` / 1000, 0)) litros, - t.totalWithoutVat - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN sale s ON s.ticketFk = t.id - AND s.quantity > 0 - JOIN itemCost ic ON ic.itemFk = s.itemFk - AND ic.warehouseFk = t.warehouseFk - JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk - AND zc.dated = util.VN_CURDATE() - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - WHERE util.VN_NOW() < (util.VN_CURDATE() + INTERVAL HOUR(zc.`hour`) HOUR) + INTERVAL MINUTE(zc.`hour`) MINUTE - AND dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND t.shipped BETWEEN util.VN_CURDATE() AND util.midnight() - GROUP BY t.addressFk - ) sub ON sub.addressFk = t.addressFk - JOIN volumeConfig vc - WHERE sub.litros < vc.minTicketVolume - AND sub.totalWithoutVat < vc.minTicketValue; - - -- VIP - INSERT INTO tmp.sale_problems(ticketFk, isVip) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE c.businessTypeFk = 'VIP' - ON DUPLICATE KEY UPDATE isVip = TRUE; - - -- Faltan componentes - INSERT INTO tmp.sale_problems(ticketFk, hasComponentLack, saleFk) - SELECT t.id, COUNT(c.id) < vRequiredComponent hasComponentLack, s.id - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN sale s ON s.ticketFk = t.id - JOIN agencyMode am ON am.id = t.agencyModeFk - JOIN deliveryMethod dm ON dm.id = am.deliveryMethodFk - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - LEFT JOIN component c ON c.id = sc.componentFk - AND c.isRequired - WHERE dm.code IN ('AGENCY','DELIVERY','PICKUP') - AND s.quantity > 0 - GROUP BY s.id - HAVING hasComponentLack; - - -- Cliente congelado - INSERT INTO tmp.sale_problems(ticketFk, isFreezed) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE c.isFreezed - ON DUPLICATE KEY UPDATE isFreezed = c.isFreezed; - - -- Credit exceeded - CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) - ENGINE = MEMORY - SELECT DISTINCT clientFk - FROM tmp.ticket_list; - - CALL client_getDebt(util.VN_CURDATE()); - - INSERT INTO tmp.sale_problems(ticketFk, risk, hasHighRisk) - SELECT DISTINCT tl.ticketFk, r.risk, ((r.risk - cc.riskTolerance) > c.credit + 10) - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - JOIN agencyMode a ON t.agencyModeFk = a.id - JOIN tmp.risk r ON r.clientFk = t.clientFk - JOIN client c ON c.id = t.clientFk - JOIN clientConfig cc - WHERE r.risk > c.credit + 10 - AND NOT a.isRiskFree - ON DUPLICATE KEY UPDATE - risk = r.risk, hasHighRisk = ((r.risk - cc.riskTolerance) > c.credit + 10); - - -- Antiguo COD 100, son peticiones de compra sin terminar - INSERT INTO tmp.sale_problems(ticketFk, hasTicketRequest) - SELECT DISTINCT tl.ticketFk, TRUE - FROM tmp.ticket_list tl - JOIN ticketRequest tr ON tr.ticketFk = tl.ticketFk - WHERE tr.isOK IS NULL - ON DUPLICATE KEY UPDATE hasTicketRequest = TRUE; + INSERT INTO tmp.sale_problems (ticketFk, + saleFk, + isFreezed, + hasHighRisk, + hasTicketRequest, + isTaxDataChecked, + hasComponentLack, + hasRounding, + isTooLittle, + isVip) + SELECT sgp.ticketFk, + s.id, + IF(FIND_IN_SET('isFreezed', s.problem), TRUE, FALSE) isFreezed, + IF(FIND_IN_SET('hasHighRisk', s.problem), TRUE, FALSE) hasHighRisk, + IF(FIND_IN_SET('hasTicketRequest', s.problem), TRUE, FALSE) hasTicketRequest, + IF(FIND_IN_SET('isTaxDataChecked', s.problem), FALSE, TRUE) isTaxDataChecked, + IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, + IF(FIND_IN_SET('hasRounding', s.problem), + LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250), + NULL + ) hasRounding, + IF(FIND_IN_SET('isTooLittle', s.problem), TRUE, FALSE) isTooLittle, + IF(FIND_IN_SET('isVip', s.problem), TRUE, FALSE) isVip + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE s.problem <> '' + GROUP BY s.id; + + INSERT INTO tmp.sale_problems (ticketFk, risk) + SELECT t.id, t.risk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk; CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock_byWarehouse (INDEX (itemFk, warehouseFk)) @@ -158,10 +93,9 @@ BEGIN JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk JOIN sector s ON s.id = p.sectorFk - GROUP BY ish.itemFk, - s.warehouseFk; + GROUP BY ish.itemFk, s.warehouseFk; - -- Disponible, Faltas, Inventario y Retrasos + -- Disponible, faltas, inventario y retrasos OPEN vCursor; l: LOOP SET vDone = FALSE; @@ -180,14 +114,14 @@ BEGIN INSERT INTO tmp.sale_problems(ticketFk, itemShortage, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, - LEFT(CONCAT('F: ',GROUP_CONCAT(i.id, ' ', i.longName, ' ')),250) problem, - s.id AS saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + SELECT sgp.ticketFk, + LEFT(CONCAT('F: ', GROUP_CONCAT(i.id, ' ', i.longName, ' ')), 250) problem, + s.id saleFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = i.id AND v.calc_id = vVisibleCache @@ -195,8 +129,8 @@ BEGIN AND av.calc_id = vAvailableCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) < s.quantity - AND IFNULL(av.available ,0) < s.quantity + WHERE IFNULL(v.visible, 0) < s.quantity + AND IFNULL(av.available, 0) < s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND NOT s.isPicked AND NOT s.reserved @@ -205,27 +139,27 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk) sub + GROUP BY sgp.ticketFk) sub ON DUPLICATE KEY UPDATE itemShortage = sub.problem, saleFk = sub.saleFk; -- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida INSERT INTO tmp.sale_problems(ticketFk, itemLost, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('I: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk - WHERE IFNULL(v.visible,0) >= s.quantity + WHERE IFNULL(v.visible, 0) >= s.quantity AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND NOT s.isPicked @@ -235,22 +169,22 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub - ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; + ON DUPLICATE KEY UPDATE itemLost = sub.problem, saleFk = sub.saleFk; -- Retraso: Disponible suficiente, pero no visible ni ubicado INSERT INTO tmp.sale_problems(ticketFk, itemDelay, saleFk) SELECT ticketFk, problem, saleFk FROM ( - SELECT tl.ticketFk, + SELECT sgp.ticketFk, LEFT(GROUP_CONCAT('R: ', i.id, ' ', i.longName, ' '), 250) problem, s.id saleFk - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk JOIN sale s ON s.ticketFk = t.id JOIN item i ON i.id = s.itemFk - JOIN itemType it on it.id = i.typeFk + JOIN itemType it ON it.id = i.typeFk JOIN itemCategory ic ON ic.id = it.categoryFk LEFT JOIN cache.visible v ON v.item_id = s.itemFk AND v.calc_id = vVisibleCache @@ -269,42 +203,29 @@ BEGIN AND NOT i.generic AND util.VN_CURDATE() = vDate AND t.warehouseFk = vWarehouseFk - GROUP BY tl.ticketFk + GROUP BY sgp.ticketFk ) sub ON DUPLICATE KEY UPDATE itemDelay = sub.problem, saleFk = sub.saleFk; - - -- Redondeo: Cantidad pedida incorrecta en al grouping de la última compra - CALL buy_getUltimate(NULL, vWarehouseFk, vDate); - INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) - SELECT ticketFk, problem ,saleFk - FROM ( - SELECT tl.ticketFk, - s.id saleFk, - LEFT(GROUP_CONCAT('RE: ',i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem - FROM tmp.ticket_list tl - JOIN ticket t ON t.id = tl.ticketFk - AND t.warehouseFk = vWarehouseFk - JOIN sale s ON s.ticketFk = tl.ticketFk - JOIN item i ON i.id = s.itemFk - JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk - JOIN buy b ON b.id = bu.buyFk - WHERE MOD(s.quantity, b.`grouping`) - GROUP BY tl.ticketFk - )sub - ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; END LOOP; CLOSE vCursor; - - INSERT INTO tmp.sale_problems(ticketFk, isTaxDataChecked) - SELECT DISTINCT tl.ticketFk, FALSE - FROM tmp.ticket_list tl - JOIN client c ON c.id = tl.clientFk - WHERE NOT c.isTaxDataChecked - ON DUPLICATE KEY UPDATE isTaxDataChecked = FALSE; + + INSERT INTO tmp.sale_problems(ticketFk, hasRounding, saleFk) + SELECT ticketFk, problem, saleFk + FROM ( + SELECT sgp.ticketFk, + s.id saleFk, + LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250) problem + FROM tmp.sale_getProblems sgp + JOIN ticket t ON t.id = sgp.ticketFk + JOIN sale s ON s.ticketFk = sgp.ticketFk + JOIN item i ON i.id = s.itemFk + WHERE FIND_IN_SET('hasRounding', s.problem) + GROUP BY sgp.ticketFk + ) sub + ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; DROP TEMPORARY TABLE - tmp.clientGetDebt, - tmp.ticket_list, + tmp.sale_getProblems, tItemShelvingStock_byWarehouse; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/sale_getProblemsByTicket.sql b/db/routines/vn/procedures/sale_getProblemsByTicket.sql index b4aaad7de..f7a066705 100644 --- a/db/routines/vn/procedures/sale_getProblemsByTicket.sql +++ b/db/routines/vn/procedures/sale_getProblemsByTicket.sql @@ -7,8 +7,7 @@ BEGIN * * @return Problems result */ - DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems; - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk, t.warehouseFk, t.shipped diff --git a/db/routines/vn/procedures/ticket_getProblems.sql b/db/routines/vn/procedures/ticket_getProblems.sql index 521e4cf2f..e9becab2a 100644 --- a/db/routines/vn/procedures/ticket_getProblems.sql +++ b/db/routines/vn/procedures/ticket_getProblems.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getProblems`(IN vIsTodayRelative tinyint(1)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getProblems`( + vIsTodayRelative tinyint(1) +) BEGIN /** * Calcula los problemas para un conjunto de tickets. From 4f2e343d0c7e78f766571ccfc683fa6035938673 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 10:40:10 +0200 Subject: [PATCH 07/48] refs #7844 Fix --- db/routines/vn/procedures/sale_getProblems.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 20e9f4c3a..d8b7264c1 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -224,8 +224,6 @@ BEGIN ) sub ON DUPLICATE KEY UPDATE hasRounding = sub.problem, saleFk = sub.saleFk; - DROP TEMPORARY TABLE - tmp.sale_getProblems, - tItemShelvingStock_byWarehouse; + DROP TEMPORARY TABLE tItemShelvingStock_byWarehouse; END$$ DELIMITER ; From 8aa06e12b3374e1476a140e029af4146b3982cbe Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 12:39:18 +0200 Subject: [PATCH 08/48] refs #7844 Fix tests part 1/2 --- db/dump/fixtures.before.sql | 162 +++++++++--------- .../vn/procedures/sale_getProblems.sql | 2 +- modules/ticket/back/methods/ticket/filter.js | 63 ++++--- .../back/methods/ticket/getTicketsFuture.js | 19 +- 4 files changed, 122 insertions(+), 124 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 60c96abb4..4b69d3b6d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -743,45 +743,45 @@ INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agen (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3), (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5); -INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`) +INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`) VALUES - (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1), - (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2), - (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3), - (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL), - (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL), - (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL), - (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL), - (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL), - (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL, NULL), - (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL), - (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL), - (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL), - (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL), - (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL), - (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), - (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), - (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), - (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL); + (1 , 3, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 121, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'hasHighRisk', 901.4), + (2 , 1, 1, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Bat cave', 1, NULL, 0, 1, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 2, 2, 'hasHighRisk', 901.4), + (3 , 1, 7, 1, 6, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -2 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 3, NULL, NULL), + (4 , 3, 2, 1, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -3 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 9, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, NULL, NULL, NULL), + (5 , 3, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -4 MONTH), INTERVAL +1 DAY), 1104, 'Stark tower', 124, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, NULL, NULL, NULL), + (6 , 1, 3, 3, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL -1 MONTH), INTERVAL +1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 10, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, NULL, 'hasHighRisk', 901.4), + (7 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Mountain Drive Gotham', 1, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTooLittle', NULL), + (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), + (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), + (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL), + (19, 1, 5, 5, NULL, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 1, NULL, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL), + (20, 1, 5, 5, 3, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Thailand', 129, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (21, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Holland', 102, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (22, NULL, 5, 5, 5, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), DATE_ADD(DATE_ADD(util.VN_CURDATE(),INTERVAL +1 MONTH), INTERVAL +1 DAY), 1109, 'Somewhere in Japan', 103, NULL, 0, 13, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), NULL, NULL, 'isTaxDataChecked', NULL), + (23, NULL, 8, 1, 7, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'address 21', 121, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest, hasHighRisk', 901.4), + (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (31, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (32, 1, 8, 1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL + 2 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (33, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -1059,50 +1059,50 @@ INSERT INTO `vn`.`ticketPackaging`(`id`, `ticketFk`, `packagingFk`, `quantity`, (2, 2, 2, 1, util.VN_CURDATE(), NULL), (3, 3, 2, 4, util.VN_CURDATE(), NULL); -INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`) +INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `price`, `discount`, `reserved`, `isPicked`, `created`, `problem`) VALUES - (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH)), - (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE()), - (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE()), - (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE()), - (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE()), - (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE()), - (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()), - (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE()), - (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE()), - (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH)), - (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH)), - (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), - (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE()), - (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE()), - (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE()), - (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE()), - (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH)), - (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE()), - (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE()), - (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE()), - (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE()); + (1, 1, 1, 'Ranged weapon longbow 200cm', 5, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (2, 2, 1, 'Melee weapon combat fist 15cm', 10, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (3, 1, 1, 'Ranged weapon longbow 200cm', 2, 100.39, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 'hasComponentLack'), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE(), NULL), + (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (12, 4, 16, 'Melee weapon heavy shield 100cm', 20, 1.71, 0, 0, 0, util.VN_CURDATE(), NULL), + (13, 2, 8, 'Melee weapon combat fist 15cm', 10, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL), + (14, 1, 8, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (15, 1, 19, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), + (16, 2, 20, 'Melee weapon combat fist 15cm', 20, 7.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (17, 2, 22, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (18, 4, 22, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (19, 1, 4, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 'hasComponentLack'), + (20, 1, 5, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 'hasComponentLack'), + (21, 1, 6, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), + (22, 1, 7, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (23, 1, 9, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (24, 1, 10, 'Ranged weapon longbow 200cm', 1, 8.07, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack, isFreezed'), + (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), 'hasRounding'), + (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL), + (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), + (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), + (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (40, 2, 34, 'Melee weapon combat fist 15cm', 10.00, 3.91, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (41, 2, 35, 'Melee weapon combat fist 15cm', 8.00, 3.01, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (42, 2, 36, 'Melee weapon combat fist 15cm', 6.00, 2.50, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'); INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) VALUES diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index d8b7264c1..258998e68 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -77,7 +77,7 @@ BEGIN JOIN item i ON i.id = s.itemFk WHERE s.problem <> '' GROUP BY s.id; - + INSERT INTO tmp.sale_problems (ticketFk, risk) SELECT t.id, t.risk FROM tmp.sale_getProblems sgp diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 0823b38b8..3e8b732af 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -224,16 +224,14 @@ module.exports = Self => { const stmts = []; let stmt; - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.filter'); - stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.filter + stmt = new ParameterizedSQL(` + CREATE OR REPLACE TEMPORARY TABLE tmp.filter (INDEX (id)) ENGINE = MEMORY - SELECT - t.id, + SELECT t.id, t.shipped, - CAST(DATE(t.shipped) AS CHAR) AS shippedDate, - HOUR(t.shipped) AS shippedHour, + CAST(DATE(t.shipped) AS CHAR) shippedDate, + HOUR(t.shipped) shippedHour, t.nickname, t.refFk, t.routeFk, @@ -241,26 +239,26 @@ module.exports = Self => { t.clientFk, t.totalWithoutVat, t.totalWithVat, - io.id AS invoiceOutId, + io.id invoiceOutId, a.provinceFk, - p.name AS province, - w.name AS warehouse, - am.name AS agencyMode, - am.id AS agencyModeFk, - st.name AS state, + p.name province, + w.name warehouse, + am.name agencyMode, + am.id agencyModeFk, + st.name state, st.classColor, - wk.lastName AS salesPerson, - ts.stateFk AS stateFk, - ts.alertLevel AS alertLevel, - ts.code AS alertLevelCode, - u.name AS userName, + wk.lastName salesPerson, + ts.stateFk stateFk, + ts.alertLevel alertLevel, + ts.code alertLevelCode, + u.name userName, c.salesPersonFk, - z.hour AS zoneLanding, - HOUR(z.hour) AS zoneHour, - MINUTE(z.hour) AS zoneMinute, - z.name AS zoneName, - z.id AS zoneFk, - CAST(z.hour AS CHAR) AS hour + z.hour zoneLanding, + HOUR(z.hour) zoneHour, + MINUTE(z.hour) zoneMinute, + z.name zoneName, + z.id zoneFk, + CAST(z.hour AS CHAR) hour FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk @@ -273,7 +271,8 @@ module.exports = Self => { LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.id - LEFT JOIN route r ON r.id = t.routeFk`); + LEFT JOIN route r ON r.id = t.routeFk + `); if (args.orderFk) { stmt.merge({ @@ -293,25 +292,25 @@ module.exports = Self => { stmt.merge(conn.makeWhere(filter.where)); stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) - AND f.shipped >= ?`, [date]); - stmts.push(stmt); + AND f.shipped >= ? + `, [date]); + stmts.push(stmt); stmts.push('CALL ticket_getProblems(FALSE)'); stmt = new ParameterizedSQL(` SELECT f.*, tp.* - FROM tmp.filter f - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id`); + FROM tmp.filter f + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + `); if (args.problems != undefined && (!args.from && !args.to)) throw new UserError('Choose a date range or days forward'); diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index ab5071be4..b7267995e 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -145,18 +145,17 @@ module.exports = Self => { stmts.push(stmt); - stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); - stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems - (INDEX (ticketFk)) - ENGINE = MEMORY - SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters - FROM tmp.filter f - LEFT JOIN alertLevel al ON al.id = f.alertLevel - WHERE (al.code = 'FREE' OR f.alertLevel IS NULL)`); - stmts.push(stmt); + CREATE OR REPLACE TEMPORARY TABLE tmp.sale_getProblems + (INDEX (ticketFk)) + ENGINE = MEMORY + SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped, f.lines, f.liters + FROM tmp.filter f + LEFT JOIN alertLevel al ON al.id = f.alertLevel + WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) + `); + stmts.push(stmt); stmts.push('CALL ticket_getProblems(FALSE)'); stmt = new ParameterizedSQL(` From 4cbea3bf7bc1dc981e523ff6dd9d99d629b12189 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 13:51:00 +0200 Subject: [PATCH 09/48] refs #7844 Fix tests part 2/2 --- db/dump/fixtures.before.sql | 20 +++++------ .../vn/procedures/sale_getProblems.sql | 36 ++++++++++--------- .../back/methods/ticket/getTicketsFuture.js | 3 +- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 4b69d3b6d..650cf5333 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -755,11 +755,11 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (8 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1101, 'Bat cave', 121, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), (9 , NULL, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1104, 'Stark tower', 124, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (10, 1, 1, 5, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'Ingram Street', 2, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isTooLittle', NULL), - (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (11, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1102, 'NY roofs', 122, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasTicketRequest', NULL), (12, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (13, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (14, 1, 2, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1104, 'Malibu Point', 4, NULL, 0, 9, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), - (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), + (15, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1105, 'An incredibly long alias for testing purposes', 125, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, 'isFreezed', NULL), (16, 1, 7, 1, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), (17, 1, 7, 2, 6, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1106, 'Many Places', 126, NULL, 0, 3, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 388.7), (18, 1, 4, 4, 4, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1108, 'Cerebro', 128, NULL, 0, 12, 5, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL +12 HOUR), NULL, NULL, 'isFreezed', NULL), @@ -771,7 +771,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (24 ,NULL, 8, 1, 7, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 5, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), (25 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Bruce Wayne', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), (26 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'An incredibly long alias for testing purposes', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), - (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, 'hasHighRisk', 901.4), + (27 ,NULL, 8, 1, NULL, util.VN_CURDATE(), util.VN_CURDATE(), 1101, 'Wolverine', 1, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, 901.4), (28, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (29, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (30, 1, 8, 1, 1, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1103, 'Phone Box', 123, NULL, 0, 1, 5, 1, util.VN_CURDATE(), NULL, NULL, NULL, NULL), @@ -781,7 +781,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (34, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1103, 'BEJAR', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL), - (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, 'isTaxDataChecked', NULL); + (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL, NULL, NULL); INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES @@ -1067,8 +1067,8 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (4, 4, 1, 'Melee weapon heavy shield 100cm', 20, 1.69, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), (5, 1, 2, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 'hasComponentLack'), (6, 1, 3, 'Ranged weapon longbow 200cm', 1, 110.33, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 'hasComponentLack'), - (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (7, 2, 11, 'Melee weapon combat fist 15cm', 15, 7.74, 0, 0, 0, util.VN_CURDATE(), NULL), + (8, 4, 11, 'Melee weapon heavy shield 100cm', 10, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), (9, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), (10, 2, 16, 'Melee weapon combat fist 15cm', 10, 7.09, 0, 0, 0, util.VN_CURDATE(), NULL), (11, 1, 16, 'Ranged weapon longbow 200cm', 1, 103.49, 0, 0, 0, util.VN_CURDATE(), NULL), @@ -1088,15 +1088,15 @@ INSERT INTO `vn`.`sale`(`id`, `itemFk`, `ticketFk`, `concept`, `quantity`, `pric (25, 4, 12, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (26, 4, 13, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (27, 4, 14, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack, isFreezed'), + (28, 4, 15, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (29, 4, 17, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (30, 4, 18, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), 'hasRounding'), - (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL), + (31, 2, 23, 'Melee weapon combat fist 15cm', -5, 7.08, 0, 0, 0, util.VN_CURDATE(), NULL), + (32, 1, 24, 'Ranged weapon longbow 200cm', -1, 8.07, 0, 0, 0, util.VN_CURDATE(), NULL), (33, 5, 14, 'Ranged weapon pistol 9mm', 50, 1.79, 0, 0, 0, util.VN_CURDATE(), NULL), (34, 4, 28, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (35, 4, 29, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), - (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), + (37, 4, 31, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), NULL), (36, 4, 30, 'Melee weapon heavy shield 100cm', 20, 1.72, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), (38, 2, 32, 'Melee weapon combat fist 15cm', 30, 7.07, 0, 0, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL +1 MONTH), 'hasComponentLack'), (39, 1, 32, 'Ranged weapon longbow 200cm', 2, 103.49, 0, 0, 0, util.VN_CURDATE(), 'hasComponentLack'), diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 258998e68..6f65a3722 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -48,40 +48,42 @@ BEGIN PRIMARY KEY (ticketFk, saleFk) ) ENGINE = MEMORY; - INSERT INTO tmp.sale_problems (ticketFk, + INSERT INTO tmp.sale_problems(ticketFk, saleFk, isFreezed, + risk, hasHighRisk, hasTicketRequest, isTaxDataChecked, hasComponentLack, hasRounding, - isTooLittle, - isVip) + isTooLittle) SELECT sgp.ticketFk, s.id, - IF(FIND_IN_SET('isFreezed', s.problem), TRUE, FALSE) isFreezed, - IF(FIND_IN_SET('hasHighRisk', s.problem), TRUE, FALSE) hasHighRisk, - IF(FIND_IN_SET('hasTicketRequest', s.problem), TRUE, FALSE) hasTicketRequest, - IF(FIND_IN_SET('isTaxDataChecked', s.problem), FALSE, TRUE) isTaxDataChecked, + IF(FIND_IN_SET('isFreezed', t.problem), TRUE, FALSE) isFreezed, + t.risk, + IF(FIND_IN_SET('hasHighRisk', t.problem), TRUE, FALSE) hasHighRisk, + IF(FIND_IN_SET('hasTicketRequest', t.problem), TRUE, FALSE) hasTicketRequest, + IF(FIND_IN_SET('isTaxDataChecked', t.problem), FALSE, TRUE) isTaxDataChecked, IF(FIND_IN_SET('hasComponentLack', s.problem), TRUE, FALSE) hasComponentLack, IF(FIND_IN_SET('hasRounding', s.problem), LEFT(GROUP_CONCAT('RE: ', i.id, ' ', IFNULL(i.longName,'') SEPARATOR ', '), 250), NULL ) hasRounding, - IF(FIND_IN_SET('isTooLittle', s.problem), TRUE, FALSE) isTooLittle, - IF(FIND_IN_SET('isVip', s.problem), TRUE, FALSE) isVip + IF(FIND_IN_SET('isTooLittle', t.problem), TRUE, FALSE) isTooLittle FROM tmp.sale_getProblems sgp JOIN ticket t ON t.id = sgp.ticketFk - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE s.problem <> '' - GROUP BY s.id; + LEFT JOIN sale s ON s.ticketFk = t.id + LEFT JOIN item i ON i.id = s.itemFk + WHERE s.problem <> '' OR t.problem <> '' OR t.risk + GROUP BY t.id, s.id; - INSERT INTO tmp.sale_problems (ticketFk, risk) - SELECT t.id, t.risk - FROM tmp.sale_getProblems sgp - JOIN ticket t ON t.id = sgp.ticketFk; + INSERT INTO tmp.sale_problems(ticketFk, isVip) + SELECT sgp.ticketFk, TRUE + FROM tmp.sale_getProblems sgp + JOIN client c ON c.id = sgp.clientFk + WHERE c.businessTypeFk = 'VIP' + ON DUPLICATE KEY UPDATE isVIP = TRUE; CREATE OR REPLACE TEMPORARY TABLE tItemShelvingStock_byWarehouse (INDEX (itemFk, warehouseFk)) diff --git a/modules/ticket/back/methods/ticket/getTicketsFuture.js b/modules/ticket/back/methods/ticket/getTicketsFuture.js index b7267995e..0fd21ea74 100644 --- a/modules/ticket/back/methods/ticket/getTicketsFuture.js +++ b/modules/ticket/back/methods/ticket/getTicketsFuture.js @@ -161,7 +161,8 @@ module.exports = Self => { stmt = new ParameterizedSQL(` SELECT f.*, tp.* FROM tmp.filter f - LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id`); + LEFT JOIN tmp.ticket_problems tp ON tp.ticketFk = f.id + `); if (args.problems != undefined && (!args.originDated && !args.futureDated)) throw new UserError('Choose a date range or days forward'); From 09a0459a7b4cbdca8690661f44e2ccf0acd2227c Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 7 Aug 2024 13:52:41 +0200 Subject: [PATCH 10/48] refs #7844 Fix tests part 2/2 --- modules/ticket/back/methods/ticket/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 1d050931b..72249fe5d 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -71,7 +71,7 @@ describe('ticket filter()', () => { const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(10); + expect(result.length).toEqual(11); await tx.rollback(); } catch (e) { From 7fc47f05060be40dbd747c6ddc1fe8ee9710d6cc Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 11:43:08 +0200 Subject: [PATCH 11/48] feat: refs #7564 Requested changes --- .../vn/procedures/ticket_setVolumeItemCost.sql | 9 +++------ db/versions/11124-greenBamboo/01-firstScript.sql | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 db/versions/11124-greenBamboo/01-firstScript.sql diff --git a/db/routines/vn/procedures/ticket_setVolumeItemCost.sql b/db/routines/vn/procedures/ticket_setVolumeItemCost.sql index c00fc63dc..f266cd769 100644 --- a/db/routines/vn/procedures/ticket_setVolumeItemCost.sql +++ b/db/routines/vn/procedures/ticket_setVolumeItemCost.sql @@ -16,17 +16,14 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk - WHERE t.id IN ( - SELECT DISTINCT ticketFk - FROM sale - WHERE itemFk = vItemFk - ) + WHERE s.itemFk = vItemFk + AND t.shipped >= util.VN_CURDATE() GROUP BY t.id; UPDATE ticket t JOIN tTicket tt ON tt.id = t.id SET t.volume = tt.volume; - + DROP TEMPORARY TABLE tTicket; END$$ DELIMITER ; diff --git a/db/versions/11124-greenBamboo/01-firstScript.sql b/db/versions/11124-greenBamboo/01-firstScript.sql new file mode 100644 index 000000000..0398e8a13 --- /dev/null +++ b/db/versions/11124-greenBamboo/01-firstScript.sql @@ -0,0 +1,16 @@ +-- Calculamos todos los volumenes de todos los tickets una sola vez +CREATE OR REPLACE TEMPORARY TABLE tTicketVolume + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN itemCost ic ON ic.itemFk = s.itemFk + AND ic.warehouseFk = t.warehouseFk + GROUP BY t.id; + +UPDATE ticket t + JOIN tTicketVolume tv ON tv.id = t.id + SET t.volume = tv.volume; + +DROP TEMPORARY TABLE tTicketVolume; From 8a03650eca59a06f412637d03a89c61f7bcce7ef Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 11:44:38 +0200 Subject: [PATCH 12/48] feat: refs #7564 Requested changes --- db/versions/11124-greenBamboo/01-firstScript.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/versions/11124-greenBamboo/01-firstScript.sql b/db/versions/11124-greenBamboo/01-firstScript.sql index 0398e8a13..ff1177455 100644 --- a/db/versions/11124-greenBamboo/01-firstScript.sql +++ b/db/versions/11124-greenBamboo/01-firstScript.sql @@ -3,13 +3,13 @@ CREATE OR REPLACE TEMPORARY TABLE tTicketVolume (PRIMARY KEY (id)) ENGINE = MEMORY SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume - FROM sale s - JOIN ticket t ON t.id = s.ticketFk - JOIN itemCost ic ON ic.itemFk = s.itemFk + FROM vn.sale s + JOIN vn.ticket t ON t.id = s.ticketFk + JOIN vn.itemCost ic ON ic.itemFk = s.itemFk AND ic.warehouseFk = t.warehouseFk GROUP BY t.id; -UPDATE ticket t +UPDATE vn.ticket t JOIN tTicketVolume tv ON tv.id = t.id SET t.volume = tv.volume; From 2b12e046e4d4b28081c2f05b4750574ad32cea88 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 11:45:50 +0200 Subject: [PATCH 13/48] feat: refs #7564 Fix version --- db/versions/11124-greenBamboo/01-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11124-greenBamboo/01-firstScript.sql b/db/versions/11124-greenBamboo/01-firstScript.sql index ff1177455..06c6918be 100644 --- a/db/versions/11124-greenBamboo/01-firstScript.sql +++ b/db/versions/11124-greenBamboo/01-firstScript.sql @@ -1,5 +1,5 @@ -- Calculamos todos los volumenes de todos los tickets una sola vez -CREATE OR REPLACE TEMPORARY TABLE tTicketVolume +CREATE OR REPLACE TEMPORARY TABLE tmp.tTicketVolume (PRIMARY KEY (id)) ENGINE = MEMORY SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume @@ -13,4 +13,4 @@ UPDATE vn.ticket t JOIN tTicketVolume tv ON tv.id = t.id SET t.volume = tv.volume; -DROP TEMPORARY TABLE tTicketVolume; +DROP TEMPORARY TABLE tmp.tTicketVolume; From c991f32f5a737069ea398270ad05e710a70ef3da Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 20 Aug 2024 12:01:28 +0200 Subject: [PATCH 14/48] feat: refs #7564 Fix version --- db/versions/11124-greenBamboo/01-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11124-greenBamboo/01-firstScript.sql b/db/versions/11124-greenBamboo/01-firstScript.sql index 06c6918be..9cacbd5ff 100644 --- a/db/versions/11124-greenBamboo/01-firstScript.sql +++ b/db/versions/11124-greenBamboo/01-firstScript.sql @@ -10,7 +10,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tTicketVolume GROUP BY t.id; UPDATE vn.ticket t - JOIN tTicketVolume tv ON tv.id = t.id + JOIN tmp.tTicketVolume tv ON tv.id = t.id SET t.volume = tv.volume; DROP TEMPORARY TABLE tmp.tTicketVolume; From 5f06ae5cf410f77f3747e50de2a8d2b9757460b3 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 26 Aug 2024 15:57:39 +0200 Subject: [PATCH 15/48] feat: refs #6760 refs #actualiza campo nickname --- .../methods/ticket/specs/transferClient.spec.js | 17 +++++++++++++---- .../back/methods/ticket/transferClient.js | 9 ++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/transferClient.spec.js b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js index 01fd8fcbe..d3ac3c6aa 100644 --- a/modules/ticket/back/methods/ticket/specs/transferClient.spec.js +++ b/modules/ticket/back/methods/ticket/specs/transferClient.spec.js @@ -8,6 +8,7 @@ describe('Ticket transferClient()', () => { const ctx = beforeAll.getCtx(); let options; let tx; + beforeEach(async() => { options = {transaction: tx}; tx = await models.Ticket.beginTransaction({}); @@ -21,21 +22,23 @@ describe('Ticket transferClient()', () => { it('should throw an error as the ticket is not editable', async() => { try { const ticketId = 4; - const clientId = 1; await models.Ticket.transferClient(ctx, ticketId, clientId, options); } catch (e) { - expect(e.message).toEqual(`This ticket is locked`); + expect(e.message).toEqual('This ticket is locked'); } }); - it('should be assigned a different clientFk in the original ticket', async() => { + it('should be assigned a different clientFk and nickname in the original ticket', async() => { await models.Ticket.transferClient(ctx, 2, clientId, options); const afterTransfer = await models.Ticket.findById(2, null, options); + const client = await models.Client.findById(clientId, {fields: ['defaultAddressFk']}, options); + const address = await models.Address.findById(client.defaultAddressFk, {fields: ['nickname']}, options); expect(afterTransfer.clientFk).toEqual(clientId); + expect(afterTransfer.nickname).toEqual(address.nickname); }); - it('should be assigned a different clientFk in the original and refund ticket and claim', async() => { + it('should be assigned a different clientFk and nickname in the original and refund ticket and claim', async() => { await models.Ticket.transferClient(ctx, originalTicketId, clientId, options); const [originalTicket, refundTicket] = await models.Ticket.find({ @@ -46,8 +49,14 @@ describe('Ticket transferClient()', () => { where: {ticketFk: originalTicketId} }, options); + const client = await models.Client.findById(clientId, {fields: ['defaultAddressFk']}, options); + const address = await models.Address.findById(client.defaultAddressFk, {fields: ['nickname']}, options); + expect(originalTicket.clientFk).toEqual(clientId); expect(refundTicket.clientFk).toEqual(clientId); expect(claim.clientFk).toEqual(clientId); + + expect(originalTicket.nickname).toEqual(address.nickname); + expect(refundTicket.nickname).toEqual(address.nickname); }); }); diff --git a/modules/ticket/back/methods/ticket/transferClient.js b/modules/ticket/back/methods/ticket/transferClient.js index d38c0e8a7..95bee008d 100644 --- a/modules/ticket/back/methods/ticket/transferClient.js +++ b/modules/ticket/back/methods/ticket/transferClient.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('transferClient', { - description: 'Transfering ticket to another client', + description: 'Transferring ticket to another client', accessType: 'WRITE', accepts: [{ arg: 'id', @@ -40,10 +40,13 @@ module.exports = Self => { include: [{relation: 'refundTicket'}, {relation: 'originalTicket'}] }, myOptions); - const {defaultAddressFk: addressFk} = await models.Client.findById(clientFk, + const client = await models.Client.findById(clientFk, {fields: ['id', 'defaultAddressFk']}, myOptions); - const attributes = {clientFk, addressFk}; + const address = await models.Address.findById(client.defaultAddressFk, + {fields: ['id', 'nickname']}, myOptions); + + const attributes = {clientFk, addressFk: client.defaultAddressFk, nickname: address.nickname}; const tickets = []; const ticketIds = []; From 83f3a057216f4a9fe863fa1d84dd2c1ffd6c8203 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 27 Aug 2024 07:24:10 +0200 Subject: [PATCH 16/48] fix: refs #7811 Tests --- back/methods/vn-user/renew-token.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index 688e9a770..f3e5c16e4 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -29,8 +29,9 @@ module.exports = Self => { return token; // Schedule to remove current token - setTimeout(() => { - Self.logout(token.id); + setTimeout(async() => { + if (await models.AccessToken.findById(token.id)) + await Self.logout(token.id); }, courtesyTime * 1000); // Get scopes From ef26d7f437ba42ced41cab64f14224f9603cb669 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 27 Aug 2024 06:05:39 +0000 Subject: [PATCH 17/48] fix(salix): #7283 ItemFixedPrice duplicated --- modules/item/back/methods/fixed-price/filter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/item/back/methods/fixed-price/filter.js b/modules/item/back/methods/fixed-price/filter.js index 9c91886c1..edc804dc4 100644 --- a/modules/item/back/methods/fixed-price/filter.js +++ b/modules/item/back/methods/fixed-price/filter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -134,7 +133,7 @@ module.exports = Self => { const stmts = []; const stmt = new ParameterizedSQL(` - SELECT fp.id, + SELECT DISTINCT fp.id, fp.itemFk, fp.warehouseFk, fp.rate2, From ce2058ec8b06356b2236de72e2feb180c453962a Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 27 Aug 2024 08:36:14 +0200 Subject: [PATCH 18/48] version --- db/versions/11200-brownDendro/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/11200-brownDendro/00-firstScript.sql diff --git a/db/versions/11200-brownDendro/00-firstScript.sql b/db/versions/11200-brownDendro/00-firstScript.sql new file mode 100644 index 000000000..943368b06 --- /dev/null +++ b/db/versions/11200-brownDendro/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +ALTER TABLE vn.saleGroup ADD stateFk TINYINT(3) UNSIGNED; + +ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_state_FK FOREIGN KEY (stateFk) REFERENCES vn.state(id) ON DELETE RESTRICT ON UPDATE CASCADE; From 2dc095e8288bc9faff7766baa3ab94104c6155ca Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 27 Aug 2024 10:07:09 +0200 Subject: [PATCH 19/48] fix: refs #7811 Renew token crash --- back/methods/vn-user/renew-token.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index f3e5c16e4..100e913ee 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -30,8 +30,11 @@ module.exports = Self => { // Schedule to remove current token setTimeout(async() => { - if (await models.AccessToken.findById(token.id)) + try { await Self.logout(token.id); + } catch (error) { + // FIXME: Crash if do throw new Error(error) + } }, courtesyTime * 1000); // Get scopes From b317c8c46223d79d898292d094f9dda7a72aa6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 10:47:09 +0200 Subject: [PATCH 20/48] fixes: refs #7760 collection problems --- .../vn/procedures/collection_assign.sql | 169 ++++----- .../vn/procedures/collection_mergeSales.sql | 30 ++ db/routines/vn/procedures/collection_new.sql | 333 ++++++++---------- db/routines/vn/procedures/sales_merge.sql | 41 --- .../vn/procedures/sales_mergeByCollection.sql | 2 +- .../vn/procedures/ticket_mergeSales.sql | 49 +++ .../ticket_splitItemPackingType.sql | 170 +++------ 7 files changed, 356 insertions(+), 438 deletions(-) create mode 100644 db/routines/vn/procedures/collection_mergeSales.sql delete mode 100644 db/routines/vn/procedures/sales_merge.sql create mode 100644 db/routines/vn/procedures/ticket_mergeSales.sql diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index f9032a91d..8e48718b5 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -13,39 +13,42 @@ BEGIN * @param vCollectionFk Id de colección */ DECLARE vHasTooMuchCollections BOOL; - DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vWarehouseFk INT; - DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; - DECLARE vErrorNumber INT; - DECLARE vErrorMsg TEXT; + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vCollectionWorker INT; + DECLARE vMaxNotAssignedCollectionLifeTime TIME; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - GET DIAGNOSTICS CONDITION 1 - vErrorNumber = MYSQL_ERRNO, - vErrorMsg = MESSAGE_TEXT; - - CALL util.debugAdd('collection_assign', JSON_OBJECT( - 'errorNumber', vErrorNumber, - 'errorMsg', vErrorMsg, - 'lockName', vLockName, - 'userFk', vUserFk - )); -- Tmp - - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - END IF; - RESIGNAL; - END; + DECLARE vCollections CURSOR FOR + WITH collections AS ( + SELECT tc.collectionFk, + SUM(sv.volume) volume, + c.saleTotalCount, + c.itemPackingTypeFk, + c.trainFk, + c.warehouseFk, + c.wagons + FROM vn.ticketCollection tc + JOIN vn.collection c ON c.id = tc.collectionFk + JOIN vn.saleVolume sv ON sv.ticketFk = tc.ticketFk + WHERE c.workerFk IS NULL + AND sv.shipped >= util.VN_CURDATE() + GROUP BY tc.collectionFk + ) SELECT c.collectionFk + FROM collections c + JOIN vn.operator o + WHERE o.workerFk = vUserFk + AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) + AND (c.itemPackingTypeFk = o.itemPackingTypeFk OR o.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; -- Si hay colecciones sin terminar, sale del proceso + CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - collection_assign_lockname - INTO vHasTooMuchCollections, - vLockName + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime + INTO vHasTooMuchCollections, vMaxNotAssignedCollectionLifeTime FROM productionConfig pc LEFT JOIN tmp.collection ON TRUE; @@ -55,69 +58,69 @@ BEGIN CALL util.throw('Hay colecciones pendientes'); END IF; - SELECT warehouseFk, itemPackingTypeFk - INTO vWarehouseFk, vItemPackingTypeFk - FROM operator - WHERE workerFk = vUserFk; - - SET vLockName = CONCAT_WS('/', - vLockName, - vWarehouseFk, - vItemPackingTypeFk - ); - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; - -- Se eliminan las colecciones sin asignar que estan obsoletas - INSERT INTO ticketTracking(stateFk, ticketFk) - SELECT s.id, tc.ticketFk - FROM `collection` c - JOIN ticketCollection tc ON tc.collectionFk = c.id - JOIN `state` s ON s.code = 'PRINTED_AUTO' - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; - DELETE c.* - FROM `collection` c - JOIN productionConfig pc - WHERE c.workerFk IS NULL - AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM `collection` c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN `state` s ON s.code = 'PRINTED_AUTO' + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > vMaxNotAssignedCollectionLifeTime; + + DELETE FROM `collection` + WHERE workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), created) > vMaxNotAssignedCollectionLifeTime; -- Se añade registro al semillero - INSERT INTO collectionHotbed(userFk) - VALUES(vUserFk); + + INSERT INTO collectionHotbed(userFk) VALUES(vUserFk); -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion - SELECT MIN(c.id) INTO vCollectionFk - FROM `collection` c - JOIN operator o - ON (o.itemPackingTypeFk = c.itemPackingTypeFk OR c.itemPackingTypeFk IS NULL) - AND o.numberOfWagons = c.wagons - AND o.trainFk = c.trainFk - AND o.warehouseFk = c.warehouseFk - AND c.workerFk IS NULL - AND (c.saleTotalCount <= o.linesLimit OR o.linesLimit IS NULL) - JOIN ( - SELECT tc.collectionFk, SUM(sv.volume) volume - FROM ticketCollection tc - JOIN saleVolume sv ON sv.ticketFk = tc.ticketFk - WHERE sv.shipped >= util.VN_CURDATE() - GROUP BY tc.collectionFk - ) sub ON sub.collectionFk = c.id - AND (volume <= o.volumeLimit OR o.volumeLimit IS NULL) - WHERE o.workerFk = vUserFk; + + OPEN vCollections; + l: LOOP + SET vDone = FALSE; + FETCH vCollections INTO vCollectionFk; + + IF vDone THEN + LEAVE l; + END IF; + + BEGIN + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + SET vCollectionFk = NULL; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + COMMIT; + LEAVE l; + END IF; + + ROLLBACK; + END; + END LOOP; + CLOSE vCollections; IF vCollectionFk IS NULL THEN CALL collection_new(vUserFk, vCollectionFk); + + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; END IF; - - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; - - DO RELEASE_LOCK(vLockName); END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_mergeSales.sql b/db/routines/vn/procedures/collection_mergeSales.sql new file mode 100644 index 000000000..270f3fa30 --- /dev/null +++ b/db/routines/vn/procedures/collection_mergeSales.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_mergeSales`(vCollectionFk INT) +BEGIN + DECLARE vDone BOOL; + -- Fetch variables + DECLARE vTicketFk INT; + + DECLARE cCur CURSOR FOR + SELECT ticketFk + FROM vn.ticketCollection + WHERE collectionFk = vCollectionFk; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + l: LOOP + SET vDone = FALSE; + + FETCH cCur INTO vTicketFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL vn.ticket_mergeSales(vTicketFk); + END LOOP; + CLOSE cCur; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index ee76f3994..b6e0d6efa 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -1,5 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_new`(vUserFk INT, OUT vCollectionFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_new`( + vUserFk INT, + OUT vCollectionFk INT +) BEGIN /** * Genera colecciones de tickets sin asignar trabajador. @@ -9,33 +12,31 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vWagons INT; DECLARE vTrainFk INT; - DECLARE vLinesLimit INT; + DECLARE vLinesLimit INT DEFAULT NULL; DECLARE vTicketLines INT; - DECLARE vVolumeLimit DECIMAL; + DECLARE vVolumeLimit DECIMAL DEFAULT NULL; DECLARE vTicketVolume DECIMAL; - DECLARE vSizeLimit INT; DECLARE vMaxTickets INT; DECLARE vStateFk VARCHAR(45); DECLARE vFirstTicketFk INT; - DECLARE vHour INT; - DECLARE vMinute INT; DECLARE vWorkerCode VARCHAR(3); - DECLARE vWagonCounter INT DEFAULT 0; + DECLARE vWagonCounter INT DEFAULT 1; DECLARE vTicketFk INT; DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vHasAssignedTickets BOOLEAN; + DECLARE vHasAssignedTickets BOOL; DECLARE vHasUniqueCollectionTime BOOL; - DECLARE vDone INT DEFAULT FALSE; - DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; + DECLARE vHeight INT; + DECLARE vVolume INT; + DECLARE vLiters INT; + DECLARE vLines INT; + DECLARE vTotalLines INT DEFAULT 0; + DECLARE vTotalVolume INT DEFAULT 0; DECLARE vFreeWagonFk INT; - DECLARE vErrorNumber INT; - DECLARE vErrorMsg TEXT; + DECLARE vDone INT DEFAULT FALSE; - DECLARE c1 CURSOR FOR + DECLARE vTickets CURSOR FOR SELECT ticketFk, `lines`, m3 FROM tmp.productionBuffer - WHERE ticketFk <> vFirstTicketFk ORDER BY HH, mm, productionOrder DESC, @@ -48,26 +49,6 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - GET DIAGNOSTICS CONDITION 1 - vErrorNumber = MYSQL_ERRNO, - vErrorMsg = MESSAGE_TEXT; - - CALL util.debugAdd('collection_new', JSON_OBJECT( - 'errorNumber', vErrorNumber, - 'errorMsg', vErrorMsg, - 'lockName', vLockName, - 'userFk', vUserFk, - 'ticketFk', vTicketFk - )); -- Tmp - - IF vLockName IS NOT NULL THEN - DO RELEASE_LOCK(vLockName); - END IF; - RESIGNAL; - END; - SELECT pc.ticketTrolleyMax * o.numberOfWagons, pc.hasUniqueCollectionTime, w.code, @@ -77,37 +58,25 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit, - o.sizeLimit, - pc.collection_new_lockname + o.volumeLimit INTO vMaxTickets, - vHasUniqueCollectionTime, - vWorkerCode, - vWarehouseFk, - vItemPackingTypeFk, - vStateFk, - vWagons, - vTrainFk, - vLinesLimit, - vVolumeLimit, - vSizeLimit, - vLockName - FROM productionConfig pc - JOIN worker w ON w.id = vUserFk + vHasUniqueCollectionTime, + vWorkerCode, + vWarehouseFk, + vItemPackingTypeFk, + vStateFk, + vWagons, + vTrainFk, + vLinesLimit, + vVolumeLimit + FROM worker w + JOIN operator o ON o.workerFk = w.id JOIN state st ON st.`code` = 'ON_PREPARATION' - JOIN operator o ON o.workerFk = vUserFk; - - SET vLockName = CONCAT_WS('/', - vLockName, - vWarehouseFk, - vItemPackingTypeFk - ); - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; + JOIN productionConfig pc + WHERE w.id = vUserFk; -- Se prepara el tren, con tantos vagones como sea necesario. + CREATE OR REPLACE TEMPORARY TABLE tTrain (wagon INT, shelve INT, @@ -118,71 +87,63 @@ BEGIN PRIMARY KEY(wagon, shelve)) ENGINE = MEMORY; - WHILE vWagons > vWagonCounter DO - SET vWagonCounter = vWagonCounter + 1; - - INSERT INTO tTrain(wagon, shelve, liters, `lines`, height) - SELECT vWagonCounter, cv.`level` , cv.liters , cv.`lines` , cv.height - FROM collectionVolumetry cv - WHERE cv.trainFk = vTrainFk + INSERT INTO tTrain (wagon, shelve, liters, `lines`, height) + WITH RECURSIVE wagonSequence AS ( + SELECT vWagonCounter wagon + UNION ALL + SELECT wagon + 1 wagon + FROM wagonSequence + WHERE wagon < vWagonCounter + vWagons -1 + ) + SELECT ws.wagon, cv.`level`, cv.liters, cv.`lines`, cv.height + FROM wagonSequence ws + JOIN vn.collectionVolumetry cv ON cv.trainFk = vTrainFk AND cv.itemPackingTypeFk = vItemPackingTypeFk; - END WHILE; -- Esto desaparecerá cuando tengamos la table cache.ticket + CALL productionControl(vWarehouseFk, 0); ALTER TABLE tmp.productionBuffer ADD COLUMN liters INT, ADD COLUMN height INT; - -- Se obtiene nº de colección. - INSERT INTO collection - SET itemPackingTypeFk = vItemPackingTypeFk, - trainFk = vTrainFk, - wagons = vWagons, - warehouseFk = vWarehouseFk; - - SELECT LAST_INSERT_ID() INTO vCollectionFk; - -- Los tickets de recogida en Algemesí sólo se sacan si están asignados. -- Los pedidos con riesgo no se sacan aunque se asignen. - DELETE pb.* + + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state WHERE (pb.agency = 'REC_ALGEMESI' AND s.code <> 'PICKER_DESIGNED') OR pb.problem LIKE '%RIESGO%'; - -- Comprobamos si hay tickets asignados. En ese caso, nos centramos - -- exclusivamente en esos tickets y los sacamos independientemente - -- de problemas o tamaños - SELECT COUNT(*) INTO vHasAssignedTickets - FROM tmp.productionBuffer pb - JOIN state s ON s.id = pb.state - WHERE s.code = 'PICKER_DESIGNED' - AND pb.workerCode = vWorkerCode; + -- Si hay tickets asignados, nos centramos exclusivamente en esos tickets + -- y los sacamos independientemente de problemas o tamaños + + SELECT EXISTS ( + SELECT TRUE + FROM tmp.productionBuffer pb + JOIN state s ON s.id = pb.state + WHERE s.code = 'PICKER_DESIGNED' + AND pb.workerCode = vWorkerCode + LIMIT 1 + ) INTO vHasAssignedTickets; -- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados + IF vHasAssignedTickets THEN - DELETE pb.* + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state WHERE s.code <> 'PICKER_DESIGNED' OR pb.workerCode <> vWorkerCode; ELSE - DELETE pb.* + DELETE pb FROM tmp.productionBuffer pb JOIN state s ON s.id = pb.state JOIN agencyMode am ON am.id = pb.agencyModeFk JOIN agency a ON a.id = am.agencyFk - LEFT JOIN ( - SELECT pb.ticketFk, MAX(i.`size`) maxSize - FROM tmp.productionBuffer pb - JOIN ticket t ON t.id = pb.ticketfk - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - GROUP BY pb.ticketFk - ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() OR (pb.ubicacion IS NULL AND a.isOwn) @@ -194,71 +155,63 @@ BEGIN OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) OR LENGTH(pb.problem) > 0 - OR (pb.lines > vLinesLimit AND vLinesLimit IS NOT NULL) - OR (pb.m3 > vVolumeLimit AND vVolumeLimit IS NOT NULL) - OR ((sub.maxSize > vSizeLimit OR sub.maxSize IS NOT NULL) AND vSizeLimit IS NOT NULL); + OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL) + OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL); END IF; - -- Es importante que el primer ticket se coja en todos los casos - SELECT ticketFk, - HH, - mm, - `lines`, - m3 - INTO vFirstTicketFk, - vHour, - vMinute, - vTicketLines, - vTicketVolume - FROM tmp.productionBuffer - ORDER BY HH, - mm, - productionOrder DESC, - m3 DESC, - agency, - zona, - routeFk, - ticketFk - LIMIT 1; - -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede IF vHasUniqueCollectionTime THEN - DELETE FROM tmp.productionBuffer - WHERE HH <> vHour - OR mm <> vMinute; + + SELECT ticketFk INTO vFirstTicketFk + FROM tmp.productionBuffer + ORDER BY HH, + mm, + productionOrder DESC, + m3 DESC, + agency, + zona, + routeFk, + ticketFk + LIMIT 1; + + DELETE pb + FROM tmp.productionBuffer pb + JOIN tmp.productionBuffer pb2 ON pb2.ticketFk = vFirstTicketFk + AND (pb.HH <> pb2.HH OR pb.mm <> pb2.mm); + END IF; - SET vTicketFk = vFirstTicketFk; - SET @lines = 0; - SET @volume = 0; - - OPEN c1; - read_loop: LOOP + OPEN vTickets; + l: LOOP SET vDone = FALSE; + FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume; + + IF vDone THEN + LEAVE l; + END IF; -- Buscamos un ticket que cumpla con los requisitos en el listado - IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL) - AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) THEN + + IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit) + AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN CALL ticket_splitItemPackingType(vTicketFk, vItemPackingTypeFk); DROP TEMPORARY TABLE tmp.ticketIPT; + SELECT COUNT(*), SUM(litros), MAX(i.`size`), SUM(sv.volume) + INTO vLines, vLiters, vHeight, vVolume + FROM saleVolume sv + JOIN sale s ON s.id = sv.saleFk + JOIN item i ON i.id = s.itemFk + WHERE sv.ticketFk = vTicketFk; + + SET vTotalVolume = vTotalVolume + vVolume, + vTotalLines = vTotalLines + vLines; + UPDATE tmp.productionBuffer pb - JOIN ( - SELECT SUM(litros) liters, - @lines:= COUNT(*) + @lines, - COUNT(*) `lines`, - MAX(i.`size`) height, - @volume := SUM(sv.volume) + @volume, - SUM(sv.volume) volume - FROM saleVolume sv - JOIN sale s ON s.id = sv.saleFk - JOIN item i ON i.id = s.itemFk - WHERE sv.ticketFk = vTicketFk - ) sub - SET pb.liters = sub.liters, - pb.`lines` = sub.`lines`, - pb.height = sub.height + SET pb.liters = vLiters, + pb.`lines` = vLines, + pb.height = vHeight WHERE pb.ticketFk = vTicketFk; UPDATE tTrain tt @@ -275,17 +228,13 @@ BEGIN tt.height LIMIT 1; - -- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre + -- Si no le encuentra una balda, intentamos darle un carro entero libre + IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - SELECT tt.wagon - INTO vFreeWagonFk - FROM tTrain tt - LEFT JOIN ( - SELECT DISTINCT wagon - FROM tTrain - WHERE ticketFk IS NOT NULL - ) nn ON nn.wagon = tt.wagon - WHERE nn.wagon IS NULL + SELECT wagon INTO vFreeWagonFk + FROM tTrain + GROUP BY wagon + HAVING SUM(IFNULL(ticketFk, 0)) = 0 ORDER BY wagon LIMIT 1; @@ -294,38 +243,35 @@ BEGIN SET ticketFk = vFirstTicketFk WHERE wagon = vFreeWagonFk; - -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo - DELETE tt.* - FROM tTrain tt - LEFT JOIN ( - SELECT DISTINCT wagon - FROM tTrain - WHERE ticketFk IS NOT NULL - ) nn ON nn.wagon = tt.wagon - WHERE nn.wagon IS NULL; - END IF; - END IF; + -- Se anulan el resto de carros libres, + -- máximo un carro con pedido excesivo - FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; - IF vDone OR NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk IS NULL) THEN - LEAVE read_loop; - END IF; - ELSE - FETCH c1 INTO vTicketFk, vTicketLines, vTicketVolume; - IF vDone THEN - LEAVE read_loop; - END IF; + DELETE tt + FROM tTrain tt + JOIN (SELECT wagon + FROM tTrain + GROUP BY wagon + HAVING SUM(IFNULL(ticketFk, 0)) = 0 + ) sub ON sub.wagon = tt.wagon; + END IF; + END IF; END IF; END LOOP; - CLOSE c1; + CLOSE vTickets; IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - UPDATE collection c - JOIN state st ON st.code = 'ON_PREPARATION' - SET c.stateFk = st.id - WHERE c.id = vCollectionFk; + -- Se obtiene nº de colección + + INSERT INTO collection + SET itemPackingTypeFk = vItemPackingTypeFk, + trainFk = vTrainFk, + wagons = vWagons, + warehouseFk = vWarehouseFk; + + SELECT LAST_INSERT_ID() INTO vCollectionFk; -- Asigna las bandejas + INSERT IGNORE INTO ticketCollection(ticketFk, collectionFk, `level`, wagon, liters) SELECT tt.ticketFk, vCollectionFk, tt.shelve, tt.wagon, tt.liters FROM tTrain tt @@ -333,37 +279,34 @@ BEGIN ORDER BY tt.wagon, tt.shelve; -- Actualiza el estado de los tickets + CALL collection_setState(vCollectionFk, vStateFk); -- Aviso para la preparacion previa + INSERT INTO ticketDown(ticketFk, collectionFk) SELECT tc.ticketFk, tc.collectionFk FROM ticketCollection tc WHERE tc.collectionFk = vCollectionFk; - CALL sales_mergeByCollection(vCollectionFk); + CALL collection_mergeSales(vCollectionFk); UPDATE `collection` c - JOIN ( + JOIN( SELECT COUNT(*) saleTotalCount, SUM(s.isPicked <> 0) salePickedCount FROM ticketCollection tc JOIN sale s ON s.ticketFk = tc.ticketFk - WHERE tc.collectionFk = vCollectionFk - AND s.quantity > 0 - ) sub + WHERE tc.collectionFk = vCollectionFk + AND s.quantity > 0 + )sub SET c.saleTotalCount = sub.saleTotalCount, c.salePickedCount = sub.salePickedCount WHERE c.id = vCollectionFk; - ELSE - DELETE FROM `collection` - WHERE id = vCollectionFk; - SET vCollectionFk = NULL; + SET vCollectionFk = NULL; END IF; - DO RELEASE_LOCK(vLockName); - DROP TEMPORARY TABLE tTrain, tmp.productionBuffer; diff --git a/db/routines/vn/procedures/sales_merge.sql b/db/routines/vn/procedures/sales_merge.sql deleted file mode 100644 index 3dd01f9bc..000000000 --- a/db/routines/vn/procedures/sales_merge.sql +++ /dev/null @@ -1,41 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sales_merge`(vTicketFk INT) -BEGIN - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - ROLLBACK; - RESIGNAL; - END; - - CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity - FROM sale s - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE s.ticketFk = vTicketFk - AND it.isMergeable - GROUP BY s.itemFk, s.price, s.discount; - - START TRANSACTION; - - UPDATE sale s - JOIN tSalesToPreserve stp ON stp.id = s.id - SET s.quantity = newQuantity - WHERE s.ticketFk = vTicketFk; - - DELETE s.* - FROM sale s - LEFT JOIN tSalesToPreserve stp ON stp.id = s.id - JOIN item i ON i.id = s.itemFk - JOIN itemType it ON it.id = i.typeFk - WHERE s.ticketFk = vTicketFk - AND stp.id IS NULL - AND it.isMergeable; - - COMMIT; - - DROP TEMPORARY TABLE tSalesToPreserve; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/sales_mergeByCollection.sql b/db/routines/vn/procedures/sales_mergeByCollection.sql index 4c0693753..6a8d11d8f 100644 --- a/db/routines/vn/procedures/sales_mergeByCollection.sql +++ b/db/routines/vn/procedures/sales_mergeByCollection.sql @@ -26,7 +26,7 @@ BEGIN LEAVE myLoop; END IF; - CALL vn.sales_merge(vTicketFk); + CALL vn.ticket_mergeSales(vTicketFk); END LOOP; diff --git a/db/routines/vn/procedures/ticket_mergeSales.sql b/db/routines/vn/procedures/ticket_mergeSales.sql new file mode 100644 index 000000000..2dc3a39da --- /dev/null +++ b/db/routines/vn/procedures/ticket_mergeSales.sql @@ -0,0 +1,49 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_mergeSales`( + vSelf INT +) +BEGIN + DECLARE vHasSalesToMerge BOOL; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT id INTO vSelf + FROM ticket + WHERE id = vSelf FOR UPDATE; + + CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve + (PRIMARY KEY (id)) + ENGINE = MEMORY + SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + WHERE s.ticketFk = vSelf + AND it.isMergeable + GROUP BY s.itemFk, s.price, s.discount + HAVING COUNT(*) > 1; + + SELECT COUNT(*) INTO vHasSalesToMerge + FROM tSalesToPreserve; + + IF vHasSalesToMerge THEN + UPDATE sale s + JOIN tSalesToPreserve stp ON stp.id = s.id + SET s.quantity = newQuantity; + + DELETE s + FROM sale s + JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk + WHERE s.ticketFk = vSelf + AND s.id <> stp.id; + END IF; + + COMMIT; + DROP TEMPORARY TABLE tSalesToPreserve; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 5ae9fb9bc..2a41369c9 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -5,139 +5,73 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_splitItemPac ) BEGIN /** - * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id inicial para el tipo propuesto. + * Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id de ticket inicial para el tipo de empaquetado propuesto. * * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original - * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) + * @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original */ - DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; - DECLARE vNewTicketFk INT; - DECLARE vPackingTypesToSplit INT; DECLARE vDone INT DEFAULT FALSE; - DECLARE vErrorNumber INT; - DECLARE vErrorMsg TEXT; + DECLARE vHasItemPackingType BOOL; + DECLARE vItemPackingTypeFk INT; + DECLARE vNewTicketFk INT; - DECLARE vSaleGroup CURSOR FOR - SELECT itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; + DECLARE vItemPackingTypes CURSOR FOR + SELECT DISTINCT itemPackingTypeFk + FROM tmp.salesToMove; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - GET DIAGNOSTICS CONDITION 1 - vErrorNumber = MYSQL_ERRNO, - vErrorMsg = MESSAGE_TEXT; + SELECT COUNT(*) INTO vHasItemPackingType + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.id = vSelf + AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; - CALL util.debugAdd('ticket_splitItemPackingType', JSON_OBJECT( - 'errorNumber', vErrorNumber, - 'errorMsg', vErrorMsg, - 'ticketFk', vSelf - )); -- Tmp - ROLLBACK; - RESIGNAL; - END; + IF NOT vHasItemPackingType THEN + CALL util.throw('The ticket has not sales with the itemPackingType'); + END IF; - START TRANSACTION; - - SELECT id - FROM sale - WHERE ticketFk = vSelf - AND NOT quantity - FOR UPDATE; - - DELETE FROM sale - WHERE NOT quantity - AND ticketFk = vSelf; - - CREATE OR REPLACE TEMPORARY TABLE tSale - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros - FROM sale s - JOIN item i ON i.id = s.itemFk - LEFT JOIN saleVolume sv ON sv.saleFk = s.id - WHERE s.ticketFk = vSelf; - - CREATE OR REPLACE TEMPORARY TABLE tSaleGroup - ENGINE = MEMORY - SELECT itemPackingTypeFk, SUM(litros) totalLitros - FROM tSale - GROUP BY itemPackingTypeFk; - - SELECT COUNT(*) INTO vPackingTypesToSplit - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; - - CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( + CREATE OR REPLACE TEMPORARY TABLE tmp.salesToMove ( ticketFk INT, - itemPackingTypeFk VARCHAR(1) - ) ENGINE = MEMORY; + saleFk INT, + itemPackingTypeFk INT + ) ENGINE=MEMORY; - CASE vPackingTypesToSplit - WHEN 0 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); - WHEN 1 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - SELECT vSelf, itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; - ELSE - OPEN vSaleGroup; - FETCH vSaleGroup INTO vItemPackingTypeFk; + INSERT INTO tmp.salesToMove (saleFk, itemPackingTypeFk) + SELECT s.id, i.itemPackingTypeFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + WHERE t.id = vSelf + AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); + OPEN vItemPackingTypes; - l: LOOP - SET vDone = FALSE; - FETCH vSaleGroup INTO vItemPackingTypeFk; + l: LOOP + SET vDone = FALSE; + FETCH vItemPackingTypes INTO vitemPackingTypeFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL ticket_Clone(vSelf, vNewTicketFk); + + UPDATE tmp.salesToMove + SET ticketFk = vNewTicketFk + WHERE itemPackingTypeFk = vItemPackingTypeFk; + + END LOOP; - IF vDone THEN - LEAVE l; - END IF; + CLOSE vItemPackingTypes; - CALL ticket_Clone(vSelf, vNewTicketFk); + UPDATE sale s + JOIN tmp.salesToMove stm ON stm.saleFk = s.id + SET s.ticketFk = stm.ticketFk + WHERE stm.ticketFk; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vNewTicketFk, vItemPackingTypeFk); - END LOOP; - - CLOSE vSaleGroup; - - SELECT s.id - FROM sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - FOR UPDATE; - - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - SET s.ticketFk = t.ticketFk; - - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tSaleGroup sg - WHERE sg.itemPackingTypeFk IS NOT NULL - ORDER BY sg.itemPackingTypeFk - LIMIT 1; - - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk - SET s.ticketFk = t.ticketFk - WHERE ts.itemPackingTypeFk IS NULL; - END CASE; - - COMMIT; - - DROP TEMPORARY TABLE - tSale, - tSaleGroup; + DROP TEMPORARY TABLE tmp.salesToMove; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file From a4cc36eed1dae8e18835b82259d3db63575bc5d5 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 27 Aug 2024 11:41:34 +0200 Subject: [PATCH 21/48] version --- db/versions/11201-limeChrysanthemum/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/11201-limeChrysanthemum/00-firstScript.sql diff --git a/db/versions/11201-limeChrysanthemum/00-firstScript.sql b/db/versions/11201-limeChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..943368b06 --- /dev/null +++ b/db/versions/11201-limeChrysanthemum/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +ALTER TABLE vn.saleGroup ADD stateFk TINYINT(3) UNSIGNED; + +ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_state_FK FOREIGN KEY (stateFk) REFERENCES vn.state(id) ON DELETE RESTRICT ON UPDATE CASCADE; From 3ac2c18da50abfba17939d5b017e181be6b67b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 13:31:07 +0200 Subject: [PATCH 22/48] fixes: refs #7760 collection problems --- .../vn/procedures/collection_mergeSales.sql | 13 ++++++------- db/routines/vn/procedures/collection_new.sql | 16 ++++++++++------ .../procedures/ticket_splitItemPackingType.sql | 10 +++++----- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/db/routines/vn/procedures/collection_mergeSales.sql b/db/routines/vn/procedures/collection_mergeSales.sql index 270f3fa30..26444d6f9 100644 --- a/db/routines/vn/procedures/collection_mergeSales.sql +++ b/db/routines/vn/procedures/collection_mergeSales.sql @@ -2,29 +2,28 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_mergeSales`(vCollectionFk INT) BEGIN DECLARE vDone BOOL; - -- Fetch variables DECLARE vTicketFk INT; - DECLARE cCur CURSOR FOR + DECLARE vTickets CURSOR FOR SELECT ticketFk - FROM vn.ticketCollection + FROM ticketCollection WHERE collectionFk = vCollectionFk; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cCur; + OPEN vTickets; l: LOOP SET vDone = FALSE; - FETCH cCur INTO vTicketFk; + FETCH vTickets INTO vTicketFk; IF vDone THEN LEAVE l; END IF; - CALL vn.ticket_mergeSales(vTicketFk); + CALL ticket_mergeSales(vTicketFk); END LOOP; - CLOSE cCur; + CLOSE vTickets; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index b6e0d6efa..250d9a03d 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -12,9 +12,10 @@ BEGIN DECLARE vWarehouseFk INT; DECLARE vWagons INT; DECLARE vTrainFk INT; - DECLARE vLinesLimit INT DEFAULT NULL; + DECLARE vLinesLimit INT; DECLARE vTicketLines INT; - DECLARE vVolumeLimit DECIMAL DEFAULT NULL; + DECLARE vVolumeLimit DECIMAL; + DECLARE vSizeLimit INT; DECLARE vTicketVolume DECIMAL; DECLARE vMaxTickets INT; DECLARE vStateFk VARCHAR(45); @@ -58,7 +59,8 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit + o.volumeLimit, + o.sizeLimit INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, @@ -68,7 +70,8 @@ BEGIN vWagons, vTrainFk, vLinesLimit, - vVolumeLimit + vVolumeLimit, + vSizeLimit FROM worker w JOIN operator o ON o.workerFk = w.id JOIN state st ON st.`code` = 'ON_PREPARATION' @@ -155,8 +158,9 @@ BEGIN OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) OR LENGTH(pb.problem) > 0 - OR (pb.lines >= vLinesLimit AND vLinesLimit IS NOT NULL) - OR (pb.m3 >= vVolumeLimit AND vVolumeLimit IS NOT NULL); + OR pb.lines > COALESCE(vLinesLimit, pb.lines) + OR pb.m3 > COALESCE(vVolumeLimit, pb.m3) + OR sub.maxSize > vSizeLimit; END IF; -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 2a41369c9..d2e4290d8 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -51,18 +51,18 @@ BEGIN l: LOOP SET vDone = FALSE; - FETCH vItemPackingTypes INTO vitemPackingTypeFk; - + FETCH vItemPackingTypes INTO vItemPackingTypeFk; + IF vDone THEN LEAVE l; END IF; - + CALL ticket_Clone(vSelf, vNewTicketFk); - + UPDATE tmp.salesToMove SET ticketFk = vNewTicketFk WHERE itemPackingTypeFk = vItemPackingTypeFk; - + END LOOP; CLOSE vItemPackingTypes; From 44072de9289c0978dc8f8c3ecccb5836503cabf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 13:36:06 +0200 Subject: [PATCH 23/48] fixes: refs #7760 collection problems --- db/routines/vn/procedures/collection_new.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 250d9a03d..8de8eaf8c 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -18,7 +18,7 @@ BEGIN DECLARE vSizeLimit INT; DECLARE vTicketVolume DECIMAL; DECLARE vMaxTickets INT; - DECLARE vStateFk VARCHAR(45); + DECLARE vStateCode VARCHAR(45); DECLARE vFirstTicketFk INT; DECLARE vWorkerCode VARCHAR(3); DECLARE vWagonCounter INT DEFAULT 1; @@ -66,7 +66,7 @@ BEGIN vWorkerCode, vWarehouseFk, vItemPackingTypeFk, - vStateFk, + vStateCode, vWagons, vTrainFk, vLinesLimit, @@ -284,7 +284,7 @@ BEGIN -- Actualiza el estado de los tickets - CALL collection_setState(vCollectionFk, vStateFk); + CALL collection_setState(vCollectionFk, vStateCode); -- Aviso para la preparacion previa From 58f8903b531a401a421a965fc3b5642bf1aa2f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 13:43:20 +0200 Subject: [PATCH 24/48] fixes: refs #7760 collection problems --- db/routines/vn/procedures/collection_new.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 8de8eaf8c..b8470cb75 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -158,8 +158,8 @@ BEGIN OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) OR LENGTH(pb.problem) > 0 - OR pb.lines > COALESCE(vLinesLimit, pb.lines) - OR pb.m3 > COALESCE(vVolumeLimit, pb.m3) + OR pb.lines > vLinesLimit + OR pb.m3 > vVolumeLimit OR sub.maxSize > vSizeLimit; END IF; From 6090e8ceeea2cac05a0d76fbc89e57d2e5f31cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 13:47:47 +0200 Subject: [PATCH 25/48] fixes: refs #7760 collection problems --- db/routines/vn/procedures/collection_new.sql | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index b8470cb75..d0b358b75 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -147,6 +147,14 @@ BEGIN JOIN state s ON s.id = pb.state JOIN agencyMode am ON am.id = pb.agencyModeFk JOIN agency a ON a.id = am.agencyFk + LEFT JOIN ( + SELECT pb.ticketFk, MAX(i.`size`) maxSize + FROM tmp.productionBuffer pb + JOIN ticket t ON t.id = pb.ticketfk + JOIN sale s ON s.ticketFk = t.id + JOIN item i ON i.id = s.itemFk + GROUP BY pb.ticketFk + ) sub ON sub.ticketFk = pb.ticketFk JOIN productionConfig pc WHERE pb.shipped <> util.VN_CURDATE() OR (pb.ubicacion IS NULL AND a.isOwn) From db2215e3fa224142011a8c60cf953d5454f4ccc8 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 27 Aug 2024 13:53:27 +0200 Subject: [PATCH 26/48] feat(salix): refs #7896 update version and changelog --- CHANGELOG.md | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6db79a40a..1e75b6986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,108 @@ +# Version 24.36 - 2024-08-27 + +### Added 🆕 + +- chore: refs #7524 WIP limit call by:jorgep +- feat(update-user): refs #7848 add twoFactor by:alexm +- feat: #3199 Requested changes by:guillermo +- feat: refs #3199 Added more scopes ticket_recalcByScope by:guillermo +- feat: refs #3199 Added one more scope ticket_recalcByScope by:guillermo +- feat: refs #3199 Created ticket_recalcItemTaxCountryByScope by:guillermo +- feat: refs #3199 Requested changes by:guillermo +- feat: refs #7346 add multiple feature by:jgallego +- feat: refs #7346 backTest checks new implementation by:jgallego +- feat: refs #7346 mas intuitivo by:jgallego +- feat: refs #7514 Changes to put srt log (origin/7514-srtLog) by:guillermo +- feat: refs #7524 add default limit (origin/7524-limitSelect) by:jorgep +- feat: refs #7524 add mock limit on find query by:jorgep +- feat: refs #7524 wip remote hooks by:jorgep +- feat: refs #7567 Changed time to call event by:guillermo +- feat: refs #7567 Requested changes by:guillermo +- feat: refs #7710 pr revision by:jgallego +- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego +- feat: refs #7712 Fix by:guillermo +- feat: refs #7712 Unify by:guillermo +- feat: refs #7712 sizeLimit (origin/7712-sizeLimit) by:guillermo +- feat: refs #7758 Add code mandateType and accountDetailType by:ivanm +- feat: refs #7758 Modify code lowerCamelCase and UNIQUE by:ivanm +- feat: refs #7758 accountDetailType fix deploy error by:ivanm +- feat: refs #7784 Changes in entry-order-pdf by:guillermo +- feat: refs #7784 Requested changes by:guillermo +- feat: refs #7799 Added Fk in vn.item.itemPackingTypeFk by:guillermo +- feat: refs #7800 Added company Fk by:guillermo +- feat: refs #7842 Added editorFk in vn.host by:guillermo +- feat: refs #7862 roadmap new fields by:ivanm +- feat: refs #7882 Added quadMindsConfig table by:guillermo + +### Changed 📦 + +- refactor: refs #7567 Fix and improvement by:guillermo +- refactor: refs #7567 Minor change by:guillermo +- refactor: refs #7756 Fix tests by:guillermo +- refactor: refs #7798 Drop bi.Greuges_comercial_detail by:guillermo +- refactor: refs #7848 adapt to lilium by:alexm + +### Fixed 🛠️ + +- feat: refs #7710 test fixed (origin/7710-cloneWithTicketPackaging, 7710-cloneWithTicketPackaging) by:jgallego +- feat: refs #7758 accountDetailType fix deploy error by:ivanm +- fix(salix): #7283 ItemFixedPrice duplicated (origin/7283_itemFixedPrice_duplicated) by:Javier Segarra +- fix: refs #7346 minor error (origin/7346, 7346) by:jgallego +- fix: refs #7355 remove and tests accounts (origin/7355-accountMigration2) by:carlossa +- fix: refs #7355 remove and tests accounts by:carlossa +- fix: refs #7524 default limit select by:jorgep +- fix: refs #7756 Foreign keys invoiceOut (origin/7756-fixRefFk) by:guillermo +- fix: refs #7756 id 0 by:guillermo +- fix: refs #7800 tpvMerchantEnable PRIMARY KEY (origin/7800-tpvMerchantEnable) by:guillermo +- fix: refs #7800 tpvMerchantEnable PRIMARY KEY by:guillermo + +# Version 24.34 - 2024-08-20 + +### Added 🆕 + +- #6900 feat: clear empty by:jorgep +- #6900 feat: empty commit by:jorgep +- chore: refs #6900 beautify code by:jorgep +- chore: refs #6989 add config model by:jorgep +- feat workerActivity refs #6078 by:sergiodt +- feat: #6453 Refactor (origin/6453-orderConfirm) by:guillermo +- feat: #6453 Rollback always split by itemPackingType by:guillermo +- feat: deleted worker module code & redirect to Lilium by:Jon +- feat: refs #6453 Added new ticket search by:guillermo +- feat: refs #6453 Fixes by:guillermo +- feat: refs #6453 Minor changes by:guillermo +- feat: refs #6453 Requested changes by:guillermo +- feat: refs #6900 drop section by:jorgep +- feat: refs #7283 order by desc date by:jorgep +- feat: refs #7323 add locale by:jorgep +- feat: refs #7323 redirect to lilium by:jorgep +- feat: refs #7646 delete scannableCodeType by:robert +- feat: refs #7713 Created ACLLog by:guillermo +- feat: refs #7774 (origin/7774-ticket_cloneWeekly) by:robert +- feat: refs #7774 #7774 Changes ticket_cloneWeekly by:guillermo +- feat: refs #7774 ticket_cloneWeekly by:robert + +### Changed 📦 + +- refactor: refs #6453 Major changes by:guillermo +- refactor: refs #6453 Minor changes by:guillermo +- refactor: refs #6453 order_confirmWithUser by:guillermo +- refactor: refs #7646 #7646 Deleted scannable* variables productionConfig by:guillermo +- refactor: refs #7820 Deprecated silexACL by:guillermo + +### Fixed 🛠️ + +- #6900 fix: #6900 rectificative filter by:jorgep +- #6900 fix: empty commit by:jorgep +- fix(orders_filter): add sourceApp accepts by:alexm +- fix: refs #6130 commit lint by:pablone +- fix: refs #6453 order_confirmWithUser by:guillermo +- fix: refs #7283 sql by:jorgep +- fix: refs #7713 ACL Log by:guillermo +- test: fix claim descriptor redirect to lilium by:alexm +- test: fix ticket redirect to lilium by:alexm +- test: fix ticket sale e2e by:alexm + # Version 24.32 - 2024-08-06 ### Added 🆕 diff --git a/package.json b/package.json index 61a9cf46c..bbb83c4b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.34.0", + "version": "24.36.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From b833fd50818d033e7eb8c09fc34a1be5cf1e2306 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 27 Aug 2024 14:45:11 +0200 Subject: [PATCH 27/48] chore: refs #7524 modify ormConfig table col --- db/versions/11204-navyMonstera/00-firstScript.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/versions/11204-navyMonstera/00-firstScript.sql diff --git a/db/versions/11204-navyMonstera/00-firstScript.sql b/db/versions/11204-navyMonstera/00-firstScript.sql new file mode 100644 index 000000000..492e3d607 --- /dev/null +++ b/db/versions/11204-navyMonstera/00-firstScript.sql @@ -0,0 +1,5 @@ +ALTER TABLE vn.ormConfig +MODIFY COLUMN id INT NOT NULL, +DROP PRIMARY KEY, +ADD CONSTRAINT ormConfig_check CHECK (id = 1), +ADD PRIMARY KEY (id); \ No newline at end of file From 9a2351b958967a3ac4d5345eea8b27c61fa31ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 17:12:41 +0200 Subject: [PATCH 28/48] Hotfix: refs #7213 ticket_isTooLittle group by addressFk --- .../vn/functions/ticket_isTooLittle.sql | 20 +++++++++++++------ .../procedures/ticket_setProblemTooLittle.sql | 13 +++++++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/db/routines/vn/functions/ticket_isTooLittle.sql b/db/routines/vn/functions/ticket_isTooLittle.sql index bcbf09035..9874f00d4 100644 --- a/db/routines/vn/functions/ticket_isTooLittle.sql +++ b/db/routines/vn/functions/ticket_isTooLittle.sql @@ -12,13 +12,21 @@ BEGIN * @return BOOL */ DECLARE vIsTooLittle TINYINT(1); - + + WITH tickets AS ( + SELECT addressFk, DATE(shipped) dated + FROM vn.ticket + WHERE id = vSelf + ) SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume - AND IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle - FROM ticket t - LEFT JOIN saleVolume sv ON sv.ticketFk = t.id - JOIN volumeConfig vc - WHERE t.id = vSelf; + AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle + FROM vn.ticket t + JOIN tickets ts ON ts.addressFk = t.addressFk + JOIN vn.volumeConfig vc + LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id + WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated) + AND sv.litros > 0 + AND t.totalWithoutVat > 0; RETURN vIsTooLittle; END$$ diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql index 48cc47809..3d972a998 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql @@ -12,13 +12,20 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.ticket (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY + WITH tickets AS ( + SELECT addressFk, DATE(shipped) dated + FROM vn.ticket + WHERE id = vSelf + ) SELECT vSelf ticketFk, - ticket_isTooLittle(vSelf) hasProblem, - ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded; + ticket_isTooLittle(vSelf) hasProblem, + ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded + FROM vn.ticket t + JOIN tickets ts ON ts.addressFk = t.addressFk + WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated); CALL ticket_setProblem('isTooLittle'); DROP TEMPORARY TABLE tmp.ticket; - END$$ DELIMITER ; \ No newline at end of file From 1ec9e5bf0969b0ca4e541b4fa6a5399fc467eaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 17:39:54 +0200 Subject: [PATCH 29/48] Hotfix: refs #7213 ticket_isTooLittle group by addressFk --- db/routines/vn/functions/ticket_isTooLittle.sql | 9 ++++----- db/routines/vn/procedures/ticket_setProblemTooLittle.sql | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/functions/ticket_isTooLittle.sql b/db/routines/vn/functions/ticket_isTooLittle.sql index 9874f00d4..dee1df29b 100644 --- a/db/routines/vn/functions/ticket_isTooLittle.sql +++ b/db/routines/vn/functions/ticket_isTooLittle.sql @@ -20,13 +20,12 @@ BEGIN ) SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle - FROM vn.ticket t - JOIN tickets ts ON ts.addressFk = t.addressFk - JOIN vn.volumeConfig vc + FROM tickets ts + JOIN vn.ticket t ON t.addressFk = ts.addressFk LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id + JOIN vn.volumeConfig vc WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated) - AND sv.litros > 0 - AND t.totalWithoutVat > 0; + AND ticket_isProblemCalcNeeded(t.id); RETURN vIsTooLittle; END$$ diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql index 3d972a998..fe2d3306d 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql @@ -17,9 +17,9 @@ BEGIN FROM vn.ticket WHERE id = vSelf ) - SELECT vSelf ticketFk, - ticket_isTooLittle(vSelf) hasProblem, - ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded + SELECT t.id ticketFk, + ticket_isTooLittle(t.id) hasProblem, + ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM vn.ticket t JOIN tickets ts ON ts.addressFk = t.addressFk WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated); From 16fd69904ba952b5c4f194f83b04f14a0d9a8fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 27 Aug 2024 18:36:07 +0200 Subject: [PATCH 30/48] fixes: refs #7760 collection problems --- db/routines/vn/procedures/collection_new.sql | 2 +- .../vn/procedures/sales_mergeByCollection.sql | 2 +- .../vn/procedures/ticket_splitItemPackingType.sql | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index d0b358b75..80c5e6172 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -165,7 +165,7 @@ BEGIN OR (NOT pb.H AND pb.V > 0 AND vItemPackingTypeFk = 'H') OR (NOT pb.V AND vItemPackingTypeFk = 'V') OR (pc.isPreviousPreparationRequired AND pb.previousWithoutParking) - OR LENGTH(pb.problem) > 0 + OR LENGTH(pb.problem) OR pb.lines > vLinesLimit OR pb.m3 > vVolumeLimit OR sub.maxSize > vSizeLimit; diff --git a/db/routines/vn/procedures/sales_mergeByCollection.sql b/db/routines/vn/procedures/sales_mergeByCollection.sql index 6a8d11d8f..04f8b5bc7 100644 --- a/db/routines/vn/procedures/sales_mergeByCollection.sql +++ b/db/routines/vn/procedures/sales_mergeByCollection.sql @@ -26,7 +26,7 @@ BEGIN LEAVE myLoop; END IF; - CALL vn.ticket_mergeSales(vTicketFk); + CALL ticket_mergeSales(vTicketFk); END LOOP; diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index d2e4290d8..86e621706 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -18,7 +18,7 @@ BEGIN DECLARE vItemPackingTypes CURSOR FOR SELECT DISTINCT itemPackingTypeFk - FROM tmp.salesToMove; + FROM tSalesToMove; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -33,13 +33,13 @@ BEGIN CALL util.throw('The ticket has not sales with the itemPackingType'); END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.salesToMove ( + CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( ticketFk INT, saleFk INT, itemPackingTypeFk INT ) ENGINE=MEMORY; - INSERT INTO tmp.salesToMove (saleFk, itemPackingTypeFk) + INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) SELECT s.id, i.itemPackingTypeFk FROM ticket t JOIN sale s ON s.ticketFk = t.id @@ -59,7 +59,7 @@ BEGIN CALL ticket_Clone(vSelf, vNewTicketFk); - UPDATE tmp.salesToMove + UPDATE tSalesToMove SET ticketFk = vNewTicketFk WHERE itemPackingTypeFk = vItemPackingTypeFk; @@ -68,10 +68,10 @@ BEGIN CLOSE vItemPackingTypes; UPDATE sale s - JOIN tmp.salesToMove stm ON stm.saleFk = s.id + JOIN tSalesToMove stm ON stm.saleFk = s.id SET s.ticketFk = stm.ticketFk WHERE stm.ticketFk; - DROP TEMPORARY TABLE tmp.salesToMove; + DROP TEMPORARY TABLE tSalesToMove; END$$ DELIMITER ; \ No newline at end of file From 97b839bf1a029a11f1dbe3275f8d09f8f5f2da61 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Aug 2024 08:10:32 +0200 Subject: [PATCH 31/48] fix: refs #6727 No delete log tables data in clean procedures --- db/routines/vn/procedures/clean.sql | 6 ------ 1 file changed, 6 deletions(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index f479d5b3e..9a90b4e85 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -19,14 +19,12 @@ BEGIN DELETE FROM workerActivity WHERE created < v2Years; DELETE FROM ticketParking WHERE created < v2Months; DELETE FROM routesMonitor WHERE dated < v2Months; - DELETE FROM workerTimeControlLog WHERE created < v2Months; DELETE FROM `message` WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; DELETE FROM ticketDown WHERE created < util.yesterday(); - DELETE FROM entryLog WHERE creationDate < v2Months; DELETE IGNORE FROM expedition WHERE created < v26Months; DELETE cs FROM sms s @@ -61,11 +59,8 @@ BEGIN DELETE b FROM buy b JOIN entryConfig e ON e.defaultEntry = b.entryFk WHERE b.created < v2Months; - DELETE FROM itemShelvingLog WHERE created < v2Months; DELETE FROM stockBuyed WHERE creationDate < v2Months; - DELETE FROM itemCleanLog WHERE created < util.VN_NOW() - INTERVAL 1 YEAR; DELETE FROM printQueue WHERE statusCode = 'printed' AND created < v2Months; - DELETE FROM ticketLog WHERE creationDate <= v5Years; -- Equipos duplicados DELETE w.* FROM workerTeam w @@ -174,7 +169,6 @@ BEGIN -- Borra los registros de collection y ticketcollection DELETE FROM collection WHERE created < v2Months; - DELETE FROM travelLog WHERE creationDate < v3Months; CALL shelving_clean(); From 3dda49b3c56a1a9f5f542db83393e521e3af9e33 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 28 Aug 2024 08:40:03 +0200 Subject: [PATCH 32/48] fix: refs #pako Deleted duplicated version --- db/versions/11200-brownDendro/00-firstScript.sql | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 db/versions/11200-brownDendro/00-firstScript.sql diff --git a/db/versions/11200-brownDendro/00-firstScript.sql b/db/versions/11200-brownDendro/00-firstScript.sql deleted file mode 100644 index 943368b06..000000000 --- a/db/versions/11200-brownDendro/00-firstScript.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Place your SQL code here -ALTER TABLE vn.saleGroup ADD stateFk TINYINT(3) UNSIGNED; - -ALTER TABLE vn.saleGroup ADD CONSTRAINT saleGroup_state_FK FOREIGN KEY (stateFk) REFERENCES vn.state(id) ON DELETE RESTRICT ON UPDATE CASCADE; From 5b49e7cf459205d691dc28191f4c2ac0f46875be Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 28 Aug 2024 06:51:32 +0000 Subject: [PATCH 33/48] fix(salix): rollback updateClaim --- modules/claim/back/methods/claim/updateClaim.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/claim/back/methods/claim/updateClaim.js b/modules/claim/back/methods/claim/updateClaim.js index 10d304496..326192385 100644 --- a/modules/claim/back/methods/claim/updateClaim.js +++ b/modules/claim/back/methods/claim/updateClaim.js @@ -108,7 +108,7 @@ module.exports = Self => { async function notifyStateChange(ctx, workerId, claim, newState) { const models = Self.app.models; - const url = await models.Url.getUrl('lilium'); + const url = await models.Url.getUrl(); const $t = ctx.req.__; const message = $t(`Claim state has changed to`, { @@ -122,7 +122,7 @@ module.exports = Self => { async function notifyPickUp(ctx, workerId, claim) { const models = Self.app.models; - const url = await models.Url.getUrl('lilium'); + const url = await models.Url.getUrl(); const $t = ctx.req.__; // $translate const message = $t('Claim will be picked', { From 27e30c0051cccc01f73e437ee5c10e689145d150 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 28 Aug 2024 09:22:31 +0200 Subject: [PATCH 34/48] fix(salix): redirect with params --- front/core/services/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index 8cee66ef0..cec7bea7f 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -56,6 +56,8 @@ export default class App { } getUrl(route, appName = 'lilium') { + const index = window.location.hash.indexOf(route.toLowerCase()); + const newRoute = index < 0 ? route : window.location.hash.substring(index); const env = process.env.NODE_ENV; const filter = { where: {and: [ @@ -67,7 +69,7 @@ export default class App { return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { if (res && res.data) - return res.data.url + route; + return res.data.url + newRoute; }) .catch(() => { this.showError('Direction not found'); From 49394b9b165444b8f0509b801a0cf282b556c201 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 28 Aug 2024 09:42:59 +0200 Subject: [PATCH 35/48] fix: change claim --- modules/claim/front/main/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/front/main/index.js b/modules/claim/front/main/index.js index cbbbe0c7e..c921d5a12 100644 --- a/modules/claim/front/main/index.js +++ b/modules/claim/front/main/index.js @@ -7,7 +7,7 @@ export default class Claim extends ModuleMain { } async $onInit() { this.$state.go('home'); - window.location.href = await this.vnApp.getUrl(`Claim/`); + window.location.href = await this.vnApp.getUrl(`claim/`); } } From 423ba8c21836dfe1b111d275f40ac8f4d4742595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 28 Aug 2024 11:59:46 +0200 Subject: [PATCH 36/48] Hotfix: refs #7213 ticket_isTooLittle group by addressFk --- db/routines/vn/functions/ticket_isTooLittle.sql | 12 ++++++------ .../vn/procedures/ticket_setProblemTooLittle.sql | 15 +++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/db/routines/vn/functions/ticket_isTooLittle.sql b/db/routines/vn/functions/ticket_isTooLittle.sql index dee1df29b..2752b3f35 100644 --- a/db/routines/vn/functions/ticket_isTooLittle.sql +++ b/db/routines/vn/functions/ticket_isTooLittle.sql @@ -2,7 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`( vSelf INT ) - RETURNS tinyint(1) + RETURNS BOOL READS SQL DATA BEGIN /** @@ -11,20 +11,20 @@ BEGIN * @param vSelf Id ticket * @return BOOL */ - DECLARE vIsTooLittle TINYINT(1); + DECLARE vIsTooLittle BOOL; - WITH tickets AS ( + WITH ticketData AS ( SELECT addressFk, DATE(shipped) dated FROM vn.ticket WHERE id = vSelf ) SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle - FROM tickets ts - JOIN vn.ticket t ON t.addressFk = ts.addressFk + FROM ticketData td + JOIN vn.ticket t ON t.addressFk = td.addressFk LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id JOIN vn.volumeConfig vc - WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated) + WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated) AND ticket_isProblemCalcNeeded(t.id); RETURN vIsTooLittle; diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql index fe2d3306d..03677a05c 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittle.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql @@ -8,22 +8,25 @@ BEGIN * * @param vSelf Id del ticket */ - + DECLARE vTicketIsTooLittle BOOL; + + SELECT ticket_isTooLittle(vSelf) INTO vTicketIsTooLittle; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket (INDEX(ticketFk, isProblemCalcNeeded)) ENGINE = MEMORY - WITH tickets AS ( + WITH ticketData AS ( SELECT addressFk, DATE(shipped) dated FROM vn.ticket WHERE id = vSelf ) SELECT t.id ticketFk, - ticket_isTooLittle(t.id) hasProblem, + vTicketIsTooLittle hasProblem, ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded FROM vn.ticket t - JOIN tickets ts ON ts.addressFk = t.addressFk - WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated); - + JOIN ticketData td ON td.addressFk = t.addressFk + WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated); + CALL ticket_setProblem('isTooLittle'); DROP TEMPORARY TABLE tmp.ticket; From 484bb48d04f99727e4b1c7dc2282b928b7af441c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 28 Aug 2024 12:33:05 +0200 Subject: [PATCH 37/48] fix: refs #7760 collection problems --- db/routines/vn/procedures/collection_new.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 80c5e6172..18b51c4d3 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -130,7 +130,6 @@ BEGIN JOIN state s ON s.id = pb.state WHERE s.code = 'PICKER_DESIGNED' AND pb.workerCode = vWorkerCode - LIMIT 1 ) INTO vHasAssignedTickets; -- Se dejan en la tabla tmp.productionBuffer sólo aquellos tickets adecuados From 611fbebd6d6226e9d532df04ceeb7582d78b205e Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 29 Aug 2024 09:35:23 +0200 Subject: [PATCH 38/48] feat: refs #7811 Added new params in datasources.json --- loopback/server/datasources.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index 341d5d578..b4bf4a79a 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -11,12 +11,17 @@ "port": "3306", "username": "root", "password": "root", + "connectionLimit": 100, + "queueLimit": 100, "multipleStatements": true, "legacyUtcDateProcessing": false, "timezone": "local", "connectTimeout": 40000, "acquireTimeout": 90000, - "waitForConnections": true + "waitForConnections": true, + "handleDisconnects": true, + "maxIdleTime": 60000, + "idleTimeout": 60000 }, "osticket": { "connector": "memory", From c7777f609b52c1bf347a783a202d9e6239691469 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 29 Aug 2024 10:10:37 +0200 Subject: [PATCH 39/48] feat: refs #7811 Added new params in datasources.json --- loopback/server/datasources.json | 1 - 1 file changed, 1 deletion(-) diff --git a/loopback/server/datasources.json b/loopback/server/datasources.json index b4bf4a79a..f1643e522 100644 --- a/loopback/server/datasources.json +++ b/loopback/server/datasources.json @@ -19,7 +19,6 @@ "connectTimeout": 40000, "acquireTimeout": 90000, "waitForConnections": true, - "handleDisconnects": true, "maxIdleTime": 60000, "idleTimeout": 60000 }, From 4e52f344f4d947e8261a285f7d2dd4a85c5b677d Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 30 Aug 2024 09:14:21 +0200 Subject: [PATCH 40/48] feat: refs #7811 Added comment --- loopback/server/connectors/vn-mysql.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 5edef4395..2012caf37 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -342,6 +342,9 @@ exports.initialize = function initialize(dataSource, callback) { } }; +// Code extracted from original Loopback MySQL connector +// since it cannot be reused, please try not to alter it. +// https://github.com/loopbackio/loopback-connector-mysql/blob/v6.2.0/lib/mysql.js MySQL.prototype.connect = function(callback) { const self = this; const options = generateOptions(this.settings); From b451641d47b314e23955f76be90799ca9546a5e0 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 30 Aug 2024 11:49:39 +0200 Subject: [PATCH 41/48] fix: refs #6897 fix filter --- modules/entry/back/methods/entry/filter.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/entry/back/methods/entry/filter.js b/modules/entry/back/methods/entry/filter.js index dcb1e3158..776544bc6 100644 --- a/modules/entry/back/methods/entry/filter.js +++ b/modules/entry/back/methods/entry/filter.js @@ -109,6 +109,11 @@ module.exports = Self => { arg: 'days', type: 'number', description: `N days interval` + }, + { + arg: 'invoiceAmount', + type: 'number', + description: `The invoice amount` } ], returns: { @@ -192,6 +197,7 @@ module.exports = Self => { e.companyFk, e.gestDocFk, e.invoiceInFk, + e.invoiceAmount, t.landed, s.name supplierName, s.nickname supplierAlias, From e8010d0f18fcbc88a0c1f1150be2142384084020 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 30 Aug 2024 12:10:33 +0200 Subject: [PATCH 42/48] fix: refs #6897 fix json --- modules/entry/back/models/entry.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/entry/back/models/entry.json b/modules/entry/back/models/entry.json index 833edf14d..383585fce 100644 --- a/modules/entry/back/models/entry.json +++ b/modules/entry/back/models/entry.json @@ -74,6 +74,9 @@ }, "observationEditorFk": { "type": "number" + }, + "invoiceAmount": { + "type": "number" } }, "relations": { @@ -108,4 +111,4 @@ "foreignKey": "typeFk" } } -} \ No newline at end of file +} From 26d93ef474cd1f2c1d6e94029f0792fc5ec295f9 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 30 Aug 2024 12:35:10 +0200 Subject: [PATCH 43/48] fix: refs #6897 travel filter --- modules/travel/back/methods/travel/filter.js | 11 +++++++++++ modules/travel/back/models/travel.json | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 3fa1d65f9..b7fadc8f2 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -71,7 +71,16 @@ module.exports = Self => { arg: 'continent', type: 'string', description: 'The continent code' + }, { + arg: 'shipmentHour', + type: 'time', + description: 'The shipment hour' }, + { + arg: 'landingHour', + type: 'time', + description: 'The landing hour' + } ], returns: { type: ['Object'], @@ -130,6 +139,8 @@ module.exports = Self => { t.isReceived, t.m3, t.kg, + t.shipmentHour, + t.landingHour, t.cargoSupplierFk, t.totalEntries, am.name agencyModeName, diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index 701894a76..d0153e044 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -44,8 +44,13 @@ }, "agencyModeFk": { "type": "number" - } - }, + }, + "shipmentHour": { + "type": "time" + }, + "landingHour": { + "type": "time" + }, "relations": { "agency": { "type": "belongsTo", From f65d36011b5ce9a2b5b5aeb4d3fbe9f4a8037bf4 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 30 Aug 2024 12:40:37 +0200 Subject: [PATCH 44/48] fix: refs #6897 back --- modules/travel/back/models/travel.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index d0153e044..46d24f975 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -46,10 +46,10 @@ "type": "number" }, "shipmentHour": { - "type": "time" + "type": "string" }, "landingHour": { - "type": "time" + "type": "string" }, "relations": { "agency": { @@ -69,3 +69,4 @@ } } } +} From 7b1a34e249e7e9743e712e93f6f0af9683007260 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 30 Aug 2024 12:47:05 +0200 Subject: [PATCH 45/48] feat: refs #7860 Update new packagings --- db/versions/11208-limeRoebelini/00-firstScript.vn.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/versions/11208-limeRoebelini/00-firstScript.vn.sql diff --git a/db/versions/11208-limeRoebelini/00-firstScript.vn.sql b/db/versions/11208-limeRoebelini/00-firstScript.vn.sql new file mode 100644 index 000000000..22b3dc924 --- /dev/null +++ b/db/versions/11208-limeRoebelini/00-firstScript.vn.sql @@ -0,0 +1,7 @@ +UPDATE vn.packaging SET id='25E' WHERE id='cactus200'; +UPDATE vn.packaging SET id='35E' WHERE id='kalan330'; +UPDATE vn.packaging SET id='45E' WHERE id='kalan400'; +UPDATE vn.packaging SET id='60E' WHERE id='kalan577'; +UPDATE vn.packaging SET id='60A' WHERE id='guzma650'; +UPDATE vn.packaging SET id='120A' WHERE id='guzma1200'; +UPDATE vn.packaging SET id='140A' WHERE id='guzma1400'; From 4a7d81f920570210b370f57856122127e679a2f8 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 30 Aug 2024 12:53:44 +0200 Subject: [PATCH 46/48] fix: refs #6897 back and tests --- modules/travel/back/methods/travel/filter.js | 7 +++---- modules/travel/back/models/travel.json | 5 +++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index b7fadc8f2..9f26423ce 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -73,12 +73,11 @@ module.exports = Self => { description: 'The continent code' }, { arg: 'shipmentHour', - type: 'time', + type: 'string', description: 'The shipment hour' - }, - { + }, { arg: 'landingHour', - type: 'time', + type: 'string', description: 'The landing hour' } ], diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index 46d24f975..0ebf683e7 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -50,7 +50,8 @@ }, "landingHour": { "type": "string" - }, + } + }, "relations": { "agency": { "type": "belongsTo", @@ -69,4 +70,4 @@ } } } -} + From 89f8e987dc7827a32eace416a3d7ebd202d99c6a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Sep 2024 14:27:04 +0200 Subject: [PATCH 47/48] feat: refs #7562 Requested changes --- db/versions/11209-pinkOrchid/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11209-pinkOrchid/00-firstScript.sql diff --git a/db/versions/11209-pinkOrchid/00-firstScript.sql b/db/versions/11209-pinkOrchid/00-firstScript.sql new file mode 100644 index 000000000..92a7a7569 --- /dev/null +++ b/db/versions/11209-pinkOrchid/00-firstScript.sql @@ -0,0 +1,6 @@ +ALTER TABLE vn.operator + MODIFY COLUMN sizeLimit int(10) unsigned DEFAULT NULL NULL COMMENT 'Límite de altura en una colección para la asignación de pedidos'; + +UPDATE vn.operator + SET sizeLimit = 90 + WHERE itemPackingTypeFk = 'V'; From 6fc8b9b8215340e2f0ad3b086abce153f6a70d40 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Sep 2024 14:41:02 +0200 Subject: [PATCH 48/48] feat: ticket 215005 Changed acl show transferClient --- modules/ticket/front/descriptor-menu/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/front/descriptor-menu/index.html b/modules/ticket/front/descriptor-menu/index.html index 3583b1202..82094d7b8 100644 --- a/modules/ticket/front/descriptor-menu/index.html +++ b/modules/ticket/front/descriptor-menu/index.html @@ -6,7 +6,7 @@