From 7f563f99bbe3254b5d2170b98618e1d52a4e241c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 31 Jan 2024 07:11:03 +0100 Subject: [PATCH 001/114] refs #5890 feat:reserves --- .../vn/events/itemShelvingSale_doReserve.sql | 8 + .../collection_addWithReservation.sql | 87 +++++++ .../vn/procedures/collection_getAssigned.sql | 77 ++++++ .../itemShelvingSale_addByCollection.sql | 51 ++++ .../procedures/itemShelvingSale_addBySale.sql | 100 +++++++ .../procedures/itemShelvingSale_doReserve.sql | 52 ++++ .../itemShelvingSale_setQuantity.sql | 244 +++++++++--------- .../itemShelvingSale_setSaleGroup.sql | 34 +++ .../procedures/itemShelvingSale_unpicked.sql | 60 +++++ .../vn/procedures/itemShelvingTransfer.sql | 89 ++++--- .../vn/procedures/itemShelving_add.sql | 125 +++++---- .../vn/triggers/itemShelving_AFTER_INSERT.sql | 27 ++ .../vn/triggers/itemShelving_AFTER_UPDATE.sql | 16 ++ .../triggers/itemShelving_BEFORE_INSERT.sql | 10 + db/versions/10852-pinkOak/00-firstScript.sql | 23 ++ 15 files changed, 777 insertions(+), 226 deletions(-) create mode 100644 db/routines/vn/events/itemShelvingSale_doReserve.sql create mode 100644 db/routines/vn/procedures/collection_addWithReservation.sql create mode 100644 db/routines/vn/procedures/collection_getAssigned.sql create mode 100644 db/routines/vn/procedures/itemShelvingSale_addByCollection.sql create mode 100644 db/routines/vn/procedures/itemShelvingSale_addBySale.sql create mode 100644 db/routines/vn/procedures/itemShelvingSale_doReserve.sql create mode 100644 db/routines/vn/procedures/itemShelvingSale_setSaleGroup.sql create mode 100644 db/routines/vn/procedures/itemShelvingSale_unpicked.sql create mode 100644 db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql create mode 100644 db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql create mode 100644 db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql create mode 100644 db/versions/10852-pinkOak/00-firstScript.sql diff --git a/db/routines/vn/events/itemShelvingSale_doReserve.sql b/db/routines/vn/events/itemShelvingSale_doReserve.sql new file mode 100644 index 000000000..228886556 --- /dev/null +++ b/db/routines/vn/events/itemShelvingSale_doReserve.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`itemShelvingSale_doReserve` + ON SCHEDULE EVERY 15 SECOND + STARTS '2023-10-16 00:00:00' + ON COMPLETION PRESERVE + ENABLE +DO CALL vn.itemShelvingSale_doReserve$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql new file mode 100644 index 000000000..ea2632b05 --- /dev/null +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -0,0 +1,87 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithReservation`( + vItemFk INT, + vQuantity INT, + vTicketFk INT +) +BEGIN +/** + * En el ámbito de las colecciones se añade una línea de sale a un ticket + * de una colección en caso de tener disponible y se realiza la reserva. + * + * @param vItemFk id of item + * @param vQuantity quantity to be added to the ticket + * @param vTicketFk ticket to which the sales line is added + */ + DECLARE vWarehouseFk INT; + DECLARE vCacheAvailableFk INT; + DECLARE vAvailable INT; + DECLARE vSaleFk INT; + DECLARE vConcept VARCHAR(50); + DECLARE vItemName VARCHAR(50); + DECLARE vHasThrow BOOLEAN DEFAULT FALSE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + SELECT t.warehouseFk INTO vWarehouseFk + FROM ticket t + JOIN ticketCollection tc ON tc.ticketFk = t.id + WHERE t.id = vTicketFk; + + CALL cache.available_refresh( + vCacheAvailableFk, + FALSE, + vWarehouseFk, + util.VN_CURDATE()); + + SELECT available INTO vAvailable + FROM cache.available + WHERE calc_id = vCacheAvailableFk + AND item_id = vItemFk; + + IF vAvailable < vQuantity THEN + SET vHasThrow = TRUE; + SELECT vAvailable, vQuantity; + ELSE + START TRANSACTION; + + SELECT `name`, + CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) + INTO vItemName, vConcept + FROM item + WHERE id = vItemFk; + + INSERT INTO ticketLog + SET originFk = vTicketFk, + userFk = getUser(), + `action` = 'update', + `description` = CONCAT('Añadido articulo ', vItemName, ' cantidad:', vQuantity); + + INSERT INTO sale + SET itemFk = vItemFk, + ticketFk = vTicketFk, + concept = vConcept, + quantity = vQuantity, + isAdded = TRUE; + + SELECT LAST_INSERT_ID() INTO vSaleFk; + + CALL sale_calculateComponent(vSaleFk, NULL); + CALL itemShelvingSale_addBySale(vSaleFk); + + IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN + SET vHasThrow = TRUE; + END IF; + END IF; + + IF vHasThrow THEN + CALL util.throw("No hay disponibilidad para el artículo seleccionado"); + ELSE + COMMIT; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql new file mode 100644 index 000000000..dead563ac --- /dev/null +++ b/db/routines/vn/procedures/collection_getAssigned.sql @@ -0,0 +1,77 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getAssigned`( + vUserFk INT, + OUT vCollectionFk INT) +proc:BEGIN +/* Comprueba si existen colecciones libres que se ajustan al perfil del usuario + * y le asigna la más antigua. + * Añade un registro al semillero de colecciones y hace la reserva para la colección + * @param vUserFk Id de usuario + * @param vCollectionFk Id de colección + */ + DECLARE vHasTooMuchCollections BOOL; + DECLARE vLockTime INT DEFAULT 15; + + -- Si hay colecciones sin terminar, sale del proceso + CALL collection_get(vUserFk); + + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 + INTO vHasTooMuchCollections + FROM tCollection + JOIN productionConfig pc ; + + DROP TEMPORARY TABLE tCollection; + + IF vHasTooMuchCollections THEN + CALL util.throw('Hay colecciones pendientes'); + LEAVE proc; + END IF; + + IF NOT GET_LOCK('collection_getAssigned', vLockTime) THEN + LEAVE proc; + END IF; + + -- Se eliminan las colecciones sin asignar que estan obsoletas + INSERT INTO ticketTracking(stateFk, ticketFk) + SELECT s.id, tc.ticketFk + FROM collection c + JOIN ticketCollection tc ON tc.collectionFk = c.id + JOIN state s ON s.code = 'PRINTED_AUTO' + JOIN productionConfig pc + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; + + DELETE c + FROM collection c + JOIN productionConfig pc + WHERE c.workerFk IS NULL + AND TIMEDIFF(util.VN_NOW(), c.created) > pc.maxNotAssignedCollectionLifeTime; + + -- Se añade registro al semillero + INSERT INTO collectionHotbed + SET userFk = vUserFk; + + -- Comprueba si hay colecciones disponibles que se ajustan a su configuracion + SELECT MIN(c.id) INTO vCollectionFk + FROM collection c + JOIN operator o ON (o.itemPackingTypeFk = c.itemPackingTypeFk + OR c.itemPackingTypeFk IS NULL) + AND o.numberOfWagons = c.wagons + AND o.trainFk = c.trainFk + AND o.warehouseFk = c.warehouseFk + AND c.workerFk IS NULL + WHERE o.workerFk = vUserFk; + + IF vCollectionFk IS NULL THEN + CALL collection_new(vUserFk, vCollectionFk); + END IF; + + UPDATE collection + SET workerFk = vUserFk + WHERE id = vCollectionFk; + + CALL itemShelvingSale_addByCollection(vCollectionFk); + + DO RELEASE_LOCK('collection_getAssigned'); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql new file mode 100644 index 000000000..4e57fed0b --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql @@ -0,0 +1,51 @@ + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addByCollection`( + vCollectionFk INT(11) +) +BEGIN +/** + * Guarda la ubicación para el contenido de una colección + * + * @param vCollectionFk Identificador de collection + */ + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSales CURSOR FOR + WITH sales AS ( + SELECT s.id saleFk, s.quantity, SUM(IFNULL(iss.quantity, 0)) quantityReserved + FROM vn.ticketCollection tc + JOIN vn.sale s ON s.ticketFk = tc.ticketFk + LEFT JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + WHERE tc.collectionFk = vCollectionFk + GROUP BY s.id + HAVING quantity <> quantityReserved + ), trackedSales AS ( + SELECT sa.saleFk + FROM sales sa + JOIN vn.saleTracking st ON st.saleFk = sa.saleFk + JOIN vn.`state` s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1 + GROUP BY sa.saleFk + ) SELECT s.saleFk + FROM sales s + LEFT JOIN trackedSales ts ON ts.saleFk = s.saleFk + WHERE ts.saleFk IS NULL; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk); + END LOOP; + CLOSE vSales; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql new file mode 100644 index 000000000..3ad581b15 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -0,0 +1,100 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_addBySale`( + vSaleFk INT +) +proc: BEGIN +/** + * Reserva una línea de venta en la ubicación más óptima + * + * @param vSaleFk Id de sale + * @param vItemShelvingSaleFk Id de reserva + */ + DECLARE vLastPickingOrder INT; + DECLARE vDone INT DEFAULT FALSE; + DECLARE vItemShelvingFk INT; + DECLARE vAvailable INT; + DECLARE vReservedQuantity INT; + DECLARE vOutStanding INT; + DECLARE vUserFk INT; + + DECLARE vItemShelvingAvailable CURSOR FOR + SELECT ish.id itemShelvingFk, + ish.available + FROM sale s + JOIN itemShelving ish ON ish.itemFk = s.itemFk + JOIN shelving sh ON sh.code = ish.shelvingFk + JOIN parking p ON p.id = sh.parkingFk + JOIN sector sc ON sc.id = p.sectorFk + JOIN productionConfig pc + WHERE s.id = vSaleFk + AND NOT sc.isHideForPickers + ORDER BY s.id, + p.pickingOrder >= vLastPickingOrder, + sh.priority DESC, + ish.available >= s.quantity DESC, + s.quantity MOD ish.grouping = 0 DESC, + ish.grouping DESC, + IF(pc.orderMode = 'Location', p.pickingOrder, ish.created); + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; +/* DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; +*/ + SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)) + INTO vLastPickingOrder, vOutStanding + FROM sale s + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN parking p ON p.id = sh.parkingFk + WHERE s.id = vSaleFk; + + IF vOutStanding <= 0 THEN + LEAVE proc; + END IF; + + SELECT getUser() INTO vUserFk; + + OPEN vItemShelvingAvailable; + l: LOOP + SET vDone = FALSE; + FETCH vItemShelvingAvailable INTO vItemShelvingFk, vAvailable; + + IF vOutStanding <= 0 OR vDone THEN + LEAVE l; + END IF; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + FOR UPDATE; + + SELECT LEAST(vOutStanding, vAvailable) INTO vReservedQuantity; + SET vOutStanding = vOutStanding - vReservedQuantity; + + IF vReservedQuantity > 0 THEN + -- START TRANSACTION; + + INSERT INTO itemShelvingSale( + itemShelvingFk, + saleFk, + quantity, + userFk) + SELECT vItemShelvingFk, + vSaleFk, + vReservedQuantity, + vUserFk; + + UPDATE itemShelving + SET available = available - vReservedQuantity + WHERE id = vItemShelvingFk; + + -- COMMIT; + END IF; + END LOOP; + CLOSE vItemShelvingAvailable; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql new file mode 100644 index 000000000..d7bf4b181 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql @@ -0,0 +1,52 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_doReserve`() +proc: BEGIN +/** + * Genera reservas de la tabla itemShelvingSaleReserv + */ + DECLARE vDone BOOL; + DECLARE vSaleFk INT; + + DECLARE vSales CURSOR FOR + SELECT DISTINCT saleFk FROM tSale; + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); + ROLLBACK; + RESIGNAL; + END; + + IF !GET_LOCK('vn.itemShelvingSale_doReserve', 0) THEN + LEAVE proc; + END IF; + + CREATE OR REPLACE TEMPORARY TABLE tSale + ENGINE = MEMORY + SELECT id, saleFk FROM itemShelvingSaleReserv; + + OPEN vSales; + + myLoop: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL itemShelvingSale_addBySale (vSaleFk); + END LOOP; + + CLOSE vSales; + + DELETE iss FROM itemShelvingSaleReserv iss JOIN tSale s ON s.id = iss.id; + + DROP TEMPORARY TABLE tSale; + + DO RELEASE_LOCK('vn.itemShelvingSale_doReserve'); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index b792534fb..13b8a16ad 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -1,118 +1,126 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`( - vItemShelvingSaleFk INT(10), - vQuantity DECIMAL(10,0), - vIsItemShelvingSaleEmpty BOOLEAN -) -BEGIN -/** - * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity - * en vn.itemShelvingSale y vn.sale.isPicked en caso necesario. - * Si la reserva de la ubicación es fallida, se regulariza la situación - * - * @param vItemShelvingSaleFk Id itemShelvingSaleFK - * @param vQuantity Cantidad real que se ha cogido de la ubicación - * @param vIsItemShelvingSaleEmpty determina si ka ubicación itemShelvingSale se ha - * quedado vacio tras el movimiento - */ - DECLARE vSaleFk INT; - DECLARE vCursorSaleFk INT; - DECLARE vItemShelvingFk INT; - DECLARE vReservedQuantity INT; - DECLARE vRemainingQuantity INT; - DECLARE vItemFk INT; - DECLARE vUserFk INT; - DECLARE vDone BOOLEAN DEFAULT FALSE; - DECLARE vSales CURSOR FOR - SELECT iss.saleFk, iss.userFk - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND s.itemFk = vItemFk - AND NOT iss.isPicked; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - - IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN - CALL util.throw('Booking completed'); - END IF; - - SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk - INTO vItemFk, vSaleFk, vItemShelvingFk - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND NOT iss.isPicked; - - UPDATE itemShelvingSale - SET isPicked = TRUE, - quantity = vQuantity - WHERE id = vItemShelvingSaleFk; - - UPDATE itemShelving - SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0,visible - vQuantity)) - WHERE id = vItemShelvingFk; - - IF vIsItemShelvingSaleEmpty THEN - OPEN vSales; -l: LOOP - SET vDone = FALSE; - FETCH vSales INTO vCursorSaleFk, vUserFk; - IF vDone THEN - LEAVE l; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk, userFk)) - ENGINE = MEMORY - SELECT vCursorSaleFk, vUserFk; - - CALL itemShelvingSale_reserveWhitUser(); - DROP TEMPORARY TABLE tmp.sale; - - END LOOP; - CLOSE vSales; - - DELETE iss - FROM itemShelvingSale iss - JOIN sale s ON s.id = iss.saleFk - WHERE iss.id = vItemShelvingSaleFk - AND s.itemFk = vItemFk - AND NOT iss.isPicked; - END IF; - - SELECT SUM(quantity) INTO vRemainingQuantity - FROM itemShelvingSale - WHERE saleFk = vSaleFk - AND NOT isPicked; - - IF vRemainingQuantity THEN - CALL itemShelvingSale_reserveBySale (vSaleFk, vRemainingQuantity, NULL); - - SELECT SUM(quantity) INTO vRemainingQuantity - FROM itemShelvingSale - WHERE saleFk = vSaleFk - AND NOT isPicked; - - IF NOT vRemainingQuantity <=> 0 THEN - SELECT SUM(iss.quantity) - INTO vReservedQuantity - FROM itemShelvingSale iss - WHERE iss.saleFk = vSaleFk; - - CALL saleTracking_new( - vSaleFk, - TRUE, - vReservedQuantity, - `account`.`myUser_getId`(), - NULL, - 'PREPARED', - TRUE); - - UPDATE sale s - SET s.quantity = vReservedQuantity - WHERE s.id = vSaleFk ; - END IF; - END IF; -END$$ -DELIMITER ; +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setQuantity`( + vItemShelvingSaleFk INT(10), + vQuantity DECIMAL(10,0), + vIsItemShelvingSaleEmpty BOOLEAN +) +BEGIN +/** + * Gestiona la reserva de un itemShelvingFk, actualizando isPicked y quantity + * en itemShelvingSale y sale.isPicked en caso necesario. + * Si la reserva de la ubicación es fallida, se regulariza la situación + * + * @param vItemShelvingSaleFk Id itemShelvingSaleFK + * @param vQuantity Cantidad real que se ha cogido de la ubicación + * @param vIsItemShelvingSaleEmpty determina si la ubicación itemShelvingSale se ha + * quedado vacio tras el movimiento + */ + DECLARE vSaleFk INT; + DECLARE vItemShelvingFk INT; + DECLARE vReservedQuantity INT; + DECLARE vRemainingQuantity INT; + DECLARE vItemFk INT; + DECLARE vTotalQuantity INT; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN + CALL util.throw('Reserva completada'); + END IF; + + SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk, SUM(IFNULL(iss.quantity,0)) + INTO vItemFk, vSaleFk, vItemShelvingFk, vReservedQuantity + FROM itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + WHERE iss.id = vItemShelvingSaleFk + AND NOT iss.isPicked; + + IF vQuantity > vReservedQuantity + OR (vQuantity < vReservedQuantity AND + (NOT vIsItemShelvingSaleEmpty OR vIsItemShelvingSaleEmpty IS NULL)) + OR (vIsItemShelvingSaleEmpty IS NOT NULL AND vQuantity = vReservedQuantity) THEN + CALL util.throw('La cantidad no puede distinta a la reserva'); + END IF; + + + START TRANSACTION; + + + UPDATE itemShelvingSale + SET isPicked = TRUE, + quantity = vQuantity + WHERE id = vItemShelvingSaleFk; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + AND FALSE + FOR UPDATE; + + UPDATE itemShelving + SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0, visible - vQuantity)) + WHERE id = vItemShelvingFk; + + COMMIT; + + IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN + + UPDATE itemShelving + SET visible = 0, + available = 0 + WHERE id = vItemShelvingFk + AND itemFk = vItemFk; + + CALL itemShelvingSale_addBySale(vSaleFk); + + START TRANSACTION; + + INSERT INTO itemShelvingSaleReserv (saleFk) + SELECT DISTINCT iss.saleFk + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + + DELETE iss + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + COMMIT; + + CALL itemShelvingSale_doReserve(); + END IF; + + SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity) + INTO vRemainingQuantity, vTotalQuantity + FROM itemShelvingSale + WHERE saleFk = vSaleFk; + + IF vRemainingQuantity = 0 THEN + START TRANSACTION; + + CALL saleTracking_new( + vSaleFk, + TRUE, + vTotalQuantity, + `account`.`myUser_getId`(), + NULL, + 'PREPARED', + TRUE); + + UPDATE sale s + SET s.quantity = vTotalQuantity, + isPicked = TRUE + WHERE s.id = vSaleFk; + + COMMIT; + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_setSaleGroup.sql b/db/routines/vn/procedures/itemShelvingSale_setSaleGroup.sql new file mode 100644 index 000000000..911034ed1 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_setSaleGroup.sql @@ -0,0 +1,34 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setSaleGroup`( + vSaleGroupFk INT(10) +) +BEGIN +/** + * Gestiona la reserva de un vn.saleGroup actualizando vn.itemShelvingSale.isPicked + * y cambiando el estado de la vn.sale + * + * @param vSaleGroupFk Id saleGroupFk + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF NOT (SELECT COUNT(*) FROM saleGroup WHERE id = vSaleGroupFk) THEN + CALL util.throw('Sale group not exists'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale iss + JOIN sale s ON s.id = iss.saleFk + JOIN saleGroupDetail sg ON sg.saleFk = s.id + SET iss.isPicked = TRUE + WHERE sg.saleGroupFk = vSaleGroupFk; + + CALL saleTracking_addPreparedSaleGroup(vSaleGroupFk); + + COMMIT; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_unpicked.sql b/db/routines/vn/procedures/itemShelvingSale_unpicked.sql new file mode 100644 index 000000000..6813a65b1 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_unpicked.sql @@ -0,0 +1,60 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_unpicked`( + vSelf INT(11) +) +BEGIN +/** + * Desmarca una línea que ya estaba sacada, devolviendo la cantidad al itemShelving + * + * @param vSelf Identificador del itemShelvingSale + */ + DECLARE vSaleFk INT; + DECLARE vReservedQuantity INT; + DECLARE vIsSaleGroup BOOL; + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + IF (SELECT NOT isPicked FROM itemShelvingSale WHERE id = vSelf) THEN + CALL util.throw('Reserva no completada'); + END IF; + + SELECT ish.saleFk, ish.quantity, IF(sg.id, TRUE, FALSE) + INTO vSaleFk, vReservedQuantity, vIsSaleGroup + FROM itemShelvingSale ish + LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk + WHERE ish.id = vSelf; + + IF vIsSaleGroup THEN + CALL util.throw('Can not unpicked a sale group'); + END IF; + + START TRANSACTION; + + UPDATE itemShelvingSale + SET isPicked = FALSE + WHERE id = vSelf; + + UPDATE sale s + JOIN itemShelvingSale ish ON ish.saleFk = s.id + SET s.isPicked = FALSE + WHERE ish.id = vSelf; + + UPDATE itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + SET ish.visible = ish.visible + iss.quantity + WHERE iss.id = vSelf; + + CALL saleTracking_new( + vSaleFk, + FALSE, + vReservedQuantity, + `account`.`myUser_getId`(), + NULL, + 'ON_PREPARATION', + TRUE); + COMMIT; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingTransfer.sql b/db/routines/vn/procedures/itemShelvingTransfer.sql index 326f8108b..2a6f9fef1 100644 --- a/db/routines/vn/procedures/itemShelvingTransfer.sql +++ b/db/routines/vn/procedures/itemShelvingTransfer.sql @@ -1,45 +1,44 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingTransfer`(vItemShelvingFk INT, vShelvingFk VARCHAR(3)) -BEGIN -/** - * Transfiere producto de una ubicación a otra, fusionando si coincide el - * packing y la fecha. - * - * @param vItemShelvingFk Identificador de itemShelving - * @param vShelvingFk Identificador de shelving - */ - DECLARE vNewItemShelvingFk INT DEFAULT 0; - - SELECT MAX(ish.id) - INTO vNewItemShelvingFk - FROM itemShelving ish - JOIN ( - SELECT - itemFk, - packing, - created - FROM itemShelving - WHERE id = vItemShelvingFk - ) ish2 - ON ish2.itemFk = ish.itemFk - AND ish2.packing = ish.packing - AND date(ish2.created) = date(ish.created) - WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; - - IF vNewItemShelvingFk THEN - UPDATE itemShelving ish - JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk - SET ish.visible = ish.visible + ish2.visible - WHERE ish.id = vNewItemShelvingFk; - - DELETE FROM itemShelving - WHERE id = vItemShelvingFk; - ELSE - UPDATE itemShelving - SET shelvingFk = vShelvingFk - WHERE id = vItemShelvingFk; - END IF; - - SELECT true; -END$$ -DELIMITER ; +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingTransfer`( + vItemShelvingFk INT, + vShelvingFk VARCHAR(3)) +BEGIN +/** + * Transfiere producto de una ubicación a otra, fusionando si coincide el + * packing y la fecha. + * + * @param vItemShelvingFk Identificador de itemShelving + * @param vShelvingFk Identificador de shelving + */ + DECLARE vNewItemShelvingFk INT DEFAULT 0; + + SELECT MAX(ish.id) + INTO vNewItemShelvingFk + FROM itemShelving ish + JOIN ( + SELECT itemFk, + packing, + created + FROM itemShelving + WHERE id = vItemShelvingFk + ) ish2 ON ish2.itemFk = ish.itemFk + AND ish2.packing = ish.packing + AND DATE(ish2.created) = DATE(ish.created) + WHERE ish.shelvingFk = vShelvingFk COLLATE utf8_unicode_ci; + + IF vNewItemShelvingFk THEN + UPDATE itemShelving ish + JOIN itemShelving ish2 ON ish2.id = vItemShelvingFk + SET ish.visible = ish.visible + ish2.visible + WHERE ish.id = vNewItemShelvingFk; + + DELETE FROM itemShelving + WHERE id = vItemShelvingFk; + ELSE + UPDATE itemShelving + SET shelvingFk = vShelvingFk + WHERE id = vItemShelvingFk; + END IF; + SELECT true; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index 02762fa0b..9bfce27ea 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -1,63 +1,62 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) -BEGIN - - -/** - * Añade registro o lo actualiza si ya existe. - * - * @param vShelvingFk matrícula del carro - * @param vBarcode el id del registro - * @param vQuantity indica la cantidad del producto - * @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra - * @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra - * @param vPacking el packing del producto, NULL para coger el de la ultima compra - * @param vWarehouseFk indica el sector - * - **/ - - DECLARE vItemFk INT; - - SELECT barcodeToItem(vBarcode) INTO vItemFk; - - IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN - - INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); - INSERT INTO shelving(code, parkingFk) - SELECT vShelvingFk, id - FROM parking - WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; - - END IF; - - IF (SELECT COUNT(*) FROM itemShelving - WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk - AND itemFk = vItemFk - AND packing = vPacking) = 1 THEN - - UPDATE itemShelving - SET visible = visible+vQuantity - 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, - grouping, - packing, - packagingFk) - - SELECT vItemFk, - vShelvingFk, - vQuantity, - IFNULL(vGrouping, b.grouping), - IFNULL(vPacking, b.packing), - IFNULL(vPackagingFk, b.packagingFk) - FROM item i - LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk - LEFT JOIN buy b ON b.id = lb.buy_id - WHERE i.id = vItemFk; - END IF; -END$$ -DELIMITER ; +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_add`(IN vShelvingFk VARCHAR(8), IN vBarcode VARCHAR(22), IN vQuantity INT, IN vPackagingFk VARCHAR(10), IN vGrouping INT, IN vPacking INT, IN vWarehouseFk INT) +BEGIN +/** + * Añade registro o lo actualiza si ya existe. + * + * @param vShelvingFk matrícula del carro + * @param vBarcode el id del registro + * @param vQuantity indica la cantidad del producto + * @param vPackagingFk el packaging del producto en itemShelving, NULL para coger el de la ultima compra + * @param vGrouping el grouping del producto en itemShelving, NULL para coger el de la ultima compra + * @param vPacking el packing del producto, NULL para coger el de la ultima compra + * @param vWarehouseFk indica el sector + * + **/ + + DECLARE vItemFk INT; + + SELECT barcodeToItem(vBarcode) INTO vItemFk; + + IF (SELECT COUNT(*) FROM shelving WHERE code = vShelvingFk COLLATE utf8_unicode_ci) = 0 THEN + + INSERT IGNORE INTO parking(code) VALUES(vShelvingFk); + INSERT INTO shelving(code, parkingFk) + SELECT vShelvingFk, id + FROM parking + WHERE `code` = vShelvingFk COLLATE utf8_unicode_ci; + + END IF; + + IF (SELECT COUNT(*) FROM itemShelving + WHERE shelvingFk COLLATE utf8_unicode_ci = vShelvingFk + AND itemFk = vItemFk + AND packing = vPacking) = 1 THEN + + UPDATE itemShelving + SET visible = visible + vQuantity + 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, + grouping, + packing, + packagingFk) + + SELECT vItemFk, + vShelvingFk, + vQuantity, + IFNULL(vGrouping, b.grouping), + IFNULL(vPacking, b.packing), + IFNULL(vPackagingFk, b.packagingFk), + vQuantity + FROM item i + LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk + LEFT JOIN buy b ON b.id = lb.buy_id + WHERE i.id = vItemFk; + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql b/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql new file mode 100644 index 000000000..784a736ec --- /dev/null +++ b/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql @@ -0,0 +1,27 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_INSERT` + AFTER INSERT ON `itemShelving` + FOR EACH ROW +BEGIN + + INSERT INTO vn.itemShelvingLog( + itemShelvingFk, + workerFk, + accion, + itemFk, + shelvingFk, + visible, + `grouping`, + packing, + available) + VALUES( NEW.id, + NEW.userFk, + 'CREA REGISTRO', + NEW.itemFk, + NEW.shelvingFk, + NEW.visible, + NEW.`grouping`, + NEW.packing, + NEW.available); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql b/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql new file mode 100644 index 000000000..23ea14e85 --- /dev/null +++ b/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql @@ -0,0 +1,16 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_UPDATE` + AFTER UPDATE ON `itemShelving` + FOR EACH ROW +BEGIN + INSERT INTO itemShelvingLog + SET itemShelvingFk = NEW.id, + workerFk = account.myUser_getId(), + accion = 'CAMBIO', + itemFk = NEW.itemFk, + shelvingFk = NEW.shelvingFk, + visible = NEW.visible, + `grouping` = NEW.`grouping`, + packing = NEW.packing; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql b/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql new file mode 100644 index 000000000..0bed738d2 --- /dev/null +++ b/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_BEFORE_INSERT` + BEFORE INSERT ON `itemShelving` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); + SET NEW.userFk = account.myUser_getId(); + SET NEW.available = NEW.visible; +END$$ +DELIMITER ; diff --git a/db/versions/10852-pinkOak/00-firstScript.sql b/db/versions/10852-pinkOak/00-firstScript.sql new file mode 100644 index 000000000..3fd8f447b --- /dev/null +++ b/db/versions/10852-pinkOak/00-firstScript.sql @@ -0,0 +1,23 @@ +ALTER TABLE vn.itemShelvingSale DROP COLUMN IF EXISTS isPicked; + +ALTER TABLE vn.itemShelvingSale + ADD isPicked TINYINT(1) DEFAULT FALSE NOT NULL; + +ALTER TABLE vn.productionConfig DROP COLUMN IF EXISTS orderMode; + +ALTER TABLE vn.productionConfig + ADD orderMode ENUM('Location', 'Age') NOT NULL DEFAULT 'Location'; + +ALTER TABLE vn.itemShelving DROP COLUMN IF EXISTS available; + +ALTER TABLE vn.itemShelving ADD available INT NULL; + +UPDATE vn.itemShelving SET available = visible; + +CREATE TABLE vn.itemShelvingSaleReserv ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `saleFk` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `itemShelvingSaleReserv_ibfk_1` (`saleFk`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci + COMMENT='Queue of changed itemShelvingSale to reserve'; From 844bab3cc84e55b6884fc56a71b00502712080d7 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 6 Feb 2024 16:17:53 +0100 Subject: [PATCH 002/114] #refs 5890 feat:add assignCollection --- back/methods/collection/assignCollection.js | 29 ++++++++++++++ .../collection/spec/assignCollection.spec.js | 38 +++++++++++++++++++ back/models/collection.js | 1 + db/versions/10852-pinkOak/00-firstScript.sql | 5 +++ loopback/locale/es.json | 6 ++- 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 back/methods/collection/assignCollection.js create mode 100644 back/methods/collection/spec/assignCollection.spec.js diff --git a/back/methods/collection/assignCollection.js b/back/methods/collection/assignCollection.js new file mode 100644 index 000000000..2ff37ab59 --- /dev/null +++ b/back/methods/collection/assignCollection.js @@ -0,0 +1,29 @@ +const UserError = require('vn-loopback/util/user-error'); +module.exports = Self => { + Self.remoteMethodCtx('assignCollection', { + description: 'Assign a collection', + accessType: 'WRITE', + http: { + path: `/assignCollection`, + verb: 'POST' + }, + returns: { + type: ['object'], + root: true + }, + }); + + Self.assignCollection = async(ctx, options) => { + const userId = ctx.req.accessToken.userId; + const myOptions = {userId}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + const [info, info2, [{'@vCollectionFk': collectionFk}]] = await Self.rawSql( + 'CALL vn.collection_getAssigned(?, @vCollectionFk);SELECT @vCollectionFk', [userId], myOptions); + if (!collectionFk) throw new UserError('There are not picking tickets'); + await Self.rawSql('CALL vn.collection_printSticker(?, NULL)', [collectionFk], myOptions); + + return collectionFk; + }; +}; diff --git a/back/methods/collection/spec/assignCollection.spec.js b/back/methods/collection/spec/assignCollection.spec.js new file mode 100644 index 000000000..340bd6a93 --- /dev/null +++ b/back/methods/collection/spec/assignCollection.spec.js @@ -0,0 +1,38 @@ +const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); + +fdescribe('ticket assignCollection()', () => { + let ctx; + let options; + let tx; + beforeEach(async() => { + ctx = { + req: { + accessToken: {userId: 1106}, + headers: {origin: 'http://localhost'}, + __: value => value + }, + args: {} + }; + + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ + active: ctx.req + }); + + options = {transaction: tx}; + tx = await models.Sale.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should throw an error when there is not picking tickets', async() => { + try { + await models.Collection.assignCollection(ctx, options); + } catch (e) { + expect(e.message).toEqual('There are not picking tickets'); + } + }); +}); diff --git a/back/models/collection.js b/back/models/collection.js index 1c10d49fa..a0d34712f 100644 --- a/back/models/collection.js +++ b/back/models/collection.js @@ -4,4 +4,5 @@ module.exports = Self => { require('../methods/collection/setSaleQuantity')(Self); require('../methods/collection/previousLabel')(Self); require('../methods/collection/getTickets')(Self); + require('../methods/collection/assignCollection')(Self); }; diff --git a/db/versions/10852-pinkOak/00-firstScript.sql b/db/versions/10852-pinkOak/00-firstScript.sql index 3fd8f447b..7af48148c 100644 --- a/db/versions/10852-pinkOak/00-firstScript.sql +++ b/db/versions/10852-pinkOak/00-firstScript.sql @@ -21,3 +21,8 @@ CREATE TABLE vn.itemShelvingSaleReserv ( KEY `itemShelvingSaleReserv_ibfk_1` (`saleFk`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue of changed itemShelvingSale to reserve'; + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES + + ('Collection', 'assignCollection', 'WRITE', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 5c7dc41b6..394fca450 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -338,5 +338,7 @@ "The alias cant be modified": "Este alias de correo no puede ser modificado", "No tickets to invoice": "No hay tickets para facturar", "Name should be uppercase": "El nombre debe ir en mayúscula", - "An email is necessary": "Es necesario un email" -} + "An email is necessary": "Es necesario un email", + "printerNotExists": "printerNotExists", + "There are not picking tickets": "No hay tickets para sacar" +} \ No newline at end of file From 93de845b6764da67a78386e2fc8496918884a740 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 16 Feb 2024 07:03:05 +0100 Subject: [PATCH 003/114] refs#5890 feat: delete trigger and modify getTickets --- back/methods/collection/getTickets.js | 2 +- .../vn/triggers/itemShelvingSale_afterInsert.sql | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 db/routines/vn/triggers/itemShelvingSale_afterInsert.sql diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 50117b954..fc77d4af3 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -68,7 +68,7 @@ module.exports = Self => { LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk JOIN item i ON i.id = s.itemFk - LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN parking p ON p.id = sh.parkingFk diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql deleted file mode 100644 index 63ca893bd..000000000 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert` - AFTER INSERT ON `itemShelvingSale` - FOR EACH ROW -BEGIN - - UPDATE vn.sale - SET isPicked = TRUE - WHERE id = NEW.saleFk; - -END$$ -DELIMITER ; From c20747434e09fd7d5d8fedcf35a7f118fc25796f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 18 Mar 2024 17:51:35 +0100 Subject: [PATCH 004/114] feat: previas con sitema de reservas refs #6861 --- ...ShelvingSale_reserveBySectorCollection.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql new file mode 100644 index 000000000..3ea351288 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE + `vn`.`itemShelvingSale_reserveBySectorCollection`(vSectorCollectionFk INT(11)) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * de la cual ya tiene generada la asociación del saleGroup con sectorCollection + * + * @param vSectorCollectionFk Identificador de sectorCollection + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk)) + ENGINE = MEMORY + SELECT s.id + FROM sectorCollectionSaleGroup sc + JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk + JOIN sale s ON sg.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + WHERE sc.sectorCollectionFk = vSectorCollectionFk + AND str.workerFk = account.myUser_getId(); + + CALL itemShelvingSale_reserve(); +END$$ +DELIMITER ; From f1e8f965b35475d3684b22d19b36abb45d449295 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 21 Mar 2024 11:59:45 +0100 Subject: [PATCH 005/114] refs #5890 itemShelving --- ...ShelvingSale_reserveBySectorCollection.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql new file mode 100644 index 000000000..3510e774e --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE + `vn`.`itemShelvingSale_reserveBySectorCollection`(vSectorCollectionFk INT(11)) +BEGIN +/** + * Reserva cantidades con ubicaciones para el contenido de una preparación previa + * de la cual ya tiene generada la asociación del saleGroup con sectorCollection + * + * @param vSectorCollectionFk Identificador de sectorCollection + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + (INDEX(saleFk)) + ENGINE = MEMORY + SELECT s.id + FROM sectorCollectionSaleGroup sc + JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk + JOIN sale s ON sg.saleFk = s.id + JOIN saleTracking str ON str.saleFk = s.id + JOIN `state` st ON st.id = str.stateFk + AND st.code = 'PREVIOUS_PREPARATION' + WHERE sc.sectorCollectionFk = vSectorCollectionFk + AND str.workerFk = account.myUser_getId(); + + CALL itemShelvingSale_reserve(); +END$$ +DELIMITER ; \ No newline at end of file From f18d61d17dab66359471710d6529c808fbff647b Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 21 Mar 2024 17:28:08 +0100 Subject: [PATCH 006/114] refs #5890 fix: dev --- back/methods/url/getUrl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/url/getUrl.js b/back/methods/url/getUrl.js index ef741e5a0..8a86ba579 100644 --- a/back/methods/url/getUrl.js +++ b/back/methods/url/getUrl.js @@ -22,7 +22,7 @@ module.exports = Self => { const {url} = await Self.app.models.Url.findOne({ where: { appName, - environment: process.env.NODE_ENV || 'development' + environment: process.env.NODE_ENV || 'dev' } }); return url; From 6db1696094f50f5fc47e07002cd933a131eb97b9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 3 Apr 2024 07:04:12 +0200 Subject: [PATCH 007/114] refs #5890 feat:trigger --- .../itemShelvingSale_addByCollection.sql | 2 +- .../vn/triggers/itemShelving_AFTER_INSERT.sql | 27 ---------------- .../vn/triggers/itemShelving_AFTER_UPDATE.sql | 16 ---------- .../triggers/itemShelving_BEFORE_INSERT.sql | 10 ------ .../vn/triggers/itemShelving_afterInsert.sql | 31 +++++++++++-------- .../vn/triggers/itemShelving_afterUpdate.sql | 10 ++++-- .../vn/triggers/itemShelving_beforeInsert.sql | 1 + .../vn/triggers/itemShelving_beforeUpdate.sql | 6 ++++ 8 files changed, 33 insertions(+), 70 deletions(-) delete mode 100644 db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql delete mode 100644 db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql delete mode 100644 db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql diff --git a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql index 4e57fed0b..9bc549235 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_ad ) BEGIN /** - * Guarda la ubicación para el contenido de una colección + * Reserva cantidades con ubicaciones para el contenido de una colección * * @param vCollectionFk Identificador de collection */ diff --git a/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql b/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql deleted file mode 100644 index 784a736ec..000000000 --- a/db/routines/vn/triggers/itemShelving_AFTER_INSERT.sql +++ /dev/null @@ -1,27 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_INSERT` - AFTER INSERT ON `itemShelving` - FOR EACH ROW -BEGIN - - INSERT INTO vn.itemShelvingLog( - itemShelvingFk, - workerFk, - accion, - itemFk, - shelvingFk, - visible, - `grouping`, - packing, - available) - VALUES( NEW.id, - NEW.userFk, - 'CREA REGISTRO', - NEW.itemFk, - NEW.shelvingFk, - NEW.visible, - NEW.`grouping`, - NEW.packing, - NEW.available); -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql b/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql deleted file mode 100644 index 23ea14e85..000000000 --- a/db/routines/vn/triggers/itemShelving_AFTER_UPDATE.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_UPDATE` - AFTER UPDATE ON `itemShelving` - FOR EACH ROW -BEGIN - INSERT INTO itemShelvingLog - SET itemShelvingFk = NEW.id, - workerFk = account.myUser_getId(), - accion = 'CAMBIO', - itemFk = NEW.itemFk, - shelvingFk = NEW.shelvingFk, - visible = NEW.visible, - `grouping` = NEW.`grouping`, - packing = NEW.packing; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql b/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql deleted file mode 100644 index 0bed738d2..000000000 --- a/db/routines/vn/triggers/itemShelving_BEFORE_INSERT.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_BEFORE_INSERT` - BEFORE INSERT ON `itemShelving` - FOR EACH ROW -BEGIN - SET NEW.editorFk = account.myUser_getId(); - SET NEW.userFk = account.myUser_getId(); - SET NEW.available = NEW.visible; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelving_afterInsert.sql b/db/routines/vn/triggers/itemShelving_afterInsert.sql index 5c0cb3853..1408615c3 100644 --- a/db/routines/vn/triggers/itemShelving_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelving_afterInsert.sql @@ -1,22 +1,27 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert` +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_INSERT` AFTER INSERT ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog( itemShelvingFk, - workerFk, - accion, - itemFk, - shelvingFk, - visible, - `grouping`, - packing) - VALUES( NEW.id, +BEGIN + + INSERT INTO vn.itemShelvingLog( + itemShelvingFk, + workerFk, + accion, + itemFk, + shelvingFk, + visible, + `grouping`, + packing, + available) + VALUES( NEW.id, NEW.userFk, 'CREA REGISTRO', NEW.itemFk, NEW.shelvingFk, NEW.visible, NEW.`grouping`, - NEW.packing - )$$ -DELIMITER ; + NEW.packing, + NEW.available); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/itemShelving_afterUpdate.sql b/db/routines/vn/triggers/itemShelving_afterUpdate.sql index 107e8ecdc..1d7dc4ac6 100644 --- a/db/routines/vn/triggers/itemShelving_afterUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_afterUpdate.sql @@ -1,8 +1,9 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate` +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_UPDATE` AFTER UPDATE ON `itemShelving` FOR EACH ROW -INSERT INTO itemShelvingLog +BEGIN + INSERT INTO itemShelvingLog SET itemShelvingFk = NEW.id, workerFk = account.myUser_getId(), accion = 'CAMBIO', @@ -10,5 +11,8 @@ INSERT INTO itemShelvingLog shelvingFk = NEW.shelvingFk, visible = NEW.visible, `grouping` = NEW.`grouping`, - packing = NEW.packing$$ + packing = NEW.packing, + available = NEW.available; + +END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelving_beforeInsert.sql b/db/routines/vn/triggers/itemShelving_beforeInsert.sql index 011cf3701..e9fe17cf2 100644 --- a/db/routines/vn/triggers/itemShelving_beforeInsert.sql +++ b/db/routines/vn/triggers/itemShelving_beforeInsert.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeIn BEGIN SET NEW.editorFk = account.myUser_getId(); SET NEW.userFk = account.myUser_getId(); + SET NEW.available = NEW.visible; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql index 6fd919d2e..214c64b45 100644 --- a/db/routines/vn/triggers/itemShelving_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_beforeUpdate.sql @@ -3,9 +3,15 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_beforeUp BEFORE UPDATE ON `itemShelving` FOR EACH ROW BEGIN + SET NEW.editorFk = account.myUser_getId(); IF NEW.userFk IS NULL THEN SET NEW.userFk = account.myUser_getId(); END IF; + + IF (NEW.visible <> OLD.visible) THEN + SET NEW.available = GREATEST(NEW.available + NEW.visible - OLD.visible, 0); + END IF; + END$$ DELIMITER ; From 78f55861365eeafaf3fe22e9278a619081b963fd Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 4 Apr 2024 09:37:34 +0200 Subject: [PATCH 008/114] refs #5890 feat:itemShelving_add --- db/routines/vn/procedures/itemShelving_add.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_add.sql b/db/routines/vn/procedures/itemShelving_add.sql index dee96f43c..09a3e5bb6 100644 --- a/db/routines/vn/procedures/itemShelving_add.sql +++ b/db/routines/vn/procedures/itemShelving_add.sql @@ -55,8 +55,7 @@ BEGIN vQuantity, IFNULL(vGrouping, b.grouping), IFNULL(vPacking, b.packing), - IFNULL(vPackagingFk, b.packagingFk), - vQuantity + IFNULL(vPackagingFk, b.packagingFk) FROM item i LEFT JOIN cache.last_buy lb ON i.id = lb.item_id AND lb.warehouse_id = vWarehouseFk LEFT JOIN buy b ON b.id = lb.buy_id From 09812c24ddcb717f7b09196bd644f0b66e6e6dc9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 8 Apr 2024 09:54:23 +0200 Subject: [PATCH 009/114] refs #5890 feat: triggers --- db/routines/vn/triggers/itemShelving_afterInsert.sql | 2 +- db/routines/vn/triggers/itemShelving_afterUpdate.sql | 2 +- db/versions/10983-chocolateDracena/00-firstScript.sql | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 db/versions/10983-chocolateDracena/00-firstScript.sql diff --git a/db/routines/vn/triggers/itemShelving_afterInsert.sql b/db/routines/vn/triggers/itemShelving_afterInsert.sql index 1408615c3..86f149473 100644 --- a/db/routines/vn/triggers/itemShelving_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelving_afterInsert.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_INSERT` +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert` AFTER INSERT ON `itemShelving` FOR EACH ROW BEGIN diff --git a/db/routines/vn/triggers/itemShelving_afterUpdate.sql b/db/routines/vn/triggers/itemShelving_afterUpdate.sql index 1d7dc4ac6..1ad57961a 100644 --- a/db/routines/vn/triggers/itemShelving_afterUpdate.sql +++ b/db/routines/vn/triggers/itemShelving_afterUpdate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_AFTER_UPDATE` +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterUpdate` AFTER UPDATE ON `itemShelving` FOR EACH ROW BEGIN diff --git a/db/versions/10983-chocolateDracena/00-firstScript.sql b/db/versions/10983-chocolateDracena/00-firstScript.sql new file mode 100644 index 000000000..2baf1b21f --- /dev/null +++ b/db/versions/10983-chocolateDracena/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here +USE vn; + +DROP TRIGGER IF EXISTS itemShelving_AFTER_UPDATE; +DROP TRIGGER IF EXISTS itemShelving_AFTER_INSERT; From 5967bd545c40df79625996295edafa515e9ebdbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 11 Apr 2024 12:16:00 +0200 Subject: [PATCH 010/114] feat: previas con reserva refs #6861 --- back/methods/collection/getSales.js | 4 +- back/methods/collection/getTickets.js | 57 +++++++-- db/routines/vn/functions/ticket_get.sql | 88 ++++++-------- .../vn/procedures/collection_getTickets.sql | 115 +++++++++++------- 4 files changed, 155 insertions(+), 109 deletions(-) diff --git a/back/methods/collection/getSales.js b/back/methods/collection/getSales.js index 78945dc80..d4bf371b2 100644 --- a/back/methods/collection/getSales.js +++ b/back/methods/collection/getSales.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('getSales', { - description: 'Get sales from ticket or collection', + description: 'Get sales from ticket, collection or sectorCollection', accessType: 'READ', accepts: [ { @@ -59,7 +59,7 @@ module.exports = Self => { if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions); for (let ticket of tickets) { - let observations = ticket.observaciones.split(' '); + let observations = ticket.observation.split(' '); for (let observation of observations) { const salesPerson = ticket.salesPersonFk; diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 50117b954..ab974e371 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -37,6 +37,7 @@ module.exports = Self => { const promises = []; const [tickets] = await Self.rawSql(`CALL vn.collection_getTickets(?)`, [id], myOptions); + const sales = await Self.rawSql(` SELECT s.ticketFk, sgd.saleGroupFk, @@ -76,17 +77,55 @@ module.exports = Self => { LEFT JOIN origin o ON o.id = i.originFk WHERE tc.collectionFk = ? GROUP BY s.id, ish.id, p.code, p2.code - ORDER BY pickingOrder;`, [id], myOptions); - + UNION ALL + SELECT s.ticketFk, + sgd.saleGroupFk, + s.id saleFk, + s.itemFk, + i.longName, + i.size, + ic.color, + o.code origin, + ish.packing, + ish.grouping, + s.isAdded, + s.originalQuantity, + s.quantity, + iss.quantity, + SUM(iss.quantity) OVER (PARTITION BY s.id ORDER BY ish.id), + ROW_NUMBER () OVER (PARTITION BY s.id ORDER BY p.pickingOrder), + COUNT(*) OVER (PARTITION BY s.id ORDER BY s.id) , + sh.code, + IFNULL(p2.code, p.code), + IFNULL(p2.pickingOrder, p.pickingOrder), + iss.id itemShelvingSaleFk, + iss.isPicked + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN saleGroup sg ON sg.id = ss.saleGroupFk + JOIN ticket t ON t.id = sg.ticketFk + JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + LEFT JOIN parking p2 ON p2.id = sg.parkingFk + JOIN item i ON i.id = s.itemFk + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + LEFT JOIN shelving sh ON sh.code = ish.shelvingFk + LEFT JOIN parking p ON p.id = sh.parkingFk + LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk + LEFT JOIN origin o ON o.id = i.originFk + WHERE sc.id = ? + GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions); if (print) await Self.rawSql(`CALL vn.collection_printSticker(?, ?)`, [id, null], myOptions); const collection = {collectionFk: id, tickets: []}; + if (tickets && tickets.length) { for (const ticket of tickets) { const ticketId = ticket.ticketFk; - if (ticket.observaciones != '') { - for (observation of ticket.observaciones.split(' ')) { + if (ticket.observation) { + for (observation of ticket.observation?.split(' ')) { if (['#', '@'].includes(observation.charAt(0))) { promises.push(Self.app.models.Chat.send(ctx, observation, $t('The ticket is in preparation', { @@ -100,11 +139,11 @@ module.exports = Self => { if (sales && sales.length) { const barcodes = await Self.rawSql(` SELECT s.id saleFk, b.code, c.id - FROM vn.sale s - LEFT JOIN vn.itemBarcode b ON b.itemFk = s.itemFk - LEFT JOIN vn.buy c ON c.itemFk = s.itemFk - LEFT JOIN vn.entry e ON e.id = c.entryFk - LEFT JOIN vn.travel tr ON tr.id = e.travelFk + FROM sale s + LEFT JOIN itemBarcode b ON b.itemFk = s.itemFk + LEFT JOIN buy c ON c.itemFk = s.itemFk + LEFT JOIN entry e ON e.id = c.entryFk + LEFT JOIN travel tr ON tr.id = e.travelFk WHERE s.ticketFk = ? AND tr.landed >= util.VN_CURDATE() - INTERVAL 1 YEAR`, [ticketId], myOptions); diff --git a/db/routines/vn/functions/ticket_get.sql b/db/routines/vn/functions/ticket_get.sql index 1f0e9a25a..b55b1297e 100644 --- a/db/routines/vn/functions/ticket_get.sql +++ b/db/routines/vn/functions/ticket_get.sql @@ -1,64 +1,44 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_get`(vParamFk INT) - RETURNS int(11) + RETURNS INT(11) NOT DETERMINISTIC READS SQL DATA -proc:BEGIN - - /* Devuelve el número de ticket o collection consultando en varias tablas posibles - * - * @param vParamFk Número a validar - * @return vValidFk Identificador validado - */ - - DECLARE vValidFk INT; +BEGIN +/** + * Devuelve el número de ticket / collection / sectorCollection consultando + * en que tabla se encuantra en la última semana + * + * @param vParamFk Número a validar + * @return vReturn Identificador validado + */ + DECLARE vReturn INT DEFAULT NULL; + DECLARE vDated DATE; - -- Tabla vn.saleGroup - SELECT s.ticketFk INTO vValidFk - FROM vn.sale s - JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id - JOIN vn.saleGroup sg ON sg.id = sgd.saleGroupFk - WHERE sg.id = vParamFk - AND sg.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()) - LIMIT 1; - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; + SET vDated = util.VN_CURDATE() - INTERVAL 1 WEEK; - -- Tabla vn.collection - SELECT c.id INTO vValidFk - FROM vn.collection c - WHERE c.id = vParamFk - AND c.created > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; + SELECT COALESCE( + (SELECT s.ticketFk + FROM sale s + JOIN saleGroupDetail sgd ON sgd.saleFk = s.id + JOIN saleGroup sg ON sg.id = sgd.saleGroupFk + WHERE sg.id = vParamFk + AND sg.created > vDated + LIMIT 1), + (SELECT c.id + FROM collection c + WHERE c.id = vParamFk + AND c.created > vDated), + (SELECT id + FROM ticket + WHERE id = vParamFk + AND shipped > vDated), + (SELECT id + FROM sectorCollection + WHERE id = vParamFk + AND created > vDated) + ) INTO vReturn; - -- Tabla vn.ticket - SELECT t.id INTO vValidFk - FROM vn.ticket t - WHERE t.id = vParamFk - AND t.shipped > TIMESTAMPADD(WEEK,-1, util.VN_CURDATE()); - - IF vValidFk THEN - - RETURN vValidFk; - - LEAVE proc; - - END IF; - - RETURN NULL; + RETURN vReturn; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 0a71ada78..09624acd2 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -2,61 +2,88 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getTickets`(vParamFk INT) BEGIN /** - * Selecciona los tickets de una colección/ticket - * @param vParamFk ticketFk/collectionFk - * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observaciones + * Selecciona los tickets de una colección/ticket/sectorCollection + * @param vParamFk ticketFk/collectionFk/sectorCollection + * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observation */ DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vDated DATE; -- Si los sacadores son los de pruebas, pinta los colores - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM vn.collection + SELECT itemPackingTypeFk + INTO vItemPackingTypeFk + FROM collection WHERE id = vParamFk; + + SET vDated = util.yesterday(); - SELECT t.id ticketFk, - IF (!(vItemPackingTypeFk <=> 'V'), cc.code,CONCAT(SUBSTRING('ABCDEFGH',tc.wagon, 1),'-',tc.`level` )) `level`, - am.name agencyName, - t.warehouseFk, - w.id salesPersonFk, - IFNULL(tob.description,'') observaciones, - cc.rgb - FROM vn.ticket t - LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 - LEFT JOIN vn.collectionColors cc - ON cc.wagon = tc.wagon - AND cc.shelve = tc.`level` - AND cc.trainFk = c2.trainFk -- PAK 23/12/21 - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = 1 - WHERE t.id = vParamFk - AND t.shipped >= util.yesterday() - UNION ALL + WITH observation AS ( + SELECT tob.ticketFk, tob.description + FROM ticketObservation tob + JOIN ticketCollection tc ON tc.ticketFk = tob.ticketFk + LEFT JOIN observationType ot ON ot.id = tob.observationTypeFk + WHERE ot.`code` = 'itemPicker' + AND tc.collectionFk = vParamFk + ) SELECT t.id ticketFk, IF(!(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, am.name agencyName, t.warehouseFk, - w.id salesPersonFk, - IFNULL(tob.description, '') observaciones, - IF(!(vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` - FROM vn.ticket t - JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk -- PAK 23/12/21 - LEFT JOIN vn.collectionColors cc + w.id salesPersonFk, + IFNULL(ob.description,'') observation, + cc.rgb + FROM ticket t + LEFT JOIN ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN collection c2 ON c2.id = tc.collectionFk + LEFT JOIN collectionColors cc + ON cc.wagon = tc.wagon + AND cc.shelve = tc.`level` + AND cc.trainFk = c2.trainFk + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker w ON w.id = c.salesPersonFk + LEFT JOIN observation ob ON ob.ticketFk = t.id + WHERE t.id = vParamFk + AND t.shipped >= vDated + UNION ALL + SELECT t.id ticketFk, + IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, + am.name agencyName, + t.warehouseFk, + w.id salesPersonFk, + ob.description, + IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` + FROM ticket t + JOIN ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN collection c2 ON c2.id = tc.collectionFk + LEFT JOIN collectionColors cc ON cc.wagon = tc.wagon AND cc.shelve = tc.`level` - AND cc.trainFk = c2.trainFk -- PAK 23/12/21 - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk - LEFT JOIN vn.ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = 1 - WHERE tc.collectionFk = vParamFk; - + AND cc.trainFk = c2.trainFk + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker w ON w.id = c.salesPersonFk + LEFT JOIN observation ob ON ob.ticketFk = t.id + WHERE tc.collectionFk = vParamFk + UNION ALL + SELECT sg.ticketFk, + NULL `level`, + am.name agencyName, + t.warehouseFk, + c.salesPersonFk, + ob.description, + NULL `rgb` + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN saleGroup sg ON sg.id = ss.saleGroupFk + JOIN ticket t ON t.id = sg.ticketFk + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN client c ON c.id = t.clientFk + WHERE sc.id = vParamFk + AND t.shipped >= vDated; END$$ DELIMITER ; From bc1397d916acea00fe70ef118c4f0d76b5d53dc8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 11 Apr 2024 12:27:16 +0200 Subject: [PATCH 011/114] refs #6861 feat: reservePrevious --- db/routines/floranet/events/clean.sql | 22 ------- .../floranet/procedures/catalogue_get.sql | 64 ------------------- .../floranet/procedures/contact_request.sql | 20 ------ .../floranet/procedures/deliveryDate_get.sql | 29 --------- .../floranet/procedures/order_confirm.sql | 25 -------- db/routines/floranet/procedures/order_put.sql | 42 ------------ .../floranet/procedures/sliders_get.sql | 20 ------ .../vn/procedures/collection_getTickets.sql | 52 +++++++-------- 8 files changed, 26 insertions(+), 248 deletions(-) delete mode 100644 db/routines/floranet/events/clean.sql delete mode 100644 db/routines/floranet/procedures/catalogue_get.sql delete mode 100644 db/routines/floranet/procedures/contact_request.sql delete mode 100644 db/routines/floranet/procedures/deliveryDate_get.sql delete mode 100644 db/routines/floranet/procedures/order_confirm.sql delete mode 100644 db/routines/floranet/procedures/order_put.sql delete mode 100644 db/routines/floranet/procedures/sliders_get.sql diff --git a/db/routines/floranet/events/clean.sql b/db/routines/floranet/events/clean.sql deleted file mode 100644 index 4477112fd..000000000 --- a/db/routines/floranet/events/clean.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE - DEFINER=`root`@`localhost` - EVENT `floranet`.`clean` - ON SCHEDULE EVERY 1 DAY - STARTS '2024-01-01 23:00:00.000' - ON COMPLETION PRESERVE - ENABLE -DO -BEGIN - DELETE - FROM `order` - WHERE created < CURDATE() - AND isPaid = FALSE; - - DELETE c.* - FROM catalogue c - LEFT JOIN `order` o ON o.catalogueFk = c.id - WHERE c.created < CURDATE() - AND o.id IS NULL; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql deleted file mode 100644 index e45fa7ddf..000000000 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ /dev/null @@ -1,64 +0,0 @@ -DROP PROCEDURE IF EXISTS floranet.catalogue_get; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) -READS SQL DATA -proc:BEGIN -/** - * Returns list, price and all the stuff regarding the floranet items - * - * @param vLanded Delivery date - * @param vPostalCode Delivery address postal code - */ - DECLARE vLastCatalogueFk INT; - DECLARE vLockName VARCHAR(20); - DECLARE vLockTime INT; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK(vLockName); - - RESIGNAL; - END; - - SET vLockName = 'catalogue_get'; - SET vLockTime = 15; - - IF NOT GET_LOCK(vLockName, vLockTime) THEN - LEAVE proc; - END IF; - - SELECT MAX(id) INTO vLastCatalogueFk - FROM catalogue; - - INSERT INTO catalogue( - name, - price, - itemFk, - dated, - postalCode, - `type`, - image, - description - ) - SELECT i.name, - i.`size`, - i.id, - vLanded, - vPostalCode, - it.name, - CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), - i.description - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP'); - - SELECT * - FROM catalogue - WHERE id > IFNULL(vLastCatalogueFk,0); - - DO RELEASE_LOCK(vLockName); - -END$$ -DELIMITER ; diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql deleted file mode 100644 index 044c22c6f..000000000 --- a/db/routines/floranet/procedures/contact_request.sql +++ /dev/null @@ -1,20 +0,0 @@ -DROP PROCEDURE IF EXISTS floranet.contact_request; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` -PROCEDURE floranet.contact_request( - vName VARCHAR(100), - vPhone VARCHAR(15), - vEmail VARCHAR(100), - vMessage TEXT) -READS SQL DATA -BEGIN -/** - * Set actions for contact request. - * - * @param vPostalCode Delivery address postal code - */ - -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql deleted file mode 100644 index 29751ebe4..000000000 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ /dev/null @@ -1,29 +0,0 @@ -DROP PROCEDURE IF EXISTS floranet.deliveryDate_get; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15)) - READS SQL DATA -BEGIN -/** - * Returns available dates for this postalCode, in the next seven days - * - * @param vPostalCode Delivery address postal code - */ - DECLARE vCurrentDayOfWeek INT; - - SET vCurrentDayOfWeek = DAYOFWEEK(NOW()); - - SELECT DISTINCT nextDay - FROM ( - SELECT CURDATE() + INTERVAL IF( - apc.dayOfWeek >= vCurrentDayOfWeek, - apc.dayOfWeek - vCurrentDayOfWeek, - 7 - apc.dayOfWeek - ) DAY nextDay, - NOW() + INTERVAL apc.hoursInAdvance - 12 HOUR minDeliveryTime - FROM addressPostCode apc - WHERE apc.postCode = vPostalCode - HAVING nextDay > minDeliveryTime) sub; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql deleted file mode 100644 index fed123663..000000000 --- a/db/routines/floranet/procedures/order_confirm.sql +++ /dev/null @@ -1,25 +0,0 @@ -DROP PROCEDURE IF EXISTS floranet.order_confirm; - -DELIMITER $$ -$$ - -CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk INT) -READS SQL DATA - -BEGIN -/** Update order.isPaid field - * - * @param vCatalogueFk floranet.catalogue.id - * - * @returns floranet.order.isPaid - */ - UPDATE `order` - SET isPaid = TRUE, - payed = NOW() - WHERE catalogueFk = vCatalogueFk; - - SELECT isPaid - FROM `order` - WHERE catalogueFk = vCatalogueFk; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql deleted file mode 100644 index c26cef19a..000000000 --- a/db/routines/floranet/procedures/order_put.sql +++ /dev/null @@ -1,42 +0,0 @@ -DROP PROCEDURE IF EXISTS floranet.order_put; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON) -READS SQL DATA -BEGIN -/** - * Get and process an order - * - * @param vOrder Data of the order - * - * Customer data: , , - * - * Item data: , - * - * Delivery data: ,
, - * - */ - INSERT IGNORE INTO `order`( - catalogueFk, - customerName, - email, - customerPhone, - message, - deliveryName, - address, - deliveryPhone - ) - VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone')) - ); - - SELECT LAST_INSERT_ID() orderFk; -END$$ -DELIMITER ; diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql deleted file mode 100644 index bd791dec7..000000000 --- a/db/routines/floranet/procedures/sliders_get.sql +++ /dev/null @@ -1,20 +0,0 @@ -DROP PROCEDURE IF EXISTS floranet.sliders_get; - -DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get() -READS SQL DATA -BEGIN -/** - * Returns list of url for sliders - */ - SELECT - CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, - i.longName - FROM vn.item i - JOIN vn.itemType it ON it.id = i.typeFk - WHERE it.code IN ('FNR','FNP') - LIMIT 3; - -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 09624acd2..3f1239e9b 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -19,9 +19,9 @@ BEGIN WITH observation AS ( SELECT tob.ticketFk, tob.description - FROM ticketObservation tob - JOIN ticketCollection tc ON tc.ticketFk = tob.ticketFk - LEFT JOIN observationType ot ON ot.id = tob.observationTypeFk + FROM vn.ticketObservation tob + JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk + LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk WHERE ot.`code` = 'itemPicker' AND tc.collectionFk = vParamFk ) @@ -32,17 +32,17 @@ BEGIN w.id salesPersonFk, IFNULL(ob.description,'') observation, cc.rgb - FROM ticket t - LEFT JOIN ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN collection c2 ON c2.id = tc.collectionFk - LEFT JOIN collectionColors cc + FROM vn.ticket t + LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE t.id = vParamFk AND t.shipped >= vDated @@ -54,17 +54,17 @@ BEGIN w.id salesPersonFk, ob.description, IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` - FROM ticket t - JOIN ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN collection c2 ON c2.id = tc.collectionFk - LEFT JOIN collectionColors cc + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE tc.collectionFk = vParamFk UNION ALL @@ -75,14 +75,14 @@ BEGIN c.salesPersonFk, ob.description, NULL `rgb` - FROM sectorCollection sc - JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id - JOIN saleGroup sg ON sg.id = ss.saleGroupFk - JOIN ticket t ON t.id = sg.ticketFk - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN agencyMode am ON am.id = z.agencyModeFk + FROM vn.sectorCollection sc + JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk + JOIN vn.ticket t ON t.id = sg.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN observation ob ON ob.ticketFk = t.id - LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN vn.client c ON c.id = t.clientFk WHERE sc.id = vParamFk AND t.shipped >= vDated; END$$ From 3a8dcbfd292a1f1846e003a657143c366db1a3a5 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 11 Apr 2024 13:45:43 +0200 Subject: [PATCH 012/114] refs #6861 feat:reserve previos --- back/methods/collection/getTickets.js | 5 +++-- .../itemShelvingSale_reserveBySectorCollection.sql | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index a16757fd4..663b70e94 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -108,13 +108,14 @@ module.exports = Self => { LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = s.id LEFT JOIN parking p2 ON p2.id = sg.parkingFk JOIN item i ON i.id = s.itemFk - LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN shelving sh ON sh.code = ish.shelvingFk LEFT JOIN parking p ON p.id = sh.parkingFk LEFT JOIN itemColor ic ON ic.itemFk = s.itemFk LEFT JOIN origin o ON o.id = i.originFk - WHERE sc.id = ? + WHERE sc.id = ? + AND sgd.saleGroupFk GROUP BY s.id, ish.id, p.code, p2.code`, [id, id], myOptions); if (print) await Self.rawSql(`CALL vn.collection_printSticker(?, ?)`, [id, null], myOptions); diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql index 3ea351288..52d83a75d 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql @@ -11,7 +11,7 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk)) ENGINE = MEMORY - SELECT s.id + SELECT s.id saleFk, str.workerFk userFK FROM sectorCollectionSaleGroup sc JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk JOIN sale s ON sg.saleFk = s.id From 0f1a086bca6c2493c9513378b1fdba8d34bea922 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 15 Apr 2024 13:03:27 +0200 Subject: [PATCH 013/114] refs #6861 feat:reserve previos --- db/routines/vn/procedures/itemShelvingSale_unpicked.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_unpicked.sql b/db/routines/vn/procedures/itemShelvingSale_unpicked.sql index 6813a65b1..889cadfd0 100644 --- a/db/routines/vn/procedures/itemShelvingSale_unpicked.sql +++ b/db/routines/vn/procedures/itemShelvingSale_unpicked.sql @@ -27,9 +27,9 @@ BEGIN LEFT JOIN saleGroupDetail sg ON sg.saleFk = ish.saleFk WHERE ish.id = vSelf; - IF vIsSaleGroup THEN + /*IF vIsSaleGroup THEN CALL util.throw('Can not unpicked a sale group'); - END IF; + END IF;*/ START TRANSACTION; From b1e8cdfd8641641874494b989d39fa1ed105fed1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 09:12:51 +0200 Subject: [PATCH 014/114] feat: refs #7168 Added vRecords param in proc --- .../vn/procedures/itemShelvingLog_get.sql | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingLog_get.sql b/db/routines/vn/procedures/itemShelvingLog_get.sql index ad67ea5cd..14d5101ee 100644 --- a/db/routines/vn/procedures/itemShelvingLog_get.sql +++ b/db/routines/vn/procedures/itemShelvingLog_get.sql @@ -1,35 +1,46 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`( + vShelvingFk VARCHAR(10), + vRecords INT +) BEGIN - /** * Devuelve el log de los item en cada carro * - * @param vShelvingFk Matrícula del carro + * @param vShelvingFk Matrícula del carro + * @param vRecords Límite de registros retornados * */ - - SELECT isl.itemShelvingFk, - isl.created, - isl.accion, - isl.itemFk, - isl.shelvingFk, - isl.quantity, - isl.visible, - isl.available, - isl.grouping, - isl.packing, - isl.stars, - item.longName, - item.size, - item.subName, - worker.code, - isl.accion - FROM item - JOIN itemShelvingLog isl ON item.id = isl.itemFk - JOIN worker ON isl.workerFk = worker.id - WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk - ORDER BY isl.created DESC; - + DECLARE vQuery TEXT; + SET vQuery = ' + SELECT isl.itemShelvingFk, + isl.created, + isl.accion, + isl.itemFk, + isl.shelvingFk, + isl.quantity, + isl.visible, + isl.available, + isl.`grouping`, + isl.packing, + isl.stars, + item.longName, + item.size, + item.subName, + worker.code, + isl.accion + FROM item + JOIN itemShelvingLog isl ON item.id = isl.itemFk + JOIN worker ON isl.workerFk = worker.id + WHERE shelvingFk = ? + OR isl.itemFk = ? + ORDER BY isl.created DESC'; + + IF vRecords IS NOT NULL THEN + SET vQuery = CONCAT(vQuery, '\nLIMIT ', vRecords); + END IF; + + EXECUTE IMMEDIATE vQuery + USING vShelvingFk, vShelvingFk; END$$ DELIMITER ; From 1140e6bbd39234cfe27a1cf00ac55c25288e87fd Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 09:27:06 +0200 Subject: [PATCH 015/114] feat: refs #7168 Minor change --- .../vn/procedures/itemShelvingLog_get.sql | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingLog_get.sql b/db/routines/vn/procedures/itemShelvingLog_get.sql index 14d5101ee..f72a31a9b 100644 --- a/db/routines/vn/procedures/itemShelvingLog_get.sql +++ b/db/routines/vn/procedures/itemShelvingLog_get.sql @@ -13,25 +13,16 @@ BEGIN */ DECLARE vQuery TEXT; SET vQuery = ' - SELECT isl.itemShelvingFk, - isl.created, - isl.accion, - isl.itemFk, + SELECT isl.itemFk, + i.longName, isl.shelvingFk, + w.code, + isl.accion, isl.quantity, - isl.visible, - isl.available, - isl.`grouping`, - isl.packing, - isl.stars, - item.longName, - item.size, - item.subName, - worker.code, - isl.accion - FROM item - JOIN itemShelvingLog isl ON item.id = isl.itemFk - JOIN worker ON isl.workerFk = worker.id + isl.created + FROM item i + JOIN itemShelvingLog isl ON i.id = isl.itemFk + JOIN worker w ON isl.workerFk = w.id WHERE shelvingFk = ? OR isl.itemFk = ? ORDER BY isl.created DESC'; From 611f907ef0122b5c6137c0d6d61b38dc1d231ea7 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 25 Apr 2024 16:15:53 +0200 Subject: [PATCH 016/114] refs #6861 feat:reserveWithReservation --- .../vn/procedures/collection_addWithReservation.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index ea2632b05..ac0721146 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -2,7 +2,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_addWithReservation`( vItemFk INT, vQuantity INT, - vTicketFk INT + vTicketFk INT, + vSaleGroupFk INT ) BEGIN /** @@ -12,7 +13,9 @@ BEGIN * @param vItemFk id of item * @param vQuantity quantity to be added to the ticket * @param vTicketFk ticket to which the sales line is added + * @param vSaleGroupFk saleGroupFk id to add saleGroupDetail */ + DECLARE vWarehouseFk INT; DECLARE vCacheAvailableFk INT; DECLARE vAvailable INT; @@ -72,7 +75,7 @@ BEGIN CALL sale_calculateComponent(vSaleFk, NULL); CALL itemShelvingSale_addBySale(vSaleFk); - + IF NOT EXISTS (SELECT TRUE FROM itemShelvingSale WHERE saleFk = vSaleFk LIMIT 1) THEN SET vHasThrow = TRUE; END IF; @@ -81,6 +84,10 @@ BEGIN IF vHasThrow THEN CALL util.throw("No hay disponibilidad para el artículo seleccionado"); ELSE + IF vSaleGroupFk THEN + INSERT INTO saleGroupDetail + SET saleFk = vSaleFk, + saleGroupFk = vSaleGroupFk, COMMIT; END IF; END$$ From 3146f4f5b611a57d371ad3456049f1300d7deb45 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 2 May 2024 14:59:30 +0200 Subject: [PATCH 017/114] refactor: refs #6701 Refactor claim_ratio_routine --- .../bi/procedures/claim_ratio_routine.sql | 166 ------------------ db/routines/vn/procedures/claimRatio_add.sql | 154 ++++++++++++++++ .../11028-silverCarnation/00-firstScript.sql | 4 + 3 files changed, 158 insertions(+), 166 deletions(-) delete mode 100644 db/routines/bi/procedures/claim_ratio_routine.sql create mode 100644 db/routines/vn/procedures/claimRatio_add.sql create mode 100644 db/versions/11028-silverCarnation/00-firstScript.sql diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql deleted file mode 100644 index ae87e15a2..000000000 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ /dev/null @@ -1,166 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bi`.`claim_ratio_routine`() -BEGIN - DECLARE vMonthToRefund INT DEFAULT 4; - - /* - * PAK 2015-11-20 - * Se trata de añadir a la tabla Greuges todos los - * cargos que luego vamos a utilizar para calcular el recobro - */ - - -- Reclamaciones demasiado sensibles - - INSERT INTO vn.greuge(shipped, clientFk, description, - amount, greugeTypeFk, ticketFk) - SELECT c.ticketCreated - , c.clientFk - , concat('Claim ', c.id,' : ', s.concept) - ,round( -1 * ((c.responsibility -1)/4) * s.quantity * - s.price * (100 - s.discount) / 100, 2) - , 4 - , s.ticketFk - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3; - - -- Reclamaciones que pasan a Maná - - INSERT INTO vn.greuge(shipped, clientFk, description, - amount, greugeTypeFk, ticketFk) - SELECT c.ticketCreated - , c.clientFk - , concat('Claim_mana ',c.id,' : ', s.concept) - ,round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2) - ,3 - ,s.ticketFk - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3 - AND c.isChargedToMana; - - -- Marcamos para no repetir - UPDATE vn.claimEnd ce - JOIN vn.claim c ON c.id = ce.claimFk - SET c.isChargedToMana = TRUE - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3; - - -- Recobros - - DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; - CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.id Id_Ticket - FROM vn.saleComponent sc - JOIN vn.sale s ON sc.saleFk = s.id - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN vn.ticketLastState ts ON ts.ticketFk = t.id - JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN vn.state st ON st.id = tt.stateFk - WHERE sc.componentFk = 17 - AND sc.isGreuge = 0 - AND t.shipped >= '2016-10-01' - AND t.shipped < util.VN_CURDATE() - AND st.alertLevel >= 3; - - DELETE g.* - FROM vn.greuge g - JOIN tmp.ticket_list t ON g.ticketFk = t.Id_Ticket - WHERE g.greugeTypeFk = 2; - - INSERT INTO vn.greuge(clientFk, description, amount,shipped, - greugeTypeFk, ticketFk) - SELECT t.clientFk - ,concat('recobro ', s.ticketFk), - round(SUM(sc.value*s.quantity),2) - AS dif, - date(t.shipped) - , 2 - ,tt.Id_Ticket - FROM vn.sale s - JOIN vn.ticket t ON t.id = s.ticketFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id - JOIN vn.saleComponent sc - ON sc.saleFk = s.id AND sc.componentFk = 17 - GROUP BY t.id - HAVING ABS(dif) > 1; - - UPDATE vn.saleComponent sc - JOIN vn.sale s ON s.id = sc.saleFk - JOIN tmp.ticket_list tt ON tt.Id_Ticket = s.ticketFk - SET sc.isGreuge = 1 - WHERE sc.componentFk = 17; - - /* - * Recalculamos la ratio de las reclamaciones, que luego - * se va a utilizar en el recobro - */ - - REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) - SELECT id, 0,0,0,0 - FROM vn.client; - - REPLACE bi.claims_ratio(Id_Cliente, Consumo, Reclamaciones, Ratio, recobro) - SELECT fm.Id_Cliente, 12 * fm.Consumo, Reclamaciones, - round(Reclamaciones / (12*fm.Consumo),4), 0 - FROM bi.facturacion_media_anual fm - LEFT JOIN( - SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) * - s.quantity * s.price * (100 - s.discount) / 100)) - AS Reclamaciones - FROM vn.sale s - JOIN vn.claimEnd ce ON ce.saleFk = s.id - JOIN vn.claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND c.claimStateFk = 3 - AND c.ticketCreated >= TIMESTAMPADD(YEAR, -1, util.VN_CURDATE()) - GROUP BY c.clientFk - ) claims ON claims.clientFk = fm.Id_Cliente; - - - -- Calculamos el porcentaje del recobro para añadirlo al precio de venta - UPDATE bi.claims_ratio cr - JOIN ( - SELECT clientFk Id_Cliente, IFNULL(SUM(amount), 0) AS Greuge - FROM vn.greuge - WHERE shipped <= util.VN_CURDATE() - GROUP BY clientFk - ) g ON g.Id_Cliente = cr.Id_Cliente - SET recobro = GREATEST(0,round(IFNULL(Greuge, 0) / - (IFNULL(Consumo, 0) * vMonthToRefund / 12 ) ,3)); - - -- Protección neonatos - UPDATE bi.claims_ratio cr - JOIN vn.firstTicketShipped fts ON fts.clientFk = cr.Id_Cliente - SET recobro = 0, Ratio = 0 - WHERE fts.shipped > TIMESTAMPADD(MONTH,-1,util.VN_CURDATE()); - - -- CLIENTE 7983, JULIAN SUAU - UPDATE bi.claims_ratio SET recobro = LEAST(0.05, recobro) WHERE Id_Cliente = 7983; - - -- CLIENTE 4358 - UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 4358; - - -- CLIENTE 5523, VERDECORA - UPDATE bi.claims_ratio SET recobro = GREATEST(0.12, recobro) WHERE Id_Cliente = 5523; - - -- CLIENTE 15979, SERVEIS VETERINARIS - UPDATE bi.claims_ratio SET recobro = GREATEST(0.05, recobro) WHERE Id_Cliente = 15979; - - -- CLIENTE 5189 i 8942, son de CSR i son el mateix client - UPDATE bi.claims_ratio cr - JOIN (SELECT sum(Consumo * recobro)/sum(Consumo) as recobro - FROM bi.claims_ratio - WHERE Id_Cliente IN ( 5189,8942) - ) sub - SET cr.recobro = sub.recobro - WHERE Id_Cliente IN ( 5189,8942); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql new file mode 100644 index 000000000..2f64f8c7e --- /dev/null +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -0,0 +1,154 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`claimRatio_add`() +BEGIN +/* +* PAK 2015-11-20 +* Se trata de añadir a la tabla Greuges todos los +* cargos que luego vamos a utilizar para calcular el recobro +*/ + DECLARE vMonthToRefund INT DEFAULT 4; + DECLARE vRecoveryGreugeType INT; + + SELECT id INTO vRecoveryGreugeType + FROM greugeType + WHERE code = 'recovery'; + + -- Reclamaciones demasiado sensibles + INSERT INTO greuge(shipped, clientFk, description, + amount, greugeTypeFk, ticketFk) + SELECT c.ticketCreated + , c.clientFk + , concat('Claim ', c.id,' : ', s.concept) + ,round( -1 * ((c.responsibility -1)/4) * s.quantity * + s.price * (100 - s.discount) / 100, 2) + , 4 + , s.ticketFk + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claim c ON c.id = ce.claimFk + WHERE ce.claimDestinationFk NOT IN (1,5) + AND NOT ce.isGreuge + AND c.claimStateFk = 3; + + -- Reclamaciones que pasan a Maná + INSERT INTO greuge(shipped, + clientFk, + `description`, + amount, + greugeTypeFk, + ticketFk) + SELECT c.ticketCreated, + c.clientFk, + concat('Claim_mana ',c.id,' : ', s.concept), + round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2), + 3, + s.ticketFk + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claim c ON c.id = ce.claimFk + WHERE ce.claimDestinationFk NOT IN (1,5) + AND NOT ce.isGreuge + AND c.claimStateFk = 3 + AND c.isChargedToMana; + + -- Marcamos para no repetir + UPDATE claimEnd ce + JOIN claim c ON c.id = ce.claimFk + SET c.isChargedToMana = TRUE + WHERE ce.claimDestinationFk NOT IN (1,5) + AND NOT ce.isGreuge + AND c.claimStateFk = 3; + + -- Recobros + CREATE OR REPLACE TEMPORARY TABLE tTicketList + (PRIMARY KEY (ticketFk)) + SELECT DISTINCT s.ticketFk + FROM saleComponent sc + JOIN sale s ON sc.saleFk = s.id + JOIN ticket t ON t.id = s.ticketFk + JOIN ticketLastState ts ON ts.ticketFk = t.id + JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN state st ON st.id = tt.stateFk + WHERE sc.componentFk = 17 + AND sc.isGreuge = 0 + AND t.shipped >= '2016-10-01' + AND t.shipped < util.VN_CURDATE() + AND st.alertLevel >= 3; + + DELETE g.* + FROM greuge g + JOIN tTicketList t ON t.ticketFk = g.ticketFk + WHERE g.greugeTypeFk = vRecoveryGreugeType; + + INSERT INTO greuge(clientFk, + `description`, + amount, + shipped, + greugeTypeFk, + ticketFk) + SELECT t.clientFk, + 'Recobro', + - ROUND(SUM(sc.value * s.quantity), 2) dif, + DATE(t.shipped), + vRecoveryGreugeType, + tl.ticketFk + FROM sale s + JOIN ticket t ON t.id = s.ticketFk + JOIN tTicketList tl ON tl.ticketFk = t.id + JOIN saleComponent sc ON sc.saleFk = s.id + AND sc.componentFk = 17 + GROUP BY t.id + HAVING ABS(dif) > 1; + + UPDATE saleComponent sc + JOIN sale s ON s.id = sc.saleFk + JOIN tTicketList tl ON tl.ticketFk = s.ticketFk + SET sc.isGreuge = TRUE + WHERE sc.componentFk = 17; + + /* + * Recalculamos la ratio de las reclamaciones, que luego + * se va a utilizar en el recobro + */ + REPLACE claimRatio(clientFk, yearSale, claimAmount, claimingRate, priceIncreasing) + SELECT id, 0, 0, 0, 0 + FROM client; + + REPLACE claimRatio(clientFk, yearSale, claimAmount, claimingRate, priceIncreasing) + SELECT cac.clientFk, 12 * cac.invoiced, totalClaims, + ROUND(totalClaims / (12 * cac.invoiced), 4), 0 + FROM bs.clientAnnualConsumption cac + LEFT JOIN( + SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) * + s.quantity * s.price * (100 - s.discount) / 100)) + totalClaims + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claim c ON c.id = ce.claimFk + WHERE ce.claimDestinationFk NOT IN (1,5) + AND c.claimStateFk = 3 + AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR + GROUP BY c.clientFk + ) claims ON claims.clientFk = fm.Id_Cliente; + + -- Calculamos el porcentaje del recobro para añadirlo al precio de venta + UPDATE claimRatio cr + JOIN ( + SELECT clientFk, IFNULL(SUM(amount), 0) AS Greuge + FROM greuge + WHERE shipped <= util.VN_CURDATE() + GROUP BY clientFk + ) g ON g.clientFk = cr.clientFk + SET cr.priceIncreasing = GREATEST(0, round(IFNULL(Greuge, 0) / + (IFNULL(Consumo, 0) * vMonthToRefund / 12 ), 3)); + + -- Protección neonatos + UPDATE claimRatio cr + JOIN firstTicketShipped fts ON fts.clientFk = cr.clientFk + SET cr.priceIncreasing = 0, + cr.claimingRate = 0 + WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH; + + DROP TEMPORARY TABLE tTicketList; +END$$ +DELIMITER ; diff --git a/db/versions/11028-silverCarnation/00-firstScript.sql b/db/versions/11028-silverCarnation/00-firstScript.sql new file mode 100644 index 000000000..f865b0caf --- /dev/null +++ b/db/versions/11028-silverCarnation/00-firstScript.sql @@ -0,0 +1,4 @@ +UPDATE IGNORE bs.nightTask + SET `procedure` = 'claimRatio_add', + `schema` = 'vn' + WHERE `procedure` = 'claim_ratio_routine'; From 883f6f18a3b48560e82446251453057f5ef4a894 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 3 May 2024 13:47:55 +0200 Subject: [PATCH 018/114] refactor: refs #6701 Refactor claim_ratio_routine --- db/routines/vn/procedures/claimRatio_add.sql | 171 ++++++++++++------- 1 file changed, 108 insertions(+), 63 deletions(-) diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index 2f64f8c7e..deb5cc068 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -7,57 +7,82 @@ BEGIN * cargos que luego vamos a utilizar para calcular el recobro */ DECLARE vMonthToRefund INT DEFAULT 4; - DECLARE vRecoveryGreugeType INT; + DECLARE vRecoveryGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'recovery'); + DECLARE vManaGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'mana'); + DECLARE vClaimGreugeType INT + DEFAULT (SELECT id FROM greugeType WHERE code = 'claim'); + DECLARE vDebtComponentType INT + DEFAULT (SELECT id FROM component WHERE code = 'debtCollection'); - SELECT id INTO vRecoveryGreugeType - FROM greugeType - WHERE code = 'recovery'; + IF vRecoveryGreugeType IS NULL + OR vManaGreugeType IS NULL + OR vClaimGreugeType IS NULL + OR vDebtComponentType IS NULL THEN + + CALL util.throw('Required variables not found'); + END IF; -- Reclamaciones demasiado sensibles - INSERT INTO greuge(shipped, clientFk, description, - amount, greugeTypeFk, ticketFk) - SELECT c.ticketCreated - , c.clientFk - , concat('Claim ', c.id,' : ', s.concept) - ,round( -1 * ((c.responsibility -1)/4) * s.quantity * - s.price * (100 - s.discount) / 100, 2) - , 4 - , s.ticketFk - FROM sale s - JOIN claimEnd ce ON ce.saleFk = s.id - JOIN claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND NOT ce.isGreuge - AND c.claimStateFk = 3; - - -- Reclamaciones que pasan a Maná - INSERT INTO greuge(shipped, - clientFk, - `description`, - amount, - greugeTypeFk, - ticketFk) + INSERT INTO greuge( + shipped, + clientFk, + `description`, + amount, + greugeTypeFk, + ticketFk + ) SELECT c.ticketCreated, c.clientFk, - concat('Claim_mana ',c.id,' : ', s.concept), - round( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2), - 3, + CONCAT('Claim ', c.id,' : ', s.concept), + ROUND(-1 * ((c.responsibility - 1) / 4) * s.quantity * + s.price * (100 - s.discount) / 100, 2), + vClaimGreugeType, s.ticketFk FROM sale s JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE ce.claimDestinationFk NOT IN ('Bueno', 'Corregido') AND NOT ce.isGreuge - AND c.claimStateFk = 3 + AND cs.code = 'resolved'; + + -- Reclamaciones que pasan a Maná + INSERT INTO greuge( + shipped, + clientFk, + `description`, + amount, + greugeTypeFk, + ticketFk + ) + SELECT c.ticketCreated, + c.clientFk, + CONCAT('Claim_mana ', c.id,' : ', s.concept), + ROUND( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2), + vManaGreugeType, + s.ticketFk + FROM sale s + JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk + JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE cd.description NOT IN ('Bueno', 'Corregido') + AND NOT ce.isGreuge + AND cs.code = 'resolved' AND c.isChargedToMana; -- Marcamos para no repetir UPDATE claimEnd ce + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk + JOIN claimState cs ON cs.id = c.claimStateFk SET c.isChargedToMana = TRUE - WHERE ce.claimDestinationFk NOT IN (1,5) + WHERE cd.description NOT IN ('Bueno', 'Corregido') AND NOT ce.isGreuge - AND c.claimStateFk = 3; + AND cs.code = 'resolved'; -- Recobros CREATE OR REPLACE TEMPORARY TABLE tTicketList @@ -69,23 +94,26 @@ BEGIN JOIN ticketLastState ts ON ts.ticketFk = t.id JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN state st ON st.id = tt.stateFk - WHERE sc.componentFk = 17 - AND sc.isGreuge = 0 + JOIN alertLevel al ON al.id = st.alertLevel + WHERE sc.componentFk = vDebtComponentType + AND NOT sc.isGreuge AND t.shipped >= '2016-10-01' AND t.shipped < util.VN_CURDATE() - AND st.alertLevel >= 3; + AND al.code = 'DELIVERED'; DELETE g.* FROM greuge g JOIN tTicketList t ON t.ticketFk = g.ticketFk WHERE g.greugeTypeFk = vRecoveryGreugeType; - INSERT INTO greuge(clientFk, - `description`, - amount, - shipped, - greugeTypeFk, - ticketFk) + INSERT INTO greuge( + clientFk, + `description`, + amount, + shipped, + greugeTypeFk, + ticketFk + ) SELECT t.clientFk, 'Recobro', - ROUND(SUM(sc.value * s.quantity), 2) dif, @@ -96,51 +124,68 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN tTicketList tl ON tl.ticketFk = t.id JOIN saleComponent sc ON sc.saleFk = s.id - AND sc.componentFk = 17 + AND sc.componentFk = vDebtComponentType GROUP BY t.id - HAVING ABS(dif) > 1; + HAVING ABS(dif) > 1; UPDATE saleComponent sc JOIN sale s ON s.id = sc.saleFk JOIN tTicketList tl ON tl.ticketFk = s.ticketFk SET sc.isGreuge = TRUE - WHERE sc.componentFk = 17; + WHERE sc.componentFk = vDebtComponentType; /* * Recalculamos la ratio de las reclamaciones, que luego * se va a utilizar en el recobro */ - REPLACE claimRatio(clientFk, yearSale, claimAmount, claimingRate, priceIncreasing) - SELECT id, 0, 0, 0, 0 - FROM client; + REPLACE claimRatio( + clientFk, + yearSale, + claimAmount, + claimingRate, + priceIncreasing + ) + SELECT id, 0, 0, 0, 0 FROM client; - REPLACE claimRatio(clientFk, yearSale, claimAmount, claimingRate, priceIncreasing) - SELECT cac.clientFk, 12 * cac.invoiced, totalClaims, - ROUND(totalClaims / (12 * cac.invoiced), 4), 0 + REPLACE claimRatio( + clientFk, + yearSale, + claimAmount, + claimingRate, + priceIncreasing + ) + SELECT cac.clientFk, + 12 * cac.invoiced, + totalClaims, + ROUND(totalClaims / (12 * cac.invoiced), 4), + 0 FROM bs.clientAnnualConsumption cac - LEFT JOIN( - SELECT c.clientFk, round(sum(-1 * ((c.responsibility -1)/4) * - s.quantity * s.price * (100 - s.discount) / 100)) - totalClaims + LEFT JOIN ( + SELECT c.clientFk, + ROUND(SUM(-1 * ((c.responsibility - 1) / 4) * + s.quantity * s.price * (100 - s.discount) + / 100)) totalClaims FROM sale s JOIN claimEnd ce ON ce.saleFk = s.id + JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk - WHERE ce.claimDestinationFk NOT IN (1,5) - AND c.claimStateFk = 3 + JOIN claimState cs ON cs.id = c.claimStateFk + WHERE ce.claimDestinationFk NOT IN ('Bueno', 'Corregido') + AND cs.code = 'resolved' AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR GROUP BY c.clientFk - ) claims ON claims.clientFk = fm.Id_Cliente; + ) sub ON sub.clientFk = cac.clientFk; -- Calculamos el porcentaje del recobro para añadirlo al precio de venta UPDATE claimRatio cr JOIN ( - SELECT clientFk, IFNULL(SUM(amount), 0) AS Greuge + SELECT clientFk, IFNULL(SUM(amount), 0) greuge FROM greuge WHERE shipped <= util.VN_CURDATE() GROUP BY clientFk - ) g ON g.clientFk = cr.clientFk - SET cr.priceIncreasing = GREATEST(0, round(IFNULL(Greuge, 0) / - (IFNULL(Consumo, 0) * vMonthToRefund / 12 ), 3)); + ) sub ON subg.clientFk = cr.clientFk + SET cr.priceIncreasing = GREATEST(0, ROUND(IFNULL(sub.greuge, 0) / + (IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3)); -- Protección neonatos UPDATE claimRatio cr From f0b814c79b895ee4ac6487a6a4494c35feaf8c64 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 3 May 2024 14:15:55 +0200 Subject: [PATCH 019/114] refactor: refs #6701 Refactor claim_ratio_routine --- db/dump/fixtures.before.sql | 6 +-- db/routines/vn/procedures/claimRatio_add.sql | 37 +++++++------------ .../11028-silverCarnation/00-firstScript.sql | 6 +++ 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 06e94c99e..6b8166caa 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -831,9 +831,9 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) VALUES (1, 'Diff', 'diff'), - (2, 'Recover', 'recover'), - (3, 'Mana', 'mana'), - (4, 'Reclaim', 'reclaim'), + (2, 'Recobro', 'recovery'), + (3, 'Maná', 'mana'), + (4, 'Reclamación', 'claim'), (5, 'Heritage', 'heritage'), (6, 'Miscellaneous', 'miscellaneous'), (7, 'Freight Pickup', 'freightPickUp'); diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index deb5cc068..36b9023da 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -2,9 +2,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`claimRatio_add`() BEGIN /* -* PAK 2015-11-20 -* Se trata de añadir a la tabla Greuges todos los -* cargos que luego vamos a utilizar para calcular el recobro +* Añade a la tabla greuges todos los cargos necesario y +* que luego lo utilizamos para calcular el recobro. */ DECLARE vMonthToRefund INT DEFAULT 4; DECLARE vRecoveryGreugeType INT @@ -61,7 +60,8 @@ BEGIN SELECT c.ticketCreated, c.clientFk, CONCAT('Claim_mana ', c.id,' : ', s.concept), - ROUND( ((c.responsibility -1)/4) * s.quantity * s.price * (100 - s.discount) / 100, 2), + ROUND(((c.responsibility - 1) / 4) * s.quantity * + s.price * (100 - s.discount) / 100, 2), vManaGreugeType, s.ticketFk FROM sale s @@ -134,20 +134,7 @@ BEGIN SET sc.isGreuge = TRUE WHERE sc.componentFk = vDebtComponentType; - /* - * Recalculamos la ratio de las reclamaciones, que luego - * se va a utilizar en el recobro - */ - REPLACE claimRatio( - clientFk, - yearSale, - claimAmount, - claimingRate, - priceIncreasing - ) - SELECT id, 0, 0, 0, 0 FROM client; - - REPLACE claimRatio( + INSERT INTO claimRatio( clientFk, yearSale, claimAmount, @@ -163,8 +150,8 @@ BEGIN LEFT JOIN ( SELECT c.clientFk, ROUND(SUM(-1 * ((c.responsibility - 1) / 4) * - s.quantity * s.price * (100 - s.discount) - / 100)) totalClaims + s.quantity * s.price * (100 - s.discount) + / 100)) totalClaims FROM sale s JOIN claimEnd ce ON ce.saleFk = s.id JOIN claimDestination cd ON cd.id = ce.claimDestinationFk @@ -183,17 +170,19 @@ BEGIN FROM greuge WHERE shipped <= util.VN_CURDATE() GROUP BY clientFk - ) sub ON subg.clientFk = cr.clientFk + ) sub ON sub.clientFk = cr.clientFk SET cr.priceIncreasing = GREATEST(0, ROUND(IFNULL(sub.greuge, 0) / - (IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3)); + (IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3)) + WHERE cr.dated = util.VN_CURDATE(); -- Protección neonatos UPDATE claimRatio cr JOIN firstTicketShipped fts ON fts.clientFk = cr.clientFk SET cr.priceIncreasing = 0, cr.claimingRate = 0 - WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH; - + WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH + AND cr.dated = util.VN_CURDATE(); + DROP TEMPORARY TABLE tTicketList; END$$ DELIMITER ; diff --git a/db/versions/11028-silverCarnation/00-firstScript.sql b/db/versions/11028-silverCarnation/00-firstScript.sql index f865b0caf..9d291f451 100644 --- a/db/versions/11028-silverCarnation/00-firstScript.sql +++ b/db/versions/11028-silverCarnation/00-firstScript.sql @@ -2,3 +2,9 @@ UPDATE IGNORE bs.nightTask SET `procedure` = 'claimRatio_add', `schema` = 'vn' WHERE `procedure` = 'claim_ratio_routine'; + +ALTER TABLE vn.claimRatio ADD dated DATE DEFAULT current_timestamp() NOT NULL; +ALTER TABLE vn.claimRatio CHANGE dated dated DATE DEFAULT current_timestamp() NOT NULL FIRST; +ALTER TABLE vn.claimRatio DROP FOREIGN KEY claimRatio_ibfk_1; +ALTER TABLE vn.claimRatio DROP PRIMARY KEY; +ALTER TABLE vn.claimRatio ADD CONSTRAINT claimRatio_pk PRIMARY KEY (dated,clientFk); From 5a0882c2ac91c5ee7c9a1b087893822549d61a17 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 8 May 2024 10:59:19 +0200 Subject: [PATCH 020/114] refs #6861 feat:sectoCollection reserve --- .../collection_addWithReservation.sql | 11 ++++---- .../procedures/itemShelvingSale_reserve.sql | 2 ++ ...ShelvingSale_reserveBySectorCollection.sql | 15 ++++++++-- .../sectorCollection_getPartial.sql | 19 +++++++++++++ .../sectorCollection_hasSalesReserved.sql | 28 +++++++++++++++++++ db/versions/10852-pinkOak/00-firstScript.sql | 2 ++ 6 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 db/routines/vn/procedures/sectorCollection_getPartial.sql create mode 100644 db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index ac0721146..cc207b572 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -85,10 +85,11 @@ BEGIN CALL util.throw("No hay disponibilidad para el artículo seleccionado"); ELSE IF vSaleGroupFk THEN - INSERT INTO saleGroupDetail - SET saleFk = vSaleFk, - saleGroupFk = vSaleGroupFk, - COMMIT; - END IF; + INSERT INTO saleGroupDetail + SET saleFk = vSaleFk, + saleGroupFk = vSaleGroupFk; + COMMIT; + END IF; + END IF ; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_reserve.sql b/db/routines/vn/procedures/itemShelvingSale_reserve.sql index afe65bd78..803059423 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reserve.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reserve.sql @@ -52,6 +52,7 @@ BEGIN FROM tmp.sale ts JOIN sale s ON s.id = ts.saleFk JOIN itemShelving ish ON ish.itemFk = s.itemFk + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id LEFT JOIN ( SELECT itemShelvingFk, SUM(quantity) reservedQuantity FROM itemShelvingSale @@ -64,6 +65,7 @@ BEGIN JOIN productionConfig pc WHERE w.id = vWarehouseFk AND NOT sc.isHideForPickers + AND iss.id IS NULL ORDER BY s.id, p.pickingOrder >= vLastPickingOrder, diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql index 52d83a75d..b8387d20c 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql @@ -8,6 +8,8 @@ BEGIN * * @param vSectorCollectionFk Identificador de sectorCollection */ + DECLARE vHasSales BOOL; + CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk)) ENGINE = MEMORY @@ -18,9 +20,18 @@ BEGIN JOIN saleTracking str ON str.saleFk = s.id JOIN `state` st ON st.id = str.stateFk AND st.code = 'PREVIOUS_PREPARATION' + LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id WHERE sc.sectorCollectionFk = vSectorCollectionFk - AND str.workerFk = account.myUser_getId(); + AND str.workerFk = account.myUser_getId() + AND iss.id IS NULL; - CALL itemShelvingSale_reserve(); + SELECT COUNT(*)INTO vHasSales + FROM tmp.sale; + + IF vHasSales THEN + CALL itemShelvingSale_reserve(); + ELSE + CALL util.throw ('There are not sales to reserve'); + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/sectorCollection_getPartial.sql b/db/routines/vn/procedures/sectorCollection_getPartial.sql new file mode 100644 index 000000000..2f59f591a --- /dev/null +++ b/db/routines/vn/procedures/sectorCollection_getPartial.sql @@ -0,0 +1,19 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getPartial`() +BEGIN +/** + * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas + * + */ + SELECT DISTINCT sc.id collectionFk, sc.created + FROM vn.sectorCollection sc + LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + LEFT JOIN vn.sale sl ON sl.id = sgd.saleFk + LEFT JOIN itemShelvingSale iss ON iss.saleFk = sl.id + WHERE sc.userFk = account.myUser_getId() + AND (ISNULL(scsg.sectorCollectionFk) + OR (NOT iss.isPicked)) + AND sc.created > util.VN_CURDATE() - INTERVAL 1 DAY; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql new file mode 100644 index 000000000..e0ef46a86 --- /dev/null +++ b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql @@ -0,0 +1,28 @@ +CREATE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1) +DETERMINISTIC +BEGIN + +/** +* Devuelve si sectorCollection tiene reservas +* @param vSelf Id de sectorCollection +* +* returns BOOLEAN +*/ + + DECLARE vHasSalesReserved BOOLEAN; + + + SELECT DISTINCT COUNT(*)>0 INTO vHasSalesReserved + FROM vn.sectorCollection sc + JOIN vn.sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk + JOIN vn.saleGroup sg ON sg.id = scsg.saleGroupFk + JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN vn.sale s ON s.id = sgd.saleFk + JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id + JOIN vn.saleTracking st ON st.saleFk = s.id + WHERE sc.id = vSelf; + + RETURN vHasSalesReserved; + +END$$ +DELIMITER ; diff --git a/db/versions/10852-pinkOak/00-firstScript.sql b/db/versions/10852-pinkOak/00-firstScript.sql index 7af48148c..369e32e92 100644 --- a/db/versions/10852-pinkOak/00-firstScript.sql +++ b/db/versions/10852-pinkOak/00-firstScript.sql @@ -3,6 +3,8 @@ ALTER TABLE vn.itemShelvingSale DROP COLUMN IF EXISTS isPicked; ALTER TABLE vn.itemShelvingSale ADD isPicked TINYINT(1) DEFAULT FALSE NOT NULL; +UPDATE vn.itemShelvingSale SET isPicked = TRUE; + ALTER TABLE vn.productionConfig DROP COLUMN IF EXISTS orderMode; ALTER TABLE vn.productionConfig From 679f9a1b9b6427ac55982d489ca20c80f14968ff Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 9 May 2024 07:07:10 +0200 Subject: [PATCH 021/114] refs #6861 feat:sectoCollection reserve --- .../vn/procedures/sectorCollection_hasSalesReserved.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql index e0ef46a86..0de49e90c 100644 --- a/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql +++ b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql @@ -1,4 +1,5 @@ -CREATE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1) DETERMINISTIC BEGIN From 22a6c3695c25958fc8c91ecbd19af3d4bfdedac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 22 May 2024 18:05:16 +0200 Subject: [PATCH 022/114] feat:concurrency issue refs #6861 --- .../vn/procedures/itemShelvingSale_addBySale.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql index 3ad581b15..7e836859a 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addBySale.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySale.sql @@ -37,12 +37,12 @@ proc: BEGIN IF(pc.orderMode = 'Location', p.pickingOrder, ish.created); DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; -/* DECLARE EXIT HANDLER FOR SQLEXCEPTION + DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; RESIGNAL; END; -*/ + SELECT MAX(p.pickingOrder), s.quantity - SUM(IFNULL(iss.quantity, 0)) INTO vLastPickingOrder, vOutStanding FROM sale s @@ -67,6 +67,8 @@ proc: BEGIN LEAVE l; END IF; + START TRANSACTION; + SELECT id INTO vItemShelvingFk FROM itemShelving WHERE id = vItemShelvingFk @@ -76,7 +78,6 @@ proc: BEGIN SET vOutStanding = vOutStanding - vReservedQuantity; IF vReservedQuantity > 0 THEN - -- START TRANSACTION; INSERT INTO itemShelvingSale( itemShelvingFk, @@ -92,8 +93,9 @@ proc: BEGIN SET available = available - vReservedQuantity WHERE id = vItemShelvingFk; - -- COMMIT; END IF; + + COMMIT; END LOOP; CLOSE vItemShelvingAvailable; END$$ From e902a84d10b66cb3a4cc032aa2baf445408ef4aa Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 23 May 2024 09:22:19 +0200 Subject: [PATCH 023/114] refactor: refs #5447 changed models --- back/models/country.json | 8 ++++++++ back/models/warehouse.json | 10 ++++++++++ loopback/locale/en.json | 9 +++++---- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/back/models/country.json b/back/models/country.json index a4c74d330..5b9d842a8 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -25,6 +25,9 @@ }, "isSocialNameUnique": { "type": "boolean" + }, + "continentFk": { + "type": "number" } }, "relations": { @@ -32,6 +35,11 @@ "type": "belongsTo", "model": "Currency", "foreignKey": "currencyFk" + }, + "continent": { + "type": "belongsTo", + "model": "Continent", + "foreignKey": "continentFk" } }, "acls": [ diff --git a/back/models/warehouse.json b/back/models/warehouse.json index dcbf7f2d2..f12b5e86e 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -24,6 +24,16 @@ }, "isManaged":{ "type": "boolean" + }, + "countryFk": { + "type": "number" + } + }, + "relations": { + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" } }, "acls": [ diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ca76eae42..601a26f5b 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -223,7 +223,8 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", - "They're not your subordinate": "They're not your subordinate", - "InvoiceIn is already booked": "InvoiceIn is already booked" -} + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate", + "InvoiceIn is already booked": "InvoiceIn is already booked", + "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency" +} \ No newline at end of file From ea4f70f460b4186c4e7d97171a023f116fc5511d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 23 May 2024 16:35:36 +0200 Subject: [PATCH 024/114] refs #6861 feat: previas a reservas --- .../vn/procedures/collection_getTickets.sql | 52 +++++----- ...temShelvingSale_addBySectorCollection.sql} | 34 ++++--- .../procedures/itemShelvingSale_reserve.sql | 94 ------------------- .../itemShelvingSale_reserveByCollection.sql | 29 ------ .../itemShelvingSale_reserveBySale.sql | 21 ----- 5 files changed, 45 insertions(+), 185 deletions(-) rename db/routines/vn/procedures/{itemShelvingSale_reserveBySectorCollection.sql => itemShelvingSale_addBySectorCollection.sql} (64%) delete mode 100644 db/routines/vn/procedures/itemShelvingSale_reserve.sql delete mode 100644 db/routines/vn/procedures/itemShelvingSale_reserveByCollection.sql delete mode 100644 db/routines/vn/procedures/itemShelvingSale_reserveBySale.sql diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 3f1239e9b..09624acd2 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -19,9 +19,9 @@ BEGIN WITH observation AS ( SELECT tob.ticketFk, tob.description - FROM vn.ticketObservation tob - JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk - LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk + FROM ticketObservation tob + JOIN ticketCollection tc ON tc.ticketFk = tob.ticketFk + LEFT JOIN observationType ot ON ot.id = tob.observationTypeFk WHERE ot.`code` = 'itemPicker' AND tc.collectionFk = vParamFk ) @@ -32,17 +32,17 @@ BEGIN w.id salesPersonFk, IFNULL(ob.description,'') observation, cc.rgb - FROM vn.ticket t - LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk - LEFT JOIN vn.collectionColors cc + FROM ticket t + LEFT JOIN ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN collection c2 ON c2.id = tc.collectionFk + LEFT JOIN collectionColors cc ON cc.wagon = tc.wagon AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE t.id = vParamFk AND t.shipped >= vDated @@ -54,17 +54,17 @@ BEGIN w.id salesPersonFk, ob.description, IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` - FROM vn.ticket t - JOIN vn.ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk - LEFT JOIN vn.collectionColors cc + FROM ticket t + JOIN ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN collection c2 ON c2.id = tc.collectionFk + LEFT JOIN collectionColors cc ON cc.wagon = tc.wagon AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN vn.client c ON c.id = t.clientFk - LEFT JOIN vn.worker w ON w.id = c.salesPersonFk + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE tc.collectionFk = vParamFk UNION ALL @@ -75,14 +75,14 @@ BEGIN c.salesPersonFk, ob.description, NULL `rgb` - FROM vn.sectorCollection sc - JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id - JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk - JOIN vn.ticket t ON t.id = sg.ticketFk - LEFT JOIN vn.zone z ON z.id = t.zoneFk - LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN saleGroup sg ON sg.id = ss.saleGroupFk + JOIN ticket t ON t.id = sg.ticketFk + LEFT JOIN zone z ON z.id = t.zoneFk + LEFT JOIN agencyMode am ON am.id = z.agencyModeFk LEFT JOIN observation ob ON ob.ticketFk = t.id - LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN client c ON c.id = t.clientFk WHERE sc.id = vParamFk AND t.shipped >= vDated; END$$ diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql similarity index 64% rename from db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql rename to db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql index b8387d20c..442abcf5d 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reserveBySectorCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addBySectorCollection.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE - `vn`.`itemShelvingSale_reserveBySectorCollection`(vSectorCollectionFk INT(11)) + `vn`.`itemShelvingSale_addBySectorCollection`(vSectorCollectionFk INT(11)) BEGIN /** * Reserva cantidades con ubicaciones para el contenido de una preparación previa @@ -8,12 +8,10 @@ BEGIN * * @param vSectorCollectionFk Identificador de sectorCollection */ - DECLARE vHasSales BOOL; - - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) - ENGINE = MEMORY - SELECT s.id saleFk, str.workerFk userFK + DECLARE vDone BOOL DEFAULT FALSE; + DECLARE vSaleFk INT; + DECLARE vSales CURSOR FOR + SELECT s.id FROM sectorCollectionSaleGroup sc JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk JOIN sale s ON sg.saleFk = s.id @@ -25,13 +23,19 @@ BEGIN AND str.workerFk = account.myUser_getId() AND iss.id IS NULL; - SELECT COUNT(*)INTO vHasSales - FROM tmp.sale; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - IF vHasSales THEN - CALL itemShelvingSale_reserve(); - ELSE - CALL util.throw ('There are not sales to reserve'); - END IF; + OPEN vSales; + l: LOOP + SET vDone = FALSE; + FETCH vSales INTO vSaleFk; + + IF vDone THEN + LEAVE l; + END IF; + + CALL itemShelvingSale_addBySale(vSaleFk); + END LOOP; + CLOSE vSales; END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_reserve.sql b/db/routines/vn/procedures/itemShelvingSale_reserve.sql deleted file mode 100644 index 803059423..000000000 --- a/db/routines/vn/procedures/itemShelvingSale_reserve.sql +++ /dev/null @@ -1,94 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserve`() -BEGIN -/** - * Reserva cantidades con ubicaciones para un conjunto de sales del mismo - * almacen. - * - * @table tmp.sale(saleFk, userFk) - */ - DECLARE vCalcFk INT; - DECLARE vWarehouseFk INT; - DECLARE vCurrentYear INT DEFAULT YEAR(util.VN_NOW()); - DECLARE vLastPickingOrder INT; - - SELECT t.warehouseFk, MAX(p.pickingOrder) - INTO vWarehouseFk, vLastPickingOrder - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN tmp.sale ts ON ts.saleFk = s.id - LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk - LEFT JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - LEFT JOIN shelving sh ON sh.code = ish.shelvingFk - LEFT JOIN parking p ON p.id = sh.parkingFk - WHERE t.warehouseFk IS NOT NULL; - - IF vWarehouseFk IS NULL THEN - CALL util.throw('Warehouse not set'); - END IF; - - CALL cache.visible_refresh(vCalcFk, FALSE, vWarehouseFk); - - SET @outstanding = 0; - SET @oldsaleFk = 0; - - CREATE OR REPLACE TEMPORARY TABLE tSalePlacementQuantity - (INDEX(saleFk)) - ENGINE = MEMORY - SELECT saleFk, userFk, quantityToReserve, itemShelvingFk - FROM( SELECT saleFk, - sub.userFk, - itemShelvingFk , - IF(saleFk <> @oldsaleFk, @outstanding := quantity, @outstanding), - @qtr := LEAST(@outstanding, available) quantityToReserve, - @outStanding := @outStanding - @qtr, - @oldsaleFk := saleFk - FROM( - SELECT ts.saleFk, - ts.userFk, - s.quantity, - ish.id itemShelvingFk, - ish.visible - IFNULL(ishr.reservedQuantity, 0) available - FROM tmp.sale ts - JOIN sale s ON s.id = ts.saleFk - JOIN itemShelving ish ON ish.itemFk = s.itemFk - LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id - LEFT JOIN ( - SELECT itemShelvingFk, SUM(quantity) reservedQuantity - FROM itemShelvingSale - WHERE NOT isPicked - GROUP BY itemShelvingFk) ishr ON ishr.itemShelvingFk = ish.id - JOIN shelving sh ON sh.code = ish.shelvingFk - JOIN parking p ON p.id = sh.parkingFk - JOIN sector sc ON sc.id = p.sectorFk - JOIN warehouse w ON w.id = sc.warehouseFk - JOIN productionConfig pc - WHERE w.id = vWarehouseFk - AND NOT sc.isHideForPickers - AND iss.id IS NULL - ORDER BY - s.id, - p.pickingOrder >= vLastPickingOrder, - sh.priority DESC, - ish.visible >= s.quantity DESC, - s.quantity MOD ish.grouping = 0 DESC, - ish.grouping DESC, - IF(pc.orderMode = 'Location', p.pickingOrder, ish.created) - )sub - )sub2 - WHERE quantityToReserve > 0; - - INSERT INTO itemShelvingSale( - itemShelvingFk, - saleFk, - quantity, - userFk) - SELECT itemShelvingFk, - saleFk, - quantityToReserve, - IFNULL(userFk, getUser()) - FROM tSalePlacementQuantity spl; - - DROP TEMPORARY TABLE tmp.sale; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_reserveByCollection.sql deleted file mode 100644 index 9a97130dd..000000000 --- a/db/routines/vn/procedures/itemShelvingSale_reserveByCollection.sql +++ /dev/null @@ -1,29 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserveByCollection`( - vCollectionFk INT(11) -) -BEGIN -/** - * Reserva cantidades con ubicaciones para el contenido de una colección - * - * @param vCollectionFk Identificador de collection - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - (INDEX(saleFk)) - ENGINE = MEMORY - SELECT s.id saleFk, NULL userFk - FROM ticketCollection tc - JOIN sale s ON s.ticketFk = tc.ticketFk - LEFT JOIN ( - SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.isChecked - AND s.semaphore = 1)st ON st.saleFk = s.id - WHERE tc.collectionFk = vCollectionFk - AND st.saleFk IS NULL - AND NOT s.isPicked; - - CALL itemShelvingSale_reserve(); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_reserveBySale.sql b/db/routines/vn/procedures/itemShelvingSale_reserveBySale.sql deleted file mode 100644 index fb245062e..000000000 --- a/db/routines/vn/procedures/itemShelvingSale_reserveBySale.sql +++ /dev/null @@ -1,21 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reserveBySale`( - vSelf INT , - vQuantity INT, - vUserFk INT -) -BEGIN -/** - * Reserva cantida y ubicación para una saleFk - * - * @param vSelf Identificador de la venta - * @param vQuantity Cantidad a reservar - * @param vUserFk Id de usuario que realiza la reserva - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.sale - ENGINE = MEMORY - SELECT vSelf saleFk, vUserFk userFk; - - CALL itemShelvingSale_reserve(); -END$$ -DELIMITER ; From 723327918b4c479c095e0702b95fb072c3887636 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 24 May 2024 15:55:23 +0200 Subject: [PATCH 025/114] refs #7406 worker formation --- db/dump/fixtures.before.sql | 15 ++++- .../worker/back/models/trainingCenter.json | 21 ++++++ .../worker/back/models/trainingCourse.json | 67 +++++++++++++++++++ .../back/models/trainingCourseType.json | 39 +++++++++++ 4 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 modules/worker/back/models/trainingCenter.json create mode 100644 modules/worker/back/models/trainingCourse.json create mode 100644 modules/worker/back/models/trainingCourseType.json diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index b8094471a..7765edc9f 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3788,14 +3788,23 @@ INSERT INTO vn.workerTeam(id, team, workerFk) VALUES (8, 1, 19); -INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) +INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); -UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; +UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; INSERT INTO `vn`.`ledgerCompany` SET fiscalYear = YEAR(util.VN_CURDATE()), bookEntry = 2; -INSERT INTO `vn`.`ledgerConfig` SET +INSERT INTO `vn`.`ledgerConfig` SET maxTolerance = 0.01; + + +INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma) + VALUES (9,2,1,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',0,1); +INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma) + VALUES (9,1,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,0); +INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma) + VALUES (9,2,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,1); + diff --git a/modules/worker/back/models/trainingCenter.json b/modules/worker/back/models/trainingCenter.json new file mode 100644 index 000000000..8c5e47873 --- /dev/null +++ b/modules/worker/back/models/trainingCenter.json @@ -0,0 +1,21 @@ +{ + "name": "TrainingCenter", + "base": "VnModel", + "options": { + "mysql": { + "table": "trainingCenter" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + } + + } +} diff --git a/modules/worker/back/models/trainingCourse.json b/modules/worker/back/models/trainingCourse.json new file mode 100644 index 000000000..7a44ad419 --- /dev/null +++ b/modules/worker/back/models/trainingCourse.json @@ -0,0 +1,67 @@ +{ + "name": "TrainingCourse", + "description": "List of workers who have completed training", + "base": "VnModel", + "options": { + "mysql": { + "table": "trainingCourse" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "workerFk": { + "type": "number", + "required": true + }, + "trainingCourseTypeFk": { + "type": "number", + "required": true + }, + "centerFk": { + "type" : "number" + }, + "started": { + "type" : "date" + }, + "ended": { + "type" : "date" + }, + "invoice": { + "type" : "string" + }, + "amount": { + "type" : "number" + }, + "remark": { + "type" : "boolean" + }, + "hasDiscount": { + "type" : "boolean" + }, + "hasDiploma": { + "type" : "boolean" + } + + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "trainingCourseType": { + "type": "belongsTo", + "model": "trainingCourseType", + "foreignKey": "trainingCourseTypeFk" + }, + "centerFk": { + "type": "belongsTo", + "model": "Center", + "foreignKey": "centerFk" + } + } +} diff --git a/modules/worker/back/models/trainingCourseType.json b/modules/worker/back/models/trainingCourseType.json new file mode 100644 index 000000000..1dc708f2f --- /dev/null +++ b/modules/worker/back/models/trainingCourseType.json @@ -0,0 +1,39 @@ +{ + "name": "trainingCourseType", + "description": "List of trainings", + "base": "VnModel", + "options": { + "mysql": { + "table": "trainingCourseType" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string", + "required": true + } + + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "trainingCourseType": { + "type": "belongsTo", + "model": "trainingCourseType", + "foreignKey": "trainingCourseTypeFk" + }, + "centerFk": { + "type": "belongsTo", + "model": "Center", + "foreignKey": "centerFk" + } + } +} From d770cd8d48a8785a20b70bab93bca0a98d2d841c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 27 May 2024 07:33:33 +0200 Subject: [PATCH 026/114] refs #6861 feat: getLock --- .../vn/procedures/collection_getAssigned.sql | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql index dead563ac..63805e701 100644 --- a/db/routines/vn/procedures/collection_getAssigned.sql +++ b/db/routines/vn/procedures/collection_getAssigned.sql @@ -10,13 +10,27 @@ proc:BEGIN * @param vCollectionFk Id de colección */ DECLARE vHasTooMuchCollections BOOL; - DECLARE vLockTime INT DEFAULT 15; + DECLARE vItemPackingTypeFk VARCHAR(1); + DECLARE vWarehouseFk INT; + DECLARE vLockName VARCHAR(215); + DECLARE vLockTime INT DEFAULT 30; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + IF vLockName IS NOT NULL THEN + DO RELEASE_LOCK(vLockName); + END IF; + + RESIGNAL; + END; -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 - INTO vHasTooMuchCollections + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, + collection_assign_lockname + INTO vHasTooMuchCollections, + vLockName FROM tCollection JOIN productionConfig pc ; @@ -27,8 +41,19 @@ proc:BEGIN LEAVE proc; END IF; - IF NOT GET_LOCK('collection_getAssigned', vLockTime) THEN - LEAVE proc; + SELECT warehouseFk, itemPackingTypeFk + INTO vWarehouseFk, vItemPackingTypeFk + FROM operator + WHERE workerFk = vUserFk; + + SET vLockName = CONCAT_WS('/', + vLockName, + vWarehouseFk, + vItemPackingTypeFk + ); + + IF NOT GET_LOCK(vLockName, vLockTime) THEN + CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); END IF; -- Se eliminan las colecciones sin asignar que estan obsoletas @@ -72,6 +97,6 @@ proc:BEGIN CALL itemShelvingSale_addByCollection(vCollectionFk); - DO RELEASE_LOCK('collection_getAssigned'); + DO RELEASE_LOCK(vLockName); END$$ DELIMITER ; \ No newline at end of file From 2cd7133a8cd25098228dfeda73a7b6e1e8281e08 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 27 May 2024 08:15:57 +0200 Subject: [PATCH 027/114] refs #6861 feat: skipTest --- back/methods/collection/spec/assignCollection.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/collection/spec/assignCollection.spec.js b/back/methods/collection/spec/assignCollection.spec.js index 340bd6a93..e8f3882a3 100644 --- a/back/methods/collection/spec/assignCollection.spec.js +++ b/back/methods/collection/spec/assignCollection.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; const LoopBackContext = require('loopback-context'); -fdescribe('ticket assignCollection()', () => { +describe('ticket assignCollection()', () => { let ctx; let options; let tx; From 74b71079f26f0ceda927500e5ae5fa84e3cd86ba Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 27 May 2024 11:33:04 +0200 Subject: [PATCH 028/114] refs #6861 feat: obsrevation --- back/methods/collection/getSales.js | 2 +- .../collection/spec/getTickets.spec.js | 4 +- .../vn/procedures/collection_getTickets.sql | 54 +++++++++---------- .../triggers/itemShelvingSale_afterInsert.sql | 12 +++++ db/versions/10852-pinkOak/00-firstScript.sql | 4 +- 5 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 db/routines/vn/triggers/itemShelvingSale_afterInsert.sql diff --git a/back/methods/collection/getSales.js b/back/methods/collection/getSales.js index 1ea5dcc3c..8f5bfaeef 100644 --- a/back/methods/collection/getSales.js +++ b/back/methods/collection/getSales.js @@ -60,7 +60,7 @@ module.exports = Self => { if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions); for (let ticket of tickets) { - let observations = ticket.observation.split(' '); + let observations = ticket.observaciones.split(' '); for (let observation of observations) { const salesPerson = ticket.salesPersonFk; diff --git a/back/methods/collection/spec/getTickets.spec.js b/back/methods/collection/spec/getTickets.spec.js index e6b9e6a17..969800839 100644 --- a/back/methods/collection/spec/getTickets.spec.js +++ b/back/methods/collection/spec/getTickets.spec.js @@ -26,8 +26,8 @@ describe('collection getTickets()', () => { expect(collectionTickets.tickets[1].ticketFk).toEqual(2); expect(collectionTickets.tickets[2].ticketFk).toEqual(23); expect(collectionTickets.tickets[0].sales[0].ticketFk).toEqual(1); - expect(collectionTickets.tickets[0].sales[1].ticketFk).toEqual(1); - expect(collectionTickets.tickets[0].sales[2].ticketFk).toEqual(1); + expect(collectionTickets.tickets[1].sales.length).toEqual(0); + expect(collectionTickets.tickets[2].sales.length).toEqual(0); expect(collectionTickets.tickets[0].sales[0].Barcodes.length).toBeTruthy(); await tx.rollback(); diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 09624acd2..8be8c8654 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -19,9 +19,9 @@ BEGIN WITH observation AS ( SELECT tob.ticketFk, tob.description - FROM ticketObservation tob - JOIN ticketCollection tc ON tc.ticketFk = tob.ticketFk - LEFT JOIN observationType ot ON ot.id = tob.observationTypeFk + FROM vn.ticketObservation tob + JOIN vn.ticketCollection tc ON tc.ticketFk = tob.ticketFk + LEFT JOIN vn.observationType ot ON ot.id = tob.observationTypeFk WHERE ot.`code` = 'itemPicker' AND tc.collectionFk = vParamFk ) @@ -30,19 +30,19 @@ BEGIN am.name agencyName, t.warehouseFk, w.id salesPersonFk, - IFNULL(ob.description,'') observation, + IFNULL(ob.description,'') observaciones, cc.rgb - FROM ticket t - LEFT JOIN ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN collection c2 ON c2.id = tc.collectionFk - LEFT JOIN collectionColors cc + FROM vn.ticket t + LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE t.id = vParamFk AND t.shipped >= vDated @@ -54,17 +54,17 @@ BEGIN w.id salesPersonFk, ob.description, IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` - FROM ticket t - JOIN ticketCollection tc ON t.id = tc.ticketFk - LEFT JOIN collection c2 ON c2.id = tc.collectionFk - LEFT JOIN collectionColors cc + FROM vn.ticket t + JOIN vn.ticketCollection tc ON t.id = tc.ticketFk + LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk + LEFT JOIN vn.collectionColors cc ON cc.wagon = tc.wagon AND cc.shelve = tc.`level` AND cc.trainFk = c2.trainFk - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN agencyMode am ON am.id = z.agencyModeFk - LEFT JOIN client c ON c.id = t.clientFk - LEFT JOIN worker w ON w.id = c.salesPersonFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE tc.collectionFk = vParamFk UNION ALL @@ -75,14 +75,14 @@ BEGIN c.salesPersonFk, ob.description, NULL `rgb` - FROM sectorCollection sc - JOIN sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id - JOIN saleGroup sg ON sg.id = ss.saleGroupFk - JOIN ticket t ON t.id = sg.ticketFk - LEFT JOIN zone z ON z.id = t.zoneFk - LEFT JOIN agencyMode am ON am.id = z.agencyModeFk + FROM vn.sectorCollection sc + JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id + JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk + JOIN vn.ticket t ON t.id = sg.ticketFk + LEFT JOIN vn.zone z ON z.id = t.zoneFk + LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN observation ob ON ob.ticketFk = t.id - LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN vn.client c ON c.id = t.clientFk WHERE sc.id = vParamFk AND t.shipped >= vDated; END$$ diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql new file mode 100644 index 000000000..71ede88f7 --- /dev/null +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -0,0 +1,12 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert` + AFTER INSERT ON `itemShelving` + FOR EACH ROW +BEGIN + + UPDATE sale s + JOIN operator o ON o.workerFk = account.myUser_getId() + SET isPicked = IF(o.isOnReservationMode, isPicked, TRUE) + WHERE id = NEW.saleFk; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/10852-pinkOak/00-firstScript.sql b/db/versions/10852-pinkOak/00-firstScript.sql index 369e32e92..7739976e6 100644 --- a/db/versions/10852-pinkOak/00-firstScript.sql +++ b/db/versions/10852-pinkOak/00-firstScript.sql @@ -27,4 +27,6 @@ CREATE TABLE vn.itemShelvingSaleReserv ( INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) VALUES - ('Collection', 'assignCollection', 'WRITE', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file + ('Collection', 'assignCollection', 'WRITE', 'ALLOW', 'ROLE', 'production'); + +ALTER TABLE vn.operator ADD IF NOT EXISTS isOnReservationMode TINYINT(1) NOT NULL DEFAULT FALSE; \ No newline at end of file From 208409acb2118e69e0485d7b2d6914bac0b45ddf Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 27 May 2024 11:50:15 +0200 Subject: [PATCH 029/114] refs #7406 add relation --- modules/worker/back/models/worker.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4e7617aab..3eab43650 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -115,6 +115,11 @@ "type": "hasMany", "model": "Locker", "foreignKey": "workerFk" + }, + "trainingCourse": { + "type": "hasMany", + "model": "TrainingCourse", + "foreignKey": "workerFk" } }, "acls":[ From e133dec514fef4a8e34757f0ba9419147d055af7 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 27 May 2024 11:55:42 +0200 Subject: [PATCH 030/114] refs #6861 feat: trigger --- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 71ede88f7..f5bd88b1b 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -1,6 +1,6 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert` - AFTER INSERT ON `itemShelving` +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert` + AFTER INSERT ON `itemShelvingSale` FOR EACH ROW BEGIN From 32aafc35453d4acdc44241814c3367c97f7b936b Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 27 May 2024 12:21:22 +0200 Subject: [PATCH 031/114] feat: refs #6861 trigger --- db/routines/vn/triggers/itemShelving_afterInsert.sql | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/triggers/itemShelving_afterInsert.sql b/db/routines/vn/triggers/itemShelving_afterInsert.sql index 86f149473..819e3e790 100644 --- a/db/routines/vn/triggers/itemShelving_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelving_afterInsert.sql @@ -3,8 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterIns AFTER INSERT ON `itemShelving` FOR EACH ROW BEGIN - - INSERT INTO vn.itemShelvingLog( + INSERT INTO vn.itemShelvingLog( itemShelvingFk, workerFk, accion, @@ -13,8 +12,10 @@ BEGIN visible, `grouping`, packing, - available) - VALUES( NEW.id, + available + ) + VALUES ( + NEW.id, NEW.userFk, 'CREA REGISTRO', NEW.itemFk, @@ -22,6 +23,7 @@ BEGIN NEW.visible, NEW.`grouping`, NEW.packing, - NEW.available); + NEW.available + ); END$$ DELIMITER ; \ No newline at end of file From 578b8a2c71348188a4da17cc568ecc2d9fa511e9 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 27 May 2024 14:28:13 +0200 Subject: [PATCH 032/114] refs #7406 changes sql, modelconfig model --- db/versions/11073-crimsonBirch/00-firstScript.sql | 9 +++++++++ modules/worker/back/model-config.json | 9 +++++++++ modules/worker/back/models/trainingCourseType.json | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/versions/11073-crimsonBirch/00-firstScript.sql diff --git a/db/versions/11073-crimsonBirch/00-firstScript.sql b/db/versions/11073-crimsonBirch/00-firstScript.sql new file mode 100644 index 000000000..2ad04468f --- /dev/null +++ b/db/versions/11073-crimsonBirch/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values. +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('TrainingCourse','*','*','ALLOW','ROLE','employee'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('TrainingCourseType','*','*','ALLOW','ROLE','employee'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('TrainingCenter','*','*','ALLOW','ROLE','employee'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','__get_trainingCourse','*','ALLOW','ROLE','employee'); diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index b7c355511..9bf2f014f 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -124,6 +124,15 @@ }, "Locker": { "dataSource": "vn" + }, + "TrainingCourse": { + "dataSource": "vn" + }, + "TrainingCourseType": { + "dataSource": "vn" + }, + "TrainingCenter": { + "dataSource": "vn" } } diff --git a/modules/worker/back/models/trainingCourseType.json b/modules/worker/back/models/trainingCourseType.json index 1dc708f2f..1a2a45bc7 100644 --- a/modules/worker/back/models/trainingCourseType.json +++ b/modules/worker/back/models/trainingCourseType.json @@ -1,5 +1,5 @@ { - "name": "trainingCourseType", + "name": "TrainingCourseType", "description": "List of trainings", "base": "VnModel", "options": { @@ -27,7 +27,7 @@ }, "trainingCourseType": { "type": "belongsTo", - "model": "trainingCourseType", + "model": "TrainingCourseType", "foreignKey": "trainingCourseTypeFk" }, "centerFk": { From eb2dd5ba5bbd3a21777137e1da4fc1fcaf2a2a98 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 27 May 2024 16:17:44 +0200 Subject: [PATCH 033/114] refs #7406 acls --- db/versions/11073-crimsonBirch/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11073-crimsonBirch/00-firstScript.sql b/db/versions/11073-crimsonBirch/00-firstScript.sql index 2ad04468f..7d76a75cd 100644 --- a/db/versions/11073-crimsonBirch/00-firstScript.sql +++ b/db/versions/11073-crimsonBirch/00-firstScript.sql @@ -6,4 +6,4 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,princi INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('TrainingCenter','*','*','ALLOW','ROLE','employee'); INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','__get_trainingCourse','*','ALLOW','ROLE','employee'); + VALUES ('Worker','__get__trainingCourse','*','ALLOW','ROLE','employee'); From b95009899ca6c2a68d106c426282d57dedd70b5b Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 28 May 2024 12:22:11 +0200 Subject: [PATCH 034/114] refs #7406 fix back --- modules/worker/back/models/trainingCourse.json | 7 +++---- .../worker/back/models/trainingCourseType.json | 18 ------------------ 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/modules/worker/back/models/trainingCourse.json b/modules/worker/back/models/trainingCourse.json index 7a44ad419..af466e13e 100644 --- a/modules/worker/back/models/trainingCourse.json +++ b/modules/worker/back/models/trainingCourse.json @@ -45,7 +45,6 @@ "hasDiploma": { "type" : "boolean" } - }, "relations": { "worker": { @@ -55,12 +54,12 @@ }, "trainingCourseType": { "type": "belongsTo", - "model": "trainingCourseType", + "model": "TrainingCourseType", "foreignKey": "trainingCourseTypeFk" }, - "centerFk": { + "trainingCenter": { "type": "belongsTo", - "model": "Center", + "model": "TrainingCenter", "foreignKey": "centerFk" } } diff --git a/modules/worker/back/models/trainingCourseType.json b/modules/worker/back/models/trainingCourseType.json index 1a2a45bc7..9bf8fc671 100644 --- a/modules/worker/back/models/trainingCourseType.json +++ b/modules/worker/back/models/trainingCourseType.json @@ -17,23 +17,5 @@ "type": "string", "required": true } - - }, - "relations": { - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "workerFk" - }, - "trainingCourseType": { - "type": "belongsTo", - "model": "TrainingCourseType", - "foreignKey": "trainingCourseTypeFk" - }, - "centerFk": { - "type": "belongsTo", - "model": "Center", - "foreignKey": "centerFk" - } } } From e09a8f2eb77007e7add79d74858c44fb11d16bd2 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 31 May 2024 12:41:38 +0200 Subject: [PATCH 035/114] refs #6897 remove code redirection --- modules/entry/front/main/index.html | 20 +------------------- modules/entry/front/main/index.js | 7 ++++++- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/modules/entry/front/main/index.html b/modules/entry/front/main/index.html index f6a4c61fc..fd40910d9 100644 --- a/modules/entry/front/main/index.html +++ b/modules/entry/front/main/index.html @@ -1,22 +1,4 @@ - - - - - - - - - - + diff --git a/modules/entry/front/main/index.js b/modules/entry/front/main/index.js index 75f1d098a..cc0a8d6a3 100644 --- a/modules/entry/front/main/index.js +++ b/modules/entry/front/main/index.js @@ -1,7 +1,12 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; -export default class Entry extends ModuleMain {} +export default class Entry extends ModuleMain { + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`entry/`); + } +} ngModule.vnComponent('vnEntry', { controller: Entry, From 4703ebbdf3ce7922f16a52d852d90ee3abd94cbe Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 3 Jun 2024 11:38:09 +0200 Subject: [PATCH 036/114] refactor: refs #7519 Minor change --- db/dump/fixtures.before.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 6b8166caa..8bcedeb8d 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -831,9 +831,9 @@ INSERT INTO `vn`.`config`(`id`, `mdbServer`, `fakeEmail`, `defaultersMaxAmount`, INSERT INTO `vn`.`greugeType`(`id`, `name`, `code`) VALUES (1, 'Diff', 'diff'), - (2, 'Recobro', 'recovery'), - (3, 'Maná', 'mana'), - (4, 'Reclamación', 'claim'), + (2, 'Recovery', 'recovery'), + (3, 'Mana', 'mana'), + (4, 'Claim', 'claim'), (5, 'Heritage', 'heritage'), (6, 'Miscellaneous', 'miscellaneous'), (7, 'Freight Pickup', 'freightPickUp'); From 8cef8eace7a92a8fb96fd124dd720fd07a455304 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 3 Jun 2024 11:41:09 +0200 Subject: [PATCH 037/114] refactor: refs #7519 Minor change --- db/routines/vn/procedures/claimRatio_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index 36b9023da..2e999f738 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -79,7 +79,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - SET c.isChargedToMana = TRUE + SET ce.isGreuge = TRUE WHERE cd.description NOT IN ('Bueno', 'Corregido') AND NOT ce.isGreuge AND cs.code = 'resolved'; From b8e95c02840358fb279008df97e0b4fed160bc0f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 3 Jun 2024 11:46:52 +0200 Subject: [PATCH 038/114] refactor: refs #7519 Minor change --- db/routines/vn/procedures/claimRatio_add.sql | 6 ++---- db/versions/11028-silverCarnation/00-firstScript.sql | 10 ---------- 2 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 db/versions/11028-silverCarnation/00-firstScript.sql diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index 2e999f738..7def0837f 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -172,16 +172,14 @@ BEGIN GROUP BY clientFk ) sub ON sub.clientFk = cr.clientFk SET cr.priceIncreasing = GREATEST(0, ROUND(IFNULL(sub.greuge, 0) / - (IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3)) - WHERE cr.dated = util.VN_CURDATE(); + (IFNULL(cr.yearSale, 0) * vMonthToRefund / 12 ), 3)); -- Protección neonatos UPDATE claimRatio cr JOIN firstTicketShipped fts ON fts.clientFk = cr.clientFk SET cr.priceIncreasing = 0, cr.claimingRate = 0 - WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH - AND cr.dated = util.VN_CURDATE(); + WHERE fts.shipped > util.VN_CURDATE() - INTERVAL 1 MONTH; DROP TEMPORARY TABLE tTicketList; END$$ diff --git a/db/versions/11028-silverCarnation/00-firstScript.sql b/db/versions/11028-silverCarnation/00-firstScript.sql deleted file mode 100644 index 9d291f451..000000000 --- a/db/versions/11028-silverCarnation/00-firstScript.sql +++ /dev/null @@ -1,10 +0,0 @@ -UPDATE IGNORE bs.nightTask - SET `procedure` = 'claimRatio_add', - `schema` = 'vn' - WHERE `procedure` = 'claim_ratio_routine'; - -ALTER TABLE vn.claimRatio ADD dated DATE DEFAULT current_timestamp() NOT NULL; -ALTER TABLE vn.claimRatio CHANGE dated dated DATE DEFAULT current_timestamp() NOT NULL FIRST; -ALTER TABLE vn.claimRatio DROP FOREIGN KEY claimRatio_ibfk_1; -ALTER TABLE vn.claimRatio DROP PRIMARY KEY; -ALTER TABLE vn.claimRatio ADD CONSTRAINT claimRatio_pk PRIMARY KEY (dated,clientFk); From 1912fdd45dcffd4553b0c48931c3ff3043b1057f Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 6 Jun 2024 17:26:23 +0200 Subject: [PATCH 039/114] refactor: refs #6286 replace name --- .../back/methods/worker-time-control/weeklyHourRecordEmail.js | 2 +- modules/worker/front/time-control/index.js | 2 +- modules/worker/front/time-control/index.spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index 816a1d22b..53bc8d022 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -35,7 +35,7 @@ module.exports = Self => { root: true }, http: { - path: '/weekly-hour-hecord-email', + path: '/weekly-hour-record-email', verb: 'POST' } }); diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 9a4c4b559..7f7bad137 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -430,7 +430,7 @@ class Controller extends Section { workerId: this.worker.id, state: 'SENDED' }; - this.$http.post(`WorkerTimeControls/weekly-hour-hecord-email`, params) + this.$http.post(`WorkerTimeControls/weekly-hour-record-email`, params) .then(() => { this.getMailStates(this.date); this.vnApp.showSuccess(this.$t('Email sended')); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 8610da46e..42df4ba9b 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -260,7 +260,7 @@ describe('Component vnWorkerTimeControl', () => { controller.date = today; controller.weekNumber = 1; - $httpBackend.expect('POST', 'WorkerTimeControls/weekly-hour-hecord-email').respond(); + $httpBackend.expect('POST', 'WorkerTimeControls/weekly-hour-record-email').respond(); controller.resendEmail(); $httpBackend.flush(); From cdc18ed84fdfd05d3ee070c3615c7cc77e6e5f62 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 7 Jun 2024 08:32:59 +0200 Subject: [PATCH 040/114] refs #6897 fix entry Salix --- e2e/paths/10-travel/03_descriptor.spec.js | 102 --------------- e2e/paths/12-entry/01_summary.spec.js | 47 ------- e2e/paths/12-entry/02_descriptor.spec.js | 49 -------- e2e/paths/12-entry/03_latestBuys.spec.js | 116 ------------------ e2e/paths/12-entry/04_create.spec.js | 34 ----- e2e/paths/12-entry/05_basicData.spec.js | 81 ------------ e2e/paths/12-entry/06_observations.spec.js | 65 ---------- e2e/paths/12-entry/07_buys.spec.js | 69 ----------- modules/entry/front/main/index.html | 21 ++++ modules/entry/front/main/index.js | 5 +- .../travel/front/descriptor-menu/index.html | 8 +- modules/travel/front/descriptor-menu/index.js | 5 + 12 files changed, 31 insertions(+), 571 deletions(-) delete mode 100644 e2e/paths/12-entry/01_summary.spec.js delete mode 100644 e2e/paths/12-entry/02_descriptor.spec.js delete mode 100644 e2e/paths/12-entry/03_latestBuys.spec.js delete mode 100644 e2e/paths/12-entry/04_create.spec.js delete mode 100644 e2e/paths/12-entry/05_basicData.spec.js delete mode 100644 e2e/paths/12-entry/06_observations.spec.js delete mode 100644 e2e/paths/12-entry/07_buys.spec.js diff --git a/e2e/paths/10-travel/03_descriptor.spec.js b/e2e/paths/10-travel/03_descriptor.spec.js index 4723cc4a3..f066a74ca 100644 --- a/e2e/paths/10-travel/03_descriptor.spec.js +++ b/e2e/paths/10-travel/03_descriptor.spec.js @@ -33,106 +33,4 @@ describe('Travel descriptor path', () => { expect(state).toBe('travel.card.summary'); }); - - it('should be redirected to the create entry view', async() => { - await page.waitToClick(selectors.travelDescriptor.dotMenu); - await page.waitToClick(selectors.travelDescriptor.dotMenuAddEntry); - await page.waitForState('entry.create'); - const state = await page.getState(); - - expect(state).toBe('entry.create'); - }); - - it('should check some data was imported from the travel', async() => { - const travel = await page.waitToGetProperty(selectors.entryCreate.travel, 'value'); - const campany = await page.waitToGetProperty(selectors.entryCreate.company, 'value'); - - expect(travel).toContain('Warehouse'); - expect(campany).toContain('VNL'); - }); - - it('should navigate back to the travel index', async() => { - await page.waitToClick('.cancel'); - await page.waitToClick(selectors.globalItems.homeButton); - await page.selectModule('travel'); - await page.waitForState('travel.index'); - const state = await page.getState(); - - expect(state).toBe('travel.index'); - }); - - it('should click on the add entry button of the third result to be redirected to create entry', async() => { - await page.keyboard.press('Enter'); - await page.waitToClick(selectors.travelIndex.firstTravelAddEntryButton); - await page.waitForState('entry.create'); - const state = await page.getState(); - - expect(state).toBe('entry.create'); - }); - - it('should check again some data was imported from the travel', async() => { - const travel = await page.waitToGetProperty(selectors.entryCreate.travel, 'value'); - const campany = await page.waitToGetProperty(selectors.entryCreate.company, 'value'); - - expect(travel).toContain('Warehouse'); - expect(campany).toContain('VNL'); - }); - - it('should navigate to the travel summary of a given travel', async() => { - await page.waitToClick('.cancel'); - await page.waitToClick(selectors.globalItems.homeButton); - await page.selectModule('travel'); - await page.write(selectors.travelIndex.generalSearchFilter, '3'); - await page.keyboard.press('Enter'); - await page.waitForState('travel.card.summary'); - const state = await page.getState(); - - expect(state).toBe('travel.card.summary'); - }); - - it('should be redirected to the create travel when using the clone option of the dot menu', async() => { - await page.waitToClick(selectors.travelDescriptor.dotMenu); - await page.waitToClick(selectors.travelDescriptor.dotMenuClone); - await page.respondToDialog('accept'); - await page.waitForState('travel.create'); - const state = await page.getState(); - - expect(state).toBe('travel.create'); - }); - - it('should edit the data to clone and then get redirected to the cloned travel basic data', async() => { - await page.clearInput(selectors.travelCreate.reference); - await page.write(selectors.travelCreate.reference, 'reference'); - await page.autocompleteSearch(selectors.travelCreate.agency, 'entanglement'); - await page.pickDate(selectors.travelCreate.shipped); - await page.pickDate(selectors.travelCreate.landed); - await page.autocompleteSearch(selectors.travelCreate.warehouseOut, 'warehouse one'); - await page.autocompleteSearch(selectors.travelCreate.warehouseIn, 'warehouse two'); - await page.waitToClick(selectors.travelCreate.saveButton); - await page.waitForState('travel.card.basicData'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should update the landed date to a future date to enable cloneWithEntries', async() => { - const nextMonth = Date.vnNew(); - nextMonth.setMonth(nextMonth.getMonth() + 1); - await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth); - await page.waitToClick(selectors.travelBasicData.save); - await page.waitForState('travel.card.basicData'); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should navigate to the summary and then clone the travel and its entries using the descriptor menu to get redirected to the cloned travel basic data', async() => { - await page.waitToClick('vn-icon[icon="launch"]'); - await page.waitForState('travel.card.summary'); - await page.waitForTimeout(1000); - await page.waitToClick(selectors.travelDescriptor.dotMenu); - await page.waitToClick(selectors.travelDescriptor.dotMenuCloneWithEntries); - await page.waitToClick(selectors.travelDescriptor.acceptClonation); - await page.waitForState('travel.card.basicData'); - }); }); diff --git a/e2e/paths/12-entry/01_summary.spec.js b/e2e/paths/12-entry/01_summary.spec.js deleted file mode 100644 index b846bc4c8..000000000 --- a/e2e/paths/12-entry/01_summary.spec.js +++ /dev/null @@ -1,47 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry summary path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('4'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the second entry summary section', async() => { - await page.waitForState('entry.card.summary'); - }); - - it(`should display details from the entry on the header`, async() => { - await page.waitForTextInElement(selectors.entrySummary.header, 'The farmer'); - const result = await page.waitToGetProperty(selectors.entrySummary.header, 'innerText'); - - expect(result).toContain('The farmer'); - }); - - it('should display some entry details like the reference', async() => { - const result = await page.waitToGetProperty(selectors.entrySummary.reference, 'innerText'); - - expect(result).toContain('Movement 4'); - }); - - it('should display other entry details like the confirmed', async() => { - const result = await page.checkboxState(selectors.entrySummary.confirmed, 'innerText'); - - expect(result).toContain('unchecked'); - }); - - it('should display all buys for the entry', async() => { - const result = await page.countElement(selectors.entrySummary.anyBuyLine); - - expect(result).toEqual(4); - }); -}); diff --git a/e2e/paths/12-entry/02_descriptor.spec.js b/e2e/paths/12-entry/02_descriptor.spec.js deleted file mode 100644 index 997a6065c..000000000 --- a/e2e/paths/12-entry/02_descriptor.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry descriptor path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('2'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should reach the second entry summary section', async() => { - await page.waitForState('entry.card.summary'); - }); - - it('should show some entry information', async() => { - const result = await page.waitToGetProperty(selectors.entryDescriptor.agency, 'innerText'); - - expect(result).toContain('inhouse pickup'); - }); - - it('should click the travels button to be redirected to the travels index filtered by the current agency', async() => { - await page.waitToClick(selectors.entryDescriptor.travelsQuicklink); - await page.expectURL('/travel/index'); - await page.expectURL('agencyModeFk'); - }); - - it('should go back to the entry summary', async() => { - await page.waitToClick(selectors.globalItems.homeButton); - await page.selectModule('entry'); - await page.accessToSearchResult('2'); - await page.waitForState('entry.card.summary'); - }); - - it('should click the entries button to be redirected to the entries index filtered by the current supplier', async() => { - await page.waitToClick(selectors.entryDescriptor.entriesQuicklink); - await page.expectURL('/entry/index'); - await page.expectURL('supplierFk'); - await page.expectURL('to'); - await page.expectURL('from'); - }); -}); diff --git a/e2e/paths/12-entry/03_latestBuys.spec.js b/e2e/paths/12-entry/03_latestBuys.spec.js deleted file mode 100644 index 9ec072912..000000000 --- a/e2e/paths/12-entry/03_latestBuys.spec.js +++ /dev/null @@ -1,116 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry lastest buys path', () => { - let browser; - let page; - const httpRequests = []; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - page.on('request', req => { - if (req.url().includes(`Buys/latestBuysFilter`)) - httpRequests.push(req.url()); - }); - await page.loginAndModule('buyer', 'entry'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should access the latest buys seccion and search not seeing the edit buys button yet', async() => { - await page.waitToClick(selectors.entryLatestBuys.latestBuysSectionButton); - await page.waitForSelector(selectors.entryLatestBuys.editBuysButton, {visible: false}); - }); - - it('should filter by name', async() => { - await page.write(selectors.entryLatestBuys.generalSearchInput, 'Melee'); - await page.keyboard.press('Enter'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('search=Melee')))).toBeDefined(); - }); - - it('should filter by reign and type', async() => { - await page.click(selectors.entryLatestBuys.firstReignIcon); - await page.autocompleteSearch(selectors.entryLatestBuys.typeInput, 'Alstroemeria'); - await page.click(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('categoryFk')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('typeFk')))).toBeDefined(); - }); - - it('should filter by sales person', async() => { - await page.autocompleteSearch(selectors.entryLatestBuys.salesPersonInput, 'buyerNick'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('salesPersonFk')))).toBeDefined(); - }); - - it('should filter by supplier', async() => { - await page.autocompleteSearch(selectors.entryLatestBuys.supplierInput, 'Farmer King'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('supplierFk')))).toBeDefined(); - }); - - it('should filter by active', async() => { - await page.waitToClick(selectors.entryLatestBuys.activeCheck); - await page.waitToClick(selectors.entryLatestBuys.activeCheck); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('active=true')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('active=false')))).toBeDefined(); - }); - - it('should filter by visible', async() => { - await page.waitToClick(selectors.entryLatestBuys.visibleCheck); - await page.waitToClick(selectors.entryLatestBuys.visibleCheck); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('visible=true')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('visible=false')))).toBeDefined(); - }); - - it('should filter by floramondo', async() => { - await page.waitToClick(selectors.entryLatestBuys.floramondoCheck); - await page.waitToClick(selectors.entryLatestBuys.floramondoCheck); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('floramondo=true')))).toBeDefined(); - expect(httpRequests.find(req => req.includes(('floramondo=false')))).toBeDefined(); - }); - - it('should filter by tag Color', async() => { - await page.waitToClick(selectors.entryLatestBuys.addTagButton); - await page.autocompleteSearch(selectors.entryLatestBuys.itemTagInput, 'Color'); - await page.autocompleteSearch(selectors.entryLatestBuys.itemTagValueInput, 'Brown'); - await page.waitToClick(selectors.entryLatestBuys.chip); - - expect(httpRequests.find(req => req.includes(('tags')))).toBeDefined(); - }); - - it('should select all lines but one and then check the edit buys button appears', async() => { - await page.waitToClick(selectors.entryLatestBuys.allBuysCheckBox); - await page.waitToClick(selectors.entryLatestBuys.secondBuyCheckBox); - await page.waitForSelector(selectors.entryLatestBuys.editBuysButton, {visible: true}); - }); - - it('should open the edit dialog', async() => { - await page.waitToClick(selectors.entryLatestBuys.editBuysButton); - await page.waitForSelector(selectors.entryLatestBuys.fieldAutocomplete, {visible: true}); - }); - - it('should search for the "Description" and type a new one for the items in each selected buy', async() => { - await page.autocompleteSearch(selectors.entryLatestBuys.fieldAutocomplete, 'Description'); - await page.write(selectors.entryLatestBuys.newValueInput, 'Crafted item'); - await page.waitToClick(selectors.entryLatestBuys.acceptEditBuysDialog); - }); - - it('should navigate to the entry.buy section by clicking one of the buys', async() => { - await page.waitToClick(selectors.entryLatestBuys.firstBuy); - await page.waitForState('entry.card.buy.index'); - }); -}); diff --git a/e2e/paths/12-entry/04_create.spec.js b/e2e/paths/12-entry/04_create.spec.js deleted file mode 100644 index 537637671..000000000 --- a/e2e/paths/12-entry/04_create.spec.js +++ /dev/null @@ -1,34 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry create path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should click the create entry button to open the form', async() => { - await page.waitToClick(selectors.entryIndex.createEntryButton); - await page.waitForState('entry.create'); - }); - - it('should fill the form to create a valid entry then redirect to basic Data', async() => { - await page.autocompleteSearch(selectors.entryIndex.newEntrySupplier, 'The farmer'); - await page.autocompleteSearch(selectors.entryIndex.newEntryTravel, 'Warehouse'); - await page.autocompleteSearch(selectors.entryIndex.newEntryCompany, 'ORN'); - - await page.waitToClick(selectors.entryIndex.saveNewEntry); - await page.waitForNavigation({ - waitUntil: 'load', - }); - await page.waitForState('entry.card.basicData'); - }); -}); diff --git a/e2e/paths/12-entry/05_basicData.spec.js b/e2e/paths/12-entry/05_basicData.spec.js deleted file mode 100644 index f1f14f8da..000000000 --- a/e2e/paths/12-entry/05_basicData.spec.js +++ /dev/null @@ -1,81 +0,0 @@ -import getBrowser from '../../helpers/puppeteer'; - -const $ = { - reference: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.reference"]', - invoiceNumber: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.invoiceNumber"]', - notes: 'vn-entry-basic-data vn-textfield[ng-model="$ctrl.entry.notes"]', - observations: 'vn-entry-basic-data vn-textarea[ng-model="$ctrl.entry.observation"]', - supplier: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.supplierFk"]', - currency: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.currencyFk"]', - commission: 'vn-entry-basic-data vn-input-number[ng-model="$ctrl.entry.commission"]', - company: 'vn-entry-basic-data vn-autocomplete[ng-model="$ctrl.entry.companyFk"]', - ordered: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isOrdered"]', - confirmed: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isConfirmed"]', - inventory: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isExcludedFromAvailable"]', - raid: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isRaid"]', - booked: 'vn-entry-basic-data vn-check[ng-model="$ctrl.entry.isBooked"]', - save: 'vn-entry-basic-data button[type=submit]', -}; - -describe('Entry basic data path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('2'); - await page.accessToSection('entry.card.basicData'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should edit the basic data and confirm the reference was edited', async() => { - await page.write($.reference, 'new movement 8'); - await page.write($.invoiceNumber, 'new movement 8'); - await page.write($.observations, ' edited'); - await page.autocompleteSearch($.supplier, 'Plants nick'); - await page.autocompleteSearch($.currency, 'eur'); - await page.clearInput($.commission); - await page.write($.commission, '100'); - await page.autocompleteSearch($.company, 'CCs'); - await page.waitToClick($.ordered); - await page.waitToClick($.confirmed); - await page.waitToClick($.inventory); - await page.waitToClick($.raid); - await page.waitToClick($.booked); - await page.waitToClick($.save); - const message = await page.waitForSnackbar(); - - await page.reloadSection('entry.card.basicData'); - const reference = await page.waitToGetProperty($.reference, 'value'); - const supplier = await page.waitToGetProperty($.supplier, 'value'); - const invoiceNumber = await page.waitToGetProperty($.invoiceNumber, 'value'); - const observations = await page.waitToGetProperty($.observations, 'value'); - const currency = await page.waitToGetProperty($.currency, 'value'); - const commission = await page.waitToGetProperty($.commission, 'value'); - const company = await page.waitToGetProperty($.company, 'value'); - const ordered = await page.checkboxState($.ordered); - const confirmed = await page.checkboxState($.confirmed); - const inventory = await page.checkboxState($.inventory); - const raid = await page.checkboxState($.raid); - const booked = await page.checkboxState($.booked); - - expect(message.text).toContain('Data saved!'); - expect(reference).toEqual('new movement 8'); - expect(supplier).toEqual('Plants nick'); - expect(invoiceNumber).toEqual('new movement 8'); - expect(observations).toEqual('observation two edited'); - expect(currency).toEqual('EUR'); - expect(commission).toEqual('100'); - expect(company).toEqual('CCs'); - expect(ordered).toBe('checked'); - expect(confirmed).toBe('checked'); - expect(inventory).toBe('checked'); - expect(raid).toBe('checked'); - expect(booked).toBe('unchecked'); - }); -}); diff --git a/e2e/paths/12-entry/06_observations.spec.js b/e2e/paths/12-entry/06_observations.spec.js deleted file mode 100644 index dcad44fb0..000000000 --- a/e2e/paths/12-entry/06_observations.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry observations path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('2'); - await page.accessToSection('entry.card.observation'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it(`should add two new observations of the same type then fail to save as they can't be repeated`, async() => { - await page.waitToClick(selectors.entryObservations.addNewObservation); - await page.waitToClick(selectors.entryObservations.addNewObservation); - await page.autocompleteSearch(selectors.entryObservations.firstObservationType, 'SalesPerson'); - await page.autocompleteSearch(selectors.entryObservations.secondObservationType, 'SalesPerson'); - await page.write(selectors.entryObservations.firstObservationDescription, 'first observation'); - await page.write(selectors.entryObservations.secondObservationDescription, 'second observation'); - await page.waitToClick(selectors.entryObservations.saveObservationsButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain(`The observation type can't be repeated`); - }); - - it('should set the 2nd observation of a different one and successfully save both', async() => { - await page.autocompleteSearch(selectors.entryObservations.secondObservationType, 'Delivery'); - await page.waitToClick(selectors.entryObservations.saveObservationsButton); - const message = await page.waitForSnackbar(); - - expect(message.text).toContain('Data saved!'); - }); - - it('should reload the section and make sure the first observation type was saved correctly', async() => { - await page.reloadSection('entry.card.observation'); - const result = await page.waitToGetProperty(selectors.entryObservations.firstObservationType, 'value'); - - expect(result).toEqual('SalesPerson'); - }); - - it('should make sure the first observation description was saved correctly', async() => { - const result = await page.waitToGetProperty(selectors.entryObservations.firstObservationDescription, 'value'); - - expect(result).toEqual('first observation'); - }); - - it('should make sure the second observation type was saved correctly', async() => { - const result = await page.waitToGetProperty(selectors.entryObservations.secondObservationType, 'value'); - - expect(result).toEqual('Delivery'); - }); - - it('should make sure the second observation description was saved correctly', async() => { - const result = await page.waitToGetProperty(selectors.entryObservations.secondObservationDescription, 'value'); - - expect(result).toEqual('second observation'); - }); -}); diff --git a/e2e/paths/12-entry/07_buys.spec.js b/e2e/paths/12-entry/07_buys.spec.js deleted file mode 100644 index b960673ec..000000000 --- a/e2e/paths/12-entry/07_buys.spec.js +++ /dev/null @@ -1,69 +0,0 @@ -import selectors from '../../helpers/selectors.js'; -import getBrowser from '../../helpers/puppeteer'; - -describe('Entry import, create and edit buys path', () => { - let browser; - let page; - - beforeAll(async() => { - browser = await getBrowser(); - page = browser.page; - await page.loginAndModule('buyer', 'entry'); - await page.accessToSearchResult('3'); - }); - - afterAll(async() => { - await browser.close(); - }); - - it('should count the summary buys and find there only one at this point', async() => { - const buysCount = await page.countElement(selectors.entrySummary.anyBuyLine); - - expect(buysCount).toEqual(2); - }); - - it('should navigate to the buy section and then click the import button opening the import form', async() => { - await page.accessToSection('entry.card.buy.index'); - await page.waitToClick(selectors.entryBuys.importButton); - await page.waitForState('entry.card.buy.import'); - }); - - it('should fill the form, import the a JSON file and select items for each import and confirm import', async() => { - let currentDir = process.cwd(); - let filePath = `${currentDir}/e2e/assets/07_import_buys.json`; - - const [fileChooser] = await Promise.all([ - page.waitForFileChooser(), - page.waitToClick(selectors.entryBuys.file) - ]); - await fileChooser.accept([filePath]); - - await page.waitForTextInField(selectors.entryBuys.ref, '200573095, 200573106, 200573117, 200573506'); - await page.waitForTextInField(selectors.entryBuys.observation, '729-6340 2846'); - - await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged weapon longbow 200cm'); - await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Ranged weapon longbow 200cm'); - await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Ranged weapon sniper rifle 113cm'); - await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Melee weapon heavy shield 100cm'); - - await page.waitToClick(selectors.entryBuys.importBuysButton); - - const message = await page.waitForSnackbar(); - const state = await page.getState(); - - expect(message.text).toContain('Data saved!'); - expect(state).toBe('entry.card.buy.index'); - }); - - it('should count the buys to find 4 buys have been added', async() => { - await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 6); - }); - - it('should delete the four buys that were just added', async() => { - await page.waitToClick(selectors.entryBuys.allBuyCheckbox); - await page.waitToClick(selectors.entryBuys.firstBuyCheckbox); - await page.waitToClick(selectors.entryBuys.deleteBuysButton); - await page.waitToClick(selectors.globalItems.acceptButton); - await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1); - }); -}); diff --git a/modules/entry/front/main/index.html b/modules/entry/front/main/index.html index fd40910d9..d55fbd60b 100644 --- a/modules/entry/front/main/index.html +++ b/modules/entry/front/main/index.html @@ -1,3 +1,24 @@ + + + + + + + + + + + + diff --git a/modules/entry/front/main/index.js b/modules/entry/front/main/index.js index cc0a8d6a3..69bddc7fc 100644 --- a/modules/entry/front/main/index.js +++ b/modules/entry/front/main/index.js @@ -2,10 +2,7 @@ import ngModule from '../module'; import ModuleMain from 'salix/components/module-main'; export default class Entry extends ModuleMain { - async $onInit() { - this.$state.go('home'); - window.location.href = await this.vnApp.getUrl(`entry/`); - } + } ngModule.vnComponent('vnEntry', { diff --git a/modules/travel/front/descriptor-menu/index.html b/modules/travel/front/descriptor-menu/index.html index 9b408994f..19831860b 100644 --- a/modules/travel/front/descriptor-menu/index.html +++ b/modules/travel/front/descriptor-menu/index.html @@ -26,8 +26,8 @@ Delete travel Add entry @@ -35,7 +35,7 @@ - - - this.$state.go('travel.card.basicData', {id: res.data})); From 310c2383cb7f76eae9383ea16843fb7ba6d98c0f Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 7 Jun 2024 09:08:21 +0200 Subject: [PATCH 041/114] fix: refs #6286 replace id for reason --- .../methods/worker-time-control/updateWorkerTimeControlMail.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js b/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js index 3594f05fe..3fd743fe3 100644 --- a/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js +++ b/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js @@ -63,7 +63,7 @@ module.exports = Self => { }, { state: args.state, - reason: args.workerId, + reason: args.reason, year: args.year, week: args.week, workerFk: args.workerId From 48550bd986f6eb72862a7489da6796de34d6051d Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 7 Jun 2024 11:35:03 +0200 Subject: [PATCH 042/114] refs #6897 fix remove --- back/nodemonConfig.json | 3 +- .../01_summary_and_descriptor.spec.js | 5 - front/module-import.js | 37 ++- modules/entry/front/basic-data/index.html | 234 --------------- modules/entry/front/basic-data/index.js | 68 ----- modules/entry/front/basic-data/style.scss | 3 - modules/entry/front/buy/import/index.html | 205 -------------- modules/entry/front/buy/import/index.js | 159 ----------- modules/entry/front/buy/import/index.spec.js | 199 ------------- modules/entry/front/buy/import/style.scss | 5 - modules/entry/front/buy/index/index.html | 243 ---------------- modules/entry/front/buy/index/index.js | 81 ------ modules/entry/front/buy/index/index.spec.js | 92 ------ modules/entry/front/buy/index/locale/es.yml | 3 - modules/entry/front/buy/index/style.scss | 42 --- modules/entry/front/buy/locale/es.yml | 8 - modules/entry/front/card/index.html | 5 - modules/entry/front/card/index.js | 59 ---- modules/entry/front/create/index.html | 69 ----- modules/entry/front/create/index.js | 43 --- modules/entry/front/create/locale/es.yml | 2 - modules/entry/front/create/style.scss | 10 - .../entry/front/descriptor-popover/index.html | 3 - .../entry/front/descriptor-popover/index.js | 9 - modules/entry/front/descriptor/index.html | 65 ----- modules/entry/front/descriptor/index.js | 99 ------- modules/entry/front/descriptor/index.spec.js | 40 --- modules/entry/front/descriptor/locale/es.yml | 7 - modules/entry/front/index.js | 14 - modules/entry/front/index/locale/es.yml | 17 -- .../front/latest-buys-search-panel/index.html | 242 ---------------- .../front/latest-buys-search-panel/index.js | 61 ---- .../latest-buys-search-panel/index.spec.js | 56 ---- .../front/latest-buys-search-panel/style.scss | 70 ----- modules/entry/front/latest-buys/index.html | 267 ------------------ modules/entry/front/latest-buys/index.js | 209 -------------- modules/entry/front/latest-buys/index.spec.js | 100 ------- modules/entry/front/latest-buys/locale/en.yml | 2 - modules/entry/front/latest-buys/locale/es.yml | 19 -- modules/entry/front/latest-buys/style.scss | 7 - modules/entry/front/locale/es.yml | 6 - modules/entry/front/log/index.html | 1 - modules/entry/front/log/index.js | 7 - modules/entry/front/log/locale/es.yml | 1 - modules/entry/front/main/index.html | 25 -- modules/entry/front/main/index.js | 11 - modules/entry/front/note/index.html | 72 ----- modules/entry/front/note/index.js | 20 -- modules/entry/front/routes.json | 92 +----- modules/entry/front/search-panel/index.html | 100 ------- modules/entry/front/search-panel/index.js | 7 - .../entry/front/search-panel/locale/es.yml | 9 - modules/entry/front/summary/index.html | 196 ------------- modules/entry/front/summary/index.js | 33 --- modules/entry/front/summary/index.spec.js | 49 ---- modules/entry/front/summary/locale/es.yml | 11 - modules/entry/front/summary/style.scss | 30 -- modules/item/front/routes.json | 8 +- modules/travel/front/routes.json | 8 +- 59 files changed, 28 insertions(+), 3520 deletions(-) delete mode 100644 modules/entry/front/basic-data/index.html delete mode 100644 modules/entry/front/basic-data/index.js delete mode 100644 modules/entry/front/basic-data/style.scss delete mode 100644 modules/entry/front/buy/import/index.html delete mode 100644 modules/entry/front/buy/import/index.js delete mode 100644 modules/entry/front/buy/import/index.spec.js delete mode 100644 modules/entry/front/buy/import/style.scss delete mode 100644 modules/entry/front/buy/index/index.html delete mode 100644 modules/entry/front/buy/index/index.js delete mode 100644 modules/entry/front/buy/index/index.spec.js delete mode 100644 modules/entry/front/buy/index/locale/es.yml delete mode 100644 modules/entry/front/buy/index/style.scss delete mode 100644 modules/entry/front/buy/locale/es.yml delete mode 100644 modules/entry/front/card/index.html delete mode 100644 modules/entry/front/card/index.js delete mode 100644 modules/entry/front/create/index.html delete mode 100644 modules/entry/front/create/index.js delete mode 100644 modules/entry/front/create/locale/es.yml delete mode 100644 modules/entry/front/create/style.scss delete mode 100644 modules/entry/front/descriptor-popover/index.html delete mode 100644 modules/entry/front/descriptor-popover/index.js delete mode 100644 modules/entry/front/descriptor/index.html delete mode 100644 modules/entry/front/descriptor/index.js delete mode 100644 modules/entry/front/descriptor/index.spec.js delete mode 100644 modules/entry/front/descriptor/locale/es.yml delete mode 100644 modules/entry/front/index/locale/es.yml delete mode 100644 modules/entry/front/latest-buys-search-panel/index.html delete mode 100644 modules/entry/front/latest-buys-search-panel/index.js delete mode 100644 modules/entry/front/latest-buys-search-panel/index.spec.js delete mode 100644 modules/entry/front/latest-buys-search-panel/style.scss delete mode 100644 modules/entry/front/latest-buys/index.html delete mode 100644 modules/entry/front/latest-buys/index.js delete mode 100644 modules/entry/front/latest-buys/index.spec.js delete mode 100644 modules/entry/front/latest-buys/locale/en.yml delete mode 100644 modules/entry/front/latest-buys/locale/es.yml delete mode 100644 modules/entry/front/latest-buys/style.scss delete mode 100644 modules/entry/front/locale/es.yml delete mode 100644 modules/entry/front/log/index.html delete mode 100644 modules/entry/front/log/index.js delete mode 100644 modules/entry/front/log/locale/es.yml delete mode 100644 modules/entry/front/main/index.html delete mode 100644 modules/entry/front/main/index.js delete mode 100644 modules/entry/front/note/index.html delete mode 100644 modules/entry/front/note/index.js delete mode 100644 modules/entry/front/search-panel/index.html delete mode 100644 modules/entry/front/search-panel/index.js delete mode 100644 modules/entry/front/search-panel/locale/es.yml delete mode 100644 modules/entry/front/summary/index.html delete mode 100644 modules/entry/front/summary/index.js delete mode 100644 modules/entry/front/summary/index.spec.js delete mode 100644 modules/entry/front/summary/locale/es.yml delete mode 100644 modules/entry/front/summary/style.scss diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json index 5138bc30e..c468a2f73 100644 --- a/back/nodemonConfig.json +++ b/back/nodemonConfig.json @@ -8,7 +8,6 @@ "modules/account/front/**/*", "modules/claim/front/**/*", "modules/client/front/**/*", - "modules/entry/front/**/*", "modules/invoiceIn/front/**/*", "modules/invoiceOut/front/**/*", "modules/item/front/**/*", @@ -22,4 +21,4 @@ "modules/worker/front/**/*", "modules/zone/front/**/*" ] -} \ No newline at end of file +} diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js index e82f851ea..a2e194e42 100644 --- a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js +++ b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js @@ -65,11 +65,6 @@ describe('Supplier summary & descriptor path', () => { await page.waitForState('supplier.card.summary'); }); - it(`should navigate to the supplier's entries`, async() => { - await page.waitToClick(selectors.supplierDescriptor.entriesButton); - await page.waitForState('entry.index'); - }); - it(`should navigate back to suppliers but a different one this time`, async() => { await page.waitToClick(selectors.globalItems.homeButton); await page.waitForState('home'); diff --git a/front/module-import.js b/front/module-import.js index bc547deeb..85731c72c 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -1,27 +1,26 @@ export default function moduleImport(moduleName) { // TODO: Webpack watches module backend files when using dynamic import - //return import( + // return import( // /* webpackInclude: /modules\/[a-z0-9-]+\/front\/index.js$/ */ // '../modules/'+ moduleName +'/front/index.js' - //); + // ); - switch(moduleName) { - case 'client' : return import('client/front'); - case 'item' : return import('item/front'); - case 'ticket' : return import('ticket/front'); - case 'order' : return import('order/front'); - case 'claim' : return import('claim/front'); - case 'zone' : return import('zone/front'); - case 'travel' : return import('travel/front'); - case 'worker' : return import('worker/front'); - case 'invoiceOut' : return import('invoiceOut/front'); - case 'invoiceIn' : return import('invoiceIn/front'); - case 'route' : return import('route/front'); - case 'entry' : return import('entry/front'); - case 'account' : return import('account/front'); - case 'supplier' : return import('supplier/front'); - case 'shelving' : return import('shelving/front'); - case 'monitor' : return import('monitor/front'); + switch (moduleName) { + case 'client': return import('client/front'); + case 'item': return import('item/front'); + case 'ticket': return import('ticket/front'); + case 'order': return import('order/front'); + case 'claim': return import('claim/front'); + case 'zone': return import('zone/front'); + case 'travel': return import('travel/front'); + case 'worker': return import('worker/front'); + case 'invoiceOut': return import('invoiceOut/front'); + case 'invoiceIn': return import('invoiceIn/front'); + case 'route': return import('route/front'); + case 'account': return import('account/front'); + case 'supplier': return import('supplier/front'); + case 'shelving': return import('shelving/front'); + case 'monitor': return import('monitor/front'); } } diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html deleted file mode 100644 index 57de1c5f7..000000000 --- a/modules/entry/front/basic-data/index.html +++ /dev/null @@ -1,234 +0,0 @@ - - - - - -
- - - - -
#{{::nickname}}
-
#{{::id}}
-
-
- - -
- {{::agencyModeName}} - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) → - {{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}}) -
-
#{{::id}}
-
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - ID - Agency - Warehouse Out - Warehouse In - Shipped - Landed - - - - - - - {{::travel.id}} - - - {{::travel.agency.name}} - {{::travel.warehouseOut.name}} - {{::travel.warehouseIn.name}} - {{::travel.shipped | date: 'dd/MM/yyyy'}} - {{::travel.landed | date: 'dd/MM/yyyy'}} - - - - - - - - diff --git a/modules/entry/front/basic-data/index.js b/modules/entry/front/basic-data/index.js deleted file mode 100644 index 564a3df5c..000000000 --- a/modules/entry/front/basic-data/index.js +++ /dev/null @@ -1,68 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - showFilterDialog(travel) { - this.activeTravel = travel; - this.travelFilterParams = {}; - this.travelFilter = { - include: [ - { - relation: 'agency', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseIn', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseOut', - scope: { - fields: ['name'] - } - } - ] - }; - - this.$.filterDialog.show(); - } - - selectTravel(id) { - this.entry.travelFk = id; - this.$.filterDialog.hide(); - } - - filter() { - const filter = this.travelFilter; - const params = this.travelFilterParams; - const where = {}; - for (let key in params) { - const value = params[key]; - if (!value) continue; - - switch (key) { - case 'agencyModeFk': - case 'warehouseInFk': - case 'warehouseOutFk': - case 'shipped': - case 'landed': - where[key] = value; - } - } - - filter.where = where; - this.$.travelsModel.applyFilter(filter); - } -} -ngModule.vnComponent('vnEntryBasicData', { - template: require('./index.html'), - bindings: { - entry: '<' - }, - controller: Controller -}); diff --git a/modules/entry/front/basic-data/style.scss b/modules/entry/front/basic-data/style.scss deleted file mode 100644 index 508aa9091..000000000 --- a/modules/entry/front/basic-data/style.scss +++ /dev/null @@ -1,3 +0,0 @@ -.travelFilter{ - width: 950px; -} diff --git a/modules/entry/front/buy/import/index.html b/modules/entry/front/buy/import/index.html deleted file mode 100644 index 28396434c..000000000 --- a/modules/entry/front/buy/import/index.html +++ /dev/null @@ -1,205 +0,0 @@ - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ItemDescriptionSizePackingGroupingBuying valueBox
- - - {{::id}} - {{::name}} - - - - - - - {{::buy.description | dashIfEmpty}}{{::buy.size | dashIfEmpty}}{{::buy.packing | dashIfEmpty}}{{::buy.grouping | dashIfEmpty}}{{::buy.buyingValue | currency: 'EUR':2}} - - -
-
-
- - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - ID - Item - Size - Producer - Color - - - - - - - {{::item.id}} - - - {{::item.name}} - {{::item.size}} - {{::item.producerName}} - {{::item.inkName}} - - - - - - - - \ No newline at end of file diff --git a/modules/entry/front/buy/import/index.js b/modules/entry/front/buy/import/index.js deleted file mode 100644 index ba0a98e62..000000000 --- a/modules/entry/front/buy/import/index.js +++ /dev/null @@ -1,159 +0,0 @@ -import ngModule from '../../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -class Controller extends Section { - constructor($element, $) { - super($element, $); - this.import = { - file: '', - invoice: null, - buys: [] - }; - } - - onFileChange($event) { - const input = $event.target; - const file = input.files[0]; - - const reader = new FileReader(); - reader.onload = event => - this.fillData(event.target.result); - reader.readAsText(file, 'UTF-8'); - } - - fillData(raw) { - const data = JSON.parse(raw); - const [invoice] = data.invoices; - - this.$.$applyAsync(() => { - this.import.observation = invoice.tx_awb; - - const companyName = invoice.tx_company; - const boxes = invoice.boxes; - const buys = []; - for (let box of boxes) { - const boxVolume = box.nu_length * box.nu_width * box.nu_height; - for (let product of box.products) { - const packing = product.nu_stems_bunch * product.nu_bunches; - buys.push({ - description: product.nm_product, - companyName: companyName, - size: product.nu_length, - packing: packing, - grouping: product.nu_stems_bunch, - buyingValue: parseFloat(product.mny_rate_stem), - volume: boxVolume, - }); - } - } - - const boxesId = boxes.map(box => box.id_box); - this.import.ref = boxesId.join(', '); - - this.fetchBuys(buys); - }); - } - - fetchBuys(buys) { - const params = {buys}; - const query = `Entries/${this.$params.id}/importBuysPreview`; - this.$http.post(query, params).then(res => { - this.import.buys = res.data; - }); - } - - onSubmit() { - try { - const params = this.import; - const hasAnyEmptyRow = params.buys.some(buy => { - return buy.itemFk == null; - }); - - if (hasAnyEmptyRow) - throw new Error(`Some of the imported buys doesn't have an item`); - - const query = `Entries/${this.$params.id}/importBuys`; - return this.$http.post(query, params) - .then(() => this.vnApp.showSuccess(this.$t('Data saved!'))) - .then(() => this.$state.go('entry.card.buy.index')); - } catch (e) { - this.vnApp.showError(this.$t(e.message)); - return false; - } - } - - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } - - showFilterDialog(buy) { - this.activeBuy = buy; - this.itemFilterParams = {}; - this.itemFilter = { - include: [ - { - relation: 'producer', - scope: { - fields: ['name'] - } - }, - { - relation: 'ink', - scope: { - fields: ['name'] - } - } - ] - }; - - this.$.filterDialog.show(); - } - - selectItem(id) { - this.activeBuy['itemFk'] = id; - this.$.filterDialog.hide(); - } - - filter() { - const filter = this.itemFilter; - const params = this.itemFilterParams; - const where = {}; - - for (let key in params) { - const value = params[key]; - if (!value) continue; - - switch (key) { - case 'name': - where[key] = {like: `%${value}%`}; - break; - case 'producerFk': - case 'typeFk': - case 'size': - case 'inkFk': - where[key] = value; - } - } - - filter.where = where; - this.$.itemsModel.applyFilter(filter); - } - - onKeyPress($event) { - if ($event.key === 'Enter') - this.filter(); - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnEntryBuyImport', { - template: require('./index.html'), - controller: Controller, - bindings: { - worker: '<' - } -}); diff --git a/modules/entry/front/buy/import/index.spec.js b/modules/entry/front/buy/import/index.spec.js deleted file mode 100644 index 036f52074..000000000 --- a/modules/entry/front/buy/import/index.spec.js +++ /dev/null @@ -1,199 +0,0 @@ -import './index.js'; - -describe('Entry', () => { - describe('Component vnEntryBuyImport', () => { - let controller; - let $httpParamSerializer; - let $httpBackend; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - $httpParamSerializer = _$httpParamSerializer_; - let $element = $compile(' { - it(`should call to the fillData() method`, () => { - controller.fetchBuys = jest.fn(); - - const rawData = `{ - "invoices": [ - { - "tx_awb": "123456", - "boxes": [ - { - "id_box": 1, - "nu_length": 1, - "nu_width": 15, - "nu_height": 80, - "products": [ - { - "nm_product": "Bow", - "nu_length": 1, - "nu_stems_bunch": 1, - "nu_bunches": 1, - "mny_rate_stem": 5.77 - } - - ] - }, - { - "id_box": 2, - "nu_length": 25, - "nu_width": 1, - "nu_height": 45, - "products": [ - { - "nm_product": "Arrow", - "nu_length": 25, - "nu_stems_bunch": 1, - "nu_bunches": 1, - "mny_rate_stem": 2.16 - } - ] - } - ] - } - ]}`; - const expectedBuys = [ - { - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - - { - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ]; - controller.fillData(rawData); - controller.$.$apply(); - - const importData = controller.import; - - expect(importData.observation).toEqual('123456'); - expect(importData.ref).toEqual('1, 2'); - - expect(controller.fetchBuys).toHaveBeenCalledWith(expectedBuys); - }); - }); - - describe('fetchBuys()', () => { - it(`should perform a query to fetch the buys data`, () => { - const buys = [ - { - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - - { - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ]; - - const query = `Entries/1/importBuysPreview`; - $httpBackend.expectPOST(query).respond(200, buys); - controller.fetchBuys(buys); - $httpBackend.flush(); - - const importData = controller.import; - - expect(importData.buys.length).toEqual(2); - }); - }); - - describe('onSubmit()', () => { - it(`should throw an error when some of the rows doesn't have an item`, () => { - jest.spyOn(controller.vnApp, 'showError'); - - controller.import = { - observation: '123456', - ref: '1, 2', - buys: [ - { - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - { - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ] - }; - - controller.onSubmit(); - - const message = `Some of the imported buys doesn't have an item`; - - expect(controller.vnApp.showError).toHaveBeenCalledWith(message); - }); - - it(`should now perform a query to update columns`, () => { - jest.spyOn(controller.vnApp, 'showSuccess'); - controller.$state.go = jest.fn(); - - controller.import = { - observation: '123456', - ref: '1, 2', - buys: [ - { - 'itemFk': 10, - 'buyingValue': 5.77, - 'description': 'Bow', - 'grouping': 1, - 'packing': 1, - 'size': 1, - 'volume': 1200}, - { - 'itemFk': 11, - 'buyingValue': 2.16, - 'description': 'Arrow', - 'grouping': 1, - 'packing': 1, - 'size': 25, - 'volume': 1125} - ] - }; - const params = controller.import; - - const query = `Entries/1/importBuys`; - $httpBackend.expectPOST(query, params).respond(200, params.buys); - controller.onSubmit(); - $httpBackend.flush(); - - const importData = controller.import; - - expect(importData.buys.length).toEqual(2); - - expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); - expect(controller.$state.go).toHaveBeenCalledWith('entry.card.buy.index'); - }); - }); - }); -}); diff --git a/modules/entry/front/buy/import/style.scss b/modules/entry/front/buy/import/style.scss deleted file mode 100644 index 9b2fb7688..000000000 --- a/modules/entry/front/buy/import/style.scss +++ /dev/null @@ -1,5 +0,0 @@ -.itemFilter { - vn-table.scrollable { - height: 500px - } -} \ No newline at end of file diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html deleted file mode 100644 index 0e0c69788..000000000 --- a/modules/entry/front/buy/index/index.html +++ /dev/null @@ -1,243 +0,0 @@ - - - - - - -
- - - - - - -

Subtotal {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

-

VAT {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

-

Total {{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - ItemQuantityPackageStickersWeightPackingGroupingBuying valueGrouping pricePacking priceImport
- - - - - {{::buy.item.id}} - - - -
{{::name}}
-
#{{::id}}
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{buy.quantity * buy.buyingValue | currency: 'EUR':2}} - -
- - - {{::buy.item.itemType.code}} - - - - {{::buy.item.size}} - - - - {{::buy.item.minPrice | currency: 'EUR':2}} - - -
- {{::buy.item.name}} - -

{{::buy.item.subName}}

-
-
- - -
-
-
-
-
- - - - - - -
- - - - diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js deleted file mode 100644 index 9131c31f6..000000000 --- a/modules/entry/front/buy/index/index.js +++ /dev/null @@ -1,81 +0,0 @@ -import ngModule from '../../module'; -import './style.scss'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - saveBuy(buy) { - const missingData = !buy.itemFk || !buy.quantity || !buy.packagingFk; - if (missingData) return; - - let options; - if (buy.id) { - options = { - query: `Buys/${buy.id}`, - method: 'patch' - }; - } - this.$http[options.method](options.query, buy).then(res => { - if (!res.data) return; - - buy = Object.assign(buy, res.data); - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - /** - * Returns checked instances - * - * @return {Array} Checked instances - */ - selectedBuys() { - if (!this.buys) return; - - return this.buys.filter(buy => { - return buy.checked; - }); - } - - deleteBuys() { - const buys = this.selectedBuys(); - const actualInstances = buys.filter(buy => buy.id); - - const params = {buys: actualInstances}; - - if (actualInstances.length) { - this.$http.post(`Buys/deleteBuys`, params).then(() => { - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - buys.forEach(buy => { - const index = this.buys.indexOf(buy); - this.buys.splice(index, 1); - }); - } - - toggleGroupingMode(buy, mode) { - const groupingMode = mode === 'grouping' ? mode : 'packing'; - const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode; - const params = { - groupingMode: newGroupingMode - }; - - this.$http.patch(`Buys/${buy.id}`, params).then(() => { - buy.groupingMode = newGroupingMode; - this.vnApp.showSuccess(this.$t('Data saved!')); - }); - } - - itemSearchFunc($search) { - return /^\d+$/.test($search) - ? {id: $search} - : {name: {like: '%' + $search + '%'}}; - } -} - -ngModule.vnComponent('vnEntryBuyIndex', { - template: require('./index.html'), - controller: Controller, - bindings: { - entry: '<' - } -}); diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js deleted file mode 100644 index f5c6d1bdb..000000000 --- a/modules/entry/front/buy/index/index.spec.js +++ /dev/null @@ -1,92 +0,0 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ -import './index.js'; - -describe('Entry buy', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject(($componentController, $compile, $rootScope, _$httpParamSerializer_, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - let $element = $compile(' { - it(`should call the buys patch route if the received buy has an ID`, () => { - const buy = {id: 1, itemFk: 1, quantity: 1, packagingFk: 1}; - - const query = `Buys/${buy.id}`; - - $httpBackend.expectPATCH(query).respond(200); - controller.saveBuy(buy); - $httpBackend.flush(); - }); - }); - - describe('deleteBuys()', () => { - it(`should perform no queries if all buys to delete were not actual instances`, () => { - controller.buys = [ - {checked: true}, - {checked: true}, - {checked: false}]; - - controller.deleteBuys(); - - expect(controller.buys.length).toEqual(1); - }); - - it(`should perform a query to delete as there's an actual instance at least`, () => { - controller.buys = [ - {checked: true, id: 1}, - {checked: true}, - {checked: false}]; - - const query = 'Buys/deleteBuys'; - - $httpBackend.expectPOST(query).respond(200); - controller.deleteBuys(); - $httpBackend.flush(); - - expect(controller.buys.length).toEqual(1); - }); - }); - - describe('toggleGroupingMode()', () => { - it(`should toggle grouping mode from grouping to packing`, () => { - const buy = {id: 999, groupingMode: 'grouping'}; - - const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: 'packing'}).respond(200); - controller.toggleGroupingMode(buy, 'packing'); - $httpBackend.flush(); - }); - - it(`should toggle grouping mode from packing to grouping`, () => { - const buy = {id: 999, groupingMode: 'packing'}; - const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: 'grouping'}).respond(200); - controller.toggleGroupingMode(buy, 'grouping'); - $httpBackend.flush(); - }); - - it(`should toggle off the grouping mode if it was packing to packing`, () => { - const buy = {id: 999, groupingMode: 'packing'}; - const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); - controller.toggleGroupingMode(buy, 'packing'); - $httpBackend.flush(); - }); - - it(`should toggle off the grouping mode if it was grouping to grouping`, () => { - const buy = {id: 999, groupingMode: 'grouping'}; - const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); - controller.toggleGroupingMode(buy, 'grouping'); - $httpBackend.flush(); - }); - }); -}); diff --git a/modules/entry/front/buy/index/locale/es.yml b/modules/entry/front/buy/index/locale/es.yml deleted file mode 100644 index 0a1ecf5b1..000000000 --- a/modules/entry/front/buy/index/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -Buys: Compras -Delete buy(s): Eliminar compra(s) -Add buy: Añadir compra \ No newline at end of file diff --git a/modules/entry/front/buy/index/style.scss b/modules/entry/front/buy/index/style.scss deleted file mode 100644 index 3fad252df..000000000 --- a/modules/entry/front/buy/index/style.scss +++ /dev/null @@ -1,42 +0,0 @@ -@import "variables"; - - -vn-entry-buy-index vn-card { - max-width: $width-xl; - - .dark-row { - background-color: lighten($color-marginal, 10%); - } - - thead tr { - border: 1px solid white;; - } - - tbody tr:nth-child(1), - tbody tr:nth-child(2) { - border-left: 1px solid $color-spacer; - border-right: 1px solid $color-spacer; - } - - tbody tr:nth-child(2) { - border-bottom: 1px solid $color-spacer; - } - - tbody{ - border-bottom: 1px solid $color-spacer; - } - - tbody:last-child { - border-bottom: 0; - } - - tbody tr:nth-child(3) { - height: inherit - } - - tr { - margin-bottom: 10px; - } -} - -$color-font-link-medium: lighten($color-font-link, 20%) diff --git a/modules/entry/front/buy/locale/es.yml b/modules/entry/front/buy/locale/es.yml deleted file mode 100644 index 55828a3c6..000000000 --- a/modules/entry/front/buy/locale/es.yml +++ /dev/null @@ -1,8 +0,0 @@ -reference: Referencia -Observation: Observación -Box: Embalaje -Import buys: Importar compras -Some of the imported buys doesn't have an item: Algunas de las compras importadas no tienen un artículo -JSON files only: Solo ficheros JSON -Filter item: Filtrar artículo -Filter...: Filtrar... \ No newline at end of file diff --git a/modules/entry/front/card/index.html b/modules/entry/front/card/index.html deleted file mode 100644 index d386a9ebf..000000000 --- a/modules/entry/front/card/index.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/modules/entry/front/card/index.js b/modules/entry/front/card/index.js deleted file mode 100644 index 96f4702e2..000000000 --- a/modules/entry/front/card/index.js +++ /dev/null @@ -1,59 +0,0 @@ -import ngModule from '../module'; -import ModuleCard from 'salix/components/module-card'; - -class Controller extends ModuleCard { - reload() { - let filter = { - include: [ - { - relation: 'company', - scope: { - fields: ['id', 'code'] - } - }, - { - relation: 'travel', - scope: { - fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], - include: [ - { - relation: 'agency', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseOut', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseIn', - scope: { - fields: ['name'] - } - } - ] - } - }, - { - relation: 'supplier', - scope: { - fields: ['id', 'nickname'] - } - }, - { - relation: 'currency' - } - ] - }; - this.$http.get(`Entries/${this.$params.id}`, {filter}) - .then(response => this.entry = response.data); - } -} - -ngModule.vnComponent('vnEntryCard', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/create/index.html b/modules/entry/front/create/index.html deleted file mode 100644 index e1e4dc064..000000000 --- a/modules/entry/front/create/index.html +++ /dev/null @@ -1,69 +0,0 @@ - - -
- - - - - - -
{{::nickname}}
-
#{{::id}}
-
-
-
- - - -
- {{::agencyModeName}} - - {{::warehouseInName}} ({{::shipped | date: 'dd/MM/yyyy'}}) - → {{::warehouseOutName}} ({{::landed | date: 'dd/MM/yyyy'}}) -
-
#{{::id}}
-
-
-
- - - - -
- - - - - - -
diff --git a/modules/entry/front/create/index.js b/modules/entry/front/create/index.js deleted file mode 100644 index 5c61730f9..000000000 --- a/modules/entry/front/create/index.js +++ /dev/null @@ -1,43 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - - this.entry = { - companyFk: this.vnConfig.companyFk - }; - - if (this.$params && this.$params.supplierFk) - this.entry.supplierFk = parseInt(this.$params.supplierFk); - if (this.$params && this.$params.travelFk) - this.entry.travelFk = parseInt(this.$params.travelFk); - if (this.$params && this.$params.companyFk) - this.entry.companyFk = parseInt(this.$params.companyFk); - } - - onSubmit() { - this.$.watcher.submit().then( - res => this.$state.go('entry.card.basicData', {id: res.data.id}) - ); - } - - searchFunction($search) { - return {or: [ - {'agencyModeName': {like: `%${$search}%`}}, - {'warehouseInName': {like: `%${$search}%`}}, - {'warehouseOutName': {like: `%${$search}%`}}, - {'shipped': new Date($search)}, - {'landed': new Date($search)} - ]}; - } -} - -Controller.$inject = ['$element', '$scope']; - -ngModule.vnComponent('vnEntryCreate', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/create/locale/es.yml b/modules/entry/front/create/locale/es.yml deleted file mode 100644 index aa269ed15..000000000 --- a/modules/entry/front/create/locale/es.yml +++ /dev/null @@ -1,2 +0,0 @@ -New entry: Nueva entrada -Required fields (*): Campos requeridos (*) \ No newline at end of file diff --git a/modules/entry/front/create/style.scss b/modules/entry/front/create/style.scss deleted file mode 100644 index 2dc52b1ff..000000000 --- a/modules/entry/front/create/style.scss +++ /dev/null @@ -1,10 +0,0 @@ -vn-entry-create { - vn-card { - position: relative - } - vn-icon[icon="info"] { - position: absolute; - top: 16px; - right: 16px - } -} \ No newline at end of file diff --git a/modules/entry/front/descriptor-popover/index.html b/modules/entry/front/descriptor-popover/index.html deleted file mode 100644 index 465a9bf51..000000000 --- a/modules/entry/front/descriptor-popover/index.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/modules/entry/front/descriptor-popover/index.js b/modules/entry/front/descriptor-popover/index.js deleted file mode 100644 index d79aed03e..000000000 --- a/modules/entry/front/descriptor-popover/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import ngModule from '../module'; -import DescriptorPopover from 'salix/components/descriptor-popover'; - -class Controller extends DescriptorPopover {} - -ngModule.vnComponent('vnEntryDescriptorPopover', { - slotTemplate: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/descriptor/index.html b/modules/entry/front/descriptor/index.html deleted file mode 100644 index 7b61a0cf5..000000000 --- a/modules/entry/front/descriptor/index.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - Show entry report - - - -
- - - - - - -
-
- - - - -
- -
-
- - - \ No newline at end of file diff --git a/modules/entry/front/descriptor/index.js b/modules/entry/front/descriptor/index.js deleted file mode 100644 index 3452a6d34..000000000 --- a/modules/entry/front/descriptor/index.js +++ /dev/null @@ -1,99 +0,0 @@ -import ngModule from '../module'; -import Descriptor from 'salix/components/descriptor'; - -class Controller extends Descriptor { - get entry() { - return this.entity; - } - - set entry(value) { - this.entity = value; - } - - get travelFilter() { - let travelFilter; - const entryTravel = this.entry && this.entry.travel; - - if (entryTravel && entryTravel.agencyModeFk) { - travelFilter = this.entry && JSON.stringify({ - agencyModeFk: entryTravel.agencyModeFk - }); - } - return travelFilter; - } - - get entryFilter() { - let entryTravel = this.entry && this.entry.travel; - - if (!entryTravel || !entryTravel.landed) return null; - - const date = new Date(entryTravel.landed); - date.setHours(0, 0, 0, 0); - - const from = new Date(date.getTime()); - from.setDate(from.getDate() - 10); - - const to = new Date(date.getTime()); - to.setDate(to.getDate() + 10); - - return JSON.stringify({ - supplierFk: this.entry.supplierFk, - from, - to - }); - } - - loadData() { - const filter = { - include: [ - { - relation: 'travel', - scope: { - fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], - include: [ - { - relation: 'agency', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseOut', - scope: { - fields: ['name'] - } - }, - { - relation: 'warehouseIn', - scope: { - fields: ['name'] - } - } - ] - } - }, - { - relation: 'supplier', - scope: { - fields: ['id', 'nickname'] - } - } - ] - }; - - return this.getData(`Entries/${this.id}`, {filter}) - .then(res => this.entity = res.data); - } - - showEntryReport() { - this.vnReport.show(`Entries/${this.id}/entry-order-pdf`); - } -} - -ngModule.vnComponent('vnEntryDescriptor', { - template: require('./index.html'), - controller: Controller, - bindings: { - entry: '<' - } -}); diff --git a/modules/entry/front/descriptor/index.spec.js b/modules/entry/front/descriptor/index.spec.js deleted file mode 100644 index 714bb9f3c..000000000 --- a/modules/entry/front/descriptor/index.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -import './index.js'; - -describe('Entry Component vnEntryDescriptor', () => { - let $httpBackend; - let controller; - const entry = {id: 2}; - - beforeEach(ngModule('entry')); - - beforeEach(inject(($componentController, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - controller = $componentController('vnEntryDescriptor', {$element: null}, {entry}); - })); - - describe('showEntryReport()', () => { - it('should open a new window showing a delivery note PDF document', () => { - jest.spyOn(controller.vnReport, 'show'); - - window.open = jasmine.createSpy('open'); - controller.showEntryReport(); - const expectedPath = `Entries/${entry.id}/entry-order-pdf`; - - expect(controller.vnReport.show).toHaveBeenCalledWith(expectedPath); - }); - }); - - describe('loadData()', () => { - it('should perform ask for the entry', () => { - let query = `Entries/${entry.id}`; - jest.spyOn(controller, 'getData'); - - $httpBackend.expectGET(query).respond(); - controller.loadData(); - $httpBackend.flush(); - - expect(controller.getData).toHaveBeenCalledTimes(1); - expect(controller.getData).toHaveBeenCalledWith(query, jasmine.any(Object)); - }); - }); -}); diff --git a/modules/entry/front/descriptor/locale/es.yml b/modules/entry/front/descriptor/locale/es.yml deleted file mode 100644 index ad2fef6f3..000000000 --- a/modules/entry/front/descriptor/locale/es.yml +++ /dev/null @@ -1,7 +0,0 @@ -Reference: Referencia -Supplier card: Ficha del proveedor -All travels with current agency: Todos los envios con la agencia actual -All entries with current supplier: Todas las entradas con el proveedor actual -Show entry report: Ver informe del pedido -Is inventory entry: Es una entrada de inventario -Is virtual entry: Es una redada \ No newline at end of file diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index 88700b166..f4cae889c 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -1,18 +1,4 @@ export * from './module'; -import './main'; import './index/'; -import './create'; -import './basic-data'; -import './latest-buys'; -import './search-panel'; -import './latest-buys-search-panel'; -import './descriptor'; -import './descriptor-popover'; -import './card'; -import './note'; -import './summary'; -import './log'; -import './buy/index'; -import './buy/import'; diff --git a/modules/entry/front/index/locale/es.yml b/modules/entry/front/index/locale/es.yml deleted file mode 100644 index cebe57a42..000000000 --- a/modules/entry/front/index/locale/es.yml +++ /dev/null @@ -1,17 +0,0 @@ -Inventory entry: Es inventario -Virtual entry: Es una redada -Supplier: Proveedor -Currency: Moneda -Company: Empresa -Confirmed: Confirmada -Ordered: Pedida -Is raid: Redada -Commission: Comisión -Landed: F. entrega -Reference: Referencia -Created: Creado -Booked: Contabilizada -Is inventory: Inventario -Status: Estado -Selection: Selección -Invoice number: Núm. factura \ No newline at end of file diff --git a/modules/entry/front/latest-buys-search-panel/index.html b/modules/entry/front/latest-buys-search-panel/index.html deleted file mode 100644 index c73bf7365..000000000 --- a/modules/entry/front/latest-buys-search-panel/index.html +++ /dev/null @@ -1,242 +0,0 @@ - - - - - - - - - - - - - - - - - - -
{{name}}
-
- {{category.name}} -
> -
-
- - - - - {{name}}: {{nickname}} - - - - - - - - - - - - - - - - - - Tags - - - - - - - - - - - - - -
- - Id/Name: {{$ctrl.filter.search}} - - - {{category.selection.name}} - - - {{type.selection.name}} - - - Sales person: {{salesPerson.selection.nickname}} - - - Supplier: {{supplier.selection.name}} - - - From: {{$ctrl.filter.from | date:'dd/MM/yyyy'}} - - - To: {{$ctrl.filter.to | date:'dd/MM/yyyy'}} - - - Active: {{$ctrl.filter.active ? '✓' : '✗'}} - - - Floramondo: {{$ctrl.filter.floramondo ? '✓' : '✗'}} - - - Visible: {{$ctrl.filter.visible ? '✓' : '✗'}} - - - {{$ctrl.showTagInfo(chipTag)}} - - -
-
diff --git a/modules/entry/front/latest-buys-search-panel/index.js b/modules/entry/front/latest-buys-search-panel/index.js deleted file mode 100644 index 4078580ea..000000000 --- a/modules/entry/front/latest-buys-search-panel/index.js +++ /dev/null @@ -1,61 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; -import './style.scss'; - -class Controller extends SearchPanel { - constructor($element, $) { - super($element, $); - } - - $onInit() { - this.filter = { - isActive: true, - tags: [] - }; - } - - changeCategory(id) { - if (this.filter.categoryFk != id) { - this.filter.categoryFk = id; - this.addFilters(); - } - } - - removeItemFilter(param) { - this.filter[param] = null; - if (param == 'categoryFk') this.filter['typeFk'] = null; - this.addFilters(); - } - - removeTag(tag) { - const index = this.filter.tags.indexOf(tag); - if (index > -1) this.filter.tags.splice(index, 1); - this.addFilters(); - } - - onKeyPress($event) { - if ($event.key === 'Enter') - this.addFilters(); - } - - addFilters() { - for (let i = 0; i < this.filter.tags.length; i++) { - if (!this.filter.tags[i].value) - this.filter.tags.splice(i, 1); - } - return this.model.addFilter({}, this.filter); - } - - showTagInfo(itemTag) { - if (!itemTag.tagFk) return itemTag.value; - return `${this.tags.find(tag => tag.id == itemTag.tagFk).name}: ${itemTag.value}`; - } -} - -ngModule.component('vnLatestBuysSearchPanel', { - template: require('./index.html'), - controller: Controller, - bindings: { - model: '<' - } -}); diff --git a/modules/entry/front/latest-buys-search-panel/index.spec.js b/modules/entry/front/latest-buys-search-panel/index.spec.js deleted file mode 100644 index c3c5acbfb..000000000 --- a/modules/entry/front/latest-buys-search-panel/index.spec.js +++ /dev/null @@ -1,56 +0,0 @@ -import './index.js'; - -describe('Entry', () => { - describe('Component vnLatestBuysSearchPanel', () => { - let $element; - let controller; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject($componentController => { - $element = angular.element(``); - controller = $componentController('vnLatestBuysSearchPanel', {$element}); - controller.model = {addFilter: () => {}}; - })); - - describe('removeItemFilter()', () => { - it(`should remove param from filter`, () => { - controller.filter = {tags: [], categoryFk: 1, typeFk: 1}; - const expectFilter = {tags: [], categoryFk: null, typeFk: null}; - - controller.removeItemFilter('categoryFk'); - - expect(controller.filter).toEqual(expectFilter); - }); - }); - - describe('removeTag()', () => { - it(`should remove tag from filter`, () => { - const tag = {tagFk: 1, value: 'Value'}; - controller.filter = {tags: [tag]}; - const expectFilter = {tags: []}; - - controller.removeTag(tag); - - expect(controller.filter).toEqual(expectFilter); - }); - }); - - describe('showTagInfo()', () => { - it(`should show tag value`, () => { - const tag = {value: 'Value'}; - const result = controller.showTagInfo(tag); - - expect(result).toEqual('Value'); - }); - - it(`should show tag name and value`, () => { - const tag = {tagFk: 1, value: 'Value'}; - controller.tags = [{id: 1, name: 'tagName'}]; - const result = controller.showTagInfo(tag); - - expect(result).toEqual('tagName: Value'); - }); - }); - }); -}); diff --git a/modules/entry/front/latest-buys-search-panel/style.scss b/modules/entry/front/latest-buys-search-panel/style.scss deleted file mode 100644 index ec189c7e4..000000000 --- a/modules/entry/front/latest-buys-search-panel/style.scss +++ /dev/null @@ -1,70 +0,0 @@ -@import "variables"; - -vn-latest-buys-search-panel vn-side-menu div { - & > .input { - padding-left: $spacing-md; - padding-right: $spacing-md; - border-color: $color-spacer; - border-bottom: $border-thin; - } - & > .horizontal { - grid-auto-flow: column; - grid-column-gap: $spacing-sm; - align-items: center; - } - & > .checks { - padding: $spacing-md; - flex-wrap: wrap; - border-color: $color-spacer; - border-bottom: $border-thin; - } - & > .tags { - padding: $spacing-md; - padding-bottom: 0%; - padding-top: 0%; - align-items: center; - } - & > .chips { - display: flex; - flex-wrap: wrap; - padding: $spacing-md; - overflow: hidden; - max-width: 100%; - border-color: $color-spacer; - border-top: $border-thin; - } - & > .item-category { - padding: $spacing-sm; - justify-content: flex-start; - align-items: flex-start; - flex-wrap: wrap; - - vn-autocomplete[vn-id="category"] { - display: none; - } - - & > vn-one { - padding: $spacing-sm; - min-width: 33.33%; - text-align: center; - box-sizing: border-box; - - & > vn-icon { - padding: $spacing-sm; - background-color: $color-font-secondary; - border-radius: 50%; - cursor: pointer; - - &.active { - background-color: $color-main; - color: #fff; - } - & > i:before { - font-size: 2.6rem; - width: 16px; - height: 16px; - } - } - } - } -} diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html deleted file mode 100644 index 2e6de83b9..000000000 --- a/modules/entry/front/latest-buys/index.html +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - Picture - Item ID - - Packing - - Grouping - - Quantity - - Description - - Size - - Tags - - Type - - Intrastat - - Origin - - Weight/Piece - - Active - - Family - - Entry - - Buying value - - Freight value - - Commission value - - Package value - - Is ignored - - Grouping - - Packing - - Min - - Ekt - - Weight - - Package - - Package out - - Landing -
- - - - - - - {{::buy.itemFk}} - - - - {{::buy.packing | dashIfEmpty}} - - - - {{::buy.grouping | dashIfEmpty}} - - {{::buy.quantity}} - {{::buy.description | dashIfEmpty}} - {{::buy.size}} -
- {{::buy.name}} - -

{{::buy.subName}}

-
-
- - -
- {{::buy.code}} - - {{::buy.intrastat}} - {{::buy.origin}}{{::buy.weightByPiece}} - - - {{::buy.family}} - - {{::buy.entryFk}} - - {{::buy.buyingValue | currency: 'EUR':3}}{{::buy.freightValue | currency: 'EUR':3}}{{::buy.comissionValue | currency: 'EUR':3}}{{::buy.packageValue | currency: 'EUR':3}} - - - {{::buy.price2 | currency: 'EUR':3}}{{::buy.price3 | currency: 'EUR':3}}{{::buy.minPrice | currency: 'EUR':3}}{{::buy.ektFk | dashIfEmpty}}{{::buy.weight}}{{::buy.packagingFk}}{{::buy.packingOut}}{{::buy.landing | date: 'dd/MM/yyyy'}}
-
-
-
-
- - - - -
- - - Edit - - {{::$ctrl.totalChecked}} - - buy(s) - - - - - - - - - - - - - - - - diff --git a/modules/entry/front/latest-buys/index.js b/modules/entry/front/latest-buys/index.js deleted file mode 100644 index 292c5b805..000000000 --- a/modules/entry/front/latest-buys/index.js +++ /dev/null @@ -1,209 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; -import './style.scss'; - -export default class Controller extends Section { - constructor($element, $) { - super($element, $); - this.editedColumn; - this.checkAll = false; - this.checkedBuys = []; - - this.smartTableOptions = { - activeButtons: { - search: true, - shownColumns: true, - }, - columns: [ - { - field: 'code', - autocomplete: { - url: 'ItemTypes', - showField: 'code', - valueField: 'code', - } - }, - { - field: 'origin', - autocomplete: { - url: 'Origins', - showField: 'code', - valueField: 'code' - } - }, - { - field: 'family', - autocomplete: { - url: 'ItemFamilies', - valueField: 'code', - showField: 'code' - } - }, - { - field: 'intrastat', - autocomplete: { - url: 'Intrastats', - showField: 'description', - valueField: 'description' - } - }, - { - field: 'packagingFk', - autocomplete: { - url: 'Packagings', - showField: 'id' - } - }, - { - field: 'isActive', - searchable: false - }, - { - field: 'isIgnored', - searchable: false - }, - { - field: 'landing', - searchable: false - } - ] - }; - } - - get columns() { - if (this._columns) return this._columns; - - this._columns = [ - {field: 'packing', displayName: this.$t('Packing')}, - {field: 'grouping', displayName: this.$t('Grouping')}, - {field: 'packageValue', displayName: this.$t('Package value')}, - {field: 'weight', displayName: this.$t('Weight')}, - {field: 'description', displayName: this.$t('Description')}, - {field: 'size', displayName: this.$t('Size')}, - {field: 'weightByPiece', displayName: this.$t('weight/Piece')}, - {field: 'packingOut', displayName: this.$t('PackingOut')}, - {field: 'landing', displayName: this.$t('Landing')} - ]; - - return this._columns; - } - - get checked() { - const buys = this.$.model.data || []; - const checkedBuys = []; - for (let buy of buys) { - if (buy.checked) - checkedBuys.push(buy); - } - - return checkedBuys; - } - - exprBuilder(param, value) { - switch (param) { - case 'id': - case 'size': - case 'weightByPiece': - case 'isActive': - case 'family': - case 'minPrice': - case 'packingOut': - return {[`i.${param}`]: value}; - case 'name': - case 'description': - return {[`i.${param}`]: {like: `%${value}%`}}; - case 'code': - return {'it.code': value}; - case 'intrastat': - return {'intr.description': value}; - case 'origin': - return {'ori.code': value}; - case 'landing': - return {[`lb.${param}`]: value}; - case 'packing': - case 'grouping': - case 'quantity': - case 'entryFk': - case 'buyingValue': - case 'freightValue': - case 'comissionValue': - case 'packageValue': - case 'isIgnored': - case 'price2': - case 'price3': - case 'ektFk': - case 'weight': - case 'packagingFk': - return {[`b.${param}`]: value}; - } - } - - uncheck() { - this.checkAll = false; - this.checkedBuys = []; - } - - get totalChecked() { - if (this.checkedDummyCount) - return this.checkedDummyCount; - - return this.checked.length; - } - - saveChecked(buyId) { - const index = this.checkedBuys.indexOf(buyId); - if (index !== -1) - return this.checkedBuys.splice(index, 1); - return this.checkedBuys.push(buyId); - } - - reCheck() { - if (!this.$.model.data) return; - if (!this.checkedBuys.length) return; - - this.$.model.data.forEach(buy => { - if (this.checkedBuys.includes(buy.id)) - buy.checked = true; - }); - } - - onEditAccept() { - const rowsToEdit = []; - for (let row of this.checked) - rowsToEdit.push({id: row.id, itemFk: row.itemFk}); - - const data = { - field: this.editedColumn.field, - newValue: this.editedColumn.newValue, - lines: rowsToEdit - }; - - if (this.checkedDummyCount && this.checkedDummyCount > 0) { - const params = {}; - if (this.$.model.userParams) { - const userParams = this.$.model.userParams; - for (let param in userParams) { - let newParam = this.exprBuilder(param, userParams[param]); - if (!newParam) - newParam = {[param]: userParams[param]}; - Object.assign(params, newParam); - } - } - if (this.$.model.userFilter) - Object.assign(params, this.$.model.userFilter.where); - - data.filter = params; - } - - return this.$http.post('Buys/editLatestBuys', data) - .then(() => { - this.uncheck(); - this.$.model.refresh(); - }); - } -} - -ngModule.component('vnEntryLatestBuys', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/latest-buys/index.spec.js b/modules/entry/front/latest-buys/index.spec.js deleted file mode 100644 index 6574303fc..000000000 --- a/modules/entry/front/latest-buys/index.spec.js +++ /dev/null @@ -1,100 +0,0 @@ -import './index.js'; - -describe('Entry', () => { - describe('Component vnEntryLatestBuys', () => { - let controller; - let $httpBackend; - - beforeEach(ngModule('entry')); - - beforeEach(angular.mock.inject(($componentController, $rootScope, _$httpBackend_) => { - $httpBackend = _$httpBackend_; - const $element = angular.element(' {}}, - edit: {hide: () => {}} - }; - })); - - describe('get columns', () => { - it(`should return a set of columns`, () => { - let result = controller.columns; - - let length = result.length; - let anyColumn = Object.keys(result[Math.floor(Math.random() * Math.floor(length))]); - - expect(anyColumn).toContain('field', 'displayName'); - }); - }); - - describe('get checked', () => { - it(`should return a set of checked lines`, () => { - controller.$.model.data = [ - {checked: true, id: 1}, - {checked: true, id: 2}, - {checked: true, id: 3}, - {checked: false, id: 4}, - ]; - - let result = controller.checked; - - expect(result.length).toEqual(3); - }); - }); - - describe('onEditAccept()', () => { - it(`should perform a query to update columns`, () => { - controller.editedColumn = {field: 'my field', newValue: 'the new value'}; - const query = 'Buys/editLatestBuys'; - - $httpBackend.expectPOST(query).respond(); - controller.onEditAccept(); - $httpBackend.flush(); - - const result = controller.checked; - - expect(result.length).toEqual(0); - }); - }); - - describe('reCheck()', () => { - it(`should recheck buys`, () => { - controller.$.model.data = [ - {checked: false, id: 1}, - {checked: false, id: 2}, - {checked: false, id: 3}, - {checked: false, id: 4}, - ]; - controller.checkedBuys = [1, 2]; - - controller.reCheck(); - - expect(controller.$.model.data[0].checked).toEqual(true); - expect(controller.$.model.data[1].checked).toEqual(true); - expect(controller.$.model.data[2].checked).toEqual(false); - expect(controller.$.model.data[3].checked).toEqual(false); - }); - }); - - describe('saveChecked()', () => { - it(`should check buy`, () => { - const buyCheck = 3; - controller.checkedBuys = [1, 2]; - - controller.saveChecked(buyCheck); - - expect(controller.checkedBuys[2]).toEqual(buyCheck); - }); - - it(`should uncheck buy`, () => { - const buyUncheck = 3; - controller.checkedBuys = [1, 2, 3]; - - controller.saveChecked(buyUncheck); - - expect(controller.checkedBuys[2]).toEqual(undefined); - }); - }); - }); -}); diff --git a/modules/entry/front/latest-buys/locale/en.yml b/modules/entry/front/latest-buys/locale/en.yml deleted file mode 100644 index 48dda861b..000000000 --- a/modules/entry/front/latest-buys/locale/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -Minimun amount: Minimun purchase quantity -PackageName: Package \ No newline at end of file diff --git a/modules/entry/front/latest-buys/locale/es.yml b/modules/entry/front/latest-buys/locale/es.yml deleted file mode 100644 index 795e3f5f4..000000000 --- a/modules/entry/front/latest-buys/locale/es.yml +++ /dev/null @@ -1,19 +0,0 @@ -Edit buy(s): Editar compra(s) -Buying value: Coste -Freight value: Porte -Commission value: Comisión -Package value: Embalaje -Is ignored: Ignorado -Is visible: Visible -Is floramondo: Floramondo -Grouping price: Precio grouping -Packing price: Precio packing -Min price: Precio min -Ekt: Ekt -Weight: Peso -Minimun amount: Cantidad mínima de compra -Field to edit: Campo a editar -PackageName: Cubo -Edit: Editar -buy(s): compra(s) -Package out: Embalaje envíos diff --git a/modules/entry/front/latest-buys/style.scss b/modules/entry/front/latest-buys/style.scss deleted file mode 100644 index a3c399edc..000000000 --- a/modules/entry/front/latest-buys/style.scss +++ /dev/null @@ -1,7 +0,0 @@ -.countLines { - flex: 0.15; - font-size: 24px; - color: orangered; - font-weight: bold; - max-width: 30px; -} diff --git a/modules/entry/front/locale/es.yml b/modules/entry/front/locale/es.yml deleted file mode 100644 index b28cbe735..000000000 --- a/modules/entry/front/locale/es.yml +++ /dev/null @@ -1,6 +0,0 @@ -#Ordenar alfabeticamente - -entry: entrada -Latest buys: Últimas compras - -# Sections diff --git a/modules/entry/front/log/index.html b/modules/entry/front/log/index.html deleted file mode 100644 index fd8ae7c2a..000000000 --- a/modules/entry/front/log/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/modules/entry/front/log/index.js b/modules/entry/front/log/index.js deleted file mode 100644 index 73218f4de..000000000 --- a/modules/entry/front/log/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -ngModule.vnComponent('vnEntryLog', { - template: require('./index.html'), - controller: Section, -}); diff --git a/modules/entry/front/log/locale/es.yml b/modules/entry/front/log/locale/es.yml deleted file mode 100644 index 094615b47..000000000 --- a/modules/entry/front/log/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -Date: Fecha \ No newline at end of file diff --git a/modules/entry/front/main/index.html b/modules/entry/front/main/index.html deleted file mode 100644 index d55fbd60b..000000000 --- a/modules/entry/front/main/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/modules/entry/front/main/index.js b/modules/entry/front/main/index.js deleted file mode 100644 index 69bddc7fc..000000000 --- a/modules/entry/front/main/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import ngModule from '../module'; -import ModuleMain from 'salix/components/module-main'; - -export default class Entry extends ModuleMain { - -} - -ngModule.vnComponent('vnEntry', { - controller: Entry, - template: require('./index.html') -}); diff --git a/modules/entry/front/note/index.html b/modules/entry/front/note/index.html deleted file mode 100644 index 5f3c7f77e..000000000 --- a/modules/entry/front/note/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/modules/entry/front/note/index.js b/modules/entry/front/note/index.js deleted file mode 100644 index fccd60913..000000000 --- a/modules/entry/front/note/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { - this.$.watcher.notifySaved(); - this.$.watcher.updateOriginalData(); - }); - } -} - -ngModule.vnComponent('vnEntryObservation', { - template: require('./index.html'), - controller: Controller, - bindings: { - entry: '<' - } -}); diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index 3934a96ee..53c599cf1 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -8,12 +8,6 @@ "main": [ {"state": "entry.index", "icon": "icon-entry"}, {"state": "entry.latestBuys", "icon": "contact_support"} - ], - "card": [ - {"state": "entry.card.basicData", "icon": "settings"}, - {"state": "entry.card.buy.index", "icon": "icon-lines"}, - {"state": "entry.card.observation", "icon": "insert_drive_file"}, - {"state": "entry.card.log", "icon": "history"} ] }, "keybindings": [ @@ -33,90 +27,6 @@ "component": "vn-entry-index", "description": "Entries", "acl": ["buyer", "administrative"] - }, - { - "url": "/latest-buys?q", - "state": "entry.latestBuys", - "component": "vn-entry-latest-buys", - "description": "Latest buys", - "acl": ["buyer", "administrative"] - }, - { - "url": "/create?supplierFk&travelFk&companyFk", - "state": "entry.create", - "component": "vn-entry-create", - "description": "New entry", - "acl": ["buyer", "administrative"] - }, - { - "url": "/:id", - "state": "entry.card", - "abstract": true, - "component": "vn-entry-card" - }, - { - "url": "/summary", - "state": "entry.card.summary", - "component": "vn-entry-summary", - "description": "Summary", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer", "administrative"] - }, - { - "url": "/basic-data", - "state": "entry.card.basicData", - "component": "vn-entry-basic-data", - "description": "Basic data", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer", "administrative"] - }, - { - "url": "/observation", - "state": "entry.card.observation", - "component": "vn-entry-observation", - "description": "Notes", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer", "administrative"] - }, - { - "url" : "/log", - "state": "entry.card.log", - "component": "vn-entry-log", - "description": "Log", - "acl": ["buyer", "administrative"] - }, - { - "url": "/buy", - "state": "entry.card.buy", - "abstract": true, - "component": "ui-view", - "acl": ["buyer"] - }, - { - "url" : "/index", - "state": "entry.card.buy.index", - "component": "vn-entry-buy-index", - "description": "Buys", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer", "administrative"] - }, - { - "url" : "/import", - "state": "entry.card.buy.import", - "component": "vn-entry-buy-import", - "description": "Import buys", - "params": { - "entry": "$ctrl.entry" - }, - "acl": ["buyer"] } ] -} \ No newline at end of file +} diff --git a/modules/entry/front/search-panel/index.html b/modules/entry/front/search-panel/index.html deleted file mode 100644 index adcb9d6d4..000000000 --- a/modules/entry/front/search-panel/index.html +++ /dev/null @@ -1,100 +0,0 @@ -
-
- - - - - - - - - - - - - - - - - - - - - - - {{name}}: {{nickname}} - - - - - - - - - - - - - - - - - - - - - -
-
\ No newline at end of file diff --git a/modules/entry/front/search-panel/index.js b/modules/entry/front/search-panel/index.js deleted file mode 100644 index e87f31056..000000000 --- a/modules/entry/front/search-panel/index.js +++ /dev/null @@ -1,7 +0,0 @@ -import ngModule from '../module'; -import SearchPanel from 'core/components/searchbar/search-panel'; - -ngModule.vnComponent('vnEntrySearchPanel', { - template: require('./index.html'), - controller: SearchPanel -}); diff --git a/modules/entry/front/search-panel/locale/es.yml b/modules/entry/front/search-panel/locale/es.yml deleted file mode 100644 index 05b71da99..000000000 --- a/modules/entry/front/search-panel/locale/es.yml +++ /dev/null @@ -1,9 +0,0 @@ -Ticket id: Id ticket -Client id: Id cliente -Nickname: Alias -From: Desde -To: Hasta -Agency: Agencia -Warehouse: Almacén -Search entry by id or a suppliers by name or alias: Buscar entrada por id o proveedores por nombre y alias -Invoice number: Núm. factura \ No newline at end of file diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html deleted file mode 100644 index baa310bb6..000000000 --- a/modules/entry/front/summary/index.html +++ /dev/null @@ -1,196 +0,0 @@ - - - -
- - - - #{{$ctrl.entryData.id}} - {{$ctrl.entryData.supplier.nickname}} -
- - - - - - - - - - - - - - - - - {{$ctrl.entryData.travel.ref}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Buys

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
QuantityStickersPackageWeightPackingGroupingBuying valueImportPVP
{{::line.quantity}}{{::line.stickers | dashIfEmpty}}{{::line.packagingFk | dashIfEmpty}}{{::line.weight}} - - {{::line.packing | dashIfEmpty}} - - - - {{::line.grouping | dashIfEmpty}} - - - {{::line.buyingValue | currency: 'EUR':2}}{{::line.quantity * line.buyingValue | currency: 'EUR':2}}{{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}}
- - {{::line.item.itemType.code}} - - - - {{::line.item.id}} - - - - {{::line.item.size}} - - - - {{::line.item.minPrice | currency: 'EUR':2}} - - -
- {{::line.item.name}} - -

{{::line.item.subName}}

-
-
- - -
- - -
-
-
- - - - - diff --git a/modules/entry/front/summary/index.js b/modules/entry/front/summary/index.js deleted file mode 100644 index 6e18bc959..000000000 --- a/modules/entry/front/summary/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import ngModule from '../module'; -import './style.scss'; -import Summary from 'salix/components/summary'; - -class Controller extends Summary { - get entry() { - if (!this._entry) - return this.$params; - - return this._entry; - } - - set entry(value) { - this._entry = value; - - if (value && value.id) - this.getEntryData(); - } - - getEntryData() { - return this.$http.get(`Entries/${this.entry.id}/getEntry`).then(response => { - this.entryData = response.data; - }); - } -} - -ngModule.vnComponent('vnEntrySummary', { - template: require('./index.html'), - controller: Controller, - bindings: { - entry: '<' - } -}); diff --git a/modules/entry/front/summary/index.spec.js b/modules/entry/front/summary/index.spec.js deleted file mode 100644 index baeb43ac8..000000000 --- a/modules/entry/front/summary/index.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import './index'; - -describe('component vnEntrySummary', () => { - let controller; - let $httpBackend; - let $scope; - - beforeEach(angular.mock.module('entry', $translateProvider => { - $translateProvider.translations('en', {}); - })); - - beforeEach(inject(($componentController, $rootScope, _$httpBackend_, _$httpParamSerializer_) => { - $httpBackend = _$httpBackend_; - $scope = $rootScope.$new(); - const $element = angular.element(``); - controller = $componentController('vnEntrySummary', {$element, $scope}); - })); - - describe('entry setter/getter', () => { - it('should check if value.id is defined', () => { - jest.spyOn(controller, 'getEntryData'); - - controller.entry = {id: 1}; - - expect(controller.getEntryData).toHaveBeenCalledWith(); - }); - - it('should return the entry and then call getEntryData()', () => { - jest.spyOn(controller, 'getEntryData'); - controller.entry = {id: 99}; - - expect(controller._entry.id).toEqual(99); - expect(controller.getEntryData).toHaveBeenCalledWith(); - }); - }); - - describe('getEntryData()', () => { - it('should perform a get and then store data on the controller', () => { - controller._entry = {id: 999}; - - const query = `Entries/${controller._entry.id}/getEntry`; - $httpBackend.expectGET(query).respond('I am the entryData'); - controller.getEntryData(); - $httpBackend.flush(); - - expect(controller.entryData).toEqual('I am the entryData'); - }); - }); -}); diff --git a/modules/entry/front/summary/locale/es.yml b/modules/entry/front/summary/locale/es.yml deleted file mode 100644 index 1761561ed..000000000 --- a/modules/entry/front/summary/locale/es.yml +++ /dev/null @@ -1,11 +0,0 @@ -Inventory: Inventario -Raid: Redada -Entry: Entrada -Stickers: Etiquetas -Item size: Tamaño -Item type: Tipo -Minimum price: Precio mínimo -Buys: Compras -Travel: Envio -Go to the entry: Ir a la entrada -Invoice number: Núm. factura diff --git a/modules/entry/front/summary/style.scss b/modules/entry/front/summary/style.scss deleted file mode 100644 index 1d5b22e30..000000000 --- a/modules/entry/front/summary/style.scss +++ /dev/null @@ -1,30 +0,0 @@ -@import "variables"; - - -vn-entry-summary .summary { - max-width: $width-lg; - - .dark-row { - background-color: lighten($color-marginal, 10%); - } - - tbody tr:nth-child(1) { - border-top: $border-thin; - } - - tbody tr:nth-child(1), - tbody tr:nth-child(2) { - border-left: $border-thin; - border-right: $border-thin - } - - tbody tr:nth-child(3) { - height: inherit - } - - tr { - margin-bottom: 10px; - } -} - -$color-font-link-medium: lighten($color-font-link, 20%) \ No newline at end of file diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 3dea69ba1..4b7cd1490 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -3,7 +3,7 @@ "name": "Items", "icon": "icon-item", "validations" : true, - "dependencies": ["worker", "client", "ticket", "entry"], + "dependencies": ["worker", "client", "ticket"], "menus": { "main": [ {"state": "item.index", "icon": "icon-item"}, @@ -19,8 +19,8 @@ {"state": "item.card.tax", "icon": "icon-tax"}, {"state": "item.card.botanical", "icon": "local_florist"}, {"state": "item.card.shelving", "icon": "icon-inventory"}, - {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, - {"state": "item.card.diary", "icon": "icon-transaction"}, + {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, + {"state": "item.card.diary", "icon": "icon-transaction"}, {"state": "item.card.log", "icon": "history"} ], "itemType": [ @@ -227,4 +227,4 @@ "acl": ["buyer"] } ] -} \ No newline at end of file +} diff --git a/modules/travel/front/routes.json b/modules/travel/front/routes.json index b2e438c6d..5a63620d4 100644 --- a/modules/travel/front/routes.json +++ b/modules/travel/front/routes.json @@ -3,7 +3,7 @@ "name": "Travels", "icon": "local_airport", "validations": true, - "dependencies": ["worker", "entry"], + "dependencies": ["worker"], "menus": { "main": [ {"state": "travel.index", "icon": "local_airport"}, @@ -45,7 +45,7 @@ "state": "travel.card.basicData", "component": "vn-travel-basic-data", "description": "Basic data", - "acl": ["buyer","logistic"], + "acl": ["buyer","logistic"], "params": { "travel": "$ctrl.travel" } @@ -97,10 +97,10 @@ "state": "travel.extraCommunity", "component": "vn-travel-extra-community", "description": "Extra community", - "acl": ["buyer"], + "acl": ["buyer"], "params": { "travel": "$ctrl.travel" } } ] -} \ No newline at end of file +} From 9b21cd5eb1e52712e34d0a7ae3941ff3c8dad612 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 08:38:58 +0200 Subject: [PATCH 043/114] refactor: refs #7490 Deleted update duaInvoiceInBooking --- .../vn/procedures/duaInvoiceInBooking.sql | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 8b4df6a73..018c72e0e 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`(vDuaFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking`( + vDuaFk INT +) BEGIN /** * Genera el asiento de un DUA y marca las entradas como confirmadas @@ -22,18 +24,6 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - UPDATE invoiceIn ii - JOIN entry e ON e.invoiceInFk = ii.id - JOIN duaEntry de ON de.entryFk = e.id - JOIN dua d ON d.id = de.duaFk - SET ii.booked = IFNULL(ii.booked, d.booked), - ii.operated = IFNULL(ii.operated, d.operated), - ii.issued = IFNULL(ii.issued, d.issued), - ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried), - e.isBooked = TRUE, - e.isConfirmed = TRUE - WHERE d.id = vDuaFk; - SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk; IF vBookEntry IS NULL THEN From fb4be69cf12737ef71bc29a2ee24a20f9e3b32ee Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 08:47:02 +0200 Subject: [PATCH 044/114] refactor: refs #7490 Added final update --- .../vn/procedures/duaInvoiceInBooking.sql | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 018c72e0e..9cbf54b4a 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -4,10 +4,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking ) BEGIN /** - * Genera el asiento de un DUA y marca las entradas como confirmadas - * - * @param vDuaFk Id del dua a recalcular - */ +* Genera el asiento de un DUA y marca las entradas como confirmadas +* +* @param vDuaFk Id del dua a recalcular +*/ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; DECLARE vBookEntry INT; @@ -29,7 +29,7 @@ BEGIN IF vBookEntry IS NULL THEN SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear FROM invoiceIn ii - JOIN entry e ON e.invoiceInFk = ii.id + JOIN `entry` e ON e.invoiceInFk = ii.id JOIN duaEntry de ON de.entryFk = e.id JOIN dua d ON d.id = de.duaFk WHERE d.id = vDuaFk @@ -60,5 +60,28 @@ l: LOOP JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id SET ii.isBooked = TRUE WHERE dii.duaFk = vDuaFk; + + UPDATE `entry` e + JOIN ( + WITH entries AS ( + SELECT e.id, de.duaFk + FROM `entry` e + JOIN duaEntry de ON de.entryFk = e.id + WHERE de.duaFk = vDuaFk + AND (NOT e.isBooked OR NOT e.isConfirmed) + ), + notBookedEntries AS ( + SELECT e.id + FROM entries e + JOIN duaEntry de ON de.entryFk = e.id + JOIN dua d ON d.id = de.duaFk + WHERE d.ASIEN IS NULL) + SELECT e.id + FROM entries e + LEFT JOIN notBookedEntries nbe ON nbe.id = e.id + WHERE nbe.id IS NULL + ) sub ON sub.id = e.id + SET e.isBooked = TRUE, + e.isConfirmed = TRUE; END$$ DELIMITER ; From 317f898c2eb1a63fea6bd0f024c1b136251b92ca Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 08:48:56 +0200 Subject: [PATCH 045/114] refactor: refs #7490 Minor changes --- db/routines/vn/procedures/duaInvoiceInBooking.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 9cbf54b4a..efaf29b41 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -4,10 +4,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`duaInvoiceInBooking ) BEGIN /** -* Genera el asiento de un DUA y marca las entradas como confirmadas -* -* @param vDuaFk Id del dua a recalcular -*/ + * Genera el asiento de un DUA y marca las entradas como confirmadas + * + * @param vDuaFk Id del dua a recalcular + */ DECLARE vDone BOOL DEFAULT FALSE; DECLARE vInvoiceFk INT; DECLARE vBookEntry INT; @@ -39,7 +39,7 @@ BEGIN OPEN vInvoicesIn; -l: LOOP + l: LOOP SET vDone = FALSE; FETCH vInvoicesIn INTO vInvoiceFk; From 5d7a570c3fb917590e4947738765eebf2f72ecec Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 11 Jun 2024 12:28:49 +0200 Subject: [PATCH 046/114] refs #6897 fix redirection --- back/nodemonConfig.json | 1 + front/module-import.js | 1 + modules/entry/front/index.js | 3 +- modules/entry/front/index/index.html | 85 ---------------------------- modules/entry/front/index/index.js | 14 ----- modules/entry/front/main/index.html | 0 modules/entry/front/main/index.js | 17 ++++++ 7 files changed, 20 insertions(+), 101 deletions(-) delete mode 100644 modules/entry/front/index/index.html delete mode 100644 modules/entry/front/index/index.js create mode 100644 modules/entry/front/main/index.html create mode 100644 modules/entry/front/main/index.js diff --git a/back/nodemonConfig.json b/back/nodemonConfig.json index c468a2f73..9552460bd 100644 --- a/back/nodemonConfig.json +++ b/back/nodemonConfig.json @@ -8,6 +8,7 @@ "modules/account/front/**/*", "modules/claim/front/**/*", "modules/client/front/**/*", + "modules/entry/front/**/*", "modules/invoiceIn/front/**/*", "modules/invoiceOut/front/**/*", "modules/item/front/**/*", diff --git a/front/module-import.js b/front/module-import.js index 85731c72c..22a2747d2 100755 --- a/front/module-import.js +++ b/front/module-import.js @@ -22,5 +22,6 @@ export default function moduleImport(moduleName) { case 'supplier': return import('supplier/front'); case 'shelving': return import('shelving/front'); case 'monitor': return import('monitor/front'); + case 'entry': return import('entry/front'); } } diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index f4cae889c..a7209a0bd 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -1,4 +1,3 @@ export * from './module'; -import './index/'; - +import './main'; diff --git a/modules/entry/front/index/index.html b/modules/entry/front/index/index.html deleted file mode 100644 index 42177be21..000000000 --- a/modules/entry/front/index/index.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - Id - Landed - Reference - Invoice number - Supplier - Booked - Confirmed - Ordered - - - - - - - - - - - - {{::entry.id}} - - - {{::entry.landed | date:'dd/MM/yyyy'}} - - - {{::entry.reference}} - {{::entry.invoiceNumber}} - {{::entry.supplierName}} - - - - - - - - - - - - - - - - - - -
- - - - - - -
\ No newline at end of file diff --git a/modules/entry/front/index/index.js b/modules/entry/front/index/index.js deleted file mode 100644 index 8635d3fb4..000000000 --- a/modules/entry/front/index/index.js +++ /dev/null @@ -1,14 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -export default class Controller extends Section { - preview(entry) { - this.entrySelected = entry; - this.$.summary.show(); - } -} - -ngModule.vnComponent('vnEntryIndex', { - template: require('./index.html'), - controller: Controller -}); diff --git a/modules/entry/front/main/index.html b/modules/entry/front/main/index.html new file mode 100644 index 000000000..e69de29bb diff --git a/modules/entry/front/main/index.js b/modules/entry/front/main/index.js new file mode 100644 index 000000000..de0beced4 --- /dev/null +++ b/modules/entry/front/main/index.js @@ -0,0 +1,17 @@ +import ngModule from '../module'; +import ModuleMain from 'salix/components/module-main'; + +export default class Entry extends ModuleMain { + constructor($element, $) { + super($element, $); + } + async $onInit() { + this.$state.go('home'); + window.location.href = await this.vnApp.getUrl(`entry/`); + } +} + +ngModule.vnComponent('vnEntry', { + controller: Entry, + template: require('./index.html') +}); From ed7218c1332d4d8c752e6816e07b111ec0100127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 11 Jun 2024 12:44:25 +0200 Subject: [PATCH 047/114] feat: previas con sitema de reservas refs #6861 --- .../collection_addWithReservation.sql | 24 ++++----- .../vn/procedures/collection_getAssigned.sql | 16 +++--- .../itemShelvingSale_addByCollection.sql | 2 +- .../itemShelvingSale_moveReserv.sql | 50 +++++++++++++++++++ ...oup.sql => itemShelvingSale_setPicked.sql} | 2 +- .../itemShelvingSale_setQuantity.sql | 45 +++-------------- ...Transfer.sql => itemShelving_transfer.sql} | 5 +- ....sql => sectorCollection_getMyPartial.sql} | 2 +- .../sectorCollection_hasSalesReserved.sql | 30 +++++------ .../vn/triggers/itemShelving_afterInsert.sql | 29 ----------- 10 files changed, 94 insertions(+), 111 deletions(-) create mode 100644 db/routines/vn/procedures/itemShelvingSale_moveReserv.sql rename db/routines/vn/procedures/{itemShelvingSale_setSaleGroup.sql => itemShelvingSale_setPicked.sql} (91%) rename db/routines/vn/procedures/{itemShelvingTransfer.sql => itemShelving_transfer.sql} (95%) rename db/routines/vn/procedures/{sectorCollection_getPartial.sql => sectorCollection_getMyPartial.sql} (95%) delete mode 100644 db/routines/vn/triggers/itemShelving_afterInsert.sql diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index cc207b572..faa00477e 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -23,7 +23,7 @@ BEGIN DECLARE vConcept VARCHAR(50); DECLARE vItemName VARCHAR(50); DECLARE vHasThrow BOOLEAN DEFAULT FALSE; - + DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; @@ -48,21 +48,14 @@ BEGIN IF vAvailable < vQuantity THEN SET vHasThrow = TRUE; - SELECT vAvailable, vQuantity; ELSE - START TRANSACTION; - SELECT `name`, CONCAT(getUser(), ' ', DATE_FORMAT(util.VN_NOW(), '%H:%i'), ' ', name) INTO vItemName, vConcept FROM item WHERE id = vItemFk; - INSERT INTO ticketLog - SET originFk = vTicketFk, - userFk = getUser(), - `action` = 'update', - `description` = CONCAT('Añadido articulo ', vItemName, ' cantidad:', vQuantity); + START TRANSACTION; INSERT INTO sale SET itemFk = vItemFk, @@ -84,12 +77,13 @@ BEGIN IF vHasThrow THEN CALL util.throw("No hay disponibilidad para el artículo seleccionado"); ELSE - IF vSaleGroupFk THEN - INSERT INTO saleGroupDetail - SET saleFk = vSaleFk, - saleGroupFk = vSaleGroupFk; - COMMIT; + IF vSaleGroupFk THEN + INSERT INTO saleGroupDetail + SET saleFk = vSaleFk, + saleGroupFk = vSaleGroupFk; END IF; - END IF ; + COMMIT; + END IF; + END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql index 63805e701..575032e2e 100644 --- a/db/routines/vn/procedures/collection_getAssigned.sql +++ b/db/routines/vn/procedures/collection_getAssigned.sql @@ -1,11 +1,14 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`collection_getAssigned`( vUserFk INT, - OUT vCollectionFk INT) -proc:BEGIN -/* Comprueba si existen colecciones libres que se ajustan al perfil del usuario + OUT vCollectionFk INT +) +BEGIN +/** + * Comprueba si existen colecciones libres que se ajustan al perfil del usuario * y le asigna la más antigua. * Añade un registro al semillero de colecciones y hace la reserva para la colección + * * @param vUserFk Id de usuario * @param vCollectionFk Id de colección */ @@ -28,17 +31,16 @@ proc:BEGIN CALL collection_get(vUserFk); SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - collection_assign_lockname + pc.collection_assign_lockname INTO vHasTooMuchCollections, vLockName - FROM tCollection - JOIN productionConfig pc ; + FROM tCollection tc + JOIN productionConfig pc; DROP TEMPORARY TABLE tCollection; IF vHasTooMuchCollections THEN CALL util.throw('Hay colecciones pendientes'); - LEAVE proc; END IF; SELECT warehouseFk, itemPackingTypeFk diff --git a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql index 9bc549235..7f9cc6616 100644 --- a/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql +++ b/db/routines/vn/procedures/itemShelvingSale_addByCollection.sql @@ -26,7 +26,7 @@ BEGIN JOIN vn.saleTracking st ON st.saleFk = sa.saleFk JOIN vn.`state` s ON s.id = st.stateFk WHERE st.isChecked - AND s.semaphore = 1 + AND s.`code` IN ('PREVIOUS_PREPARATION', 'OK PREVIOUS', 'OK STOWAWAY') GROUP BY sa.saleFk ) SELECT s.saleFk FROM sales s diff --git a/db/routines/vn/procedures/itemShelvingSale_moveReserv.sql b/db/routines/vn/procedures/itemShelvingSale_moveReserv.sql new file mode 100644 index 000000000..7001ee4b8 --- /dev/null +++ b/db/routines/vn/procedures/itemShelvingSale_moveReserv.sql @@ -0,0 +1,50 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_moveReserv`( + vItemShelvingFk INT(10), + vItemFk INT(10) +) +BEGIN +/** + * Elimina reservas de un itemShelvingSale e intenta reservar en otra ubicación + * + * @param vItemShelvingFk Id itemShelving + */ + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + SELECT id INTO vItemShelvingFk + FROM itemShelving + WHERE id = vItemShelvingFk + AND FALSE + FOR UPDATE; + + UPDATE itemShelving + SET visible = 0, + available = 0 + WHERE id = vItemShelvingFk + AND itemFk = vItemFk; + + INSERT INTO itemShelvingSaleReserv (saleFk) + SELECT DISTINCT iss.saleFk + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + + DELETE iss + FROM itemShelvingSale iss + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk + WHERE iss.itemShelvingFk = vItemShelvingFk + AND ish.itemFk = vItemFk + AND NOT iss.isPicked; + COMMIT; + + CALL itemShelvingSale_doReserve(); +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_setSaleGroup.sql b/db/routines/vn/procedures/itemShelvingSale_setPicked.sql similarity index 91% rename from db/routines/vn/procedures/itemShelvingSale_setSaleGroup.sql rename to db/routines/vn/procedures/itemShelvingSale_setPicked.sql index 911034ed1..c1e58a9d1 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setSaleGroup.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setPicked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setSaleGroup`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setPicked`( vSaleGroupFk INT(10) ) BEGIN diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 13b8a16ad..6f008ab33 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -46,10 +46,8 @@ BEGIN CALL util.throw('La cantidad no puede distinta a la reserva'); END IF; - START TRANSACTION; - UPDATE itemShelvingSale SET isPicked = TRUE, quantity = vQuantity @@ -62,41 +60,10 @@ BEGIN FOR UPDATE; UPDATE itemShelving - SET visible = IF(vIsItemShelvingSaleEmpty, 0, GREATEST(0, visible - vQuantity)) + SET visible = GREATEST(0, visible - vQuantity) WHERE id = vItemShelvingFk; - COMMIT; - IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - - UPDATE itemShelving - SET visible = 0, - available = 0 - WHERE id = vItemShelvingFk - AND itemFk = vItemFk; - - CALL itemShelvingSale_addBySale(vSaleFk); - - START TRANSACTION; - - INSERT INTO itemShelvingSaleReserv (saleFk) - SELECT DISTINCT iss.saleFk - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - - DELETE iss - FROM itemShelvingSale iss - JOIN itemShelving ish ON ish.id = iss.itemShelvingFk - WHERE iss.itemShelvingFk = vItemShelvingFk - AND ish.itemFk = vItemFk - AND NOT iss.isPicked; - COMMIT; - - CALL itemShelvingSale_doReserve(); - END IF; SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity) INTO vRemainingQuantity, vTotalQuantity @@ -104,8 +71,6 @@ BEGIN WHERE saleFk = vSaleFk; IF vRemainingQuantity = 0 THEN - START TRANSACTION; - CALL saleTracking_new( vSaleFk, TRUE, @@ -119,8 +84,12 @@ BEGIN SET s.quantity = vTotalQuantity, isPicked = TRUE WHERE s.id = vSaleFk; - - COMMIT; + END IF; + + COMMIT; + + IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN + CALL itemShelvingSale_moveReserv(vItemShelvingFk, vQuantity); END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingTransfer.sql b/db/routines/vn/procedures/itemShelving_transfer.sql similarity index 95% rename from db/routines/vn/procedures/itemShelvingTransfer.sql rename to db/routines/vn/procedures/itemShelving_transfer.sql index 07012a654..47a9a7cf0 100644 --- a/db/routines/vn/procedures/itemShelvingTransfer.sql +++ b/db/routines/vn/procedures/itemShelving_transfer.sql @@ -1,7 +1,8 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingTransfer`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_transfer`( vItemShelvingFk INT, - vShelvingFk VARCHAR(3)) + vShelvingFk VARCHAR(10) +) BEGIN /** * Transfiere producto de una ubicación a otra, fusionando si coincide el diff --git a/db/routines/vn/procedures/sectorCollection_getPartial.sql b/db/routines/vn/procedures/sectorCollection_getMyPartial.sql similarity index 95% rename from db/routines/vn/procedures/sectorCollection_getPartial.sql rename to db/routines/vn/procedures/sectorCollection_getMyPartial.sql index 2f59f591a..23e21d2f3 100644 --- a/db/routines/vn/procedures/sectorCollection_getPartial.sql +++ b/db/routines/vn/procedures/sectorCollection_getMyPartial.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getPartial`() +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sectorCollection_getMyPartial`() BEGIN /** * Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas diff --git a/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql index 0de49e90c..acb460190 100644 --- a/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql +++ b/db/routines/vn/procedures/sectorCollection_hasSalesReserved.sql @@ -2,28 +2,24 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1) DETERMINISTIC BEGIN - /** -* Devuelve si sectorCollection tiene reservas -* @param vSelf Id de sectorCollection -* -* returns BOOLEAN -*/ - + * Devuelve si sectorCollection tiene reservas + * @param vSelf Id de sectorCollection + * + * returns BOOLEAN + */ DECLARE vHasSalesReserved BOOLEAN; - - SELECT DISTINCT COUNT(*)>0 INTO vHasSalesReserved - FROM vn.sectorCollection sc - JOIN vn.sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk - JOIN vn.saleGroup sg ON sg.id = scsg.saleGroupFk - JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id - JOIN vn.sale s ON s.id = sgd.saleFk - JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id - JOIN vn.saleTracking st ON st.saleFk = s.id + SELECT DISTINCT COUNT(*) INTO vHasSalesReserved + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk + JOIN saleGroup sg ON sg.id = scsg.saleGroupFk + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = sg.id + JOIN sale s ON s.id = sgd.saleFk + JOIN itemShelvingSale iss ON iss.saleFk = s.id + JOIN saleTracking st ON st.saleFk = s.id WHERE sc.id = vSelf; RETURN vHasSalesReserved; - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelving_afterInsert.sql b/db/routines/vn/triggers/itemShelving_afterInsert.sql deleted file mode 100644 index 819e3e790..000000000 --- a/db/routines/vn/triggers/itemShelving_afterInsert.sql +++ /dev/null @@ -1,29 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelving_afterInsert` - AFTER INSERT ON `itemShelving` - FOR EACH ROW -BEGIN - INSERT INTO vn.itemShelvingLog( - itemShelvingFk, - workerFk, - accion, - itemFk, - shelvingFk, - visible, - `grouping`, - packing, - available - ) - VALUES ( - NEW.id, - NEW.userFk, - 'CREA REGISTRO', - NEW.itemFk, - NEW.shelvingFk, - NEW.visible, - NEW.`grouping`, - NEW.packing, - NEW.available - ); -END$$ -DELIMITER ; \ No newline at end of file From d75e008a23d14675cec169e478cc03d8ad44732a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 11 Jun 2024 12:49:33 +0200 Subject: [PATCH 048/114] feat: previas con sitema de reservas refs #6861 --- .../procedures/collection_addWithReservation.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index faa00477e..b483eff39 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -76,14 +76,14 @@ BEGIN IF vHasThrow THEN CALL util.throw("No hay disponibilidad para el artículo seleccionado"); - ELSE - IF vSaleGroupFk THEN - INSERT INTO saleGroupDetail - SET saleFk = vSaleFk, - saleGroupFk = vSaleGroupFk; - END IF; - COMMIT; END IF; - + + IF vSaleGroupFk THEN + INSERT INTO saleGroupDetail + SET saleFk = vSaleFk, + saleGroupFk = vSaleGroupFk; + END IF; + + COMMIT; END$$ DELIMITER ; From b9d1c3228b016fe52483faf669963d00b66e3d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 11 Jun 2024 18:43:26 +0200 Subject: [PATCH 049/114] feat: previas con sitema de reservas refs #6861 --- .../vn/procedures/collection_addWithReservation.sql | 2 +- db/routines/vn/procedures/collection_getAssigned.sql | 2 +- db/routines/vn/procedures/collection_getTickets.sql | 8 ++++---- .../vn/procedures/itemShelvingSale_setQuantity.sql | 6 +++--- ...ingSale_moveReserv.sql => itemShelving_moveReserv.sql} | 7 +++---- .../vn/procedures/sectorCollection_getMyPartial.sql | 3 +-- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 6 +++--- 7 files changed, 16 insertions(+), 18 deletions(-) rename db/routines/vn/procedures/{itemShelvingSale_moveReserv.sql => itemShelving_moveReserv.sql} (82%) diff --git a/db/routines/vn/procedures/collection_addWithReservation.sql b/db/routines/vn/procedures/collection_addWithReservation.sql index b483eff39..e3f4eb8d2 100644 --- a/db/routines/vn/procedures/collection_addWithReservation.sql +++ b/db/routines/vn/procedures/collection_addWithReservation.sql @@ -75,7 +75,7 @@ BEGIN END IF; IF vHasThrow THEN - CALL util.throw("No hay disponibilidad para el artículo seleccionado"); + CALL util.throw("There is no available for the selected item"); END IF; IF vSaleGroupFk THEN diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql index 575032e2e..bfaa3096b 100644 --- a/db/routines/vn/procedures/collection_getAssigned.sql +++ b/db/routines/vn/procedures/collection_getAssigned.sql @@ -40,7 +40,7 @@ BEGIN DROP TEMPORARY TABLE tCollection; IF vHasTooMuchCollections THEN - CALL util.throw('Hay colecciones pendientes'); + CALL util.throw('There are pending collections'); END IF; SELECT warehouseFk, itemPackingTypeFk diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index 8be8c8654..7ecff571a 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -7,7 +7,7 @@ BEGIN * @return Retorna ticketFk, level, agencyName, warehouseFk, salesPersonFk, observation */ DECLARE vItemPackingTypeFk VARCHAR(1); - DECLARE vDated DATE; + DECLARE vYesterday DATE; -- Si los sacadores son los de pruebas, pinta los colores SELECT itemPackingTypeFk @@ -15,7 +15,7 @@ BEGIN FROM collection WHERE id = vParamFk; - SET vDated = util.yesterday(); + SET vYesterday = util.yesterday(); WITH observation AS ( SELECT tob.ticketFk, tob.description @@ -45,7 +45,7 @@ BEGIN LEFT JOIN vn.worker w ON w.id = c.salesPersonFk LEFT JOIN observation ob ON ob.ticketFk = t.id WHERE t.id = vParamFk - AND t.shipped >= vDated + AND t.shipped >= vYesterday UNION ALL SELECT t.id ticketFk, IF(NOT(vItemPackingTypeFk <=> 'V'), cc.code, CONCAT(SUBSTRING('ABCDEFGH', tc.wagon, 1), '-', tc.`level`)) `level`, @@ -84,6 +84,6 @@ BEGIN LEFT JOIN observation ob ON ob.ticketFk = t.id LEFT JOIN vn.client c ON c.id = t.clientFk WHERE sc.id = vParamFk - AND t.shipped >= vDated; + AND t.shipped >= vYesterday; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 6f008ab33..aed4053bf 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -29,7 +29,7 @@ BEGIN END; IF (SELECT isPicked FROM itemShelvingSale WHERE id = vItemShelvingSaleFk) THEN - CALL util.throw('Reserva completada'); + CALL util.throw('Reservation completed'); END IF; SELECT s.itemFk, iss.saleFk, iss.itemShelvingFk, SUM(IFNULL(iss.quantity,0)) @@ -43,7 +43,7 @@ BEGIN OR (vQuantity < vReservedQuantity AND (NOT vIsItemShelvingSaleEmpty OR vIsItemShelvingSaleEmpty IS NULL)) OR (vIsItemShelvingSaleEmpty IS NOT NULL AND vQuantity = vReservedQuantity) THEN - CALL util.throw('La cantidad no puede distinta a la reserva'); + CALL util.throw('The quantity cannot be different from the reserved'); END IF; START TRANSACTION; @@ -89,7 +89,7 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - CALL itemShelvingSale_moveReserv(vItemShelvingFk, vQuantity); + CALL itemShelving_moveReserv(vItemShelvingFk, vQuantity); END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/itemShelvingSale_moveReserv.sql b/db/routines/vn/procedures/itemShelving_moveReserv.sql similarity index 82% rename from db/routines/vn/procedures/itemShelvingSale_moveReserv.sql rename to db/routines/vn/procedures/itemShelving_moveReserv.sql index 7001ee4b8..cff8f6e92 100644 --- a/db/routines/vn/procedures/itemShelvingSale_moveReserv.sql +++ b/db/routines/vn/procedures/itemShelving_moveReserv.sql @@ -1,11 +1,11 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_moveReserv`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_moveReserv`( vItemShelvingFk INT(10), vItemFk INT(10) ) BEGIN /** - * Elimina reservas de un itemShelvingSale e intenta reservar en otra ubicación + * Elimina reservas de un itemShelving e intenta reservar en otra ubicación * * @param vItemShelvingFk Id itemShelving */ @@ -17,10 +17,9 @@ BEGIN START TRANSACTION; - SELECT id INTO vItemShelvingFk + SELECT id INTO vItemShelvingFk FROM itemShelving WHERE id = vItemShelvingFk - AND FALSE FOR UPDATE; UPDATE itemShelving diff --git a/db/routines/vn/procedures/sectorCollection_getMyPartial.sql b/db/routines/vn/procedures/sectorCollection_getMyPartial.sql index 23e21d2f3..21f26770a 100644 --- a/db/routines/vn/procedures/sectorCollection_getMyPartial.sql +++ b/db/routines/vn/procedures/sectorCollection_getMyPartial.sql @@ -12,8 +12,7 @@ BEGIN LEFT JOIN vn.sale sl ON sl.id = sgd.saleFk LEFT JOIN itemShelvingSale iss ON iss.saleFk = sl.id WHERE sc.userFk = account.myUser_getId() - AND (ISNULL(scsg.sectorCollectionFk) - OR (NOT iss.isPicked)) + AND (scsg.sectorCollectionFk IS NULL OR NOT iss.isPicked) AND sc.created > util.VN_CURDATE() - INTERVAL 1 DAY; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index f5bd88b1b..0c609d328 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -5,8 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_afte BEGIN UPDATE sale s - JOIN operator o ON o.workerFk = account.myUser_getId() - SET isPicked = IF(o.isOnReservationMode, isPicked, TRUE) - WHERE id = NEW.saleFk; + JOIN operator o ON o.workerFk = account.myUser_getId() + SET s.isPicked = IF(o.isOnReservationMode, isPicked, TRUE) + WHERE id = NEW.saleFk; END$$ DELIMITER ; \ No newline at end of file From dcb9d54105ecc500869ad3c8c1b3b07dbbac4ecb Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 12 Jun 2024 11:48:01 +0200 Subject: [PATCH 050/114] feat: refs #7545 Deleted hasIncoterms client column --- db/versions/11099-greenFern/00-firstScript.sql | 3 +++ modules/client/back/methods/client/updateFiscalData.js | 4 ---- modules/client/back/models/client.json | 3 --- modules/client/front/fiscal-data/index.html | 5 ----- 4 files changed, 3 insertions(+), 12 deletions(-) create mode 100644 db/versions/11099-greenFern/00-firstScript.sql diff --git a/db/versions/11099-greenFern/00-firstScript.sql b/db/versions/11099-greenFern/00-firstScript.sql new file mode 100644 index 000000000..7dd84d1b7 --- /dev/null +++ b/db/versions/11099-greenFern/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.client + CHANGE hasIncoterms hasIncoterms__ tinyint(1) DEFAULT 0 NOT NULL + COMMENT '@deprecated 2024-06-12 refs #7545 Received incoterms authorization from client'; \ No newline at end of file diff --git a/modules/client/back/methods/client/updateFiscalData.js b/modules/client/back/methods/client/updateFiscalData.js index 9a6255215..851648658 100644 --- a/modules/client/back/methods/client/updateFiscalData.js +++ b/modules/client/back/methods/client/updateFiscalData.js @@ -96,10 +96,6 @@ module.exports = Self => { arg: 'despiteOfClient', type: 'any' }, - { - arg: 'hasIncoterms', - type: 'boolean' - }, { arg: 'hasElectronicInvoice', type: 'boolean' diff --git a/modules/client/back/models/client.json b/modules/client/back/models/client.json index 510857595..f3eb9919b 100644 --- a/modules/client/back/models/client.json +++ b/modules/client/back/models/client.json @@ -97,9 +97,6 @@ "hasCoreVnh": { "type": "boolean" }, - "hasIncoterms": { - "type": "boolean" - }, "isTaxDataChecked":{ "type": "boolean" }, diff --git a/modules/client/front/fiscal-data/index.html b/modules/client/front/fiscal-data/index.html index c366c8ca3..979f45fcc 100644 --- a/modules/client/front/fiscal-data/index.html +++ b/modules/client/front/fiscal-data/index.html @@ -184,11 +184,6 @@ - - Date: Wed, 12 Jun 2024 14:26:26 +0200 Subject: [PATCH 051/114] feat: refs #7490 Changes --- .../vn/procedures/duaInvoiceInBooking.sql | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index efaf29b41..1f026e96b 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -24,6 +24,16 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + UPDATE invoiceIn ii + JOIN entry e ON e.invoiceInFk = ii.id + JOIN duaEntry de ON de.entryFk = e.id + JOIN dua d ON d.id = de.duaFk + SET ii.booked = IFNULL(ii.booked, d.booked), + ii.operated = IFNULL(ii.operated, d.operated), + ii.issued = IFNULL(ii.issued, d.issued), + ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried) + WHERE d.id = vDuaFk; + SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk; IF vBookEntry IS NULL THEN @@ -65,21 +75,21 @@ BEGIN JOIN ( WITH entries AS ( SELECT e.id, de.duaFk - FROM `entry` e + FROM `entry` e JOIN duaEntry de ON de.entryFk = e.id WHERE de.duaFk = vDuaFk AND (NOT e.isBooked OR NOT e.isConfirmed) ), notBookedEntries AS ( SELECT e.id - FROM entries e - JOIN duaEntry de ON de.entryFk = e.id - JOIN dua d ON d.id = de.duaFk - WHERE d.ASIEN IS NULL) - SELECT e.id + FROM duaEntry + WHERE duaFk = vDuaFk + AND NOT customsValue + ) + SELECT e.id FROM entries e - LEFT JOIN notBookedEntries nbe ON nbe.id = e.id - WHERE nbe.id IS NULL + LEFT JOIN notBookedEntries nbe ON nbe.entryFk = e.id + WHERE nbe.entryFk IS NULL ) sub ON sub.id = e.id SET e.isBooked = TRUE, e.isConfirmed = TRUE; From b72de3570a33419345c9969ed2d9e7435480d578 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 12 Jun 2024 14:41:35 +0200 Subject: [PATCH 052/114] refs #6897 fix redirection --- modules/entry/front/main/locale/es.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 modules/entry/front/main/locale/es.yml diff --git a/modules/entry/front/main/locale/es.yml b/modules/entry/front/main/locale/es.yml new file mode 100644 index 000000000..e69de29bb From 30caf79490e5ecdf3e10fe7204b62352e0efc468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 12 Jun 2024 16:12:06 +0200 Subject: [PATCH 053/114] feat: previas con sitema de reservas refs #6861 --- ...mShelving_moveReserv.sql => itemShelvingSale_reallocate.sql} | 2 +- db/routines/vn/procedures/itemShelvingSale_setQuantity.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename db/routines/vn/procedures/{itemShelving_moveReserv.sql => itemShelvingSale_reallocate.sql} (92%) diff --git a/db/routines/vn/procedures/itemShelving_moveReserv.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql similarity index 92% rename from db/routines/vn/procedures/itemShelving_moveReserv.sql rename to db/routines/vn/procedures/itemShelvingSale_reallocate.sql index cff8f6e92..ab898bdd4 100644 --- a/db/routines/vn/procedures/itemShelving_moveReserv.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelving_moveReserv`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_reallocate`( vItemShelvingFk INT(10), vItemFk INT(10) ) diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index aed4053bf..700821592 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -89,7 +89,7 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - CALL itemShelving_moveReserv(vItemShelvingFk, vQuantity); + CALL itemShelvingSale_reallocate(vItemShelvingFk, vQuantity); END IF; END$$ DELIMITER ; \ No newline at end of file From 3c1544ac9dd79c1922599cc8232d8c024ea8e4dc Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 13 Jun 2024 09:20:43 +0200 Subject: [PATCH 054/114] refs #6897 fix es.yml --- modules/entry/front/main/locale/es.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/entry/front/main/locale/es.yml b/modules/entry/front/main/locale/es.yml index e69de29bb..de408b311 100644 --- a/modules/entry/front/main/locale/es.yml +++ b/modules/entry/front/main/locale/es.yml @@ -0,0 +1 @@ +entry: entry From cfc5e327154fdc7e5a680395c7ccfce22bde4199 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 13 Jun 2024 13:11:50 +0200 Subject: [PATCH 055/114] feat: refs #6701 Fix error --- db/routines/vn/procedures/claimRatio_add.sql | 43 ++++++++++--------- .../11101-limeCordyline/00-firstScript.sql | 4 ++ 2 files changed, 26 insertions(+), 21 deletions(-) create mode 100644 db/versions/11101-limeCordyline/00-firstScript.sql diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index 7def0837f..8d94805db 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -44,7 +44,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE ce.claimDestinationFk NOT IN ('Bueno', 'Corregido') + WHERE cd.description NOT IN ('Bueno', 'Corregido') AND NOT ce.isGreuge AND cs.code = 'resolved'; @@ -86,20 +86,20 @@ BEGIN -- Recobros CREATE OR REPLACE TEMPORARY TABLE tTicketList - (PRIMARY KEY (ticketFk)) - SELECT DISTINCT s.ticketFk - FROM saleComponent sc - JOIN sale s ON sc.saleFk = s.id - JOIN ticket t ON t.id = s.ticketFk - JOIN ticketLastState ts ON ts.ticketFk = t.id - JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk - JOIN state st ON st.id = tt.stateFk - JOIN alertLevel al ON al.id = st.alertLevel - WHERE sc.componentFk = vDebtComponentType - AND NOT sc.isGreuge - AND t.shipped >= '2016-10-01' - AND t.shipped < util.VN_CURDATE() - AND al.code = 'DELIVERED'; + (PRIMARY KEY (ticketFk)) + SELECT DISTINCT s.ticketFk + FROM saleComponent sc + JOIN sale s ON sc.saleFk = s.id + JOIN ticket t ON t.id = s.ticketFk + JOIN ticketLastState ts ON ts.ticketFk = t.id + JOIN ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN state st ON st.id = tt.stateFk + JOIN alertLevel al ON al.id = st.alertLevel + WHERE sc.componentFk = vDebtComponentType + AND NOT sc.isGreuge + AND t.shipped >= '2016-10-01' + AND t.shipped < util.VN_CURDATE() + AND al.code = 'DELIVERED'; DELETE g.* FROM greuge g @@ -133,20 +133,21 @@ BEGIN JOIN tTicketList tl ON tl.ticketFk = s.ticketFk SET sc.isGreuge = TRUE WHERE sc.componentFk = vDebtComponentType; - - INSERT INTO claimRatio( + + REPLACE claimRatio( clientFk, yearSale, claimAmount, claimingRate, priceIncreasing ) - SELECT cac.clientFk, + SELECT c.id, 12 * cac.invoiced, totalClaims, ROUND(totalClaims / (12 * cac.invoiced), 4), 0 - FROM bs.clientAnnualConsumption cac + FROM client c + LEFT JOIN bs.clientAnnualConsumption cac ON cac.clientFk = c.id LEFT JOIN ( SELECT c.clientFk, ROUND(SUM(-1 * ((c.responsibility - 1) / 4) * @@ -157,11 +158,11 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE ce.claimDestinationFk NOT IN ('Bueno', 'Corregido') + WHERE cd.description NOT IN ('Bueno', 'Corregido') AND cs.code = 'resolved' AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR GROUP BY c.clientFk - ) sub ON sub.clientFk = cac.clientFk; + ) sub ON sub.clientFk = c.id; -- Calculamos el porcentaje del recobro para añadirlo al precio de venta UPDATE claimRatio cr diff --git a/db/versions/11101-limeCordyline/00-firstScript.sql b/db/versions/11101-limeCordyline/00-firstScript.sql new file mode 100644 index 000000000..e9ffa1b12 --- /dev/null +++ b/db/versions/11101-limeCordyline/00-firstScript.sql @@ -0,0 +1,4 @@ +UPDATE IGNORE bs.nightTask + SET `schema` = 'vn', + `procedure` = 'claimRatio_add' + WHERE `procedure` = 'claim_ratio_routine'; From 784bd91e041e889392ffcf16526dd2b688a1badd Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 13 Jun 2024 13:43:28 +0200 Subject: [PATCH 056/114] fix: refs #6286 update WorkerTimeControl permissions --- .../00-modifyTimeControlAcls.sql | 18 ++++++++ .../worker-time-control/getMailStates.js | 4 ++ .../resendWeeklyHourEmail.js | 4 ++ .../specs/getMailStates.spec.js | 42 +++++++++++-------- ...olMail.spec.js => updateMailState.spec.js} | 22 +++++----- ...rTimeControlMail.js => updateMailState.js} | 15 +++---- .../weeklyHourRecordEmail.js | 2 +- .../worker/back/models/worker-time-control.js | 2 +- .../back/models/worker-time-control.json | 21 +++++++--- 9 files changed, 87 insertions(+), 43 deletions(-) create mode 100644 db/versions/11100-silverGerbera/00-modifyTimeControlAcls.sql rename modules/worker/back/methods/worker-time-control/specs/{updateWorkerTimeControlMail.spec.js => updateMailState.spec.js} (82%) rename modules/worker/back/methods/worker-time-control/{updateWorkerTimeControlMail.js => updateMailState.js} (85%) diff --git a/db/versions/11100-silverGerbera/00-modifyTimeControlAcls.sql b/db/versions/11100-silverGerbera/00-modifyTimeControlAcls.sql new file mode 100644 index 000000000..473441a7e --- /dev/null +++ b/db/versions/11100-silverGerbera/00-modifyTimeControlAcls.sql @@ -0,0 +1,18 @@ +UPDATE salix.ACL + SET principalId = 'teamBoss' + WHERE property IN ('addTimeEntry', 'deleteTimeEntry', 'updateTimeEntry', 'weeklyHourRecordEmail'); + +UPDATE salix.ACL SET principalId = 'developer' WHERE property = 'sendMail'; + +UPDATE salix.ACL + SET property = 'updateMailState' + WHERE property = 'updateWorkerTimeControlMail'; + +INSERT INTO salix.ACL(model, property, accessType, permission, principalType, principalId) + VALUES + ('WorkerTimeControl', 'addTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'deleteTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'updateTimeEntry', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'weeklyHourRecordEmail', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'sendMail', 'WRITE', 'ALLOW', 'ROLE', 'hr'), + ('WorkerTimeControl', 'updateMailState', 'WRITE', 'ALLOW', 'ROLE', 'hr'); \ No newline at end of file diff --git a/modules/worker/back/methods/worker-time-control/getMailStates.js b/modules/worker/back/methods/worker-time-control/getMailStates.js index 855b5adc3..d55c185a5 100644 --- a/modules/worker/back/methods/worker-time-control/getMailStates.js +++ b/modules/worker/back/methods/worker-time-control/getMailStates.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { Self.remoteMethodCtx('getMailStates', { description: 'Get the states of a month about time control mail', @@ -36,6 +38,8 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); + if (!await models.Worker.isSubordinate(ctx, workerId)) throw new UserError(`You don't have enough privileges`); + const times = await models.Time.find({ fields: ['week'], where: { diff --git a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js index 885637118..68d03f7e4 100644 --- a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js +++ b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js @@ -1,4 +1,5 @@ const moment = require('moment'); +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('resendWeeklyHourEmail', { @@ -35,6 +36,9 @@ module.exports = Self => { const yearNumber = dated.getFullYear(); const weekNumber = moment(dated).isoWeek(); + if (!await models.Worker.isSubordinate(ctx, workerId) || workerId === ctx.req.accessToken.userId) + throw new UserError(`You don't have enough privileges`); + const workerTimeControlMail = await models.WorkerTimeControlMail.findOne({ where: { workerFk: workerId, diff --git a/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js b/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js index cbad32323..083236ec6 100644 --- a/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/getMailStates.spec.js @@ -1,28 +1,36 @@ const models = require('vn-loopback/server/server').models; describe('workerTimeControl getMailStates()', () => { - const workerId = 9; - const ctx = {args: { - month: 12, - year: 2000 - }}; + const developerId = 9; + const developerBossId = 120; + const employeeId = 1; + + let ctx; + let tx; + let opts; + + beforeEach(async() => { + ctx = {req: {accessToken: {userId: developerBossId}}, args: {month: 12, year: 2000}}; + tx = await models.WorkerTimeControl.beginTransaction({}); + opts = {transaction: tx}; + }); + + afterEach(async() => await tx.rollback()); it('should get the states of a month about time control mail', async() => { - const tx = await models.WorkerTimeControl.beginTransaction({}); + const response = await models.WorkerTimeControl.getMailStates(ctx, developerId, opts); + expect(response[0].state).toEqual('REVISE'); + expect(response[1].state).toEqual('SENDED'); + expect(response[2].state).toEqual('CONFIRMED'); + }); + + it('should throw an error if they are not subordinates', async() => { + ctx.req.accessToken.userId = employeeId; try { - const options = {transaction: tx}; - - const response = await models.WorkerTimeControl.getMailStates(ctx, workerId, options); - - expect(response[0].state).toEqual('REVISE'); - expect(response[1].state).toEqual('SENDED'); - expect(response[2].state).toEqual('CONFIRMED'); - - await tx.rollback(); + await models.WorkerTimeControl.getMailStates(ctx, developerId, opts); } catch (e) { - await tx.rollback(); - throw e; + expect(e.message).toEqual('You don\'t have enough privileges'); } }); }); diff --git a/modules/worker/back/methods/worker-time-control/specs/updateWorkerTimeControlMail.spec.js b/modules/worker/back/methods/worker-time-control/specs/updateMailState.spec.js similarity index 82% rename from modules/worker/back/methods/worker-time-control/specs/updateWorkerTimeControlMail.spec.js rename to modules/worker/back/methods/worker-time-control/specs/updateMailState.spec.js index 3b5b2b73f..151b6ca94 100644 --- a/modules/worker/back/methods/worker-time-control/specs/updateWorkerTimeControlMail.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/updateMailState.spec.js @@ -1,10 +1,11 @@ const models = require('vn-loopback/server/server').models; -describe('updateWorkerTimeControlMail()', () => { +describe('updateMailState()', () => { + const developerId = 9; + const employeeId = 1; it('should update WorkerTimeControlMail if exist record', async() => { const tx = await models.WorkerTimeControlMail.beginTransaction({}); const args = { - workerId: 9, week: 50, year: 2000, state: 'CONFIRMED' @@ -15,15 +16,15 @@ describe('updateWorkerTimeControlMail()', () => { const options = {transaction: tx}; const beforeMail = await models.WorkerTimeControlMail.findOne({ where: { - workerFk: args.workerId, + workerFk: developerId, year: args.year, week: args.week, } }, options); - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options); + await models.WorkerTimeControl.updateMailState(ctx, developerId, options); const afterMail = await models.WorkerTimeControlMail.findOne({ where: { - workerFk: args.workerId, + workerFk: developerId, year: args.year, week: args.week, } @@ -42,7 +43,6 @@ describe('updateWorkerTimeControlMail()', () => { it('should insert WorkerTimeControlMail if exist record', async() => { const tx = await models.WorkerTimeControlMail.beginTransaction({}); const args = { - workerId: 1, week: 51, year: 2000, state: 'SENDED' @@ -53,15 +53,15 @@ describe('updateWorkerTimeControlMail()', () => { const options = {transaction: tx}; const beforeMail = await models.WorkerTimeControlMail.find({ where: { - workerFk: args.workerId, + workerFk: employeeId, year: args.year, week: args.week, } }, options); - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options); + await models.WorkerTimeControl.updateMailState(ctx, employeeId, options); const afterMail = await models.WorkerTimeControlMail.find({ where: { - workerFk: args.workerId, + workerFk: employeeId, year: args.year, week: args.week, } @@ -80,7 +80,7 @@ describe('updateWorkerTimeControlMail()', () => { it('should throw error if not exist any record in this week', async() => { const tx = await models.WorkerTimeControlMail.beginTransaction({}); const ctx = {args: { - workerId: 1, + workerId: employeeId, week: 1, year: 0, state: 'SENDED' @@ -89,7 +89,7 @@ describe('updateWorkerTimeControlMail()', () => { let error; try { const options = {transaction: tx}; - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, options); + await models.WorkerTimeControl.updateMailState(ctx, employeeId, options); await tx.rollback(); } catch (e) { diff --git a/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js b/modules/worker/back/methods/worker-time-control/updateMailState.js similarity index 85% rename from modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js rename to modules/worker/back/methods/worker-time-control/updateMailState.js index 3fd743fe3..c3bacaac0 100644 --- a/modules/worker/back/methods/worker-time-control/updateWorkerTimeControlMail.js +++ b/modules/worker/back/methods/worker-time-control/updateMailState.js @@ -1,12 +1,13 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('updateWorkerTimeControlMail', { + Self.remoteMethodCtx('updateMailState', { description: 'Updates the state of WorkerTimeControlMail', accessType: 'WRITE', accepts: [{ - arg: 'workerId', + arg: 'id', type: 'number', - required: true + description: 'The worker id', + http: {source: 'path'} }, { arg: 'year', @@ -32,12 +33,12 @@ module.exports = Self => { root: true }, http: { - path: `/updateWorkerTimeControlMail`, + path: `/:id/updateMailState`, verb: 'POST' } }); - Self.updateWorkerTimeControlMail = async(ctx, options) => { + Self.updateMailState = async(ctx, id, options) => { const models = Self.app.models; const args = ctx.args; const myOptions = {}; @@ -59,14 +60,14 @@ module.exports = Self => { { year: args.year, week: args.week, - workerFk: args.workerId + workerFk: id }, { state: args.state, reason: args.reason, year: args.year, week: args.week, - workerFk: args.workerId + workerFk: id }, myOptions); diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index 53bc8d022..f19ab17e1 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -61,7 +61,7 @@ module.exports = Self => { const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; ctx.args.url = url; - await models.WorkerTimeControl.updateWorkerTimeControlMail(ctx, myOptions); + await models.WorkerTimeControl.updateMailState(ctx, ctx.workerId, myOptions); return Self.sendTemplate(ctx, 'weekly-hour-record'); }; diff --git a/modules/worker/back/models/worker-time-control.js b/modules/worker/back/models/worker-time-control.js index 1457c7a46..92f1bacf0 100644 --- a/modules/worker/back/models/worker-time-control.js +++ b/modules/worker/back/models/worker-time-control.js @@ -6,7 +6,7 @@ module.exports = Self => { require('../methods/worker-time-control/deleteTimeEntry')(Self); require('../methods/worker-time-control/updateTimeEntry')(Self); require('../methods/worker-time-control/sendMail')(Self); - require('../methods/worker-time-control/updateWorkerTimeControlMail')(Self); + require('../methods/worker-time-control/updateMailState')(Self); require('../methods/worker-time-control/weeklyHourRecordEmail')(Self); require('../methods/worker-time-control/getMailStates')(Self); require('../methods/worker-time-control/resendWeeklyHourEmail')(Self); diff --git a/modules/worker/back/models/worker-time-control.json b/modules/worker/back/models/worker-time-control.json index e2b74875a..3d408c18f 100644 --- a/modules/worker/back/models/worker-time-control.json +++ b/modules/worker/back/models/worker-time-control.json @@ -36,15 +36,24 @@ "model": "VnUser", "foreignKey": "userFk" }, - "worker": { - "type": "hasOne", - "model": "Worker", - "foreignKey": "id" + "worker": { + "type": "hasOne", + "model": "Worker", + "foreignKey": "id" }, "warehouse": { "type": "belongsTo", "model": "Warehouse", "foreignKey": "warehouseFk" } - } -} + }, + "acls": [ + { + "property": "updateMailState", + "accessType": "WRITE", + "permission": "ALLOW", + "principalType": "ROLE", + "principalId": "$owner" + } + ] +} \ No newline at end of file From c2e4e187d689333e43b353269707383937bf93b8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 13 Jun 2024 14:21:59 +0200 Subject: [PATCH 057/114] feat itemShelvingSale refs #6861 --- db/routines/vn/procedures/itemShelvingSale_setQuantity.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 700821592..6c556f1ff 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -70,7 +70,7 @@ BEGIN FROM itemShelvingSale WHERE saleFk = vSaleFk; - IF vRemainingQuantity = 0 THEN + IF vRemainingQuantity = 0 AND NOT vIsItemShelvingSaleEmpty THEN CALL saleTracking_new( vSaleFk, TRUE, @@ -89,7 +89,9 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - CALL itemShelvingSale_reallocate(vItemShelvingFk, vQuantity); + INSERT INTO itemShelvingSaleReserv (saleFk) + SELECT vSaleFk; + CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk); END IF; END$$ DELIMITER ; \ No newline at end of file From 202884fdce1ccbf984cb1fcf49e2a16be971dd34 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 14 Jun 2024 14:25:15 +0200 Subject: [PATCH 058/114] feat: refs #6238 add travelKgPercentage table and model --- .../00-createTravelKgPercentage.sql | 17 +++++++++++++++ .../methods/travel/extraCommunityFilter.js | 14 ++++++++++++- modules/travel/back/model-config.json | 5 ++++- .../back/models/travel-kg-percentage.json | 21 +++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql create mode 100644 modules/travel/back/models/travel-kg-percentage.json diff --git a/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql new file mode 100644 index 000000000..9df89d869 --- /dev/null +++ b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql @@ -0,0 +1,17 @@ +CREATE TABLE IF NOT EXISTS travelKgPercentage ( + value INT(3) PRIMARY KEY, + className VARCHAR(50) +); + +INSERT INTO travelKgPercentage (value, className) + VALUES + (80, 'primary'), + (100, 'alert'); + +INSERT INTO salix.ACL + SET model = 'TravelKgPercentage', + property = '*', + accessType = 'READ', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'employee'; \ No newline at end of file diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 488297318..107bf6f39 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -138,7 +138,19 @@ module.exports = Self => { b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0) - ) as volumeKg + ) as volumeKg, + ROUND(GREATEST( + CAST(SUM(b.weight * b.stickers) AS INT), + CAST( + SUM(vc.aerealVolumetricDensity * + b.stickers * + IF(pkg.volume, + pkg.volume, + pkg.width * pkg.depth * pkg.height + ) / 1000000 + ) AS INT + ) + ) / t.kg * 100, 0) percentageKg FROM travel t LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN entry e ON e.travelFk = t.id diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index ed5c071b3..952ce0d20 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -11,6 +11,9 @@ "Thermograph": { "dataSource": "vn" }, + "TravelKgPercentage": { + "dataSource": "vn" + }, "TravelThermograph": { "dataSource": "vn" }, @@ -20,4 +23,4 @@ "Temperature": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/travel/back/models/travel-kg-percentage.json b/modules/travel/back/models/travel-kg-percentage.json new file mode 100644 index 000000000..e99a88999 --- /dev/null +++ b/modules/travel/back/models/travel-kg-percentage.json @@ -0,0 +1,21 @@ +{ + "name": "TravelKgPercentage", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "travelKgPercentage" + } + }, + "properties": { + "value": { + "type": "number", + "id": true + }, + "className": { + "type": "string" + } + } +} \ No newline at end of file From 1d0b89ed526b03bf5f40b85705dcb0550b848b21 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 17 Jun 2024 09:42:16 +0200 Subject: [PATCH 059/114] refs #7519 Requested changes --- db/dump/fixtures.before.sql | 4 ++-- db/routines/vn/procedures/claimRatio_add.sql | 9 ++++++--- db/versions/11101-limeCordyline/00-firstScript.sql | 8 ++++++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 60ef58861..eb165aeec 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1885,9 +1885,9 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina (1, 31, 4, 21, 2), (2, 32, 3, 21, 3); -INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) +INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`, `monthsToRefund`, `minShipped`) VALUES - (1, 50); + (1, 5, 4, '2016-10-01'); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index 8d94805db..c375f8736 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -5,7 +5,8 @@ BEGIN * Añade a la tabla greuges todos los cargos necesario y * que luego lo utilizamos para calcular el recobro. */ - DECLARE vMonthToRefund INT DEFAULT 4; + DECLARE vMonthToRefund INT + DEFAULT (SELECT monthsToRefund FROM claimConfig); DECLARE vRecoveryGreugeType INT DEFAULT (SELECT id FROM greugeType WHERE code = 'recovery'); DECLARE vManaGreugeType INT @@ -15,7 +16,8 @@ BEGIN DECLARE vDebtComponentType INT DEFAULT (SELECT id FROM component WHERE code = 'debtCollection'); - IF vRecoveryGreugeType IS NULL + IF vMonthToRefund IS NULL + OR vRecoveryGreugeType IS NULL OR vManaGreugeType IS NULL OR vClaimGreugeType IS NULL OR vDebtComponentType IS NULL THEN @@ -87,6 +89,7 @@ BEGIN -- Recobros CREATE OR REPLACE TEMPORARY TABLE tTicketList (PRIMARY KEY (ticketFk)) + ENGINE = MEMORY SELECT DISTINCT s.ticketFk FROM saleComponent sc JOIN sale s ON sc.saleFk = s.id @@ -97,7 +100,7 @@ BEGIN JOIN alertLevel al ON al.id = st.alertLevel WHERE sc.componentFk = vDebtComponentType AND NOT sc.isGreuge - AND t.shipped >= '2016-10-01' + AND t.shipped >= (SELECT minShipped FROM claimConfig) AND t.shipped < util.VN_CURDATE() AND al.code = 'DELIVERED'; diff --git a/db/versions/11101-limeCordyline/00-firstScript.sql b/db/versions/11101-limeCordyline/00-firstScript.sql index e9ffa1b12..d6f30ce3f 100644 --- a/db/versions/11101-limeCordyline/00-firstScript.sql +++ b/db/versions/11101-limeCordyline/00-firstScript.sql @@ -2,3 +2,11 @@ UPDATE IGNORE bs.nightTask SET `schema` = 'vn', `procedure` = 'claimRatio_add' WHERE `procedure` = 'claim_ratio_routine'; + +ALTER TABLE vn.claimConfig + ADD monthsToRefund int(11) DEFAULT NULL NULL, + ADD minShipped date DEFAULT NULL NULL; + +UPDATE IGNORE vn.claimConfig + SET monthsToRefund = 4, + minShipped = '2016-10-01'; From 54b6ef491f02a3ff1c2d4b59e6084e06e1ac97e6 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jun 2024 10:23:30 +0200 Subject: [PATCH 060/114] refs #7409 back --- .../worker/back/models/payroll-component.json | 27 +++++++++++ modules/worker/back/models/worker-income.json | 45 +++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 modules/worker/back/models/payroll-component.json create mode 100644 modules/worker/back/models/worker-income.json diff --git a/modules/worker/back/models/payroll-component.json b/modules/worker/back/models/payroll-component.json new file mode 100644 index 000000000..92b6c3835 --- /dev/null +++ b/modules/worker/back/models/payroll-component.json @@ -0,0 +1,27 @@ +{ + "name": "PayrollComponent", + "base": "VnModel", + "options": { + "mysql": { + "table": "payrollComponent" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "name": { + "type": "string" + }, + "isSalaryAgreed": { + "type": "number" + }, + "isVariable": { + "type": "number" + }, + "isException": { + "type": "number" + } + } +} diff --git a/modules/worker/back/models/worker-income.json b/modules/worker/back/models/worker-income.json new file mode 100644 index 000000000..ae9f56604 --- /dev/null +++ b/modules/worker/back/models/worker-income.json @@ -0,0 +1,45 @@ +{ + "name": "WorkerIncome", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerIncome" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + }, + "debit": { + "type": "number" + }, + "credit": { + "type": "number" + }, + "incomeTypeFk": { + "type": "number" + }, + "paymentDate": { + "type": "date" + }, + "workerFk": { + "type": "number" + }, + "concept": { + "type": "string" + } + }, + "relations": { + "payrollComponent": { + "type": "belongsTo", + "model": "payrollComponent", + "foreignKey": "id" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "id" + } + } +} From fa8c1b38797bae32a4d8fd926140b93a50e1b313 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jun 2024 13:50:07 +0200 Subject: [PATCH 061/114] acls, fixtures, models --- db/dump/fixtures.before.sql | 19 +++++++++++++++++++ .../11103-limeBirch/00-firstScript.sql | 8 ++++++++ modules/worker/back/model-config.json | 6 ++++++ modules/worker/back/models/worker-income.json | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 db/versions/11103-limeBirch/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 058c5cd2a..7890fb7e8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3882,3 +3882,22 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli (1, '2001-05-17', 1, 5), (1, '2001-05-18', 1, 5); +INSERT INTO vn.payrollComponent +(id, name, isSalaryAgreed, isVariable, isException) +VALUES(1, 'Salario1', 1, 0, 0); +INSERT INTO vn.payrollComponent +(id, name, isSalaryAgreed, isVariable, isException) +VALUES(2, 'Salario2', 1, 1, 0); +INSERT INTO vn.payrollComponent +(id, name, isSalaryAgreed, isVariable, isException) +VALUES(3, 'Salario3', 1, 0, 1); + + +INSERT INTO vn.workerIncome +(debit, credit, incomeTypeFk, paymentDate, workerFk, concept) +VALUES(1000.00, 900.00, 2, '2000-01-01', 1106, NULL); +INSERT INTO vn.workerIncome +(debit, credit, incomeTypeFk, paymentDate, workerFk, concept) +VALUES(1001.00, 800.00, 2, '2000-01-01', 1106, NULL); + + diff --git a/db/versions/11103-limeBirch/00-firstScript.sql b/db/versions/11103-limeBirch/00-firstScript.sql new file mode 100644 index 000000000..5c55e4087 --- /dev/null +++ b/db/versions/11103-limeBirch/00-firstScript.sql @@ -0,0 +1,8 @@ +-- Place your SQL code here +INSERT INTO salix.ACL +(id, model, property, accessType, permission, principalType, principalId) +VALUES(872, 'WorkerIncome', '*', '*', 'ALLOW', 'ROLE', 'hr'); +INSERT INTO salix.ACL +(id, model, property, accessType, permission, principalType, principalId) +VALUES(873, 'PayrollComponent', '*', '*', 'ALLOW', 'ROLE', 'hr'); + diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index b7c355511..46c062775 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -124,6 +124,12 @@ }, "Locker": { "dataSource": "vn" + }, + "PayrollComponent": { + "dataSource": "vn" + }, + "WorkerIncome": { + "dataSource": "vn" } } diff --git a/modules/worker/back/models/worker-income.json b/modules/worker/back/models/worker-income.json index ae9f56604..1ba9c1738 100644 --- a/modules/worker/back/models/worker-income.json +++ b/modules/worker/back/models/worker-income.json @@ -37,7 +37,7 @@ "foreignKey": "id" }, "worker": { - "type": "belongsTo", + "type": "hasMany", "model": "Worker", "foreignKey": "id" } From e8c7b55329c64c90e17ee8f5765d5059dfab711f Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 17 Jun 2024 14:17:43 +0200 Subject: [PATCH 062/114] fix(WorkerIncome): refs #7409 fix models --- modules/worker/back/models/worker-income.json | 10 +++++----- modules/worker/back/models/worker.json | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/worker/back/models/worker-income.json b/modules/worker/back/models/worker-income.json index 1ba9c1738..3a7f3407a 100644 --- a/modules/worker/back/models/worker-income.json +++ b/modules/worker/back/models/worker-income.json @@ -33,13 +33,13 @@ "relations": { "payrollComponent": { "type": "belongsTo", - "model": "payrollComponent", + "model": "PayrollComponent", "foreignKey": "id" }, - "worker": { - "type": "hasMany", + "worker": { + "type": "belongsTo", "model": "Worker", - "foreignKey": "id" - } + "foreignKey": "workerFk" + } } } diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4796c6373..4d3f57b9f 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -115,6 +115,11 @@ "type": "hasMany", "model": "Locker", "foreignKey": "workerFk" + }, + "incomes": { + "type": "hasMany", + "model": "WorkerIncome", + "foreignKey": "workerFk" } }, "acls": [ @@ -126,4 +131,4 @@ "principalId": "$owner" } ] -} \ No newline at end of file +} From 3e25fff90fbf4cad5c93ffe4c5798276654a177c Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 17 Jun 2024 15:50:58 +0200 Subject: [PATCH 063/114] refs #7409 acl --- db/versions/11103-limeBirch/00-firstScript.sql | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/versions/11103-limeBirch/00-firstScript.sql b/db/versions/11103-limeBirch/00-firstScript.sql index 5c55e4087..9dcfb518c 100644 --- a/db/versions/11103-limeBirch/00-firstScript.sql +++ b/db/versions/11103-limeBirch/00-firstScript.sql @@ -1,8 +1,9 @@ -- Place your SQL code here INSERT INTO salix.ACL -(id, model, property, accessType, permission, principalType, principalId) -VALUES(872, 'WorkerIncome', '*', '*', 'ALLOW', 'ROLE', 'hr'); +(model, property, accessType, permission, principalType, principalId) +VALUES('WorkerIncome', '*', '*', 'ALLOW', 'ROLE', 'hr'); INSERT INTO salix.ACL -(id, model, property, accessType, permission, principalType, principalId) -VALUES(873, 'PayrollComponent', '*', '*', 'ALLOW', 'ROLE', 'hr'); - +(model, property, accessType, permission, principalType, principalId) +VALUES('PayrollComponent', '*', '*', 'ALLOW', 'ROLE', 'hr'); +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('WorkerIncome','__get__workerIncomes','*','ALLOW','ROLE','hr'); From 671290b9a01fdb33115350fbd84ae602d4e03698 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 17 Jun 2024 16:45:51 +0200 Subject: [PATCH 064/114] refs #7313 delete vn.itemPackaging.workerFk --- db/versions/11104-wheatErica/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11104-wheatErica/00-firstScript.sql diff --git a/db/versions/11104-wheatErica/00-firstScript.sql b/db/versions/11104-wheatErica/00-firstScript.sql new file mode 100644 index 000000000..11811f399 --- /dev/null +++ b/db/versions/11104-wheatErica/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticketPackaging DROP FOREIGN KEY ticketPackaging_fk3; +ALTER TABLE vn.ticketPackaging DROP COLUMN workerFk; \ No newline at end of file From 7566ca1acb65a23fa234fc8e2b8fccd67f90c725 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 18 Jun 2024 08:21:38 +0200 Subject: [PATCH 065/114] build: increase version 2428 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b8281e0d..95d696fc3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.26.0", + "version": "24.28.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 9fc027a3c646953b4f364e7df13512d082d76e1b Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 18 Jun 2024 08:24:06 +0200 Subject: [PATCH 066/114] tickets deleted excluded --- db/routines/vn/procedures/supplierPackaging_ReportSource.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index a3401843a..751ee58f0 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -99,6 +99,7 @@ BEGIN WHERE su.id = vSupplierFk AND t.shipped < vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY s.itemFk UNION ALL SELECT vSupplierFk, @@ -140,6 +141,7 @@ BEGIN WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY p.itemFk ORDER BY itemFk, landed, entryFk ) sub From 52a34c8f2db156b773d66a0c80512fda504b314e Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 18 Jun 2024 09:18:09 +0200 Subject: [PATCH 067/114] refs #7409 fix acls --- db/versions/11103-limeBirch/00-firstScript.sql | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/db/versions/11103-limeBirch/00-firstScript.sql b/db/versions/11103-limeBirch/00-firstScript.sql index 9dcfb518c..2c0a396ce 100644 --- a/db/versions/11103-limeBirch/00-firstScript.sql +++ b/db/versions/11103-limeBirch/00-firstScript.sql @@ -1,9 +1,6 @@ -- Place your SQL code here -INSERT INTO salix.ACL -(model, property, accessType, permission, principalType, principalId) -VALUES('WorkerIncome', '*', '*', 'ALLOW', 'ROLE', 'hr'); -INSERT INTO salix.ACL -(model, property, accessType, permission, principalType, principalId) -VALUES('PayrollComponent', '*', '*', 'ALLOW', 'ROLE', 'hr'); -INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('WorkerIncome','__get__workerIncomes','*','ALLOW','ROLE','hr'); +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES + ('WorkerIncome', '*', '*', 'ALLOW', 'ROLE', 'hr'), + ('PayrollComponent', '*', '*', 'ALLOW', 'ROLE', 'hr'), + ('Worker', '__get__incomes', '*', 'ALLOW', 'ROLE', 'hr'); From 3070d1ef0182b4e3d098cdd8c2b32bfd93176314 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 18 Jun 2024 10:04:21 +0200 Subject: [PATCH 068/114] refactor: refs #6238 drop useless round --- .../methods/travel/extraCommunityFilter.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 107bf6f39..dcb704ff5 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -139,18 +139,18 @@ module.exports = Self => { IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0) ) as volumeKg, - ROUND(GREATEST( - CAST(SUM(b.weight * b.stickers) AS INT), - CAST( - SUM(vc.aerealVolumetricDensity * - b.stickers * - IF(pkg.volume, - pkg.volume, - pkg.width * pkg.depth * pkg.height - ) / 1000000 - ) AS INT + GREATEST( + CAST(SUM(b.weight * b.stickers) AS INT), + CAST( + SUM(vc.aerealVolumetricDensity * + b.stickers * + IF(pkg.volume, + pkg.volume, + pkg.width * pkg.depth * pkg.height + ) / 1000000 + ) AS INT ) - ) / t.kg * 100, 0) percentageKg + / t.kg * 100, 0) percentageKg FROM travel t LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN entry e ON e.travelFk = t.id From 6cf7c5867124fdb21f24f5242a621b398bf7c1e0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 18 Jun 2024 12:59:55 +0200 Subject: [PATCH 069/114] fix: refs #6238 use scheme --- .../11102-wheatCarnation/00-createTravelKgPercentage.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql index 9df89d869..6c8bb4784 100644 --- a/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql +++ b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql @@ -1,9 +1,9 @@ -CREATE TABLE IF NOT EXISTS travelKgPercentage ( +CREATE TABLE IF NOT EXISTS vn.travelKgPercentage ( value INT(3) PRIMARY KEY, className VARCHAR(50) ); -INSERT INTO travelKgPercentage (value, className) +INSERT INTO vn.travelKgPercentage (value, className) VALUES (80, 'primary'), (100, 'alert'); From bf62f40c87cb72d61981d1ae8a5c73b9a86ab172 Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 19 Jun 2024 07:17:25 +0200 Subject: [PATCH 070/114] actualizada la rama --- .../vn/procedures/supplierPackaging_ReportSource.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index 751ee58f0..d12ba9d4e 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -5,10 +5,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_R ) BEGIN /** -* Selecciona los embalajes de un proveedor a partir de una fecha +* Create a report with packaging balance * -* @param vFromDated Fecha de la que partir -* @param vSupplierFk Id del proveedor +* @param vFromDated Starting date +* @param vSupplierFk Supplier ID */ SET @vBalance = 0; SET @vItemFk = NULL; From 1fa0a841da97f7d56d0e097e348fba941403ab61 Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 19 Jun 2024 07:26:30 +0200 Subject: [PATCH 071/114] TP previous --- db/routines/vn/procedures/supplierPackaging_ReportSource.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index d12ba9d4e..7cc72848f 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -139,7 +139,7 @@ BEGIN JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi WHERE su.id = vSupplierFk - AND t.shipped >= vFromDated + AND t.shipped < vFromDated AND p.isPackageReturnable AND NOT t.isDeleted GROUP BY p.itemFk From 637c6a9035e0b37907c5fc71e9cf239ae461a80e Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 19 Jun 2024 09:40:24 +0200 Subject: [PATCH 072/114] feat: refs #7216 logUnpaid --- modules/client/back/locale/client-unpaid/en.yml | 5 +++++ modules/client/back/locale/client-unpaid/es.yml | 5 +++++ modules/client/back/models/client-unpaid.json | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 modules/client/back/locale/client-unpaid/en.yml create mode 100644 modules/client/back/locale/client-unpaid/es.yml diff --git a/modules/client/back/locale/client-unpaid/en.yml b/modules/client/back/locale/client-unpaid/en.yml new file mode 100644 index 000000000..77a993671 --- /dev/null +++ b/modules/client/back/locale/client-unpaid/en.yml @@ -0,0 +1,5 @@ +name: uppaid +columns: + clientFk: client + dated: date + amount: amount diff --git a/modules/client/back/locale/client-unpaid/es.yml b/modules/client/back/locale/client-unpaid/es.yml new file mode 100644 index 000000000..e24236109 --- /dev/null +++ b/modules/client/back/locale/client-unpaid/es.yml @@ -0,0 +1,5 @@ +name: impagado +columns: + clientFk: cliente + dated: fecha + amount: cantidad diff --git a/modules/client/back/models/client-unpaid.json b/modules/client/back/models/client-unpaid.json index 0fc3a9195..6637c3940 100644 --- a/modules/client/back/models/client-unpaid.json +++ b/modules/client/back/models/client-unpaid.json @@ -1,6 +1,9 @@ { "name": "ClientUnpaid", "base": "VnModel", + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "clientUnpaid" @@ -25,4 +28,4 @@ "foreignKey": "clientFk" } } -} \ No newline at end of file +} From 49e01218e9d9dfffb71c9715339e482db6bf2759 Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 19 Jun 2024 10:45:37 +0200 Subject: [PATCH 073/114] Warehouse name --- .../vn/procedures/supplierPackaging_ReportSource.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index 7cc72848f..a8e506244 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -68,7 +68,7 @@ BEGIN DATE(t.shipped), -LEAST(s.quantity,0) `in`, GREATEST(s.quantity,0) `out`, - t.warehouseFk, + w.name, s.price * (100 - s.discount) / 100 FROM sale s JOIN item i ON i.id = s.itemFk @@ -76,6 +76,7 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi + JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable @@ -110,7 +111,7 @@ BEGIN DATE(t.shipped), -LEAST(tp.quantity,0) `in`, GREATEST(tp.quantity,0) `out`, - t.warehouseFk, + w.name, 0 FROM ticketPackaging tp JOIN packaging p ON p.id = tp.packagingFk @@ -118,6 +119,7 @@ BEGIN JOIN ticket t ON t.id = tp.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi + JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable From 1a8df4d87c0a554bde7b55ac54dffdadc73c6555 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 19 Jun 2024 13:41:37 +0200 Subject: [PATCH 074/114] feat: refs #7216 triggers --- db/routines/vn/triggers/clientUnpaid_beforeInsert.sql | 8 ++++++++ db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql | 8 ++++++++ db/versions/11110-grayGerbera/00-clientUnpaid.sql | 4 ++++ modules/client/back/locale/client-unpaid/en.yml | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/triggers/clientUnpaid_beforeInsert.sql create mode 100644 db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql create mode 100644 db/versions/11110-grayGerbera/00-clientUnpaid.sql diff --git a/db/routines/vn/triggers/clientUnpaid_beforeInsert.sql b/db/routines/vn/triggers/clientUnpaid_beforeInsert.sql new file mode 100644 index 000000000..279a81b73 --- /dev/null +++ b/db/routines/vn/triggers/clientUnpaid_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientUnpaid_beforeInsert` + BEFORE INSERT ON `clientUnpaid` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql b/db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql new file mode 100644 index 000000000..13cac3fa7 --- /dev/null +++ b/db/routines/vn/triggers/clientUnpaid_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientUnpaid_beforeUpdate` + BEFORE UPDATE ON `clientUnpaid` + FOR EACH ROW +BEGIN + SET NEW.editorFk = account.myUser_getId(); +END$$ +DELIMITER ; diff --git a/db/versions/11110-grayGerbera/00-clientUnpaid.sql b/db/versions/11110-grayGerbera/00-clientUnpaid.sql new file mode 100644 index 000000000..06fd51555 --- /dev/null +++ b/db/versions/11110-grayGerbera/00-clientUnpaid.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.clientUnpaid + ADD editorFk INT UNSIGNED NULL, + ADD CONSTRAINT ClientUnpaid_editorFk FOREIGN KEY (editorFk) + REFERENCES account.`user`(id); diff --git a/modules/client/back/locale/client-unpaid/en.yml b/modules/client/back/locale/client-unpaid/en.yml index 77a993671..10f797c97 100644 --- a/modules/client/back/locale/client-unpaid/en.yml +++ b/modules/client/back/locale/client-unpaid/en.yml @@ -1,4 +1,4 @@ -name: uppaid +name: unpaid columns: clientFk: client dated: date From b2ad44980909fd2ecd7d3bc29cb2a0a25755b869 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 19 Jun 2024 14:38:56 +0200 Subject: [PATCH 075/114] feat: refs #7027 mailError managed --- loopback/locale/en.json | 5 +++-- loopback/locale/es.json | 5 +++-- loopback/locale/fr.json | 3 ++- print/core/email.js | 8 ++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a2332fdca..1e5733442 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -232,5 +232,6 @@ "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member", "It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated", "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated", - "Cannot add holidays on this day": "Cannot add holidays on this day" -} \ No newline at end of file + "Cannot add holidays on this day": "Cannot add holidays on this day", + "Cannot send mail": "Cannot send mail" +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 714475374..cf8133759 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -365,5 +365,6 @@ "You can only have one PDA": "Solo puedes tener un PDA", "It has been invoiced but the PDF 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" -} \ No newline at end of file + "Payment method is required": "El método de pago es obligatorio", + "Cannot send mail": "Não é possível enviar o email" +} diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 1dbd162d8..49584ef0e 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -359,5 +359,6 @@ "Select ticket or client": "Choisissez un ticket ou un client", "It was not able to create the invoice": "Il n'a pas été possible de créer la facture", "It has been invoiced but the PDF could not be generated": "La facture a été émise mais le PDF n'a pas pu être généré", - "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré" + "It has been invoiced but the PDF of refund not be generated": "Il a été facturé mais le PDF de remboursement n'a pas été généré", + "Cannot send mail": "Impossible d'envoyer le mail" } diff --git a/print/core/email.js b/print/core/email.js index 5de13099a..a0bcf9122 100644 --- a/print/core/email.js +++ b/print/core/email.js @@ -2,6 +2,7 @@ const path = require('path'); const smtp = require('./smtp'); const Component = require('./component'); const Report = require('./report'); +const UserError = require('vn-loopback/util/user-error'); if (!process.env.OPENSSL_CONF) process.env.OPENSSL_CONF = '/etc/ssl/'; @@ -9,7 +10,6 @@ if (!process.env.OPENSSL_CONF) class Email extends Component { constructor(name, args) { super(name); - this.args = args; } @@ -88,7 +88,11 @@ class Email extends Component { force: options.force }; - return await smtp.send(mailOptions); + try { + return await smtp.send(mailOptions); + } catch (error) { + throw new UserError('Cannot send mail'); + } } } From c87f060d5166807a93642ad8a9d3655a21269829 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 20 Jun 2024 09:21:27 +0200 Subject: [PATCH 076/114] feat boxPicking refs #7357 --- back/model-config.json | 5 ++++- back/models/expedition_PrintOut.json | 24 ++++++++++++++++++++++++ db/dump/fixtures.before.sql | 8 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 back/models/expedition_PrintOut.json diff --git a/back/model-config.json b/back/model-config.json index b643ab54f..58fa86797 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -64,6 +64,9 @@ "EmailUser": { "dataSource": "vn" }, + "Expedition_PrintOut": { + "dataSource": "vn" + }, "Image": { "dataSource": "vn" }, @@ -190,4 +193,4 @@ "RouteConfig": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/back/models/expedition_PrintOut.json b/back/models/expedition_PrintOut.json new file mode 100644 index 000000000..6f521cda3 --- /dev/null +++ b/back/models/expedition_PrintOut.json @@ -0,0 +1,24 @@ +{ + "name": "Expedition_PrintOut", + "base": "VnModel", + "options": { + "mysql": { + "table": "dipole.expedition_PrintOut" + } + }, + "properties": { + "expeditionFk": { + "type": "number", + "id": true, + "description": "id expeditionFk" + }, + "itemFk": { + "type": "number", + "required": true + }, + "shelvingFk": { + "type": "string", + "required": true + } + } +} \ No newline at end of file diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 058c5cd2a..dc9efacf1 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3882,3 +3882,11 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli (1, '2001-05-17', 1, 5), (1, '2001-05-18', 1, 5); + +INSERT INTO dipole.printer (id, description) + VALUES(1, ''); + + INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, + truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) + VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); + From c1c01df3c3f05f5402335143e752d93809b1d595 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 20 Jun 2024 09:37:22 +0200 Subject: [PATCH 077/114] feat itemShelving_filterBuyer refs #7023 --- db/routines/vn/procedures/itemShelving_filterBuyer.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_filterBuyer.sql b/db/routines/vn/procedures/itemShelving_filterBuyer.sql index 7112aa48e..894a14464 100644 --- a/db/routines/vn/procedures/itemShelving_filterBuyer.sql +++ b/db/routines/vn/procedures/itemShelving_filterBuyer.sql @@ -15,7 +15,7 @@ proc:BEGIN SELECT * FROM (SELECT sub.itemFk, sub.longName, - CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, + CONCAT('Hoy quedan por sacar ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, CONCAT(IF(sub2.itemFk, IF(sub2.pendiente > (sub.upstairs + sub.downstairs),'(1) ','(2) '),'(3) ' ),sub.producer) producer, sub.upstairs, sub.downstairs, @@ -52,7 +52,7 @@ proc:BEGIN UNION ALL SELECT v.item_id, i.longName, - CONCAT('Hoy saldrán ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, + CONCAT('Hoy quedan por sacar ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, CONCAT(IF(sub5.pendiente,'(0) ','(3) ')) producer, 0, 0, From 182cd3fa8e79423f5cf28c0b13931ee2ceb48e55 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 20 Jun 2024 11:34:51 +0200 Subject: [PATCH 078/114] feat boxPicking refs #7357 --- db/dump/fixtures.before.sql | 2 +- loopback/locale/es.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index dc9efacf1..9cd470dab 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3883,7 +3883,7 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli (1, '2001-05-18', 1, 5); -INSERT INTO dipole.printer (id, description) + INSERT INTO dipole.printer (id, description) VALUES(1, ''); INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 714475374..047774684 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -365,5 +365,6 @@ "You can only have one PDA": "Solo puedes tener un PDA", "It has been invoiced but the PDF 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" + "Payment method is required": "El método de pago es obligatorio", + "CLIENT_NOT_ESPECIFIED": "CLIENT_NOT_ESPECIFIED" } \ No newline at end of file From 7d3c07aaaecc61fd1caa83221af430185b235b42 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Thu, 20 Jun 2024 10:44:31 +0000 Subject: [PATCH 079/114] Actualizar README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b052bd8bf..2ad83c2e4 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Pull from repository. Run this commands on project root directory to install Node dependencies. ``` -$ npm install +$ pnpm install $ gulp install ``` From 833a7c87db39ef0bdd10b13f2b2d060098b2fcdb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 20 Jun 2024 16:26:56 +0200 Subject: [PATCH 080/114] feat boxPicking refs #7357 --- loopback/locale/es.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 047774684..714475374 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -365,6 +365,5 @@ "You can only have one PDA": "Solo puedes tener un PDA", "It has been invoiced but the PDF 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", - "CLIENT_NOT_ESPECIFIED": "CLIENT_NOT_ESPECIFIED" + "Payment method is required": "El método de pago es obligatorio" } \ No newline at end of file From ed49c98c1c51ee5f7848e4a7d7ca811b1d93640e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 20 Jun 2024 18:18:03 +0200 Subject: [PATCH 081/114] fnpmeat: previas con sitema de reservas refs #6861 --- db/routines/vn/procedures/itemShelvingSale_setQuantity.sql | 5 +---- db/routines/vn/triggers/itemShelvingSale_afterInsert.sql | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 700821592..f3fed7c44 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -55,16 +55,13 @@ BEGIN SELECT id INTO vItemShelvingFk FROM itemShelving - WHERE id = vItemShelvingFk - AND FALSE + WHERE id = vItemShelvingFk FOR UPDATE; UPDATE itemShelving SET visible = GREATEST(0, visible - vQuantity) WHERE id = vItemShelvingFk; - - SELECT SUM(IF(isPicked, 0, quantity)), SUM(quantity) INTO vRemainingQuantity, vTotalQuantity FROM itemShelvingSale diff --git a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql index 0c609d328..ef0048b34 100644 --- a/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql +++ b/db/routines/vn/triggers/itemShelvingSale_afterInsert.sql @@ -6,7 +6,7 @@ BEGIN UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() - SET s.isPicked = IF(o.isOnReservationMode, isPicked, TRUE) + SET s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE) WHERE id = NEW.saleFk; END$$ DELIMITER ; \ No newline at end of file From 13952f60e178ef6a147fe8f98cdd5e84aafce9c0 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 21 Jun 2024 07:18:10 +0200 Subject: [PATCH 082/114] feat boxPicking refs #7357 --- back/models/expedition_PrintOut.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/back/models/expedition_PrintOut.json b/back/models/expedition_PrintOut.json index 6f521cda3..23a2fdbc4 100644 --- a/back/models/expedition_PrintOut.json +++ b/back/models/expedition_PrintOut.json @@ -13,12 +13,7 @@ "description": "id expeditionFk" }, "itemFk": { - "type": "number", - "required": true - }, - "shelvingFk": { - "type": "string", - "required": true + "type": "number" } } } \ No newline at end of file From fe154b9ee84f9db7c5e4edaa0ffd25b9156a7e4b Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 21 Jun 2024 08:32:22 +0200 Subject: [PATCH 083/114] sref --- .../supplierPackaging_ReportSource.sql | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index a8e506244..63285203b 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -22,7 +22,7 @@ BEGIN landed, `in`, `out`, - warehouse, + sref, buyingValue, IF ( NOT (@vItemFk <=> sub.itemFk), @@ -31,19 +31,20 @@ BEGIN ) balance, @vItemFk := sub.itemFk previousItemFk FROM ( - SELECT supplierFk, - itemFk, - longName, - supplier, - CONCAT('E',entryFk) entryFk, - landed, - `in`, - `out`, - warehouse, - buyingValue - FROM supplierPackaging - WHERE supplierFk = vSupplierFk - AND landed >= vFromDated + SELECT sp.supplierFk, + sp.itemFk, + sp.longName, + sp.supplier, + CONCAT('E',sp.entryFk) entryFk, + sp.landed, + sp.`in`, + sp.`out`, + e.invoiceNumber sref, + sp.buyingValue + FROM supplierPackaging sp + JOIN entry e ON e.id = sp.entryFk + WHERE sp.supplierFk = vSupplierFk + AND sp.landed >= vFromDated UNION ALL SELECT vSupplierFk, itemFk, @@ -68,7 +69,7 @@ BEGIN DATE(t.shipped), -LEAST(s.quantity,0) `in`, GREATEST(s.quantity,0) `out`, - w.name, + t.cmrFk, s.price * (100 - s.discount) / 100 FROM sale s JOIN item i ON i.id = s.itemFk @@ -76,7 +77,6 @@ BEGIN JOIN ticket t ON t.id = s.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi - JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable @@ -111,7 +111,7 @@ BEGIN DATE(t.shipped), -LEAST(tp.quantity,0) `in`, GREATEST(tp.quantity,0) `out`, - w.name, + t.cmrFk, 0 FROM ticketPackaging tp JOIN packaging p ON p.id = tp.packagingFk @@ -119,7 +119,6 @@ BEGIN JOIN ticket t ON t.id = tp.ticketFk JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi - JOIN warehouse w ON w.id = t.warehouseFk WHERE su.id = vSupplierFk AND t.shipped >= vFromDated AND p.isPackageReturnable @@ -157,7 +156,7 @@ BEGIN landed, CAST(`in` AS DECIMAL(10,0)) `in`, CAST(`out` AS DECIMAL(10,0)) `out`, - warehouse, + sref, buyingValue, balance FROM tSupplierPackaging From 42b483e27e28878722206ee07cea699d4575cb43 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 21 Jun 2024 08:35:35 +0200 Subject: [PATCH 084/114] feat: refs #7555 remove account.password__ --- db/versions/11111-tealAralia/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11111-tealAralia/00-firstScript.sql diff --git a/db/versions/11111-tealAralia/00-firstScript.sql b/db/versions/11111-tealAralia/00-firstScript.sql new file mode 100644 index 000000000..4ef10d5f2 --- /dev/null +++ b/db/versions/11111-tealAralia/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE account.`user` DROP COLUMN password__; From 3fa7eb1d2aa03ca39289bb9836f5b997c0de0ca5 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 21 Jun 2024 13:01:19 +0200 Subject: [PATCH 085/114] feat itemShelving_filterBuyer refs #7023 --- db/routines/vn/procedures/itemShelving_filterBuyer.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_filterBuyer.sql b/db/routines/vn/procedures/itemShelving_filterBuyer.sql index 894a14464..2fdf21ee1 100644 --- a/db/routines/vn/procedures/itemShelving_filterBuyer.sql +++ b/db/routines/vn/procedures/itemShelving_filterBuyer.sql @@ -15,13 +15,14 @@ proc:BEGIN SELECT * FROM (SELECT sub.itemFk, sub.longName, - CONCAT('Hoy quedan por sacar ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, + CONCAT('Hoy saldrán ', CAST(sub2.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, CONCAT(IF(sub2.itemFk, IF(sub2.pendiente > (sub.upstairs + sub.downstairs),'(1) ','(2) '),'(3) ' ),sub.producer) producer, sub.upstairs, sub.downstairs, sub.visible, CAST(visible - upstairs - downstairs AS DECIMAL(10,0)) nicho, - sub.name itemColour + sub.name itemColour, + CAST(sub2.pendiente AS DECIMAL(10,0)) pendingAmount FROM (SELECT iss.itemFk, CONCAT(i.longName, ' ', IFNULL(i.size, ''),' ', IFNULL(i.subName, '') ) longName, '' size, @@ -52,13 +53,14 @@ proc:BEGIN UNION ALL SELECT v.item_id, i.longName, - CONCAT('Hoy quedan por sacar ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, + CONCAT('Hoy saldrán ', CAST(sub5.pendiente AS DECIMAL(10,0)), ' unidades.') `size`, CONCAT(IF(sub5.pendiente,'(0) ','(3) ')) producer, 0, 0, v.visible, v.visible nicho, - ik.name itemColour + ik.name itemColour, + CAST(sub5.pendiente AS DECIMAL(10,0) pendingAmount FROM cache.visible v JOIN item i ON i.id = v.item_id LEFT JOIN ink ik ON ik.id = i.inkFk From 41316537006c336064476cadd7add125ed74bbe9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 21 Jun 2024 13:02:36 +0200 Subject: [PATCH 086/114] feat itemShelving_filterBuyer refs #7023 --- db/routines/vn/procedures/itemShelving_filterBuyer.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_filterBuyer.sql b/db/routines/vn/procedures/itemShelving_filterBuyer.sql index 2fdf21ee1..d4675ea0e 100644 --- a/db/routines/vn/procedures/itemShelving_filterBuyer.sql +++ b/db/routines/vn/procedures/itemShelving_filterBuyer.sql @@ -60,7 +60,7 @@ proc:BEGIN v.visible, v.visible nicho, ik.name itemColour, - CAST(sub5.pendiente AS DECIMAL(10,0) pendingAmount + CAST(sub5.pendiente AS DECIMAL(10,0)) pendingAmount FROM cache.visible v JOIN item i ON i.id = v.item_id LEFT JOIN ink ik ON ik.id = i.inkFk From cf79711f6aa2e0c675fedd11bc61cf67e3b87b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 24 Jun 2024 13:30:03 +0200 Subject: [PATCH 087/114] feat: previas con sitema de reservas refs #6861 --- db/routines/vn/procedures/itemShelvingSale_doReserve.sql | 6 +++--- db/routines/vn/procedures/itemShelvingSale_reallocate.sql | 2 +- db/routines/vn/procedures/itemShelvingSale_setQuantity.sql | 2 +- db/versions/10852-pinkOak/00-firstScript.sql | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql index d7bf4b181..629e303b3 100644 --- a/db/routines/vn/procedures/itemShelvingSale_doReserve.sql +++ b/db/routines/vn/procedures/itemShelvingSale_doReserve.sql @@ -2,7 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_doReserve`() proc: BEGIN /** - * Genera reservas de la tabla itemShelvingSaleReserv + * Genera reservas de la tabla vn.itemShelvingSaleReserve */ DECLARE vDone BOOL; DECLARE vSaleFk INT; @@ -26,7 +26,7 @@ proc: BEGIN CREATE OR REPLACE TEMPORARY TABLE tSale ENGINE = MEMORY - SELECT id, saleFk FROM itemShelvingSaleReserv; + SELECT id, saleFk FROM itemShelvingSaleReserve; OPEN vSales; @@ -43,7 +43,7 @@ proc: BEGIN CLOSE vSales; - DELETE iss FROM itemShelvingSaleReserv iss JOIN tSale s ON s.id = iss.id; + DELETE iss FROM itemShelvingSaleReserve iss JOIN tSale s ON s.id = iss.id; DROP TEMPORARY TABLE tSale; diff --git a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql index ab898bdd4..85230a386 100644 --- a/db/routines/vn/procedures/itemShelvingSale_reallocate.sql +++ b/db/routines/vn/procedures/itemShelvingSale_reallocate.sql @@ -28,7 +28,7 @@ BEGIN WHERE id = vItemShelvingFk AND itemFk = vItemFk; - INSERT INTO itemShelvingSaleReserv (saleFk) + INSERT INTO itemShelvingSaleReserve (saleFk) SELECT DISTINCT iss.saleFk FROM itemShelvingSale iss JOIN itemShelving ish ON ish.id = iss.itemShelvingFk diff --git a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql index 00427039a..42f915ead 100644 --- a/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql +++ b/db/routines/vn/procedures/itemShelvingSale_setQuantity.sql @@ -86,7 +86,7 @@ BEGIN COMMIT; IF vIsItemShelvingSaleEmpty AND vQuantity <> vReservedQuantity THEN - INSERT INTO itemShelvingSaleReserv (saleFk) + INSERT INTO itemShelvingSaleReserve (saleFk) SELECT vSaleFk; CALL itemShelvingSale_reallocate(vItemShelvingFk, vItemFk); END IF; diff --git a/db/versions/10852-pinkOak/00-firstScript.sql b/db/versions/10852-pinkOak/00-firstScript.sql index 7739976e6..41b75c7e1 100644 --- a/db/versions/10852-pinkOak/00-firstScript.sql +++ b/db/versions/10852-pinkOak/00-firstScript.sql @@ -16,11 +16,11 @@ ALTER TABLE vn.itemShelving ADD available INT NULL; UPDATE vn.itemShelving SET available = visible; -CREATE TABLE vn.itemShelvingSaleReserv ( +CREATE TABLE vn.itemShelvingSaleReserve ( `id` int(11) NOT NULL AUTO_INCREMENT, `saleFk` int(11) NOT NULL, PRIMARY KEY (`id`), - KEY `itemShelvingSaleReserv_ibfk_1` (`saleFk`) + KEY `itemShelvingSaleReserve_ibfk_1` (`saleFk`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Queue of changed itemShelvingSale to reserve'; From 655bbe4967e34ca9fa02adc70f77b40503979785 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 25 Jun 2024 12:29:17 +0200 Subject: [PATCH 088/114] refs #7406 fix pr --- db/dump/fixtures.before.sql | 10 ++++------ db/versions/11073-crimsonBirch/00-firstScript.sql | 8 ++++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 941a046b0..0be918fbb 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3828,7 +3828,6 @@ INSERT INTO vn.workerTeam(id, team, workerFk) INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); -UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES ('1M', 'M', 1), ('2M', 'M', 9), @@ -3848,11 +3847,10 @@ INSERT INTO `vn`.`ledgerConfig` SET INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma) - VALUES (9,2,1,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',0,1); -INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma) - VALUES (9,1,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,0); -INSERT INTO vn.trainingCourse (workerFk,trainingCourseTypeFk,centerFk,started,ended,hasDiscount,hasDiploma) - VALUES (9,2,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,1); + VALUES + (9,2,1,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',0,1), + (9,1,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,0), + (9,2,2,'2018-06-20 00:00:00.000','2020-06-24 00:00:00.000',1,1); INSERT INTO vn.sectorCollection SET id = 2, diff --git a/db/versions/11073-crimsonBirch/00-firstScript.sql b/db/versions/11073-crimsonBirch/00-firstScript.sql index 7d76a75cd..e82d342c9 100644 --- a/db/versions/11073-crimsonBirch/00-firstScript.sql +++ b/db/versions/11073-crimsonBirch/00-firstScript.sql @@ -1,9 +1,9 @@ -- Auto-generated SQL script. Actual values for binary/complex data types may differ - what you see is the default string representation of values. INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('TrainingCourse','*','*','ALLOW','ROLE','employee'); + VALUES ('TrainingCourse','*','*','ALLOW','ROLE','hr'); INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('TrainingCourseType','*','*','ALLOW','ROLE','employee'); + VALUES ('TrainingCourseType','*','*','ALLOW','ROLE','hr'); INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('TrainingCenter','*','*','ALLOW','ROLE','employee'); + VALUES ('TrainingCenter','*','*','ALLOW','ROLE','hr'); INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','__get__trainingCourse','*','ALLOW','ROLE','employee'); + VALUES ('Worker','__get__trainingCourse','*','ALLOW','ROLE','hr'); From 248358fbd7ed63ab213d9a99d942fd7e0cc57462 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 25 Jun 2024 12:35:25 +0200 Subject: [PATCH 089/114] refs #7409 fix pr --- db/dump/fixtures.before.sql | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 1f19ba510..bc73916ba 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3884,20 +3884,16 @@ INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHoli INSERT INTO vn.payrollComponent (id, name, isSalaryAgreed, isVariable, isException) -VALUES(1, 'Salario1', 1, 0, 0); -INSERT INTO vn.payrollComponent -(id, name, isSalaryAgreed, isVariable, isException) -VALUES(2, 'Salario2', 1, 1, 0); -INSERT INTO vn.payrollComponent -(id, name, isSalaryAgreed, isVariable, isException) -VALUES(3, 'Salario3', 1, 0, 1); + VALUES + (1, 'Salario1', 1, 0, 0), + (2, 'Salario2', 1, 1, 0), + (3, 'Salario3', 1, 0, 1); INSERT INTO vn.workerIncome (debit, credit, incomeTypeFk, paymentDate, workerFk, concept) -VALUES(1000.00, 900.00, 2, '2000-01-01', 1106, NULL); -INSERT INTO vn.workerIncome -(debit, credit, incomeTypeFk, paymentDate, workerFk, concept) -VALUES(1001.00, 800.00, 2, '2000-01-01', 1106, NULL); + VALUES + (1000.00, 900.00, 2, '2000-01-01', 1106, NULL), + (1001.00, 800.00, 2, '2000-01-01', 1106, NULL); From f5bc0482d2d88822bb5e0f34517bb150a9f295ef Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 25 Jun 2024 12:36:28 +0200 Subject: [PATCH 090/114] refs #7409 resolve conflicts --- db/dump/fixtures.before.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 77b63f45c..ae9ab621c 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3897,10 +3897,10 @@ INSERT INTO vn.workerIncome (1001.00, 800.00, 2, '2000-01-01', 1106, NULL); - INSERT INTO dipole.printer (id, description) - VALUES(1, ''); +INSERT INTO dipole.printer (id, description) +VALUES(1, ''); - INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, - truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) - VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); +INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, +truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) +VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); From 4bf00bd428fb1455411f4bbc6596f02460f2c838 Mon Sep 17 00:00:00 2001 From: Pako Date: Tue, 25 Jun 2024 12:51:14 +0200 Subject: [PATCH 091/114] version 240625 --- .../floranet/procedures/catalogue_get.sql | 27 +++++++++++-------- .../floranet/procedures/deliveryDate_get.sql | 4 +-- .../floranet/procedures/order_confirm.sql | 4 +-- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index 7ce32cfac..1e224c810 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -1,16 +1,15 @@ -DROP PROCEDURE IF EXISTS floranet.catalogue_get; - DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, vPostalCode VARCHAR(15)) READS SQL DATA proc:BEGIN /** - * Returns list, price and all the stuff regarding the floranet items. + * Returns list, price and all the stuff regarding the floranet items, for the designed shop * * @param vLanded Delivery date * @param vPostalCode Delivery address postal code */ + DECLARE vAddressFk INT; DECLARE vLastCatalogueFk INT; DECLARE vLockName VARCHAR(20); DECLARE vLockTime INT; @@ -21,7 +20,7 @@ proc:BEGIN RESIGNAL; END; - + SET vLockName = 'catalogue_get'; SET vLockTime = 15; @@ -32,6 +31,15 @@ proc:BEGIN SELECT MAX(id) INTO vLastCatalogueFk FROM catalogue; + SELECT addressFk + INTO vAddressFk + FROM addressPostCode apc + WHERE apc.dayOfWeek = dayOfWeek(vLanded) + AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR + AND apc.postCode = vPostalCode + -- Aquí hay que incluir los criterios de selección de tienda + LIMIT 1; + INSERT INTO catalogue( name, price, @@ -51,17 +59,14 @@ proc:BEGIN it.name, CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image), i.description, - apc.addressFk + vAddressFk FROM vn.item i JOIN (SELECT itemFk, SUM(quantity * cost) price FROM recipe GROUP BY itemFk) r ON r.itemFk = i.id JOIN vn.itemType it ON it.id = i.typeFk - JOIN addressPostCode apc - ON apc.dayOfWeek = dayOfWeek(vLanded) - AND NOW() < vLanded - INTERVAL apc.hoursInAdvance HOUR - AND apc.postCode = vPostalCode - JOIN vn.address a ON a.id = apc.addressFk; + JOIN addressPostCode apc ON addressFk = vAddressFk + JOIN vn.address a ON a.id = vAddressFk; SELECT * FROM catalogue diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql index a235e8c31..70cb48818 100644 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -1,8 +1,6 @@ -DROP PROCEDURE IF EXISTS floranet.deliveryDate_get; - DELIMITER $$ $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPostalCode VARCHAR(15)) READS SQL DATA BEGIN /** diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql index 3b9413da9..98e15bbab 100644 --- a/db/routines/floranet/procedures/order_confirm.sql +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -101,7 +101,7 @@ proc:BEGIN vNewTicketFk, c.itemFk, CONCAT('Entrega: ',c.name), - - c.price, + - apc.deliveryCost, 1 FROM catalogue c JOIN addressPostCode apc @@ -119,7 +119,7 @@ proc:BEGIN vNewTicketFk, r.elementFk, i.longName, - r.cost, + 0, r.quantity FROM catalogue c JOIN recipe r ON r.itemFk = c.itemFk From 85854e0713d07a3e525a6a0e5fd7a64c350dc406 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 25 Jun 2024 13:14:44 +0200 Subject: [PATCH 092/114] warmFix: use vn --- db/routines/vn/procedures/duaInvoiceInBooking.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/duaInvoiceInBooking.sql b/db/routines/vn/procedures/duaInvoiceInBooking.sql index 1f026e96b..6d0c9f517 100644 --- a/db/routines/vn/procedures/duaInvoiceInBooking.sql +++ b/db/routines/vn/procedures/duaInvoiceInBooking.sql @@ -36,7 +36,7 @@ BEGIN SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk; - IF vBookEntry IS NULL THEN + IF vBookEntry IS NULL THEN SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear FROM invoiceIn ii JOIN `entry` e ON e.invoiceInFk = ii.id @@ -45,7 +45,7 @@ BEGIN WHERE d.id = vDuaFk LIMIT 1; CALL ledger_nextTx(vFiscalYear, vBookEntry); - END IF; + END IF; OPEN vInvoicesIn; @@ -75,14 +75,14 @@ BEGIN JOIN ( WITH entries AS ( SELECT e.id, de.duaFk - FROM `entry` e - JOIN duaEntry de ON de.entryFk = e.id + FROM vn.`entry` e + JOIN vn.duaEntry de ON de.entryFk = e.id WHERE de.duaFk = vDuaFk AND (NOT e.isBooked OR NOT e.isConfirmed) ), notBookedEntries AS ( SELECT e.id - FROM duaEntry + FROM vn.duaEntry WHERE duaFk = vDuaFk AND NOT customsValue ) From c551e229fba16626939303deda5c4c3582eff2bd Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 25 Jun 2024 13:30:46 +0200 Subject: [PATCH 093/114] feat itemShelvingLog refs #7168 --- .../11116-tealRuscus/00-firstScript.sql | 3 ++ modules/item/back/model-config.json | 5 +- .../item/back/models/item-shelving-log.json | 52 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 db/versions/11116-tealRuscus/00-firstScript.sql create mode 100644 modules/item/back/models/item-shelving-log.json diff --git a/db/versions/11116-tealRuscus/00-firstScript.sql b/db/versions/11116-tealRuscus/00-firstScript.sql new file mode 100644 index 000000000..a74021dd5 --- /dev/null +++ b/db/versions/11116-tealRuscus/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +USE vn; +INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('ItemShelvingLog', '*', 'READ', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 40d73f1a6..2d06e1ada 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -50,6 +50,9 @@ "ItemShelving": { "dataSource": "vn" }, + "ItemShelvingLog": { + "dataSource": "vn" + }, "ItemShelvingSale": { "dataSource": "vn" }, @@ -74,4 +77,4 @@ "FixedPrice": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/item/back/models/item-shelving-log.json b/modules/item/back/models/item-shelving-log.json new file mode 100644 index 000000000..f976008f1 --- /dev/null +++ b/modules/item/back/models/item-shelving-log.json @@ -0,0 +1,52 @@ +{ + "name": "ItemShelvingLog", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "itemShelvingLog" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "created": { + "type": "date" + }, + "shelvingFk": { + "type": "string" + }, + "itemFk": { + "type": "number" + }, + "visible": { + "type": "number" + }, + "accion": { + "type": "string" + } + }, + "relations": { + "item": { + "type": "belongsTo", + "model": "Item", + "foreignKey": "itemFk" + }, + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "shelving": { + "type": "belongsTo", + "model": "Shelving", + "foreignKey": "shelvingFk", + "primaryKey": "code" + } + } +} \ No newline at end of file From acf308fd16672094e326ac1b4fbfe28e64098f52 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 25 Jun 2024 13:35:21 +0200 Subject: [PATCH 094/114] feat itemShelvingLog refs #7168 --- db/versions/11116-tealRuscus/00-firstScript.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/versions/11116-tealRuscus/00-firstScript.sql b/db/versions/11116-tealRuscus/00-firstScript.sql index a74021dd5..dc577a36b 100644 --- a/db/versions/11116-tealRuscus/00-firstScript.sql +++ b/db/versions/11116-tealRuscus/00-firstScript.sql @@ -1,3 +1,8 @@ -- Place your SQL code here USE vn; -INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('ItemShelvingLog', '*', 'READ', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file +INSERT INTO salix.ACL ( model, property, accessType, permission, principalType, principalId) VALUES('ItemShelvingLog', '*', 'READ', 'ALLOW', 'ROLE', 'production'); + +-- redmine regularitzar parking per a que no tinguen espais +ALTER TABLE parking DROP CONSTRAINT chkParkingCodeFormat; +ALTER TABLE parking +ADD CONSTRAINT chkParkingCodeFormat CHECK (CHAR_LENGTH(code) > 4 AND code REGEXP ('^[^ ]+-[^ ]+$')); \ No newline at end of file From e55af8d36f48f7e3fb99ca32c006df3527879fb4 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 25 Jun 2024 13:41:10 +0200 Subject: [PATCH 095/114] feat itemShelvingLog refs #7168 --- .../vn/procedures/itemShelvingLog_get.sql | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/db/routines/vn/procedures/itemShelvingLog_get.sql b/db/routines/vn/procedures/itemShelvingLog_get.sql index f72a31a9b..ad67ea5cd 100644 --- a/db/routines/vn/procedures/itemShelvingLog_get.sql +++ b/db/routines/vn/procedures/itemShelvingLog_get.sql @@ -1,37 +1,35 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`( - vShelvingFk VARCHAR(10), - vRecords INT -) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingLog_get`(vShelvingFk VARCHAR(10) ) BEGIN + /** * Devuelve el log de los item en cada carro * - * @param vShelvingFk Matrícula del carro - * @param vRecords Límite de registros retornados + * @param vShelvingFk Matrícula del carro * */ - DECLARE vQuery TEXT; - SET vQuery = ' - SELECT isl.itemFk, - i.longName, - isl.shelvingFk, - w.code, - isl.accion, - isl.quantity, - isl.created - FROM item i - JOIN itemShelvingLog isl ON i.id = isl.itemFk - JOIN worker w ON isl.workerFk = w.id - WHERE shelvingFk = ? - OR isl.itemFk = ? - ORDER BY isl.created DESC'; - - IF vRecords IS NOT NULL THEN - SET vQuery = CONCAT(vQuery, '\nLIMIT ', vRecords); - END IF; - - EXECUTE IMMEDIATE vQuery - USING vShelvingFk, vShelvingFk; + + SELECT isl.itemShelvingFk, + isl.created, + isl.accion, + isl.itemFk, + isl.shelvingFk, + isl.quantity, + isl.visible, + isl.available, + isl.grouping, + isl.packing, + isl.stars, + item.longName, + item.size, + item.subName, + worker.code, + isl.accion + FROM item + JOIN itemShelvingLog isl ON item.id = isl.itemFk + JOIN worker ON isl.workerFk = worker.id + WHERE shelvingFk = vShelvingFk OR isl.itemFk = vShelvingFk + ORDER BY isl.created DESC; + END$$ DELIMITER ; From d1ed4b44590c0fb1765fbcbe36bb9703f740fc3f Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 25 Jun 2024 16:03:59 +0200 Subject: [PATCH 096/114] refs #7409 fix back --- modules/worker/back/models/worker.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 323c2cd28..2c749144b 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -118,7 +118,8 @@ }, "incomes": { "type": "hasMany", - "model": "WorkerIncome" + "model": "WorkerIncome", + "foreignKey": "workerFk" }, "trainingCourse": { "type": "hasMany", From 1f6fd8d6d1455f9d76b08890f78da1e991b776b9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 25 Jun 2024 17:27:00 +0200 Subject: [PATCH 097/114] feat: refs #6286 check if is teamBoss --- .../back/methods/worker-time-control/resendWeeklyHourEmail.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js index 68d03f7e4..ed6b4e6ab 100644 --- a/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js +++ b/modules/worker/back/methods/worker-time-control/resendWeeklyHourEmail.js @@ -35,8 +35,10 @@ module.exports = Self => { const yearNumber = dated.getFullYear(); const weekNumber = moment(dated).isoWeek(); + const isSubordinate = await models.Worker.isSubordinate(ctx, workerId, myOptions); + const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - if (!await models.Worker.isSubordinate(ctx, workerId) || workerId === ctx.req.accessToken.userId) + if (!isSubordinate || (workerId === ctx.req.accessToken.userId && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); const workerTimeControlMail = await models.WorkerTimeControlMail.findOne({ From cca62ae90242766767c64f18df758d2b9b45385f Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 26 Jun 2024 12:25:18 +0200 Subject: [PATCH 098/114] feat: return sql check error --- loopback/locale/es.json | 3 ++- loopback/server/middleware/error-handler.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 5b5928993..e2be5d013 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -366,5 +366,6 @@ "It has been invoiced but the PDF 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": "Não é possível enviar o email", + "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos" } diff --git a/loopback/server/middleware/error-handler.js b/loopback/server/middleware/error-handler.js index cc7b81618..beeff95ae 100644 --- a/loopback/server/middleware/error-handler.js +++ b/loopback/server/middleware/error-handler.js @@ -22,7 +22,7 @@ module.exports = function() { } // MySQL user-defined exceptions - if (err.sqlState == '45000') + if (err.sqlState == '45000' || err?.errno == 4025) return next(new UserError(req.__(err.sqlMessage))); // Logs error to console From cbc00b90b96797da9672aed997c2f77cd6fe9b53 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 26 Jun 2024 14:02:25 +0200 Subject: [PATCH 099/114] feat front-reservas refs #6861 --- modules/worker/back/models/operator.json | 44 +++++++++++++----------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/modules/worker/back/models/operator.json b/modules/worker/back/models/operator.json index a2f3ee01c..d4832bccf 100644 --- a/modules/worker/back/models/operator.json +++ b/modules/worker/back/models/operator.json @@ -26,29 +26,33 @@ }, "labelerFk": { "type": "number" + }, + "isOnReservationMode": { + "type": "boolean", + "required": true } - }, + }, "relations": { - "sector": { - "type": "belongsTo", - "model": "Sector", - "foreignKey": "sectorFk" - }, + "sector": { + "type": "belongsTo", + "model": "Sector", + "foreignKey": "sectorFk" + }, "train": { - "type": "belongsTo", - "model": "Train", - "foreignKey": "trainFk" - }, + "type": "belongsTo", + "model": "Train", + "foreignKey": "trainFk" + }, "printer": { - "type": "belongsTo", - "model": "Printer", - "foreignKey": "labelerFk" - }, + "type": "belongsTo", + "model": "Printer", + "foreignKey": "labelerFk" + }, "itemPackingType": { - "type": "belongsTo", - "model": "ItemPackingType", - "foreignKey": "itemPackingTypeFk", + "type": "belongsTo", + "model": "ItemPackingType", + "foreignKey": "itemPackingTypeFk", "primaryKey": "code" - } - } -} + } + } +} \ No newline at end of file From 47a0cb6d4f7e4be3a02fc7f884ee0cbd09929c61 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 27 Jun 2024 09:27:37 +0200 Subject: [PATCH 100/114] fix: refs #6238 insert ignore --- .../11102-wheatCarnation/00-createTravelKgPercentage.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql index 6c8bb4784..3abcd0074 100644 --- a/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql +++ b/db/versions/11102-wheatCarnation/00-createTravelKgPercentage.sql @@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS vn.travelKgPercentage ( className VARCHAR(50) ); -INSERT INTO vn.travelKgPercentage (value, className) +INSERT IGNORE INTO vn.travelKgPercentage (value, className) VALUES (80, 'primary'), (100, 'alert'); From 1b7c7336afcb918f807b270be5729b698cf73886 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 27 Jun 2024 10:08:58 +0200 Subject: [PATCH 101/114] fix: refs #6238 delete unused SQL script --- .../11114-goldenDracena/00-firstScript.sql | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 db/versions/11114-goldenDracena/00-firstScript.sql diff --git a/db/versions/11114-goldenDracena/00-firstScript.sql b/db/versions/11114-goldenDracena/00-firstScript.sql deleted file mode 100644 index cc283f418..000000000 --- a/db/versions/11114-goldenDracena/00-firstScript.sql +++ /dev/null @@ -1,18 +0,0 @@ --- Place your SQL code here -CREATE TABLE IF NOT EXISTS vn.travelKgPercentage ( - value INT(3) PRIMARY KEY, - className VARCHAR(50) -); - -INSERT IGNORE INTO vn.travelKgPercentage (value, className) - VALUES - (80, 'primary'), - (100, 'alert'); - -INSERT IGNORE INTO salix.ACL - SET model = 'TravelKgPercentage', - property = '*', - accessType = 'READ', - permission = 'ALLOW', - principalType = 'ROLE', - principalId = 'employee'; \ No newline at end of file From 746fa82f2a9d782e2989d4ee440d5fc6ad5924ee Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 27 Jun 2024 13:20:52 +0200 Subject: [PATCH 102/114] feat expeditionPalletPrint refs #5210 --- .../vn/procedures/expeditionPallet_printLabel.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/expeditionPallet_printLabel.sql b/db/routines/vn/procedures/expeditionPallet_printLabel.sql index ada11daab..7aaf8cedb 100644 --- a/db/routines/vn/procedures/expeditionPallet_printLabel.sql +++ b/db/routines/vn/procedures/expeditionPallet_printLabel.sql @@ -9,7 +9,16 @@ BEGIN */ DECLARE vPrinterFk INT; DECLARE vUserFk INT DEFAULT account.myUser_getId(); - + DECLARE vIsInExpeditionPallet BOOL; + + SELECT COUNT(id) INTO vIsInExpeditionPallet + FROM expeditionPallet + WHERE id = vSelf; + + IF NOT vIsInExpeditionPallet THEN + CALL util.throw("ExpeditionPallet not exists"); + END IF; + SELECT o.labelerFk INTO vPrinterFk FROM operator o WHERE o.workerFk = vUserFk; From f1f57a388d8daf5b99f8032c7e6b5508c8b99560 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 28 Jun 2024 08:45:18 +0200 Subject: [PATCH 103/114] feat: refs #7296 drop column expeditionTruckFk --- db/versions/11117-blueGalax/00-firstScript.sql | 2 ++ modules/ticket/back/methods/ticket/addSale.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 db/versions/11117-blueGalax/00-firstScript.sql diff --git a/db/versions/11117-blueGalax/00-firstScript.sql b/db/versions/11117-blueGalax/00-firstScript.sql new file mode 100644 index 000000000..63ea40cd2 --- /dev/null +++ b/db/versions/11117-blueGalax/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +ALTER TABLE vn.routesMonitor DROP COLUMN expeditionTruckFk; \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index 8dc7a633c..c0eb3b58b 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -70,7 +70,7 @@ module.exports = Self => { quantity: quantity }, myOptions); - await Self.rawSql('CALL vn.sale_calculateComponent(?, NULL)', [newSale.id], myOptions); + await Self.rawSql('CALL vn.sale_calculateComponent(?, )', [newSale.id], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [id], myOptions); const sale = await models.Sale.findById(newSale.id, { From ca3750ebac9397782e16eaee4561df84a92d9ffd Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 28 Jun 2024 08:46:54 +0200 Subject: [PATCH 104/114] feat: refs #7296 --- modules/ticket/back/methods/ticket/addSale.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/addSale.js b/modules/ticket/back/methods/ticket/addSale.js index c0eb3b58b..8dc7a633c 100644 --- a/modules/ticket/back/methods/ticket/addSale.js +++ b/modules/ticket/back/methods/ticket/addSale.js @@ -70,7 +70,7 @@ module.exports = Self => { quantity: quantity }, myOptions); - await Self.rawSql('CALL vn.sale_calculateComponent(?, )', [newSale.id], myOptions); + await Self.rawSql('CALL vn.sale_calculateComponent(?, NULL)', [newSale.id], myOptions); await Self.rawSql('CALL vn.ticket_recalc(?, NULL)', [id], myOptions); const sale = await models.Sale.findById(newSale.id, { From 19bf606330b622c947a8056eb997703123ef276a Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 28 Jun 2024 12:57:27 +0200 Subject: [PATCH 105/114] refs #7644 First commit --- .../entry/back/methods/entry/entryLabel.js | 36 ++++++++ modules/entry/back/models/entry.js | 1 + .../reports/entry-label/assets/css/import.js | 12 +++ .../reports/entry-label/assets/css/style.css | 58 ++++++++++++ .../reports/entry-label/entry-label.html | 89 +++++++++++++++++++ .../reports/entry-label/entry-label.js | 36 ++++++++ .../reports/entry-label/locale/es.yml | 1 + .../reports/entry-label/options.json | 11 +++ .../reports/entry-label/sql/entry.sql | 17 ++++ 9 files changed, 261 insertions(+) create mode 100644 modules/entry/back/methods/entry/entryLabel.js create mode 100644 print/templates/reports/entry-label/assets/css/import.js create mode 100644 print/templates/reports/entry-label/assets/css/style.css create mode 100644 print/templates/reports/entry-label/entry-label.html create mode 100755 print/templates/reports/entry-label/entry-label.js create mode 100644 print/templates/reports/entry-label/locale/es.yml create mode 100644 print/templates/reports/entry-label/options.json create mode 100644 print/templates/reports/entry-label/sql/entry.sql diff --git a/modules/entry/back/methods/entry/entryLabel.js b/modules/entry/back/methods/entry/entryLabel.js new file mode 100644 index 000000000..50e82b54c --- /dev/null +++ b/modules/entry/back/methods/entry/entryLabel.js @@ -0,0 +1,36 @@ +module.exports = Self => { + Self.remoteMethodCtx('entryLabel', { + description: 'Returns the entry labels', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The entry id', + http: {source: 'path'} + } + ], + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], + http: { + path: '/:id/entry-label', + verb: 'GET' + } + }); + + Self.entryLabel = (ctx, id) => Self.printReport(ctx, id, 'entry-label'); +}; diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 6148ae559..10f63b9f0 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -9,6 +9,7 @@ module.exports = Self => { require('../methods/entry/entryOrderPdf')(Self); require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); + require('../methods/entry/entryLabel')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/print/templates/reports/entry-label/assets/css/import.js b/print/templates/reports/entry-label/assets/css/import.js new file mode 100644 index 000000000..37a98dfdd --- /dev/null +++ b/print/templates/reports/entry-label/assets/css/import.js @@ -0,0 +1,12 @@ +const Stylesheet = require(`vn-print/core/stylesheet`); + +const path = require('path'); +const vnPrintPath = path.resolve('print'); + +module.exports = new Stylesheet([ + `${vnPrintPath}/common/css/spacing.css`, + `${vnPrintPath}/common/css/misc.css`, + `${vnPrintPath}/common/css/layout.css`, + `${vnPrintPath}/common/css/report.css`, + `${__dirname}/style.css`]) + .mergeStyles(); diff --git a/print/templates/reports/entry-label/assets/css/style.css b/print/templates/reports/entry-label/assets/css/style.css new file mode 100644 index 000000000..ccafa7078 --- /dev/null +++ b/print/templates/reports/entry-label/assets/css/style.css @@ -0,0 +1,58 @@ +html { + height: 100%; + margin-top: -6px; +} +* { + box-sizing: border-box; + font-family: "Roboto", "Helvetica", "Arial", sans-serif; + font-size: 28px; +} +table { + border: 1px solid; + width: 100%; + font-size: inherit; +} +td { + border: 1px solid; + padding: 5px; + width: 100%; +} +#barcode { + text-align: center; +} +span { + font-size: 48px; + font-weight: bold; +} +.lbl { + color: gray; + font-weight: lighter; + font-size: 18px; + display: block; +} +.flex-container { + display: flex; + justify-content: space-between; +} +.flex-item { + flex: 1; +} +.section { + height: 50px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +#variant { + width: 314px; +} +#producer { + width: 471px; +} +.cell { + width: 157px; +} + +#leftBox { + border-right: 1px solid; +} \ No newline at end of file diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/entry-label/entry-label.html new file mode 100644 index 000000000..6973adbea --- /dev/null +++ b/print/templates/reports/entry-label/entry-label.html @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Variedad: + {{buy.name}} +
+
+
+ Medida: + {{buy.size}} +
+
+
+ Categoría: + {{buy.category}} +
+
+
+ Color: + {{buy.color}} +
+
+
+ Origen: + {{buy.origin}} +
+
+
+ Packing: + {{buy.packing}} +
+
+
+ Grouping: + {{buy.grouping}} +
+
+
+ Und. venta: + {{buy.stems}} +
+
+
+ {{buy.id}} +
+
+ Productor: + {{buy.producer}} +
+
+
+
+ Control: + 06/11 +
+
+ Caja nº: + {{`${buy.labelNum} / ${maxLabelNum}`}} +
+
+
+ diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/entry-label/entry-label.js new file mode 100755 index 000000000..62186df4c --- /dev/null +++ b/print/templates/reports/entry-label/entry-label.js @@ -0,0 +1,36 @@ +const vnReport = require('../../../core/mixins/vn-report.js'); +const {DOMImplementation, XMLSerializer} = require('xmldom'); +const jsBarcode = require('jsbarcode'); + +module.exports = { + name: 'entry-label', + mixins: [vnReport], + async serverPrefetch() { + this.buys = await this.rawSqlFromDef('entry', [this.id]); + const maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); + this.maxLabelNum = maxLabelNum; + }, + methods: { + getBarcode(id) { + const xmlSerializer = new XMLSerializer(); + const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null); + const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + + jsBarcode(svgNode, id, { + xmlDocument: document, + format: 'code128', + displayValue: false, + width: 3.8, + height: 115, + }); + return xmlSerializer.serializeToString(svgNode); + } + }, + props: { + id: { + type: Number, + required: true, + description: 'The entry id' + } + } +}; diff --git a/print/templates/reports/entry-label/locale/es.yml b/print/templates/reports/entry-label/locale/es.yml new file mode 100644 index 000000000..278946f3e --- /dev/null +++ b/print/templates/reports/entry-label/locale/es.yml @@ -0,0 +1 @@ +reportName: Etiqueta \ No newline at end of file diff --git a/print/templates/reports/entry-label/options.json b/print/templates/reports/entry-label/options.json new file mode 100644 index 000000000..d2ed03e32 --- /dev/null +++ b/print/templates/reports/entry-label/options.json @@ -0,0 +1,11 @@ +{ + "width": "10cm", + "height": "10.3cm", + "margin": { + "top": "0.17cm", + "right": "0.2cm", + "bottom": "0cm", + "left": "0cm" + }, + "printBackground": true +} \ No newline at end of file diff --git a/print/templates/reports/entry-label/sql/entry.sql b/print/templates/reports/entry-label/sql/entry.sql new file mode 100644 index 000000000..21511df64 --- /dev/null +++ b/print/templates/reports/entry-label/sql/entry.sql @@ -0,0 +1,17 @@ +SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, + i.name, + i.`size`, + i.category, + ink.id color, + o.code origin, + b.packing, + b.`grouping`, + i.stems, + b.id, + p.name producer + FROM buy b + JOIN item i ON i.id = b.itemFk + LEFT JOIN producer p ON p.id = i.producerFk + LEFT JOIN ink ON ink.id = i.inkFk + LEFT JOIN origin o ON o.id = i.originFk + WHERE b.entryFk = ? \ No newline at end of file From 85c7336d923edccbac888dfd8f367744a8ed5a56 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 28 Jun 2024 14:52:19 +0200 Subject: [PATCH 106/114] refs #7644 Minor changes --- .../reports/entry-label/assets/css/style.css | 29 +++--------- .../reports/entry-label/entry-label.html | 46 +++++++++---------- .../reports/entry-label/entry-label.js | 3 +- .../reports/entry-label/options.json | 2 +- .../reports/entry-label/sql/entry.sql | 2 +- 5 files changed, 32 insertions(+), 50 deletions(-) diff --git a/print/templates/reports/entry-label/assets/css/style.css b/print/templates/reports/entry-label/assets/css/style.css index ccafa7078..0d4a2891d 100644 --- a/print/templates/reports/entry-label/assets/css/style.css +++ b/print/templates/reports/entry-label/assets/css/style.css @@ -1,10 +1,6 @@ html { - height: 100%; - margin-top: -6px; -} -* { - box-sizing: border-box; font-family: "Roboto", "Helvetica", "Arial", sans-serif; + margin-top: -7px; font-size: 28px; } table { @@ -17,9 +13,6 @@ td { padding: 5px; width: 100%; } -#barcode { - text-align: center; -} span { font-size: 48px; font-weight: bold; @@ -30,29 +23,19 @@ span { font-size: 18px; display: block; } -.flex-container { - display: flex; - justify-content: space-between; -} -.flex-item { - flex: 1; -} -.section { +.cell { + width: 157px; height: 50px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.barcode { + text-align: center; +} #variant { width: 314px; } #producer { width: 471px; -} -.cell { - width: 157px; -} - -#leftBox { - border-right: 1px solid; } \ No newline at end of file diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/entry-label/entry-label.html index 6973adbea..53980c534 100644 --- a/print/templates/reports/entry-label/entry-label.html +++ b/print/templates/reports/entry-label/entry-label.html @@ -4,14 +4,14 @@ -
- Variedad: +
+ Variedad {{buy.name}}
- Medida: + Medida {{buy.size}}
@@ -19,68 +19,68 @@
- Categoría: + Categoría {{buy.category}}
- Color: + Color {{buy.color}}
- Origen: - {{buy.origin}} + Origen + {{buy.code}}
- Packing: + Packing {{buy.packing}}
- Grouping: + Grouping {{buy.grouping}}
- Und. venta: + Ud. venta {{buy.stems}}
- +
{{buy.id}} -
- Productor: +
+ Productor {{buy.producer}}
- -
-
- Control: - 06/11 -
-
- Caja nº: - {{`${buy.labelNum} / ${maxLabelNum}`}} -
+ +
+ Control + 06 / 11 +
+ + +
+ Caja nº + {{`${buy.labelNum} / ${maxLabelNum}`}}
diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/entry-label/entry-label.js index 62186df4c..e3788261a 100755 --- a/print/templates/reports/entry-label/entry-label.js +++ b/print/templates/reports/entry-label/entry-label.js @@ -7,8 +7,7 @@ module.exports = { mixins: [vnReport], async serverPrefetch() { this.buys = await this.rawSqlFromDef('entry', [this.id]); - const maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); - this.maxLabelNum = maxLabelNum; + this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); }, methods: { getBarcode(id) { diff --git a/print/templates/reports/entry-label/options.json b/print/templates/reports/entry-label/options.json index d2ed03e32..4ed0461b3 100644 --- a/print/templates/reports/entry-label/options.json +++ b/print/templates/reports/entry-label/options.json @@ -1,6 +1,6 @@ { "width": "10cm", - "height": "10.3cm", + "height": "10cm", "margin": { "top": "0.17cm", "right": "0.2cm", diff --git a/print/templates/reports/entry-label/sql/entry.sql b/print/templates/reports/entry-label/sql/entry.sql index 21511df64..50b34bd03 100644 --- a/print/templates/reports/entry-label/sql/entry.sql +++ b/print/templates/reports/entry-label/sql/entry.sql @@ -3,7 +3,7 @@ SELECT ROW_NUMBER() OVER(ORDER BY b.id) labelNum, i.`size`, i.category, ink.id color, - o.code origin, + o.code, b.packing, b.`grouping`, i.stems, From 355e426ccf8213b4795e93ed7971d77dc7158c67 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 1 Jul 2024 07:19:00 +0200 Subject: [PATCH 107/114] mail-alias-account con mixin --- modules/account/back/models/mail-alias-account.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/account/back/models/mail-alias-account.json b/modules/account/back/models/mail-alias-account.json index 54e986ef7..46d4793e6 100644 --- a/modules/account/back/models/mail-alias-account.json +++ b/modules/account/back/models/mail-alias-account.json @@ -6,6 +6,9 @@ "table": "account.mailAliasAccount" } }, + "mixins": { + "Loggable": true + }, "properties": { "id": { "type": "number", From 7bf55c68154aeaa4771c12621bae19c75af123b5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 08:00:27 +0200 Subject: [PATCH 108/114] refs #7644 Added control source --- print/templates/reports/entry-label/entry-label.html | 2 +- print/templates/reports/entry-label/entry-label.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/entry-label/entry-label.html index 53980c534..65fbfb806 100644 --- a/print/templates/reports/entry-label/entry-label.html +++ b/print/templates/reports/entry-label/entry-label.html @@ -74,7 +74,7 @@
Control - 06 / 11 + {{`${weekNum} / ${dayNum}`}}
diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/entry-label/entry-label.js index e3788261a..08d2acc49 100755 --- a/print/templates/reports/entry-label/entry-label.js +++ b/print/templates/reports/entry-label/entry-label.js @@ -1,6 +1,7 @@ const vnReport = require('../../../core/mixins/vn-report.js'); const {DOMImplementation, XMLSerializer} = require('xmldom'); const jsBarcode = require('jsbarcode'); +const moment = require('moment'); module.exports = { name: 'entry-label', @@ -8,6 +9,9 @@ module.exports = { async serverPrefetch() { this.buys = await this.rawSqlFromDef('entry', [this.id]); this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); + const date = new Date(); + this.weekNum = moment(date).isoWeek(); + this.dayNum = moment(date).day(); }, methods: { getBarcode(id) { From 5c8d8ba2800d3496956681bc6ebcdc4bf9f628a4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 1 Jul 2024 09:07:36 +0200 Subject: [PATCH 109/114] refs #7644 Added locales and changed name of method --- .../entry/{entryLabel.js => buyLabel.js} | 8 +++---- modules/entry/back/models/entry.js | 2 +- .../assets/css/import.js | 0 .../assets/css/style.css | 0 .../buy-label.html} | 22 +++++++++---------- .../entry-label.js => buy-label/buy-label.js} | 4 ++-- .../templates/reports/buy-label/locale/en.yml | 12 ++++++++++ .../templates/reports/buy-label/locale/es.yml | 12 ++++++++++ .../{entry-label => buy-label}/options.json | 0 .../sql/entry.sql => buy-label/sql/buys.sql} | 0 .../reports/entry-label/locale/es.yml | 1 - 11 files changed, 42 insertions(+), 19 deletions(-) rename modules/entry/back/methods/entry/{entryLabel.js => buyLabel.js} (78%) rename print/templates/reports/{entry-label => buy-label}/assets/css/import.js (100%) rename print/templates/reports/{entry-label => buy-label}/assets/css/style.css (100%) rename print/templates/reports/{entry-label/entry-label.html => buy-label/buy-label.html} (73%) rename print/templates/reports/{entry-label/entry-label.js => buy-label/buy-label.js} (93%) create mode 100644 print/templates/reports/buy-label/locale/en.yml create mode 100644 print/templates/reports/buy-label/locale/es.yml rename print/templates/reports/{entry-label => buy-label}/options.json (100%) rename print/templates/reports/{entry-label/sql/entry.sql => buy-label/sql/buys.sql} (100%) delete mode 100644 print/templates/reports/entry-label/locale/es.yml diff --git a/modules/entry/back/methods/entry/entryLabel.js b/modules/entry/back/methods/entry/buyLabel.js similarity index 78% rename from modules/entry/back/methods/entry/entryLabel.js rename to modules/entry/back/methods/entry/buyLabel.js index 50e82b54c..650b05c97 100644 --- a/modules/entry/back/methods/entry/entryLabel.js +++ b/modules/entry/back/methods/entry/buyLabel.js @@ -1,6 +1,6 @@ module.exports = Self => { - Self.remoteMethodCtx('entryLabel', { - description: 'Returns the entry labels', + Self.remoteMethodCtx('buyLabel', { + description: 'Returns the entry buys labels', accessType: 'READ', accepts: [ { @@ -27,10 +27,10 @@ module.exports = Self => { } ], http: { - path: '/:id/entry-label', + path: '/:id/buy-label', verb: 'GET' } }); - Self.entryLabel = (ctx, id) => Self.printReport(ctx, id, 'entry-label'); + Self.buyLabel = (ctx, id) => Self.printReport(ctx, id, 'buy-label'); }; diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 10f63b9f0..6e27e1ece 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -9,7 +9,7 @@ module.exports = Self => { require('../methods/entry/entryOrderPdf')(Self); require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); - require('../methods/entry/entryLabel')(Self); + require('../methods/entry/buyLabel')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; diff --git a/print/templates/reports/entry-label/assets/css/import.js b/print/templates/reports/buy-label/assets/css/import.js similarity index 100% rename from print/templates/reports/entry-label/assets/css/import.js rename to print/templates/reports/buy-label/assets/css/import.js diff --git a/print/templates/reports/entry-label/assets/css/style.css b/print/templates/reports/buy-label/assets/css/style.css similarity index 100% rename from print/templates/reports/entry-label/assets/css/style.css rename to print/templates/reports/buy-label/assets/css/style.css diff --git a/print/templates/reports/entry-label/entry-label.html b/print/templates/reports/buy-label/buy-label.html similarity index 73% rename from print/templates/reports/entry-label/entry-label.html rename to print/templates/reports/buy-label/buy-label.html index 65fbfb806..494cdcbc5 100644 --- a/print/templates/reports/entry-label/entry-label.html +++ b/print/templates/reports/buy-label/buy-label.html @@ -5,13 +5,13 @@
- Variedad + {{$t('variety')}} {{buy.name}}
- Medida + {{$t('size')}} {{buy.size}}
@@ -19,19 +19,19 @@
- Categoría + {{$t('category')}} {{buy.category}}
- Color + {{$t('color')}} {{buy.color}}
- Origen + {{$t('origin')}} {{buy.code}}
@@ -39,19 +39,19 @@
- Packing + {{$t('packing')}} {{buy.packing}}
- Grouping + {{$t('grouping')}} {{buy.grouping}}
- Ud. venta + {{$t('saleUnit')}} {{buy.stems}}
@@ -65,7 +65,7 @@
- Productor + {{$t('producer')}} {{buy.producer}}
@@ -73,13 +73,13 @@
- Control + {{$t('control')}} {{`${weekNum} / ${dayNum}`}}
- Caja nº + {{$t('boxNum')}} {{`${buy.labelNum} / ${maxLabelNum}`}}
diff --git a/print/templates/reports/entry-label/entry-label.js b/print/templates/reports/buy-label/buy-label.js similarity index 93% rename from print/templates/reports/entry-label/entry-label.js rename to print/templates/reports/buy-label/buy-label.js index 08d2acc49..b6e0a5031 100755 --- a/print/templates/reports/entry-label/entry-label.js +++ b/print/templates/reports/buy-label/buy-label.js @@ -4,10 +4,10 @@ const jsBarcode = require('jsbarcode'); const moment = require('moment'); module.exports = { - name: 'entry-label', + name: 'buy-label', mixins: [vnReport], async serverPrefetch() { - this.buys = await this.rawSqlFromDef('entry', [this.id]); + this.buys = await this.rawSqlFromDef('buys', [this.id]); this.maxLabelNum = Math.max(...this.buys.map(buy => buy.labelNum)); const date = new Date(); this.weekNum = moment(date).isoWeek(); diff --git a/print/templates/reports/buy-label/locale/en.yml b/print/templates/reports/buy-label/locale/en.yml new file mode 100644 index 000000000..d48d00771 --- /dev/null +++ b/print/templates/reports/buy-label/locale/en.yml @@ -0,0 +1,12 @@ +reportName: Entry buys +variety: Bariety +size: Size +category: Category +color: Color +origin: Origin +packing: Packing +grouping: Grouping +unitSale: Un. sale +producer: Producer +control: Control +boxNum: Box no. \ No newline at end of file diff --git a/print/templates/reports/buy-label/locale/es.yml b/print/templates/reports/buy-label/locale/es.yml new file mode 100644 index 000000000..33a4a499d --- /dev/null +++ b/print/templates/reports/buy-label/locale/es.yml @@ -0,0 +1,12 @@ +reportName: Etiqueta de compras +variety: Variedad +size: Medida +category: Categoría +color: Color +origin: Origen +packing: Packing +grouping: Grouping +saleUnit: Sale un. +producer: Productor +control: Control +boxNum: Caja nº \ No newline at end of file diff --git a/print/templates/reports/entry-label/options.json b/print/templates/reports/buy-label/options.json similarity index 100% rename from print/templates/reports/entry-label/options.json rename to print/templates/reports/buy-label/options.json diff --git a/print/templates/reports/entry-label/sql/entry.sql b/print/templates/reports/buy-label/sql/buys.sql similarity index 100% rename from print/templates/reports/entry-label/sql/entry.sql rename to print/templates/reports/buy-label/sql/buys.sql diff --git a/print/templates/reports/entry-label/locale/es.yml b/print/templates/reports/entry-label/locale/es.yml deleted file mode 100644 index 278946f3e..000000000 --- a/print/templates/reports/entry-label/locale/es.yml +++ /dev/null @@ -1 +0,0 @@ -reportName: Etiqueta \ No newline at end of file From 3ad23465042d1476ce47f97c403a7752a489640e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 1 Jul 2024 09:25:00 +0200 Subject: [PATCH 110/114] feat refactor setParking REGEXP refs #7575 --- db/routines/vn/procedures/setParking.sql | 66 ++++++++++++------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/db/routines/vn/procedures/setParking.sql b/db/routines/vn/procedures/setParking.sql index 97a40bbe0..d6def07de 100644 --- a/db/routines/vn/procedures/setParking.sql +++ b/db/routines/vn/procedures/setParking.sql @@ -22,40 +22,42 @@ proc: BEGIN CALL util.throw('parkingNotExist'); LEAVE proc; END IF; + + IF vParam REGEXP '^[0-9]+$' THEN + -- Se comprueba si es una preparación previa + SELECT COUNT(*) INTO vIsSaleGroup + FROM vn.saleGroup sg + WHERE sg.id = vParam; - -- Se comprueba si es una preparación previa - SELECT COUNT(*) INTO vIsSaleGroup - FROM vn.saleGroup sg - WHERE sg.id = vParam; + IF vIsSaleGroup THEN + CALL vn.saleGroup_setParking(vParam, vParkingFk); + LEAVE proc; + END IF; - IF vIsSaleGroup THEN - CALL vn.saleGroup_setParking(vParam, vParkingFk); - LEAVE proc; + -- Se comprueba si es un ticket + SELECT COUNT(*) INTO vIsTicket + FROM vn.ticket t + WHERE t.id = vParam + AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + + IF vIsTicket THEN + CALL vn.ticket_setParking(vParam, vParkingFk); + LEAVE proc; + END IF; + + -- Se comprueba si es una coleccion de tickets + SELECT COUNT(*) INTO vIsCollection + FROM vn.collection c + WHERE c.id = vParam + AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); + + IF vIsCollection THEN + CALL vn.collection_setParking(vParam, vParkingFk); + LEAVE proc; + END IF; + ELSE + -- Por descarte, se considera una matrícula + CALL vn.shelving_setParking(vParam, vParkingFk); END IF; - - -- Se comprueba si es un ticket - SELECT COUNT(*) INTO vIsTicket - FROM vn.ticket t - WHERE t.id = vParam - AND t.shipped >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsTicket THEN - CALL vn.ticket_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Se comprueba si es una coleccion de tickets - SELECT COUNT(*) INTO vIsCollection - FROM vn.collection c - WHERE c.id = vParam - AND c.created >= TIMESTAMPADD(WEEK,-1,util.VN_CURDATE()); - - IF vIsCollection THEN - CALL vn.collection_setParking(vParam, vParkingFk); - LEAVE proc; - END IF; - - -- Por descarte, se considera una matrícula - CALL vn.shelving_setParking(vParam, vParkingFk); END$$ DELIMITER ; From 1561e15d5ed1e567996319ad00bf47d7d7889417 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 3 Jul 2024 09:21:58 +0200 Subject: [PATCH 111/114] feat roadmap refs #7195 --- back/models/warehouse.json | 107 ++++++++------ .../11081-wheatRaphis/00-firstScript.sql | 8 + .../roadmapStop/getPalletMatchState.js | 62 ++++++++ .../specs/getPalletMatchState.spec.js | 12 ++ modules/route/back/models/roadmap.json | 138 ++++++++++-------- modules/route/back/models/roadmapStop.js | 3 + modules/route/back/models/roadmapStop.json | 86 +++++------ 7 files changed, 262 insertions(+), 154 deletions(-) create mode 100644 db/versions/11081-wheatRaphis/00-firstScript.sql create mode 100644 modules/route/back/methods/roadmapStop/getPalletMatchState.js create mode 100644 modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js create mode 100644 modules/route/back/models/roadmapStop.js diff --git a/back/models/warehouse.json b/back/models/warehouse.json index f12b5e86e..756a538c0 100644 --- a/back/models/warehouse.json +++ b/back/models/warehouse.json @@ -1,48 +1,59 @@ -{ - "name": "Warehouse", - "description": "Warehouses from where orders are sent", - "base": "VnModel", - "options": { - "mysql": { - "table": "warehouse" - } - }, - "properties": { - "id": { - "id": true, - "type": "number", - "forceId": false - }, - "name": { - "type": "string" - }, - "code": { - "type": "string" - }, - "isInventory": { - "type": "number" - }, - "isManaged":{ - "type": "boolean" - }, - "countryFk": { - "type": "number" - } - }, - "relations": { - "country": { - "type": "belongsTo", - "model": "Country", - "foreignKey": "countryFk" - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ], - "scope" : {"where": {"isForTicket": {"neq": 0}}} -} +{ + "name": "Warehouse", + "description": "Warehouses from where orders are sent", + "base": "VnModel", + "options": { + "mysql": { + "table": "warehouse" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "forceId": false + }, + "name": { + "type": "string" + }, + "code": { + "type": "string" + }, + "isInventory": { + "type": "number" + }, + "isManaged": { + "type": "boolean" + }, + "countryFk": { + "type": "number" + } + }, + "relations": { + "country": { + "type": "belongsTo", + "model": "Country", + "foreignKey": "countryFk" + }, + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ], + "scope": { + "where": { + "isForTicket": { + "neq": 0 + } + } + } +} \ No newline at end of file diff --git a/db/versions/11081-wheatRaphis/00-firstScript.sql b/db/versions/11081-wheatRaphis/00-firstScript.sql new file mode 100644 index 000000000..2e4424c5a --- /dev/null +++ b/db/versions/11081-wheatRaphis/00-firstScript.sql @@ -0,0 +1,8 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.roadmap ADD kmStart mediumint(9) DEFAULT NULL NULL; +ALTER TABLE vn.roadmap ADD kmEnd mediumint(9) DEFAULT NULL NULL; +ALTER TABLE vn.roadmap ADD started DATETIME NULL; +ALTER TABLE vn.roadmap ADD finished DATETIME NULL; diff --git a/modules/route/back/methods/roadmapStop/getPalletMatchState.js b/modules/route/back/methods/roadmapStop/getPalletMatchState.js new file mode 100644 index 000000000..234c254c4 --- /dev/null +++ b/modules/route/back/methods/roadmapStop/getPalletMatchState.js @@ -0,0 +1,62 @@ +module.exports = Self => { + Self.remoteMethod('getPalletMatchState', { + description: 'Get list of pallet from truckFk with true or false if state is matched', + accessType: 'WRITE', + accepts: [{ + arg: 'truckFk', + type: 'number', + required: true, + description: 'The truckFk id' + }, + { + arg: 'state', + type: 'string', + required: true, + description: 'State code' + }], + returns: { + type: 'object', + root: true + }, + http: { + path: `/getPalletMatchState`, + verb: 'GET' + } + }); + + Self.getPalletMatchState = async(truckFk, state, options) => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const result = await Self.rawSql(` + WITH tPallet AS( + SELECT ep.id pallet, e.id expedition, e.stateTypeFk + FROM vn.expeditionPallet ep + JOIN vn.expeditionScan es ON es.palletFk = ep.id + JOIN expedition e ON e.id = es.expeditionFk + WHERE ep.truckFk = ? + ),totalPalletExpedition AS( + SELECT t.*, COUNT(expedition) totalPalletExpedition + FROM tPallet t + GROUP BY expedition + ),totalPalletExpeditionCode AS( + SELECT t.*, COUNT(expedition) totalPalletExpeditionCode + FROM tPallet t + JOIN vn.expeditionStateType est ON est.id = t.stateTypeFk + WHERE code = ? + GROUP BY expedition + ) + SELECT t.pallet, + tpe.totalPalletExpedition = tpec.totalPalletExpeditionCode hasMatchStateCode + FROM tPallet t + LEFT JOIN totalPalletExpedition tpe ON tpe.expedition = t.expedition + LEFT JOIN totalPalletExpeditionCode tpec ON tpec.expedition = t.expedition + GROUP BY t.pallet;`, + [truckFk, state], + myOptions); + + return result; + }; +}; diff --git a/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js new file mode 100644 index 000000000..24f742c76 --- /dev/null +++ b/modules/route/back/methods/roadmapStop/specs/getPalletMatchState.spec.js @@ -0,0 +1,12 @@ + +const {models} = require('vn-loopback/server/server'); + +describe('roadMapStop getPalletMatchState()', () => { + it('should return list of pallet with true or false if state is matched', async() => { + const truckFk = 1; + const state = 'ON DELIVERY'; + const result = await models.RoadmapStop.getPalletMatchState(truckFk, state); + + expect(result[0].hasMatchStateCode).toBe(1); + }); +}); diff --git a/modules/route/back/models/roadmap.json b/modules/route/back/models/roadmap.json index 01572d718..dcac035ce 100644 --- a/modules/route/back/models/roadmap.json +++ b/modules/route/back/models/roadmap.json @@ -1,63 +1,75 @@ -{ - "name": "Roadmap", - "base": "VnModel", - "options": { - "mysql": { - "table": "roadmap" - } - }, - "properties": { - "id": { - "type": "number", - "id": true, - "description": "Identifier" - }, - "name": { - "type": "string" - }, - "tractorPlate": { - "type": "string" - }, - "trailerPlate": { - "type": "string" - }, - "phone": { - "type": "string" - }, - "supplierFk": { - "type": "number" - }, - "etd": { - "type": "date" - }, - "observations": { - "type": "string" - }, - "userFk": { - "type": "number" - }, - "price": { - "type": "number" - }, - "driverName": { - "type": "string" - } - }, - "relations": { - "worker": { - "type": "belongsTo", - "model": "Worker", - "foreignKey": "id" - }, - "supplier": { - "type": "belongsTo", - "model": "Supplier", - "foreignKey": "supplierFk" - }, - "roadmapStop": { - "type": "hasMany", - "model": "RoadmapStop", - "foreignKey": "roadmapFk" - } - } -} +{ + "name": "Roadmap", + "base": "VnModel", + "options": { + "mysql": { + "table": "roadmap" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string" + }, + "tractorPlate": { + "type": "string" + }, + "trailerPlate": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "supplierFk": { + "type": "number" + }, + "etd": { + "type": "date" + }, + "observations": { + "type": "string" + }, + "userFk": { + "type": "number" + }, + "price": { + "type": "number" + }, + "driverName": { + "type": "string" + }, + "kmStart": { + "type": "number" + }, + "kmEnd": { + "type": "number" + }, + "started": { + "type": "date" + }, + "finished": { + "type": "date" + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "id" + }, + "supplier": { + "type": "belongsTo", + "model": "Supplier", + "foreignKey": "supplierFk" + }, + "roadmapStop": { + "type": "hasMany", + "model": "RoadmapStop", + "foreignKey": "roadmapFk" + } + } +} \ No newline at end of file diff --git a/modules/route/back/models/roadmapStop.js b/modules/route/back/models/roadmapStop.js new file mode 100644 index 000000000..1ce3f409e --- /dev/null +++ b/modules/route/back/models/roadmapStop.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/roadmapStop/getPalletMatchState')(Self); +}; diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json index 74b02cd7a..edd615aae 100644 --- a/modules/route/back/models/roadmapStop.json +++ b/modules/route/back/models/roadmapStop.json @@ -1,43 +1,43 @@ -{ - "name": "RoadmapStop", - "base": "VnModel", - "options": { - "mysql": { - "table": "roadmapStop" - } - }, - "properties": { - "id": { - "type": "number", - "id": true, - "description": "Identifier" - }, - "roadmapFk": { - "type": "number" - }, - "addressFk": { - "type": "number" - }, - "eta": { - "type": "date" - }, - "description": { - "type": "string" - }, - "userFk": { - "type": "number" - } - }, - "relations": { - "roadmap": { - "type": "belongsTo", - "model": "Roadmap", - "foreignKey": "roadmapFk" - }, - "address": { - "type": "belongsTo", - "model": "Address", - "foreignKey": "addressFk" - } - } -} +{ + "name": "RoadmapStop", + "base": "VnModel", + "options": { + "mysql": { + "table": "roadmapStop" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "roadmapFk": { + "type": "number" + }, + "addressFk": { + "type": "number" + }, + "eta": { + "type": "date" + }, + "description": { + "type": "string" + }, + "userFk": { + "type": "number" + } + }, + "relations": { + "roadmap": { + "type": "belongsTo", + "model": "Roadmap", + "foreignKey": "roadmapFk" + }, + "address": { + "type": "belongsTo", + "model": "RoadmapAddress", + "foreignKey": "addressFk" + } + } +} \ No newline at end of file From 108a62f73870e319ce1aab5132a317101fe4f817 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 4 Jul 2024 09:32:56 +0200 Subject: [PATCH 112/114] refs #7486 Fix tests --- db/routines/vn/procedures/collection_getAssigned.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/collection_getAssigned.sql b/db/routines/vn/procedures/collection_getAssigned.sql index bfaa3096b..947b53229 100644 --- a/db/routines/vn/procedures/collection_getAssigned.sql +++ b/db/routines/vn/procedures/collection_getAssigned.sql @@ -34,10 +34,10 @@ BEGIN pc.collection_assign_lockname INTO vHasTooMuchCollections, vLockName - FROM tCollection tc + FROM tmp.collection c JOIN productionConfig pc; - DROP TEMPORARY TABLE tCollection; + DROP TEMPORARY TABLE tmp.collection; IF vHasTooMuchCollections THEN CALL util.throw('There are pending collections'); From f3f450463b628ac57cb811985e3659519bf0fe70 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 5 Jul 2024 10:47:26 +0200 Subject: [PATCH 113/114] warmFix getSales refs #6861 --- back/methods/collection/getSales.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/back/methods/collection/getSales.js b/back/methods/collection/getSales.js index 8f5bfaeef..a9e5f2e60 100644 --- a/back/methods/collection/getSales.js +++ b/back/methods/collection/getSales.js @@ -60,15 +60,17 @@ module.exports = Self => { if (print) await Self.rawSql('CALL vn.collection_printSticker(?,NULL)', [id], myOptions); for (let ticket of tickets) { - let observations = ticket.observaciones.split(' '); + if (ticket.observaciones) { + let observations = ticket.observaciones.split(' '); - for (let observation of observations) { - const salesPerson = ticket.salesPersonFk; - if (observation.startsWith('#') || observation.startsWith('@')) { - await models.Chat.send(ctx, - observation, - $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson}) - ); + for (let observation of observations) { + const salesPerson = ticket.salesPersonFk; + if (observation.startsWith('#') || observation.startsWith('@')) { + await models.Chat.send(ctx, + observation, + $t('ticketCommercial', {ticket: ticket.ticketFk, salesPerson}) + ); + } } } } From f1276d6f560bf59baaaf01a7721957352bf0ef20 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 8 Jul 2024 14:51:50 +0200 Subject: [PATCH 114/114] changelog --- CHANGELOG.md | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b322f9f25..4572b137a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,83 @@ +# Version 24.28 - 2024-07-09 + +### Added 🆕 + +- feat boxPicking refs #7357 by:sergiodt +- feat boxPicking refs #7357 (origin/7357_dipole_review) by:sergiodt +- feat:concurrency issue refs #6861 by:Carlos Andrés +- feat expeditionPalletPrint refs #5210 by:sergiodt +- feat front-reservas refs #6861 (origin/6861-Reservas-front) by:sergiodt +- feat itemShelving_filterBuyer refs #7023 by:sergiodt +- feat itemShelvingLog refs #7168 by:sergiodt +- feat itemShelvingSale refs #6861 by:sergiodt +- feat: previas con reserva refs #6861 by:Carlos Andrés +- feat: previas con sitema de reservas refs #6861 by:Carlos Andrés +- feat: previas con sitema de reservas refs #6861 (origin/6861-Pasar-modo-trabajo-de-previa-a-reservas) by:Carlos Andrés +- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt +- feat: refs #6238 add travelKgPercentage table and model (origin/6238-addPercentage) by:jorgep +- feat: refs #6286 check if is teamBoss (origin/6286-setRightWorkerTimeControlAcls) by:jorgep +- feat: refs #6701 Fix error by:guillermo +- feat: refs #6861 trigger by:sergiodt +- feat: refs #7027 mailError managed by:jgallego +- feat: refs #7168 Added vRecords param in proc by:guillermo +- feat: refs #7168 Minor change by:guillermo +- feat: refs #7216 logUnpaid (origin/7216-clientUnpaid) by:jgallego +- feat: refs #7216 triggers by:jgallego +- feat: refs #7296 by:robert +- feat: refs #7296 drop column expeditionTruckFk by:robert +- feat: refs #7490 Changes (origin/7490-duaInvoiceInBooking) by:guillermo +- feat: refs #7545 Deleted hasIncoterms client column (origin/7545-hasIncoterms) by:guillermo +- feat: refs #7555 remove account.password__ by:alexm +- feat: return sql check error by:alexm +- feat roadmap refs #7195 by:sergiodt +- #refs 5890 feat:add assignCollection by:sergiodt +- refs#5890 feat: delete trigger and modify getTickets by:sergiodt +- refs #5890 feat:itemShelving_add by:sergiodt +- refs #5890 feat:reserves by:sergiodt +- refs #5890 feat:trigger by:sergiodt +- refs #5890 feat: triggers by:sergiodt +- refs #6861 feat: getLock by:sergiodt +- refs #6861 feat: obsrevation by:sergiodt +- refs #6861 feat: previas a reservas by:sergiodt +- refs #6861 feat:reserve previos by:sergiodt +- refs #6861 feat: reservePrevious by:sergiodt +- refs #6861 feat:reserveWithReservation by:sergiodt +- refs #6861 feat:sectoCollection reserve by:sergiodt +- refs #6861 feat: skipTest by:sergiodt +- refs #6861 feat: trigger by:sergiodt + +### Changed 📦 + +- feat refactor setParking REGEXP refs #7575 (origin/7575_setParking_regExp) by:sergiodt +- refactor: refs #5447 changed models by:Jon +- refactor: refs #6238 drop useless round by:jorgep +- refactor: refs #6286 replace name by:jorgep +- refactor: refs #6701 Refactor claim_ratio_routine by:guillermo +- refactor: refs #7490 Added final update by:guillermo +- refactor: refs #7490 Deleted update duaInvoiceInBooking by:guillermo +- refactor: refs #7490 Minor changes by:guillermo +- refactor: refs #7519 Minor change by:guillermo + +### Fixed 🛠️ + +- acls, fixtures, models by:carlossa +- fix: refs #6238 delete unused SQL script by:jorgep +- fix: refs #6238 insert ignore by:jorgep +- fix: refs #6238 use scheme by:jorgep +- fix: refs #6286 replace id for reason by:jorgep +- fix: refs #6286 update WorkerTimeControl permissions by:jorgep +- fix(WorkerIncome): refs #7409 fix models by:alexm +- refs #5890 fix: dev by:sergiodt +- refs #6897 fix entry Salix by:carlossa +- refs #6897 fix es.yml by:carlossa +- refs #6897 fix redirection by:carlossa +- refs #6897 fix remove by:carlossa +- refs #7406 fix back by:carlossa +- refs #7406 fix pr by:carlossa +- refs #7409 fix acls by:carlossa +- refs #7409 fix back (origin/7409-workerIncome) by:carlossa +- refs #7409 fix pr by:carlossa + # Version 24.24 - 2024-06-11 ### Added 🆕