From 97b07ea561e1456ea1480785c2328e58dbb1743d Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 9 Sep 2024 13:56:30 +0200 Subject: [PATCH 01/46] fix: refs #7356 ticket weekly filter --- modules/ticket/back/methods/ticket-weekly/filter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket-weekly/filter.js b/modules/ticket/back/methods/ticket-weekly/filter.js index a43b5e270..d988f0c10 100644 --- a/modules/ticket/back/methods/ticket-weekly/filter.js +++ b/modules/ticket/back/methods/ticket-weekly/filter.js @@ -66,7 +66,7 @@ module.exports = Self => { FROM ticketWeekly tw JOIN ticket t ON t.id = tw.ticketFk JOIN client c ON c.id = t.clientFk - JOIN account.user u ON u.id = c.salesPersonFk + LEFT JOIN account.user u ON u.id = c.salesPersonFk JOIN warehouse wh ON wh.id = t.warehouseFk LEFT JOIN agencyMode am ON am.id = tw.agencyModeFk` ); From d5f18b918778976bc8df0f5e1b3bef2daf3397e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 18 Sep 2024 10:25:21 +0200 Subject: [PATCH 02/46] fix: collection_new --- .../ticket_splitItemPackingType.sql | 92 +++++++------------ 1 file changed, 34 insertions(+), 58 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 6baf944ee..63e219764 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -5,23 +5,21 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki ) proc: 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 + * @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; - DECLARE vNewTicketFk INT; - DECLARE vPackingTypesToSplit INT; DECLARE vDone INT DEFAULT FALSE; + DECLARE 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 tSalesToMove; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -36,59 +34,39 @@ proc: BEGIN LEAVE proc; END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( + CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( 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 tSalesToMove (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; + IF vDone THEN + LEAVE l; + END IF; - CALL ticket_Clone(vSelf, vNewTicketFk); + CALL ticket_Clone(vSelf, vNewTicketFk); - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vNewTicketFk, vItemPackingTypeFk); - END LOOP; + UPDATE tSalesToMove + SET ticketFk = vNewTicketFk + WHERE itemPackingTypeFk = vItemPackingTypeFk; - CLOSE vSaleGroup; + END LOOP; - 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; + CLOSE vItemPackingTypes; UPDATE sale s JOIN tSalesToMove stm ON stm.saleFk = s.id @@ -105,8 +83,6 @@ proc: BEGIN UNION SELECT vSelf, vOriginalItemPackingTypeFk; - DROP TEMPORARY TABLE - tSale, - tSaleGroup; + DROP TEMPORARY TABLE tSalesToMove; END$$ DELIMITER ; From 4f9b6030e8ed1d2dbabc3b93a21692b6f7872751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 18 Sep 2024 10:30:16 +0200 Subject: [PATCH 03/46] fix: collection_new --- db/routines/vn/procedures/collection_new.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 6a15ce73c..782243c03 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -200,14 +200,6 @@ BEGIN OR pb.hasPlantTray; END IF; - -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede - IF vHasUniqueCollectionTime THEN - 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; - SELECT ticketFk INTO vFirstTicketFk FROM tmp.productionBuffer ORDER BY HH, @@ -219,6 +211,14 @@ BEGIN routeFk, ticketFk LIMIT 1; + + -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede + IF vHasUniqueCollectionTime THEN + 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; From 26a078504f8ccb4e63cbb31d50a1b42658a7a450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 18 Sep 2024 11:27:57 +0200 Subject: [PATCH 04/46] fix: collection_new --- db/routines/vn/procedures/collection_new.sql | 290 ++++++++---------- .../vn/procedures/ticket_mergeSales.sql | 38 ++- 2 files changed, 146 insertions(+), 182 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 782243c03..eef0cc9f6 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -12,30 +12,29 @@ BEGIN DECLARE vLinesLimit INT; DECLARE vTicketLines INT; DECLARE vVolumeLimit DECIMAL; - DECLARE vTicketVolume DECIMAL; DECLARE vSizeLimit INT; + DECLARE vTicketVolume DECIMAL; DECLARE vMaxTickets INT; - DECLARE vStateFk VARCHAR(45); + DECLARE vStateCode 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 +47,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, @@ -78,36 +57,26 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, - o.sizeLimit, - pc.collection_new_lockname + o.sizeLimit 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, + vStateCode, + vWagons, + vTrainFk, + vLinesLimit, + vVolumeLimit, + vSizeLimit + 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,59 +87,58 @@ 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 + ) 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 @@ -193,13 +161,21 @@ 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 OR pb.hasPlantTray; END IF; + -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede + IF vHasUniqueCollectionTime THEN + 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; + SELECT ticketFk INTO vFirstTicketFk FROM tmp.productionBuffer ORDER BY HH, @@ -211,46 +187,38 @@ BEGIN routeFk, ticketFk LIMIT 1; - - -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede - IF vHasUniqueCollectionTime THEN - 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 @@ -267,17 +235,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; @@ -286,38 +250,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 @@ -325,37 +286,34 @@ BEGIN ORDER BY tt.wagon, tt.shelve; -- Actualiza el estado de los tickets - CALL collection_setState(vCollectionFk, vStateFk); + + CALL collection_setState(vCollectionFk, vStateCode); -- 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/ticket_mergeSales.sql b/db/routines/vn/procedures/ticket_mergeSales.sql index 28b2dc1c0..2dc3a39da 100644 --- a/db/routines/vn/procedures/ticket_mergeSales.sql +++ b/db/routines/vn/procedures/ticket_mergeSales.sql @@ -3,41 +3,47 @@ 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 + 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; + GROUP BY s.itemFk, s.price, s.discount + HAVING COUNT(*) > 1; - START TRANSACTION; + SELECT COUNT(*) INTO vHasSalesToMerge + FROM tSalesToPreserve; - UPDATE sale s - JOIN tSalesToPreserve stp ON stp.id = s.id - SET s.quantity = newQuantity - WHERE s.ticketFk = vSelf; + IF vHasSalesToMerge THEN + UPDATE sale s + JOIN tSalesToPreserve stp ON stp.id = s.id + SET s.quantity = newQuantity; - 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 = vSelf - AND stp.id IS NULL - AND it.isMergeable; + 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 ; From 6c4b1cd522ddafa1521af1daea938831695b0a7b Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 18 Sep 2024 11:37:47 +0200 Subject: [PATCH 05/46] fix(shelving_clean): less time por shelving removal --- db/routines/vn/procedures/shelving_clean.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/shelving_clean.sql b/db/routines/vn/procedures/shelving_clean.sql index d2cb7caad..2e913f19c 100644 --- a/db/routines/vn/procedures/shelving_clean.sql +++ b/db/routines/vn/procedures/shelving_clean.sql @@ -25,7 +25,7 @@ UPDATE shelving sh AND ( sh.parked IS NULL OR - sh.parked < TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()) + sh.parked < TIMESTAMPADD(WEEK,-2,util.VN_CURDATE()) ) AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN ( SELECT DISTINCT LEFT(its.shelvingFk, 2) From eb22a77e259b17bb9810e9dd4c4e4586d770503c Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 18 Sep 2024 11:48:50 +0200 Subject: [PATCH 06/46] fix: timesstampadd to interval --- db/routines/vn/procedures/shelving_clean.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/shelving_clean.sql b/db/routines/vn/procedures/shelving_clean.sql index 2e913f19c..0b29968bc 100644 --- a/db/routines/vn/procedures/shelving_clean.sql +++ b/db/routines/vn/procedures/shelving_clean.sql @@ -25,8 +25,9 @@ UPDATE shelving sh AND ( sh.parked IS NULL OR - sh.parked < TIMESTAMPADD(WEEK,-2,util.VN_CURDATE()) - ) + sh.parked < util.VN_CURDATE() - INTERVAL 2 WEEK + ) + AND IF(code REGEXP '^[A-Za-z]{2}[0-9]', LEFT (code, 2) NOT IN ( SELECT DISTINCT LEFT(its.shelvingFk, 2) FROM itemShelving its From b48c221028cd1580c4528bbed95f73a3bba9843c Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 19 Sep 2024 08:33:33 +0200 Subject: [PATCH 07/46] feat: refs #8000 refs #800 catalog_calculate itemMaxLength --- db/routines/vn/procedures/catalog_calculate.sql | 5 ++++- db/versions/11248-azureOrchid/00-firstScript.sql | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 db/versions/11248-azureOrchid/00-firstScript.sql diff --git a/db/routines/vn/procedures/catalog_calculate.sql b/db/routines/vn/procedures/catalog_calculate.sql index 17e7450cc..39bf2b441 100644 --- a/db/routines/vn/procedures/catalog_calculate.sql +++ b/db/routines/vn/procedures/catalog_calculate.sql @@ -126,7 +126,10 @@ BEGIN AND a.available > 0 AND (sub.itemAllowed OR NOT it.isFloramondo OR anr.available > 0) AND (ag.isAnyVolumeAllowed OR NOT itt.isUnconventionalSize) - AND (itc.isReclining OR it.`size` IS NULL OR it.`size` < z.itemMaxSize OR z.itemMaxSize IS NULL) + AND (it.`size` IS NULL + OR IF(itc.isReclining, + it.size <= z.itemMaxLength OR z.itemMaxLength IS NULL, + it.size <= z.itemMaxSize OR z.itemMaxSize IS NULL)) AND cit.id IS NULL AND zit.id IS NULL AND ait.id IS NULL; diff --git a/db/versions/11248-azureOrchid/00-firstScript.sql b/db/versions/11248-azureOrchid/00-firstScript.sql new file mode 100644 index 000000000..24b4259bc --- /dev/null +++ b/db/versions/11248-azureOrchid/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.`zone` + ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL; \ No newline at end of file From e8a203efc701f415bb7b5032f57e43f2404bad58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 19 Sep 2024 12:09:36 +0200 Subject: [PATCH 08/46] fix: ticket_splitItemPackingType --- .../vn/procedures/ticket_splitItemPackingType.sql | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 63e219764..c0b3d9625 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -30,6 +30,12 @@ proc: BEGIN WHERE t.id = vSelf AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( + ticketFk INT, + itemPackingTypeFk VARCHAR(1) + ) ENGINE=MEMORY + SELECT vSelf, vOriginalItemPackingTypeFk; + IF NOT vHasItemPackingType THEN LEAVE proc; END IF; @@ -73,15 +79,10 @@ proc: BEGIN SET s.ticketFk = stm.ticketFk WHERE stm.ticketFk; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( - ticketFk INT, - itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY + INSERT INTO tmp.ticketIPT SELECT ticketFk, itemPackingTypeFk FROM tSalesToMove - GROUP BY ticketFk - UNION - SELECT vSelf, vOriginalItemPackingTypeFk; + GROUP BY ticketFk; DROP TEMPORARY TABLE tSalesToMove; END$$ From 5456490dcd9278b3047593bd85558bab3e66a3a9 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 19 Sep 2024 12:09:47 +0200 Subject: [PATCH 09/46] feat: refs #8000 poner comentario --- db/versions/11248-azureOrchid/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11248-azureOrchid/00-firstScript.sql b/db/versions/11248-azureOrchid/00-firstScript.sql index 24b4259bc..72eafeba1 100644 --- a/db/versions/11248-azureOrchid/00-firstScript.sql +++ b/db/versions/11248-azureOrchid/00-firstScript.sql @@ -1,2 +1,2 @@ ALTER TABLE vn.`zone` - ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL; \ No newline at end of file + ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos inclinados'; \ No newline at end of file From b642147d82a25aa3823041300c70a9f491a5deb5 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 19 Sep 2024 13:14:22 +0200 Subject: [PATCH 10/46] feat: refs #7356 added new filter field --- modules/ticket/back/methods/ticket/filter.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index 2209c8df4..c3eea4201 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -76,7 +76,8 @@ module.exports = Self => { { arg: 'myTeam', type: 'boolean', - description: `Whether to show only tickets for the current logged user team (For now it shows only the current user tickets)` + description: `Whether to show only tickets for the current logged user team + (For now it shows only the current user tickets)` }, { arg: 'problems', @@ -258,7 +259,8 @@ module.exports = Self => { MINUTE(z.hour) zoneMinute, z.name zoneName, z.id zoneFk, - CAST(z.hour AS CHAR) hour + CAST(z.hour AS CHAR) hour, + a.nickname addressNickname FROM ticket t LEFT JOIN invoiceOut io ON t.refFk = io.ref LEFT JOIN zone z ON z.id = t.zoneFk From 4c0e05fdab6b428413bef10604f03e42cfd3d360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 19 Sep 2024 18:03:59 +0200 Subject: [PATCH 11/46] fix: refs #8011 Previas compo F --- .../vn/procedures/previousSticker_get.sql | 54 ++++++++++--------- .../reports/previa-label/previa-label.html | 2 +- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/db/routines/vn/procedures/previousSticker_get.sql b/db/routines/vn/procedures/previousSticker_get.sql index 90f2bec37..f43a23773 100644 --- a/db/routines/vn/procedures/previousSticker_get.sql +++ b/db/routines/vn/procedures/previousSticker_get.sql @@ -1,58 +1,60 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`previousSticker_get`(vSaleGroupFk INT) +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`previousSticker_get`( + vSaleGroupFk INT +) BEGIN /** * Devuelve los campos a imprimir en una etiqueta de preparación previa. - * Actualiza el valor de vn.saleGroup.parkingFk en el caso de que exista un + * Actualiza el valor de saleGroup.parkingFk en el caso de que exista un * saleGroup del mismo ticket con parking, del mismo sector, para que todos se * pongan juntos. * - * @param vSaleGroupFk Identificador de vn.saleGroup + * @param vSaleGroupFk Identificador de saleGroup */ DECLARE vTicketFk INT; DECLARE vParkingFk INT; DECLARE vSectorFk INT; + DECLARE vPreviousLines INT; - SELECT s.ticketFk - INTO vTicketFk - FROM vn.saleGroupDetail sgd - JOIN vn.sale s ON s.id = sgd.saleFk - WHERE sgd.saleGroupFk = vSaleGroupFk - LIMIT 1; + SELECT s.ticketFk, COUNT(*) + INTO vTicketFk, vPreviousLines + FROM saleGroupDetail sgd + JOIN sale s ON s.id = sgd.saleFk + WHERE sgd.saleGroupFk = vSaleGroupFk; SELECT sg.parkingFk, sc.sectorFk INTO vParkingFk, vSectorFk - FROM vn.saleGroup sg - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id - JOIN vn.sectorCollection sc ON sc.id = scsg.sectorCollectionFk - JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id - JOIN vn.sale s ON s.id = sgd.saleFk + FROM saleGroup sg + JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sg.id + JOIN sectorCollection sc ON sc.id = scsg.sectorCollectionFk + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN sale s ON s.id = sgd.saleFk WHERE s.ticketFk = vTicketFk AND sg.parkingFk IS NOT NULL LIMIT 1; - UPDATE vn.saleGroup sg + UPDATE saleGroup sg SET sg.parkingFk = vParkingFk WHERE sg.id = vSaleGroupFk AND sg.sectorFk = vSectorFk; SELECT sgd.saleGroupFk, t.id ticketFk, - p.code as location, - t.observations, + vPreviousLines previousLines, IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute , IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk , - count(*) items, + COUNT(*) ticketLines, + p.code `location`, sc.description sector - FROM vn.sale s - JOIN vn.item i ON i.id = s.itemFk - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk - JOIN vn.sector sc ON sc.id = sg.sectorFk - JOIN vn.ticket t ON t.id = s.ticketFk - LEFT JOIN vn.parking p ON p.id = sg.parkingFk - LEFT JOIN vn.`zone` z ON z.id = t.zoneFk + FROM sale s + JOIN item i ON i.id = s.itemFk + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + JOIN sector sc ON sc.id = sg.sectorFk + JOIN ticket t ON t.id = s.ticketFk + LEFT JOIN parking p ON p.id = sg.parkingFk + LEFT JOIN `zone` z ON z.id = t.zoneFk WHERE sgd.saleGroupFk = vSaleGroupFk; END$$ DELIMITER ; diff --git a/print/templates/reports/previa-label/previa-label.html b/print/templates/reports/previa-label/previa-label.html index 1dc9b14d0..68042e978 100644 --- a/print/templates/reports/previa-label/previa-label.html +++ b/print/templates/reports/previa-label/previa-label.html @@ -19,7 +19,7 @@
{{previa.itemPackingTypeFk}}
{{previa.shippingHour}}:{{previa.shippingMinute}}
-
{{previa.items}}
+
{{previa.previousLines}}
From 0c35e1fa9c6c87cb0c96169fe3aff2485261e360 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 20 Sep 2024 07:33:05 +0200 Subject: [PATCH 12/46] feat: refs #8000 modificar comentario --- db/versions/11248-azureOrchid/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11248-azureOrchid/00-firstScript.sql b/db/versions/11248-azureOrchid/00-firstScript.sql index 72eafeba1..85386c4d8 100644 --- a/db/versions/11248-azureOrchid/00-firstScript.sql +++ b/db/versions/11248-azureOrchid/00-firstScript.sql @@ -1,2 +1,2 @@ ALTER TABLE vn.`zone` - ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos inclinados'; \ No newline at end of file + ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos reclinados'; \ No newline at end of file From 1b4a324c3c7861f753ecba5a206d506a32caf4fc Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 20 Sep 2024 07:58:15 +0200 Subject: [PATCH 13/46] feat: refs #8000 modificar comentarios --- db/versions/11248-azureOrchid/00-firstScript.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/versions/11248-azureOrchid/00-firstScript.sql b/db/versions/11248-azureOrchid/00-firstScript.sql index 85386c4d8..b13a726a8 100644 --- a/db/versions/11248-azureOrchid/00-firstScript.sql +++ b/db/versions/11248-azureOrchid/00-firstScript.sql @@ -1,2 +1,3 @@ -ALTER TABLE vn.`zone` - ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos reclinados'; \ No newline at end of file +ALTER TABLE vn.`zone` + ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos reclinados que esa agencia puede transportar', + MODIFY COLUMN itemMaxSize int(11) DEFAULT NULL NULL COMMENT 'Altura maxima de los articulos que esa agencia puede transportar'; From 889b86644bb0e4fbdc20bbc0a42284fba2dd998a Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 20 Sep 2024 09:14:38 +0200 Subject: [PATCH 14/46] fix: refs #6898 filter fix --- modules/supplier/back/methods/supplier/filter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/supplier/back/methods/supplier/filter.js b/modules/supplier/back/methods/supplier/filter.js index 0b473f7df..a52eb6444 100644 --- a/modules/supplier/back/methods/supplier/filter.js +++ b/modules/supplier/back/methods/supplier/filter.js @@ -81,7 +81,7 @@ module.exports = Self => { let stmts = []; let stmt; stmt = new ParameterizedSQL( - `SELECT + `SELECT s.id, s.name AS socialName, s.nickname AS alias, @@ -92,10 +92,13 @@ module.exports = Self => { s.payDay, s.phone, s.city, + s.countryFk, + c.name country, pm.name AS payMethod, pd.payDem AS payDem FROM vn.supplier s LEFT JOIN vn.payMethod pm ON pm.id = s.payMethodFk + LEFT JOIN vn.country c ON c.id = s.countryFk LEFT JOIN vn.payDem pd ON pd.id = s.payDemFk` ); From 633766e58b1ab6c6668e673518c6f8d0520ab91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 20 Sep 2024 10:06:10 +0200 Subject: [PATCH 15/46] fix: recupero version anterior --- db/routines/vn/procedures/collection_new.sql | 301 ++++++++++-------- .../vn/procedures/productionControl.sql | 16 +- .../vn/procedures/ticket_mergeSales.sql | 38 +-- .../ticket_splitItemPackingType.sql | 147 +++++---- 4 files changed, 293 insertions(+), 209 deletions(-) diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index eef0cc9f6..dc1280373 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -12,29 +12,30 @@ BEGIN DECLARE vLinesLimit INT; DECLARE vTicketLines INT; DECLARE vVolumeLimit DECIMAL; - DECLARE vSizeLimit INT; DECLARE vTicketVolume DECIMAL; + DECLARE vSizeLimit INT; DECLARE vMaxTickets INT; - DECLARE vStateCode VARCHAR(45); + DECLARE vStateFk VARCHAR(45); DECLARE vFirstTicketFk INT; + DECLARE vHour INT; + DECLARE vMinute INT; DECLARE vWorkerCode VARCHAR(3); - DECLARE vWagonCounter INT DEFAULT 1; + DECLARE vWagonCounter INT DEFAULT 0; DECLARE vTicketFk INT; DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vHasAssignedTickets BOOL; + DECLARE vHasAssignedTickets BOOLEAN; DECLARE vHasUniqueCollectionTime BOOL; - 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 vDone INT DEFAULT FALSE; + DECLARE vLockName VARCHAR(215); + DECLARE vLockTime INT DEFAULT 30; + DECLARE vFreeWagonFk INT; + DECLARE vErrorNumber INT; + DECLARE vErrorMsg TEXT; - DECLARE vTickets CURSOR FOR + DECLARE c1 CURSOR FOR SELECT ticketFk, `lines`, m3 FROM tmp.productionBuffer + WHERE ticketFk <> vFirstTicketFk ORDER BY HH, mm, productionOrder DESC, @@ -47,6 +48,26 @@ 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, @@ -57,26 +78,36 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, - o.sizeLimit + o.sizeLimit, + pc.collection_new_lockname INTO vMaxTickets, - vHasUniqueCollectionTime, - vWorkerCode, - vWarehouseFk, - vItemPackingTypeFk, - vStateCode, - vWagons, - vTrainFk, - vLinesLimit, - vVolumeLimit, - vSizeLimit - FROM worker w - JOIN operator o ON o.workerFk = w.id + vHasUniqueCollectionTime, + vWorkerCode, + vWarehouseFk, + vItemPackingTypeFk, + vStateFk, + vWagons, + vTrainFk, + vLinesLimit, + vVolumeLimit, + vSizeLimit, + vLockName + FROM productionConfig pc + JOIN worker w ON w.id = vUserFk JOIN state st ON st.`code` = 'ON_PREPARATION' - JOIN productionConfig pc - WHERE w.id = vUserFk; + 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; -- Se prepara el tren, con tantos vagones como sea necesario. - CREATE OR REPLACE TEMPORARY TABLE tTrain (wagon INT, shelve INT, @@ -87,58 +118,59 @@ BEGIN PRIMARY KEY(wagon, shelve)) ENGINE = MEMORY; - 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 + 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 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%'; - -- 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 - ) INTO vHasAssignedTickets; + -- 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; -- 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 @@ -161,24 +193,26 @@ 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) + OR LENGTH(pb.problem) > 0 OR pb.lines > vLinesLimit OR pb.m3 > vVolumeLimit OR sub.maxSize > vSizeLimit OR pb.hasPlantTray; END IF; - -- Hay que excluir aquellos que no tengan la misma hora de preparacion, si procede - IF vHasUniqueCollectionTime THEN - 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; - - SELECT ticketFk INTO vFirstTicketFk + -- 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, + ORDER BY HH, mm, productionOrder DESC, m3 DESC, @@ -188,37 +222,44 @@ BEGIN ticketFk LIMIT 1; - OPEN vTickets; - l: LOOP - SET vDone = FALSE; - FETCH vTickets INTO vTicketFk, vTicketLines, vTicketVolume; + -- 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; + END IF; - IF vDone THEN - LEAVE l; - END IF; + SET vTicketFk = vFirstTicketFk; + SET @lines = 0; + SET @volume = 0; + + OPEN c1; + read_loop: LOOP + SET vDone = FALSE; -- Buscamos un ticket que cumpla con los requisitos en el listado - - IF (vLinesLimit IS NULL OR (vTotalLines + vTicketLines) <= vLinesLimit) - AND (vVolumeLimit IS NULL OR (vTotalVolume + vTicketVolume) <= vVolumeLimit) THEN + IF ((vTicketLines + @lines) <= vLinesLimit OR vLinesLimit IS NULL) + AND ((vTicketVolume + @volume) <= vVolumeLimit OR vVolumeLimit IS NULL) 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 - SET pb.liters = vLiters, - pb.`lines` = vLines, - pb.height = vHeight + 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 WHERE pb.ticketFk = vTicketFk; UPDATE tTrain tt @@ -235,13 +276,17 @@ BEGIN tt.height LIMIT 1; - -- Si no le encuentra una balda, intentamos darle un carro entero libre - + -- Si no le encuentra una balda adecuada, intentamos darle un carro entero si queda alguno libre IF NOT (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - SELECT wagon INTO vFreeWagonFk - FROM tTrain - GROUP BY wagon - HAVING SUM(IFNULL(ticketFk, 0)) = 0 + 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 ORDER BY wagon LIMIT 1; @@ -250,35 +295,38 @@ BEGIN SET ticketFk = vFirstTicketFk WHERE wagon = vFreeWagonFk; - -- Se anulan el resto de carros libres, - -- máximo un carro con pedido excesivo - - DELETE tt + -- Se anulan el resto de carros libres para que sólo uno lleve un pedido excesivo + 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; + 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; + END IF; + + 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; END IF; END LOOP; - CLOSE vTickets; + CLOSE c1; IF (SELECT COUNT(*) FROM tTrain WHERE ticketFk) THEN - -- Se obtiene nº de colección - - INSERT INTO collection - SET itemPackingTypeFk = vItemPackingTypeFk, - trainFk = vTrainFk, - wagons = vWagons, - warehouseFk = vWarehouseFk; - - SELECT LAST_INSERT_ID() INTO vCollectionFk; + UPDATE collection c + JOIN state st ON st.code = 'ON_PREPARATION' + SET c.stateFk = st.id + WHERE c.id = 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 @@ -286,34 +334,37 @@ BEGIN ORDER BY tt.wagon, tt.shelve; -- Actualiza el estado de los tickets - - CALL collection_setState(vCollectionFk, vStateCode); + 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 collection_mergeSales(vCollectionFk); + CALL sales_mergeByCollection(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 - SET vCollectionFk = NULL; + DELETE FROM `collection` + WHERE id = vCollectionFk; + SET vCollectionFk = NULL; END IF; + DO RELEASE_LOCK(vLockName); + DROP TEMPORARY TABLE tTrain, tmp.productionBuffer; diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index de4339454..a654d35a3 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -99,7 +99,7 @@ proc: BEGIN LEFT JOIN `zone` z ON z.id = t.zoneFk LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk AND DATE(t.shipped) = zc.dated - LEFT JOIN ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN ticketParking tp ON tp.ticketFk = t.id LEFT JOIN parking pk ON pk.id = tp.parkingFk WHERE t.warehouseFk = vWarehouseFk AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); @@ -124,8 +124,8 @@ proc: BEGIN ADD COLUMN `collectionN` INT; UPDATE tmp.productionBuffer pb - JOIN tmp.ticket_problems tp ON tp.ticketFk = pb.ticketFk - SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage, ''), + JOIN tmp.ticket_problems tp ON tp.ticketFk = pb.ticketFk + SET pb.problem = TRIM(CAST(CONCAT( IFNULL(tp.itemShortage, ''), IFNULL(tp.itemDelay, ''), IFNULL(tp.itemLost, ''), IF(tp.isFreezed, ' CONGELADO',''), @@ -141,7 +141,7 @@ proc: BEGIN LEFT JOIN bs.clientNewBorn cnb ON cnb.clientFk = pb.clientFk JOIN productionConfig pc SET pb.problem = TRIM(CAST(CONCAT('NUEVO ', pb.problem) AS CHAR(255))) - WHERE (cnb.clientFk IS NULL OR cnb.isRookie) + WHERE (cnb.clientFk IS NULL OR cnb.isRookie) AND pc.rookieDays; -- Líneas y volumen por ticket @@ -268,10 +268,12 @@ proc: BEGIN UPDATE tmp.productionBuffer pb JOIN sale s ON s.ticketFk = pb.ticketFk JOIN item i ON i.id = s.itemFk - JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk - AND lb.item_id = s.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN cache.last_buy lb ON lb.warehouse_id = vWarehouseFk AND lb.item_id = s.itemFk JOIN buy b ON b.id = lb.buy_id JOIN packaging p ON p.id = b.packagingFk + JOIN productionConfig pc SET pb.hasPlantTray = TRUE WHERE p.isPlantTray AND s.quantity >= b.packing @@ -285,4 +287,4 @@ proc: BEGIN tItemShelvingStock, tItemPackingType; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_mergeSales.sql b/db/routines/vn/procedures/ticket_mergeSales.sql index 2dc3a39da..28b2dc1c0 100644 --- a/db/routines/vn/procedures/ticket_mergeSales.sql +++ b/db/routines/vn/procedures/ticket_mergeSales.sql @@ -3,47 +3,41 @@ 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 + 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; + GROUP BY s.itemFk, s.price, s.discount; - SELECT COUNT(*) INTO vHasSalesToMerge - FROM tSalesToPreserve; + START TRANSACTION; - IF vHasSalesToMerge THEN - UPDATE sale s - JOIN tSalesToPreserve stp ON stp.id = s.id - SET s.quantity = newQuantity; + UPDATE sale s + JOIN tSalesToPreserve stp ON stp.id = s.id + SET s.quantity = newQuantity + WHERE s.ticketFk = vSelf; - DELETE s - FROM sale s - JOIN tSalesToPreserve stp ON stp.itemFk = s.itemFk - WHERE s.ticketFk = vSelf - AND s.id <> stp.id; - END IF; + 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 = vSelf + AND stp.id IS NULL + AND it.isMergeable; 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 c0b3d9625..0ee865af5 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -3,87 +3,124 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki vSelf INT, vOriginalItemPackingTypeFk VARCHAR(1) ) -proc: BEGIN +BEGIN /** - * 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. + * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id inicial para el tipo propuesto. * * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo empaquetado al que se mantiene el ticket original + * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vDone INT DEFAULT FALSE; - DECLARE vHasItemPackingType BOOL; - DECLARE vItemPackingTypeFk INT; + DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; + DECLARE vPackingTypesToSplit INT; + DECLARE vDone INT DEFAULT FALSE; - DECLARE vItemPackingTypes CURSOR FOR - SELECT DISTINCT itemPackingTypeFk - FROM tSalesToMove; + DECLARE vSaleGroup CURSOR FOR + SELECT itemPackingTypeFk + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL + ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - 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; + 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( ticketFk INT, itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY - SELECT vSelf, vOriginalItemPackingTypeFk; + ) ENGINE = MEMORY; - IF NOT vHasItemPackingType THEN - LEAVE proc; - END IF; + 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; - CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( - ticketFk INT, - saleFk INT, - itemPackingTypeFk INT - ) ENGINE=MEMORY; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vSelf, vItemPackingTypeFk); - INSERT INTO tSalesToMove (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; + l: LOOP + SET vDone = FALSE; + FETCH vSaleGroup INTO vItemPackingTypeFk; - OPEN vItemPackingTypes; + IF vDone THEN + LEAVE l; + END IF; - l: LOOP - SET vDone = FALSE; - FETCH vItemPackingTypes INTO vItemPackingTypeFk; + CALL ticket_Clone(vSelf, vNewTicketFk); - IF vDone THEN - LEAVE l; - END IF; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vNewTicketFk, vItemPackingTypeFk); + END LOOP; - CALL ticket_Clone(vSelf, vNewTicketFk); + CLOSE vSaleGroup; - UPDATE tSalesToMove - SET ticketFk = vNewTicketFk - WHERE itemPackingTypeFk = vItemPackingTypeFk; + 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; - END LOOP; + 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; - CLOSE vItemPackingTypes; + SELECT itemPackingTypeFk INTO vItemPackingTypeFk + FROM tSaleGroup sg + WHERE sg.itemPackingTypeFk IS NOT NULL + ORDER BY sg.itemPackingTypeFk + LIMIT 1; - UPDATE sale s - JOIN tSalesToMove stm ON stm.saleFk = s.id - SET s.ticketFk = stm.ticketFk - WHERE stm.ticketFk; + 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; - INSERT INTO tmp.ticketIPT - SELECT ticketFk, itemPackingTypeFk - FROM tSalesToMove - GROUP BY ticketFk; + COMMIT; - DROP TEMPORARY TABLE tSalesToMove; + DROP TEMPORARY TABLE + tSale, + tSaleGroup; END$$ DELIMITER ; From a65700abed81fff506d0dfa00d33d9bcadc2be8c Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 20 Sep 2024 10:37:36 +0200 Subject: [PATCH 16/46] feat: refs #8000 modificar comentario --- db/versions/11248-azureOrchid/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11248-azureOrchid/00-firstScript.sql b/db/versions/11248-azureOrchid/00-firstScript.sql index b13a726a8..a4a4bd740 100644 --- a/db/versions/11248-azureOrchid/00-firstScript.sql +++ b/db/versions/11248-azureOrchid/00-firstScript.sql @@ -1,3 +1,3 @@ ALTER TABLE vn.`zone` - ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos reclinados que esa agencia puede transportar', + ADD COLUMN IF NOT EXISTS itemMaxLength int(11) NULL COMMENT 'Longitud maxima para articulos acostados que esa agencia puede transportar', MODIFY COLUMN itemMaxSize int(11) DEFAULT NULL NULL COMMENT 'Altura maxima de los articulos que esa agencia puede transportar'; From fb1e77f9c4c931cb0ac1242a1c58d14b5da6e90c Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 20 Sep 2024 11:06:38 +0200 Subject: [PATCH 17/46] fix: refs #7404 fix back data source --- db/dump/fixtures.before.sql | 5 +- ...Traslation.sql => item_calculateStock.sql} | 10 ++- .../vn/procedures/stockBought_calculate.sql | 59 ++++++++++------- .../vn/procedures/stockBuyedByWorker.sql | 2 +- db/routines/vn/procedures/stockBuyed_add.sql | 2 +- .../methods/stock-bought/getStockBought.js | 9 ++- .../stock-bought/getStockBoughtDetail.js | 65 ++++++++++--------- 7 files changed, 83 insertions(+), 69 deletions(-) rename db/routines/vn/procedures/{stockTraslation.sql => item_calculateStock.sql} (71%) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c0d151b2c..a3d5067ca 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1506,7 +1506,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (7, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 4, 1, 50.00, 500, 'seventh travel', 2, 1, 7), (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10), (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10), - (11, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4); + (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4), + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `isRaid`, `evaNotes`) VALUES @@ -1520,7 +1521,7 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, 1, ''), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, 1, ''), (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, 1, ''), - (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 1, 1, ''); + (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, 0, ''); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) VALUES (2, 4, 1); diff --git a/db/routines/vn/procedures/stockTraslation.sql b/db/routines/vn/procedures/item_calculateStock.sql similarity index 71% rename from db/routines/vn/procedures/stockTraslation.sql rename to db/routines/vn/procedures/item_calculateStock.sql index 4cc64fe3b..976ac10e4 100644 --- a/db/routines/vn/procedures/stockTraslation.sql +++ b/db/routines/vn/procedures/item_calculateStock.sql @@ -1,15 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`stockTraslation`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`item_calculateStock`( vDated DATE ) BEGIN /** - * Calcula el stock del almacén de subasta desde FechaInventario hasta vDated - * sin tener en cuenta las salidas del mismo dia vDated - * para ver el transporte a reservar + * Calculate the stock of the auction warehouse from the inventory date to vDated * - * @param vDated Fecha hasta la cual calcula el stock - * @return tmp.item + * @param vDated Date to calculate the stock. + * @return tmp.item, tmp.buyUltimate */ DECLARE vAuctionWarehouseFk INT; diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index 6eabe015c..10048e76d 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -1,12 +1,16 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`() -BEGIN +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`( + vDated DATE +)BEGIN /** - * Inserts the purchase volume per buyer - * into stockBought according to the current date. + * Calculate the stock of the auction warehouse from the inventory date to vDated + * without taking into account the outputs of the same day vDated + * + * @param vDated Date to calculate the stock. */ - DECLARE vDated DATE; - SET vDated = util.VN_CURDATE(); + IF vDated < util.VN_CURDATE() THEN + CALL util.error('The date to calculate the stock is less than the current date'); + END IF; CREATE OR REPLACE TEMPORARY TABLE tStockBought SELECT workerFk, reserve @@ -16,26 +20,27 @@ BEGIN DELETE FROM stockBought WHERE dated = vDated; - INSERT INTO stockBought (workerFk, bought, dated) + CALL item_calculateStock(vDated); + + INSERT INTO stockBought(workerFk, bought, dated) SELECT it.workerFk, - ROUND(SUM( - (ac.conversionCoefficient * - (b.quantity / b.packing) * - buy_getVolume(b.id) - ) / (vc.trolleyM3 * 1000000) - ), 1), + SUM( + (ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / vc.palletM3 / 1000000 bought, vDated - FROM entry e - JOIN travel t ON t.id = e.travelFk - JOIN warehouse w ON w.id = t.warehouseInFk - JOIN buy b ON b.entryFk = e.id - JOIN item i ON i.id = b.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN auctionConfig ac + FROM itemType it + JOIN item i ON i.typeFk = it.id + LEFT JOIN tmp.item ti ON ti.itemFk = i.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN warehouse wh ON wh.code = 'VNH' + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = wh.id + JOIN buy b ON b.id = bu.buyFk JOIN volumeConfig vc - WHERE t.shipped = vDated - AND t.warehouseInFk = ac.warehouseFk - GROUP BY it.workerFk; + WHERE ic.display + GROUP BY it.workerFk + HAVING bought; UPDATE stockBought s JOIN tStockBought ts ON ts.workerFk = s.workerFk @@ -45,8 +50,12 @@ BEGIN INSERT INTO stockBought (workerFk, reserve, dated) SELECT ts.workerFk, ts.reserve, vDated FROM tStockBought ts - WHERE ts.workerFk NOT IN (SELECT workerFk FROM stockBought WHERE dated = vDated); + WHERE ts.workerFk NOT IN ( + SELECT workerFk + FROM stockBought + WHERE dated = vDated + ); - DROP TEMPORARY TABLE tStockBought; + DROP TEMPORARY TABLE tStockBought, tmp.item, tmp.buyUltimate; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/stockBuyedByWorker.sql b/db/routines/vn/procedures/stockBuyedByWorker.sql index a0bad78d4..13bda0133 100644 --- a/db/routines/vn/procedures/stockBuyedByWorker.sql +++ b/db/routines/vn/procedures/stockBuyedByWorker.sql @@ -23,7 +23,7 @@ BEGIN WHERE dated = vDated AND userFk = vWorker; - CALL stockTraslation(vDated); + CALL item_calculateStock(vDated); INSERT INTO stockBuyed(userFk, buyed, `dated`, reserved, requested, description) SELECT it.workerFk, diff --git a/db/routines/vn/procedures/stockBuyed_add.sql b/db/routines/vn/procedures/stockBuyed_add.sql index 104a2d34d..aab85e7fa 100644 --- a/db/routines/vn/procedures/stockBuyed_add.sql +++ b/db/routines/vn/procedures/stockBuyed_add.sql @@ -18,7 +18,7 @@ BEGIN DELETE FROM stockBuyed WHERE dated = vDated; - CALL stockTraslation(vDated); + CALL item_calculateStock(vDated); INSERT INTO stockBuyed(userFk, buyed, `dated`, description) SELECT it.workerFk, diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js index 94e206ece..d16cf9d14 100644 --- a/modules/entry/back/methods/stock-bought/getStockBought.js +++ b/modules/entry/back/methods/stock-bought/getStockBought.js @@ -29,15 +29,14 @@ module.exports = Self => { dated.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0); - if (dated.getTime() === today.getTime()) - await models.StockBought.rawSql(`CALL vn.stockBought_calculate()`); + if (dated.getTime() >= today.getTime()) + await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]); const filter = { - where: { - dated: dated - }, + where: {dated}, include: [ { + fields: ['workerFk', 'reserve', 'bought'], relation: 'worker', scope: { include: [ diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index 6f09f1f67..2e2ddd79f 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -11,6 +11,7 @@ module.exports = Self => { arg: 'dated', type: 'string', description: 'The date to filter', + required: true, } ], returns: { @@ -24,35 +25,41 @@ module.exports = Self => { }); Self.getStockBoughtDetail = async(workerFk, dated) => { - if (!dated) { - dated = Date.vnNew(); - dated.setHours(0, 0, 0, 0); + const models = Self.app.models; + await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated]); + const tx = await models.Collection.beginTransaction({}); + const options = {transaction: tx}; + let result; + try { + await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], options); + result = await Self.rawSql( + `SELECT b.entryFk entryFk, + i.id itemFk, + i.name itemName, + ti.quantity, + (ac.conversionCoefficient * (ti.quantity / b.packing) * buy_getVolume(b.id)) + / (vc.trolleyM3 * 1000000) volume, + b.packagingFk packagingFk, + b.packing + FROM tmp.item ti + JOIN item i ON i.id = ti.itemFk + JOIN itemType it ON i.typeFk = it.id + JOIN itemCategory ic ON ic.id = it.categoryFk + JOIN worker w ON w.id = it.workerFk + JOIN auctionConfig ac + JOIN tmp.buyUltimate bu ON bu.itemFk = i.id + AND bu.warehouseFk = ac.warehouseFk + JOIN buy b ON b.id = bu.buyFk + JOIN volumeConfig vc + WHERE ic.display + AND w.id = ?`, + [workerFk], options + ); + await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], options); + } catch (e) { + await tx.rollback(); + throw e; } - return Self.rawSql( - `SELECT e.id entryFk, - i.id itemFk, - i.longName itemName, - b.quantity, - ROUND((ac.conversionCoefficient * - (b.quantity / b.packing) * - buy_getVolume(b.id) - ) / (vc.trolleyM3 * 1000000), - 2 - ) volume, - b.packagingFk, - b.packing - FROM entry e - JOIN travel t ON t.id = e.travelFk - JOIN buy b ON b.entryFk = e.id - JOIN item i ON i.id = b.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN worker w ON w.id = it.workerFk - JOIN auctionConfig ac - JOIN volumeConfig vc - WHERE t.warehouseInFk = ac.warehouseFk - AND it.workerFk = ? - AND t.shipped = util.VN_CURDATE()`, - [workerFk] - ); + return result; }; }; From 564d23653cc5fff96dbe40743d7bb05738cb075c Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 20 Sep 2024 13:24:00 +0200 Subject: [PATCH 18/46] fix: acls --- db/versions/11253-limeChico/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/11253-limeChico/00-firstScript.sql diff --git a/db/versions/11253-limeChico/00-firstScript.sql b/db/versions/11253-limeChico/00-firstScript.sql new file mode 100644 index 000000000..b67d8c12d --- /dev/null +++ b/db/versions/11253-limeChico/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Auto-generated SQL script #202409201320 +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Postcode','*','WRITE','ALLOW','ROLE','administrative'); + From 346893455ff3f3c17998ef5e08a48be658337dfc Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 20 Sep 2024 13:38:53 +0200 Subject: [PATCH 19/46] fix: remove comment --- db/versions/11253-limeChico/00-firstScript.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/versions/11253-limeChico/00-firstScript.sql b/db/versions/11253-limeChico/00-firstScript.sql index b67d8c12d..acf1de15c 100644 --- a/db/versions/11253-limeChico/00-firstScript.sql +++ b/db/versions/11253-limeChico/00-firstScript.sql @@ -1,4 +1,3 @@ --- Auto-generated SQL script #202409201320 INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('Postcode','*','WRITE','ALLOW','ROLE','administrative'); From 190c964ec2a2d3e90f168af873bfcf8a4df7852d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 20 Sep 2024 13:50:08 +0200 Subject: [PATCH 20/46] fix: refs#8011 previousSticker_get --- .../vn/procedures/previousSticker_get.sql | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/previousSticker_get.sql b/db/routines/vn/procedures/previousSticker_get.sql index f43a23773..b4b4d1c35 100644 --- a/db/routines/vn/procedures/previousSticker_get.sql +++ b/db/routines/vn/procedures/previousSticker_get.sql @@ -14,13 +14,17 @@ BEGIN DECLARE vTicketFk INT; DECLARE vParkingFk INT; DECLARE vSectorFk INT; - DECLARE vPreviousLines INT; + DECLARE vTicketLines INT; - SELECT s.ticketFk, COUNT(*) - INTO vTicketFk, vPreviousLines - FROM saleGroupDetail sgd - JOIN sale s ON s.id = sgd.saleFk - WHERE sgd.saleGroupFk = vSaleGroupFk; + WITH ticketData AS( + SELECT s.ticketFk + FROM vn.saleGroupDetail sgd + JOIN vn.sale s ON s.id = sgd.saleFk + WHERE sgd.saleGroupFk = vSaleGroupFk + ) + SELECT COUNT(*), s.ticketFk INTO vTicketLines, vTicketFk + FROM vn.sale s + JOIN ticketData td ON td.ticketFk = s.ticketFk; SELECT sg.parkingFk, sc.sectorFk INTO vParkingFk, vSectorFk @@ -40,11 +44,11 @@ BEGIN SELECT sgd.saleGroupFk, t.id ticketFk, - vPreviousLines previousLines, + COUNT(*) previousLines, IF(HOUR(t.shipped), HOUR(t.shipped), HOUR(z.`hour`)) shippingHour, IF(MINUTE(t.shipped), MINUTE(t.shipped), MINUTE(z.`hour`)) shippingMinute , IFNULL(MAX(i.itemPackingTypeFk),'H') itemPackingTypeFk , - COUNT(*) ticketLines, + vTicketLines ticketLines, p.code `location`, sc.description sector FROM sale s From e25415f8207fe218d917781b8fcc44decfe6c3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 20 Sep 2024 13:54:22 +0200 Subject: [PATCH 21/46] fix: refs#8011 previousSticker_get --- db/routines/vn/procedures/previousSticker_get.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/previousSticker_get.sql b/db/routines/vn/procedures/previousSticker_get.sql index b4b4d1c35..ad3dbd1c4 100644 --- a/db/routines/vn/procedures/previousSticker_get.sql +++ b/db/routines/vn/procedures/previousSticker_get.sql @@ -17,7 +17,7 @@ BEGIN DECLARE vTicketLines INT; WITH ticketData AS( - SELECT s.ticketFk + SELECT DISTINCT s.ticketFk FROM vn.saleGroupDetail sgd JOIN vn.sale s ON s.id = sgd.saleFk WHERE sgd.saleGroupFk = vSaleGroupFk From c6d5e2f292248272948a6b801a94ed8c6451d916 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 23 Sep 2024 08:09:24 +0200 Subject: [PATCH 22/46] fix: hotFix backLimit refs #6964 --- modules/item/back/methods/item-shelving/getListItemNewer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js index c4bb3da8b..74c73532a 100644 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -63,8 +63,7 @@ module.exports = Self => { FROM tItemShelving ti JOIN tItemInSector tis ON tis.itemFk = ti.itemFk JOIN vn.productionConfig pc - WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created - LIMIT 10;`, + WHERE ti.created + INTERVAL pc.itemOlderReviewHours HOUR < tis.created;`, [shelvingFk, shelvingFk], myOptions); return result; }; From 459f6601b7553a8518a1841d929200140555dfc6 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 23 Sep 2024 10:02:01 +0200 Subject: [PATCH 23/46] fix: refs #7404 add transaction on detail calculate --- .../stock-bought/getStockBoughtDetail.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js index 2e2ddd79f..3e040d0d3 100644 --- a/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js +++ b/modules/entry/back/methods/stock-bought/getStockBoughtDetail.js @@ -26,12 +26,20 @@ module.exports = Self => { Self.getStockBoughtDetail = async(workerFk, dated) => { const models = Self.app.models; - await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated]); - const tx = await models.Collection.beginTransaction({}); - const options = {transaction: tx}; + const myOptions = {}; + let tx; let result; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + try { - await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], options); + await models.StockBought.rawSql(`CALL vn.item_calculateStock(?)`, [dated], myOptions); result = await Self.rawSql( `SELECT b.entryFk entryFk, i.id itemFk, @@ -53,13 +61,14 @@ module.exports = Self => { JOIN volumeConfig vc WHERE ic.display AND w.id = ?`, - [workerFk], options + [workerFk], myOptions ); - await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], options); + await Self.rawSql(`DROP TEMPORARY TABLE tmp.item, tmp.buyUltimate;`, [], myOptions); + if (tx) await tx.commit(); + return result; } catch (e) { await tx.rollback(); throw e; } - return result; }; }; From 80985fbd56ec1a49bc7214e986e993c4317846cf Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 23 Sep 2024 10:14:09 +0200 Subject: [PATCH 24/46] fix: refs #7404 round data and fix specs --- db/routines/vn/procedures/stockBought_calculate.sql | 8 ++++---- .../back/methods/item/specs/lastEntriesFilter.spec.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index 10048e76d..570ddc0a6 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -24,10 +24,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calcula INSERT INTO stockBought(workerFk, bought, dated) SELECT it.workerFk, - SUM( - (ti.quantity / b.packing) * - buy_getVolume(b.id) - ) / vc.palletM3 / 1000000 bought, + ROUND(SUM( + (ti.quantity / b.packing) * + buy_getVolume(b.id) + ) / vc.palletM3 / 1000000, 1) bought, vDated FROM itemType it JOIN item i ON i.typeFk = it.id diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 00488e534..c67c420d2 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -13,7 +13,7 @@ describe('item lastEntriesFilter()', () => { const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - expect(result.length).toEqual(1); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { @@ -37,7 +37,7 @@ describe('item lastEntriesFilter()', () => { const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - expect(result.length).toEqual(5); + expect(result.length).toEqual(6); await tx.rollback(); } catch (e) { From 31d5a7a6350cbe9c78ed51e8878526854a4fdf07 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 23 Sep 2024 11:53:27 +0200 Subject: [PATCH 25/46] feat: refs #8000 add column --- modules/zone/back/models/zone.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index cf7371053..5b25e40d1 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -42,6 +42,9 @@ }, "itemMaxSize": { "type": "number" + }, + "itemMaxLength": { + "type": "number" } }, "relations": { From 4689681618d554cff5733a50ac789dde094fa92f Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 23 Sep 2024 12:07:06 +0200 Subject: [PATCH 26/46] fix(salix): add administrative ACLs --- db/versions/11256-grayFern/00-firstScript.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 db/versions/11256-grayFern/00-firstScript.sql diff --git a/db/versions/11256-grayFern/00-firstScript.sql b/db/versions/11256-grayFern/00-firstScript.sql new file mode 100644 index 000000000..7dcd380a7 --- /dev/null +++ b/db/versions/11256-grayFern/00-firstScript.sql @@ -0,0 +1,6 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Province','*','WRITE','ALLOW','ROLE','administrative'); + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Town','*','WRITE','ALLOW','ROLE','administrative'); + From 9a0b487d2076e2ff4ba01b044644019fcaded28e Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 23 Sep 2024 13:12:53 +0200 Subject: [PATCH 27/46] feat: refs #8030 new table --- .../11258-silverTulip/00-firstScript.sql | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 db/versions/11258-silverTulip/00-firstScript.sql diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql new file mode 100644 index 000000000..6da8666a2 --- /dev/null +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -0,0 +1,23 @@ +-- Place your SQL code here +-- Place your SQL code here + +CREATE TABLE `priceDelta` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', + `maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size', + `inkFk` varchar(3) DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `fromDated` date DEFAULT NULL, + `toDated` date DEFAULT NULL, + `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', + `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + PRIMARY KEY (`id`), + KEY `priceDelta_itemType_FK` (`itemTypeFk`), + KEY `priceDelta_ink_FK` (`inkFk`), + KEY `priceDelta_producer_FK` (`producerFk`), + CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; \ No newline at end of file From 882f1eb7c29a1edced3bcb5f2e6b002580d755e6 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 23 Sep 2024 15:30:10 +0200 Subject: [PATCH 28/46] feat(travelFilter): add daysOnward --- modules/travel/back/methods/travel/filter.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index 9f26423ce..e24a7659c 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -79,6 +79,10 @@ module.exports = Self => { arg: 'landingHour', type: 'string', description: 'The landing hour' + }, { + arg: 'daysOnward', + type: 'number', + description: 'The days onward' } ], returns: { @@ -92,8 +96,11 @@ module.exports = Self => { }); Self.filter = async(ctx, filter) => { - let conn = Self.dataSource.connector; - let where = buildFilter(ctx.args, (param, value) => { + const conn = Self.dataSource.connector; + const today = Date.vnNew(); + const future = Date.vnNew(); + + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) @@ -109,6 +116,12 @@ module.exports = Self => { return {'t.landed': {gte: value}}; case 'landedTo': return {'t.landed': {lte: value}}; + case 'daysOnward': + + today.setHours(0, 0, 0, 0); + future.setDate(today.getDate() + value); + future.setHours(23, 59, 59, 999); + return {'t.landed': {between: [today, future]}}; case 'id': case 'agencyModeFk': case 'warehouseOutFk': From 3988eb0d971cd55e8db71a4b36837da3be4c71e1 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 24 Sep 2024 07:31:22 +0200 Subject: [PATCH 29/46] fix: refs #7404 back and e2e --- db/routines/vn/procedures/stockBought_calculate.sql | 5 +++-- modules/entry/back/methods/stock-bought/getStockBought.js | 3 +-- .../item/back/methods/item/specs/lastEntriesFilter.spec.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/stockBought_calculate.sql b/db/routines/vn/procedures/stockBought_calculate.sql index 570ddc0a6..0930a86de 100644 --- a/db/routines/vn/procedures/stockBought_calculate.sql +++ b/db/routines/vn/procedures/stockBought_calculate.sql @@ -1,7 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calculate`( vDated DATE -)BEGIN +) +proc: BEGIN /** * Calculate the stock of the auction warehouse from the inventory date to vDated * without taking into account the outputs of the same day vDated @@ -9,7 +10,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`stockBought_calcula * @param vDated Date to calculate the stock. */ IF vDated < util.VN_CURDATE() THEN - CALL util.error('The date to calculate the stock is less than the current date'); + LEAVE proc; END IF; CREATE OR REPLACE TEMPORARY TABLE tStockBought diff --git a/modules/entry/back/methods/stock-bought/getStockBought.js b/modules/entry/back/methods/stock-bought/getStockBought.js index d16cf9d14..c1f99c496 100644 --- a/modules/entry/back/methods/stock-bought/getStockBought.js +++ b/modules/entry/back/methods/stock-bought/getStockBought.js @@ -29,8 +29,7 @@ module.exports = Self => { dated.setHours(0, 0, 0, 0); today.setHours(0, 0, 0, 0); - if (dated.getTime() >= today.getTime()) - await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]); + await models.StockBought.rawSql(`CALL vn.stockBought_calculate(?)`, [dated]); const filter = { where: {dated}, diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index c67c420d2..41a33b911 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,6 +1,6 @@ const {models} = require('vn-loopback/server/server'); describe('item lastEntriesFilter()', () => { - it('should return one entry for the given item', async() => { + it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); const maxDate = Date.vnNew(); From acabd3e15448ae97ab524e8fd8bd8a5e24b7a313 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 08:50:34 +0200 Subject: [PATCH 30/46] feat(catalog_componentCalculate): refs #8030 new component improved The procedure has now the component "bonus", a special price increasing for a group of items Refs: #8030 --- .../procedures/catalog_componentCalculate.sql | 55 +++++++++++++++---- .../11258-silverTulip/00-firstScript.sql | 8 +-- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 7ac383e8f..0b131d7a9 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -25,18 +25,39 @@ BEGIN FROM address WHERE id = vAddressFk; - CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice + CREATE OR REPLACE TEMPORARY TABLE tPriceDelta (INDEX (itemFk)) - ENGINE = MEMORY - SELECT * FROM ( + ENGINE = MEMORY + SELECT i.id itemFk, + SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, + SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing + FROM vn.item i + JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk + JOIN buy b ON b.id = lb.buy_id + JOIN tmp.priceDelta pd + ON pd.itemTypeFk = i.typeFk + AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) + AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`) + AND (pd.inkFk IS NULL OR pd.inkFk = i.inkFk) + AND (pd.originFk IS NULL OR pd.originFk = i.originFk) + AND (pd.producerFk IS NULL OR pd.producerFk = i.producerFk) + AND (pd.warehouseFk IS NULL OR pd.warehouseFk = vWarehouseFk) + WHERE (pd.fromDated IS NULL OR pd.fromDated <= vShipped) + AND (pd.toDated IS NULL OR pd.toDated >= vShipped) + GROUP BY i.id; + + CREATE OR REPLACE TEMPORARY TABLE tSpecialPrice + (INDEX (itemFk)) + ENGINE = MEMORY + SELECT * FROM ( SELECT * - FROM specialPrice - WHERE (clientFk = vClientFk OR clientFk IS NULL) - AND started <= vShipped - AND (ended >= vShipped OR ended IS NULL) - ORDER BY (clientFk = vClientFk) DESC, id DESC - LIMIT 10000000000000000000) t - GROUP BY itemFk; + FROM specialPrice + WHERE (clientFk = vClientFk OR clientFk IS NULL) + AND started <= vShipped + AND (ended >= vShipped OR ended IS NULL) + ORDER BY (clientFk = vClientFk) DESC, id DESC + LIMIT 10000000000000000000) t + GROUP BY itemFk; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketComponentCalculate (PRIMARY KEY (itemFk, warehouseFk)) @@ -108,6 +129,17 @@ BEGIN JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk GROUP BY tc.itemFk, warehouseFk; + -- priceDelta Bonus del comprador a un rango de productos Refs: #8030 + INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) + SELECT + tcb.warehouseFk, + tcb.itemFk, + c.id, + tcb.base * (1 + IFNULL(tpd.ratIncreasing,0)) + IFNULL(tpd.absIncreasing,0) + FROM tmp.ticketComponentBase tcb + JOIN component c ON c.code = 'bonus' + JOIN tPriceDelta tpd ON tpd.itemFk = tcb.itemFk; + -- RECOBRO INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) SELECT tcb.warehouseFk, tcb.itemFk, c2.id, @@ -303,6 +335,7 @@ BEGIN tmp.ticketComponentBase, tmp.ticketComponentRate, tmp.ticketComponentCopy, - tSpecialPrice; + tPriceDelta, + tSpecialPrice; END$$ DELIMITER ; diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql index 6da8666a2..753c279c0 100644 --- a/db/versions/11258-silverTulip/00-firstScript.sql +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -1,7 +1,6 @@ --- Place your SQL code here --- Place your SQL code here +-- vn.priceDelta definition -CREATE TABLE `priceDelta` ( +CREATE OR REPLACE TABLE vn.priceDelta ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemTypeFk` smallint(5) unsigned NOT NULL, `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', @@ -13,6 +12,7 @@ CREATE TABLE `priceDelta` ( `toDated` date DEFAULT NULL, `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + `warehouseFk` smallint(6) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `priceDelta_itemType_FK` (`itemTypeFk`), KEY `priceDelta_ink_FK` (`inkFk`), @@ -20,4 +20,4 @@ CREATE TABLE `priceDelta` ( CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; \ No newline at end of file +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; \ No newline at end of file From a5f3dbc15a583b890c4abbe547563d103b75857f Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 24 Sep 2024 08:55:24 +0200 Subject: [PATCH 31/46] fix: refs #7404 last entries spec --- modules/item/back/methods/item/specs/lastEntriesFilter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 41a33b911..2fd30c2ca 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -22,7 +22,7 @@ describe('item lastEntriesFilter()', () => { } }); - it('should return five entries for the given item', async() => { + it('should return six entries for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2, 1); From fb7208d898278a5e6806b04d51512e26ad19f8b9 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 09:05:30 +0200 Subject: [PATCH 32/46] fix: refs #8030 warehouse filter Warehouse is also needed to make the filter Refs: #8030 --- .../vn/procedures/catalog_componentCalculate.sql | 9 +++++---- db/versions/11258-silverTulip/00-firstScript.sql | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 0b131d7a9..f13675e4b 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -30,10 +30,9 @@ BEGIN ENGINE = MEMORY SELECT i.id itemFk, SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, - SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing + SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing, + pd.warehouseFk FROM vn.item i - JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = vWarehouseFk - JOIN buy b ON b.id = lb.buy_id JOIN tmp.priceDelta pd ON pd.itemTypeFk = i.typeFk AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) @@ -138,7 +137,9 @@ BEGIN tcb.base * (1 + IFNULL(tpd.ratIncreasing,0)) + IFNULL(tpd.absIncreasing,0) FROM tmp.ticketComponentBase tcb JOIN component c ON c.code = 'bonus' - JOIN tPriceDelta tpd ON tpd.itemFk = tcb.itemFk; + JOIN tPriceDelta tpd + ON tpd.itemFk = tcb.itemFk + AND tpd.warehouseFk = tcb.warehouseFk; -- RECOBRO INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql index 753c279c0..6f0f1906a 100644 --- a/db/versions/11258-silverTulip/00-firstScript.sql +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -1,6 +1,8 @@ -- vn.priceDelta definition -CREATE OR REPLACE TABLE vn.priceDelta ( +-- vn.priceDelta definition + +CREATE OR REPLACE TABLE vn.`priceDelta` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemTypeFk` smallint(5) unsigned NOT NULL, `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', @@ -12,12 +14,14 @@ CREATE OR REPLACE TABLE vn.priceDelta ( `toDated` date DEFAULT NULL, `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', - `warehouseFk` smallint(6) unsigned DEFAULT NULL, + `warehouseFk` smallint(6) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `priceDelta_itemType_FK` (`itemTypeFk`), KEY `priceDelta_ink_FK` (`inkFk`), KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; \ No newline at end of file From 91801b19795b7dcc652ef6af87cc152bc5aba37d Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 10:27:27 +0200 Subject: [PATCH 33/46] fix: refs #8030 redmine revision updates Changes recomended by the reviewer Refs: #8030 --- db/routines/vn/procedures/catalog_componentCalculate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index f13675e4b..b1f8e3eea 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -128,7 +128,7 @@ BEGIN JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk GROUP BY tc.itemFk, warehouseFk; - -- priceDelta Bonus del comprador a un rango de productos Refs: #8030 + -- Bonus del comprador a un rango de productos INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) SELECT tcb.warehouseFk, From 5c8f42a3aee541ac7d68aee2245c90daaa7ecd34 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 10:27:27 +0200 Subject: [PATCH 34/46] fix: refs #8030 redmine revision updates Changes recomended by the reviewer Refs: #8030 --- db/routines/vn/procedures/catalog_componentCalculate.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index f13675e4b..7d68661e1 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -32,8 +32,8 @@ BEGIN SUM(IFNULL(pd.absIncreasing,0)) absIncreasing, SUM(IFNULL(pd.ratIncreasing,0)) ratIncreasing, pd.warehouseFk - FROM vn.item i - JOIN tmp.priceDelta pd + FROM item i + JOIN priceDelta pd ON pd.itemTypeFk = i.typeFk AND (pd.minSize IS NULL OR pd.minSize <= i.`size`) AND (pd.maxSize IS NULL OR pd.maxSize >= i.`size`) @@ -128,7 +128,7 @@ BEGIN JOIN tmp.ticketComponentCalculate tcc ON tcc.itemFk = tc.itemFk AND tcc.warehouseFk = tc.warehouseFk GROUP BY tc.itemFk, warehouseFk; - -- priceDelta Bonus del comprador a un rango de productos Refs: #8030 + -- Bonus del comprador a un rango de productos INSERT INTO tmp.ticketComponent(warehouseFk, itemFk, componentFk, cost) SELECT tcb.warehouseFk, From 1be5fced3c424190d6a583236fd9b4862a2d0d0d Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 10:59:15 +0200 Subject: [PATCH 35/46] fix: refs #8030 little bugs --- db/routines/vn/procedures/catalog_componentCalculate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 7d68661e1..33e34f913 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -134,7 +134,7 @@ BEGIN tcb.warehouseFk, tcb.itemFk, c.id, - tcb.base * (1 + IFNULL(tpd.ratIncreasing,0)) + IFNULL(tpd.absIncreasing,0) + (tcb.base * (1 + IFNULL(tpd.ratIncreasing / 100,0))) + IFNULL(tpd.absIncreasing,0) FROM tmp.ticketComponentBase tcb JOIN component c ON c.code = 'bonus' JOIN tPriceDelta tpd From 7e449c5716e517a8ec63b31661caf467a07bbafc Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 11:54:12 +0200 Subject: [PATCH 36/46] fix: refs #8030 bugs --- db/routines/vn/procedures/catalog_componentCalculate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 33e34f913..29707fda5 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -134,7 +134,7 @@ BEGIN tcb.warehouseFk, tcb.itemFk, c.id, - (tcb.base * (1 + IFNULL(tpd.ratIncreasing / 100,0))) + IFNULL(tpd.absIncreasing,0) + IFNULL(tcb.base * tpd.ratIncreasing / 100,0) + IFNULL(tpd.absIncreasing,0) FROM tmp.ticketComponentBase tcb JOIN component c ON c.code = 'bonus' JOIN tPriceDelta tpd From f6e188063404ea95a6b35e25648f71368973f552 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 12:06:08 +0200 Subject: [PATCH 37/46] fix: refs #8030 test change --- db/routines/vn/procedures/catalog_componentCalculate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 29707fda5..d4ce88ca7 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -7,7 +7,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`catalog_componentCalc ) BEGIN /** - * Calcula los componentes de los articulos de tmp.ticketLot + * Calcula los componentes de los articulos de la tabla tmp.ticketLot * * @param vZoneFk para calcular el transporte * @param vAddressFk Consignatario From 4ed6f3591292ea0869f4259645d6a7c60477a3f5 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 24 Sep 2024 12:24:56 +0200 Subject: [PATCH 38/46] build: init version 24.42 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ae7c3764..8f9670903 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.40.0", + "version": "24.42.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 7a343d60e68525ec5169731e7080685c8ab3efb8 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 13:04:03 +0200 Subject: [PATCH 39/46] feat: refs #8030 new fields for vn.priceDelta --- db/versions/11258-silverTulip/00-firstScript.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql index 6f0f1906a..060dbc515 100644 --- a/db/versions/11258-silverTulip/00-firstScript.sql +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -1,8 +1,6 @@ -- vn.priceDelta definition --- vn.priceDelta definition - -CREATE OR REPLACE TABLE vn.`priceDelta` ( +CREATE OR REPLACE TABLE vn.priceDelta ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `itemTypeFk` smallint(5) unsigned NOT NULL, `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', @@ -15,13 +13,17 @@ CREATE OR REPLACE TABLE vn.`priceDelta` ( `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', `warehouseFk` smallint(6) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), KEY `priceDelta_itemType_FK` (`itemTypeFk`), KEY `priceDelta_ink_FK` (`inkFk`), KEY `priceDelta_producer_FK` (`producerFk`), KEY `priceDelta_warehouse_FK` (`warehouseFk`), + KEY `priceDelta_worker_FK` (`editorFk`), CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, - CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; \ No newline at end of file From e33429f47418b8fdf031656cc28381b6ee235e08 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 13:53:24 +0200 Subject: [PATCH 40/46] fix: refs #8030 grant actions to buyer --- db/versions/11258-silverTulip/00-firstScript.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql index 060dbc515..c5b99b34f 100644 --- a/db/versions/11258-silverTulip/00-firstScript.sql +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -26,4 +26,6 @@ CREATE OR REPLACE TABLE vn.priceDelta ( CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; \ No newline at end of file +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; + +GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE priceDelta TO buyer; \ No newline at end of file From 785778e58aea777b65ea2708466575a266767fe3 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 13:56:41 +0200 Subject: [PATCH 41/46] fix: refs #8030 database selected for grant --- db/versions/11258-silverTulip/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11258-silverTulip/00-firstScript.sql b/db/versions/11258-silverTulip/00-firstScript.sql index c5b99b34f..79910fa76 100644 --- a/db/versions/11258-silverTulip/00-firstScript.sql +++ b/db/versions/11258-silverTulip/00-firstScript.sql @@ -28,4 +28,4 @@ CREATE OR REPLACE TABLE vn.priceDelta ( CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; -GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE priceDelta TO buyer; \ No newline at end of file +GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer; \ No newline at end of file From 64376b7503c63231ab923d014243c36341408c24 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 24 Sep 2024 14:04:29 +0200 Subject: [PATCH 42/46] fix: refs #8030 new table version --- db/versions/11260-navyCyca/00-firstScript.sql | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 db/versions/11260-navyCyca/00-firstScript.sql diff --git a/db/versions/11260-navyCyca/00-firstScript.sql b/db/versions/11260-navyCyca/00-firstScript.sql new file mode 100644 index 000000000..0824ea5f7 --- /dev/null +++ b/db/versions/11260-navyCyca/00-firstScript.sql @@ -0,0 +1,32 @@ +-- Place your SQL code here +-- vn.priceDelta definition + +CREATE OR REPLACE TABLE vn.priceDelta ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `itemTypeFk` smallint(5) unsigned NOT NULL, + `minSize` int(10) unsigned DEFAULT NULL COMMENT 'Minimum item.size', + `maxSize` int(10) unsigned DEFAULT NULL COMMENT 'Maximum item.size', + `inkFk` varchar(3) DEFAULT NULL, + `originFk` tinyint(2) unsigned DEFAULT NULL, + `producerFk` mediumint(3) unsigned DEFAULT NULL, + `fromDated` date DEFAULT NULL, + `toDated` date DEFAULT NULL, + `absIncreasing` decimal(10,3) DEFAULT NULL COMMENT 'Absolute increasing of final price', + `ratIncreasing` int(11) DEFAULT NULL COMMENT 'Increasing ratio for the cost price', + `warehouseFk` smallint(6) unsigned NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), + `editorFk` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `priceDelta_itemType_FK` (`itemTypeFk`), + KEY `priceDelta_ink_FK` (`inkFk`), + KEY `priceDelta_producer_FK` (`producerFk`), + KEY `priceDelta_warehouse_FK` (`warehouseFk`), + KEY `priceDelta_worker_FK` (`editorFk`), + CONSTRAINT `priceDelta_ink_FK` FOREIGN KEY (`inkFk`) REFERENCES `ink` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_itemType_FK` FOREIGN KEY (`itemTypeFk`) REFERENCES `itemType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_producer_FK` FOREIGN KEY (`producerFk`) REFERENCES `producer` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_warehouse_FK` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE, + CONSTRAINT `priceDelta_worker_FK` FOREIGN KEY (`editorFk`) REFERENCES `worker` (`id`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Defines the increasing o decreasing for ranges of items'; + +GRANT INSERT, SELECT, UPDATE, DELETE ON TABLE vn.priceDelta TO buyer; \ No newline at end of file From 98f33807dd743868e41b1d99194c71feafb9916d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 24 Sep 2024 16:48:48 +0200 Subject: [PATCH 43/46] fix: updateAvailable refs #6861 --- .../vn/procedures/clearShelvingList.sql | 8 --- .../procedures/itemShelvingMakeFromDate.sql | 58 ------------------- .../itemShelvingPlacementSupplyAdd.sql | 20 ------- .../vn/procedures/itemShelvingSale_Add.sql | 3 +- .../itemShelving_selfConsumption.sql | 9 +-- .../vn/procedures/itemShelving_transfer.sql | 3 +- db/routines/vn/procedures/item_devalueA2.sql | 3 +- 7 files changed, 11 insertions(+), 93 deletions(-) delete mode 100644 db/routines/vn/procedures/clearShelvingList.sql delete mode 100644 db/routines/vn/procedures/itemShelvingMakeFromDate.sql delete mode 100644 db/routines/vn/procedures/itemShelvingPlacementSupplyAdd.sql diff --git a/db/routines/vn/procedures/clearShelvingList.sql b/db/routines/vn/procedures/clearShelvingList.sql deleted file mode 100644 index 1ba726e85..000000000 --- a/db/routines/vn/procedures/clearShelvingList.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`clearShelvingList`(vShelvingFk VARCHAR(8)) -BEGIN - UPDATE vn.itemShelving - SET visible = 0 - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk COLLATE utf8_unicode_ci; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingMakeFromDate.sql b/db/routines/vn/procedures/itemShelvingMakeFromDate.sql deleted file mode 100644 index 4918d55e1..000000000 --- a/db/routines/vn/procedures/itemShelvingMakeFromDate.sql +++ /dev/null @@ -1,58 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingMakeFromDate`(IN `vShelvingFk` VARCHAR(8), IN `vBarcode` VARCHAR(22), IN `vQuantity` INT, IN `vPackagingFk` VARCHAR(10), IN `vGrouping` INT, IN `vPacking` INT, IN `vWarehouseFk` INT, `vCreated` VARCHAR(22)) -BEGIN - - DECLARE vItemFk INT; - - SELECT vn.barcodeToItem(vBarcode) INTO vItemFk; - - SELECT itemFk INTO vItemFk - FROM vn.buy b - WHERE b.id = vItemFk; - - IF (SELECT COUNT(*) FROM vn.shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN - - INSERT IGNORE INTO vn.parking(`code`) VALUES(vShelvingFk); - INSERT INTO vn.shelving(`code`, parkingFk) - SELECT vShelvingFk, id - FROM vn.parking - WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - - IF (SELECT COUNT(*) FROM vn.itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN - - UPDATE vn.itemShelving - SET visible = visible+vQuantity, - created = vCreated - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking; - - ELSE - CALL cache.last_buy_refresh(FALSE); - INSERT INTO itemShelving( itemFk, - shelvingFk, - visible, - created, - `grouping`, - packing, - packagingFk) - SELECT vItemFk, - vShelvingFk, - vQuantity, - vCreated, - IF(vGrouping = 0, IFNULL(b.packing, vPacking), vGrouping) `grouping`, - IF(vPacking = 0, b.packing, vPacking) packing, - IF(vPackagingFk = '', b.packagingFk, vPackagingFk) packaging - FROM vn.item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingPlacementSupplyAdd.sql b/db/routines/vn/procedures/itemShelvingPlacementSupplyAdd.sql deleted file mode 100644 index 085a3fe4b..000000000 --- a/db/routines/vn/procedures/itemShelvingPlacementSupplyAdd.sql +++ /dev/null @@ -1,20 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelvingPlacementSupplyAdd`(vItemShelvingFk INT, vItemPlacementSupplyFk INT, vQuantity INT) -BEGIN - - INSERT INTO vn.itemShelvingPlacementSupply( itemShelvingFk, - itemPlacementSupplyFk, - quantity, - userFk) - VALUES (vItemShelvingFk, - vItemPlacementSupplyFk, - vQuantity, - getUser()); - - UPDATE vn.itemShelving - SET visible = visible - vQuantity - WHERE id = vItemShelvingFk; - - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_Add.sql b/db/routines/vn/procedures/itemShelvingSale_Add.sql index 05b6b9d45..c00f25150 100644 --- a/db/routines/vn/procedures/itemShelvingSale_Add.sql +++ b/db/routines/vn/procedures/itemShelvingSale_Add.sql @@ -18,7 +18,8 @@ BEGIN getUser()); UPDATE itemShelving - SET visible = visible - vQuantity + SET visible = visible - vQuantity, + available = available - vQuantity WHERE id = vItemShelvingFk; UPDATE vn.saleTracking diff --git a/db/routines/vn/procedures/itemShelving_selfConsumption.sql b/db/routines/vn/procedures/itemShelving_selfConsumption.sql index 25ff2363c..083d8d74c 100644 --- a/db/routines/vn/procedures/itemShelving_selfConsumption.sql +++ b/db/routines/vn/procedures/itemShelving_selfConsumption.sql @@ -6,12 +6,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`itemShelving_selfCons ) BEGIN /** - * Leave the indicated amount on the shelf + * Leave the indicated amount on the shelve * and create a ticket with the difference. * - * @param vShelvingFk id of the shelf where the item is located. + * @param vShelvingFk id of the shelve where the item is located. * @param vItemFk article of which the self-consumption ticket is to be created. - * @param vQuantity amount that will stay on the shelf + * @param vQuantity amount that will stay on the shelve */ DECLARE vVisible INT; DECLARE vClientFk INT; @@ -80,7 +80,8 @@ BEGIN WHERE id = vItemFk; UPDATE itemShelving - SET visible = IF(id = vItemShelvingFk, vQuantity, 0) + SET visible = IF(id = vItemShelvingFk, vQuantity, 0), + available = IF(id = vItemShelvingFk, vQuantity, 0) WHERE shelvingFk = vShelvingFk AND itemFk = vItemFk; diff --git a/db/routines/vn/procedures/itemShelving_transfer.sql b/db/routines/vn/procedures/itemShelving_transfer.sql index 3597da7e1..95d70227f 100644 --- a/db/routines/vn/procedures/itemShelving_transfer.sql +++ b/db/routines/vn/procedures/itemShelving_transfer.sql @@ -31,7 +31,8 @@ BEGIN IF vNewItemShelvingFk THEN UPDATE itemShelving ish JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk - SET ish.visible = ish.visible + ish2.visible + SET ish.visible = ish.visible + ish2.visible, + ish.available = ish.available + ish2.available WHERE ish.id = vNewItemShelvingFk; DELETE FROM itemShelving diff --git a/db/routines/vn/procedures/item_devalueA2.sql b/db/routines/vn/procedures/item_devalueA2.sql index 44ae306ec..d0178f6a7 100644 --- a/db/routines/vn/procedures/item_devalueA2.sql +++ b/db/routines/vn/procedures/item_devalueA2.sql @@ -303,7 +303,8 @@ BEGIN WHERE id = vTargetItemShelvingFk; ELSE UPDATE itemShelving - SET visible = vCurrentVisible - vQuantity + SET visible = vCurrentVisible - vQuantity, + available = GREATEST(0, available - vQuantity) WHERE id = vTargetItemShelvingFk; END IF; From b7767887141c4e3f63a1f5bce42fd1288914f07d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 25 Sep 2024 08:35:15 +0200 Subject: [PATCH 44/46] feat: refs #7855 delete isChecked --- db/versions/11264-turquoisePaniculata/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11264-turquoisePaniculata/00-firstScript.sql diff --git a/db/versions/11264-turquoisePaniculata/00-firstScript.sql b/db/versions/11264-turquoisePaniculata/00-firstScript.sql new file mode 100644 index 000000000..9115e1460 --- /dev/null +++ b/db/versions/11264-turquoisePaniculata/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here + +ALTER TABLE dipole.expedition_PrintOut DROP COLUMN IF EXISTS isChecked; From eb85181ea06d9fe8d5052c73cb7f7c9d17c9c2a8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 25 Sep 2024 08:43:38 +0200 Subject: [PATCH 45/46] feat: refs #7855 delete isChecked --- db/versions/11264-turquoisePaniculata/00-firstScript.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/versions/11264-turquoisePaniculata/00-firstScript.sql b/db/versions/11264-turquoisePaniculata/00-firstScript.sql index 9115e1460..8ca3df265 100644 --- a/db/versions/11264-turquoisePaniculata/00-firstScript.sql +++ b/db/versions/11264-turquoisePaniculata/00-firstScript.sql @@ -1,3 +1 @@ --- Place your SQL code here - ALTER TABLE dipole.expedition_PrintOut DROP COLUMN IF EXISTS isChecked; From aadce7971b60ebbd6b8480a4c921480a3183ff62 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 25 Sep 2024 12:06:50 +0200 Subject: [PATCH 46/46] fix: translation --- loopback/locale/es.json | 4 ++-- loopback/locale/pt.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8b443d96b..b9933f596 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -366,11 +366,11 @@ "The invoices have been created but the PDFs could not be generated": "Se ha facturado pero no se ha podido generar el PDF", "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", "Payment method is required": "El método de pago es obligatorio", - "Cannot send mail": "Não é possível enviar o email", + "Cannot send mail": "No se pudo enviar el correo", "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", "The entry not have stickers": "La entrada no tiene etiquetas", "Too many records": "Demasiados registros", "Original invoice not found": "Factura original no encontrada", "The entry has no lines or does not exist": "La entrada no tiene lineas o no existe" -} \ No newline at end of file +} diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 6425db9ed..a6a65710f 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -360,6 +360,6 @@ "It was not able to create the invoice": "Não foi possível criar a fatura", "The invoices have been created but the PDFs could not be generated": "Foi faturado, mas o PDF não pôde ser gerado", "It has been invoiced but the PDF of refund not be generated": "Foi faturado mas não foi gerado o PDF do reembolso", - "Original invoice not found": "Fatura original não encontrada" - + "Original invoice not found": "Fatura original não encontrada", + "Cannot send mail": "Não é possível enviar o email" }