From 4c0dec19d415f384d2701ff8b90f7179dbd4ee21 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 4 Nov 2024 07:48:28 +0100 Subject: [PATCH 1/6] feat: refs #7266 buyFkForPrint --- db/routines/vn/procedures/itemShelving_get.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 606bb8bd9..58163a89f 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -17,7 +17,8 @@ BEGIN s.priority, ish.isChecked, ic.url, - ish.available + ish.available, + ish.buyFk FROM itemShelving ish JOIN item i ON i.id = ish.itemFk JOIN shelving s ON vSelf = s.code COLLATE utf8_unicode_ci From 37548e5e646cc40faee6c31a73c22274f20f78b4 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 4 Nov 2024 08:59:10 +0100 Subject: [PATCH 2/6] feat: refs #7266 buyFkForPrint --- db/routines/vn/procedures/itemShelving_get.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/itemShelving_get.sql b/db/routines/vn/procedures/itemShelving_get.sql index 58163a89f..07384b721 100644 --- a/db/routines/vn/procedures/itemShelving_get.sql +++ b/db/routines/vn/procedures/itemShelving_get.sql @@ -7,9 +7,10 @@ BEGIN * @param vSelf matrícula del carro **/ SELECT ish.itemFk item, - IFNULL(i.longName, CONCAT(i.name, ' ', i.size)) description, + i.name, + i.longName, + i.size, ish.visible, - CEIL(ish.visible/ish.packing) stickers, ish.packing, ish.grouping, p.code, From 85ded59cb36ecd3c894be58a45cb9d2b36eb7b28 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 4 Nov 2024 13:46:54 +0100 Subject: [PATCH 3/6] refactor: refs #6920 add correct role --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 595027b09..f25a4aab4 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2454,7 +2454,7 @@ INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`, ` INSERT INTO `vn`.`dmsType` (`id`, `name`, `readRoleFk`, `writeRoleFk`, `code`) VALUES - (1, 'Facturas Recibidas', NULL, NULL, 'invoiceIn'), + (1, 'Facturas Recibidas', 1, 1, 'invoiceIn'), (2, 'Doc oficial', NULL, NULL, 'officialDoc'), (3, 'Laboral', 37, 37, 'hhrrData'), (4, 'Albaranes recibidos', NULL, NULL, 'deliveryNote'), From c113d837972177d1fb2ce320847deb536d6ae7e3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 5 Nov 2024 16:42:51 +0100 Subject: [PATCH 4/6] feat: refs #6845 userInterface --- .../vn/procedures/collection_getTickets.sql | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/collection_getTickets.sql b/db/routines/vn/procedures/collection_getTickets.sql index fed7a3eb6..a468d7582 100644 --- a/db/routines/vn/procedures/collection_getTickets.sql +++ b/db/routines/vn/procedures/collection_getTickets.sql @@ -30,7 +30,9 @@ BEGIN t.warehouseFk, w.id salesPersonFk, IFNULL(ob.description,'') observaciones, - cc.rgb + cc.rgb, + p.code parkingCode, + IF (ps.ticketFk, TRUE, FALSE) isAdvanced FROM vn.ticket t LEFT JOIN vn.ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk @@ -42,7 +44,10 @@ BEGIN 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 + LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking p ON tp.parkingFk = p.id + LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id WHERE t.id = vParamFk AND t.shipped >= vYesterday UNION @@ -52,7 +57,9 @@ BEGIN t.warehouseFk, w.id salesPersonFk, ob.description, - IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb` + IF(NOT (vItemPackingTypeFk <=> 'V'), cc.rgb, NULL) `rgb`, + p.code parkingCode, + IF (ps.ticketFk, TRUE, FALSE) isAdvanced FROM vn.ticket t JOIN vn.ticketCollection tc ON t.id = tc.ticketFk LEFT JOIN vn.collection c2 ON c2.id = tc.collectionFk @@ -64,7 +71,10 @@ BEGIN 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 + LEFT JOIN observation ob ON ob.ticketFk = t.id + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking p ON tp.parkingFk = p.id + LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id WHERE tc.collectionFk = vParamFk UNION SELECT sg.ticketFk, @@ -73,7 +83,9 @@ BEGIN t.warehouseFk, c.salesPersonFk, ob.description, - NULL `rgb` + NULL `rgb`, + p.code parkingCode, + IF (ps.ticketFk, TRUE, FALSE) isAdvanced FROM vn.sectorCollection sc JOIN vn.sectorCollectionSaleGroup ss ON ss.sectorCollectionFk = sc.id JOIN vn.saleGroup sg ON sg.id = ss.saleGroupFk @@ -81,7 +93,10 @@ BEGIN 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 vn.client c ON c.id = t.clientFk + LEFT JOIN vn.client c ON c.id = t.clientFk + LEFT JOIN vn.ticketParking tp ON tp.ticketFk = t.id + LEFT JOIN vn.parking p ON tp.parkingFk = p.id + LEFT JOIN vn.packingSiteAdvanced ps ON ps.ticketFk = t.id WHERE sc.id = vParamFk AND t.shipped >= vYesterday GROUP BY ticketFk; From d95e455ccf9ca542fd4e9b832e942bb0be1be966 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 7 Nov 2024 14:48:31 +0100 Subject: [PATCH 5/6] fix: refs #7935 sin modificar autonomy --- db/versions/11274-redGerbera/00-firstScript4.sql | 1 - 1 file changed, 1 deletion(-) delete mode 100644 db/versions/11274-redGerbera/00-firstScript4.sql diff --git a/db/versions/11274-redGerbera/00-firstScript4.sql b/db/versions/11274-redGerbera/00-firstScript4.sql deleted file mode 100644 index c1f574379..000000000 --- a/db/versions/11274-redGerbera/00-firstScript4.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.autonomy MODIFY COLUMN isUeeMember tinyint(1) DEFAULT FALSE NOT NULL; \ No newline at end of file From a254cb19cda0fd44fdbe6cf668924f39a57a92e2 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 11 Nov 2024 07:40:17 +0100 Subject: [PATCH 6/6] feat: refs #4948 Added ticket_selfConsumptionPackaging --- .../expedition_selfConsumptionPackaging.sql | 93 +++++++++++++++++++ .../vn/triggers/expedition_afterDelete.sql | 2 + 2 files changed, 95 insertions(+) create mode 100644 db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql diff --git a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql new file mode 100644 index 000000000..43660f215 --- /dev/null +++ b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql @@ -0,0 +1,93 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expedition_selfConsumptionPackaging`( + vSelf INT, + vAction ENUM('add', 'remove') +) +BEGIN +/** + * Maneja el consumo de cajas para autoconsumo, permitiendo + * añadir o quitar cajas utilizadas según la acción indicada. + * + * @param vSelf Id de expedición + */ + DECLARE vClientFk INT; + DECLARE vAddressFk INT; + DECLARE vItemFk INT; + DECLARE vItemName VARCHAR(50); + DECLARE vWarehouseFk INT; + DECLARE vCreated DATE; + DECLARE vTicketFk INT; + DECLARE vSaleFk INT; + DECLARE vQuantity INT; + + IF vAction NOT IN ('add', 'remove') THEN + CALL util.throw('Action not supported'); + END IF; + + SELECT pc.clientSelfConsumptionFk, + pc.addressSelfConsumptionFk, + i.id, + i.name, + t.warehouseFk, + e.created + INTO vClientFk, + vAddressFk, + vItemFk, + vItemName, + vWarehouseFk, + vCreated + FROM expedition e + JOIN packaging p ON p.id = e.packagingFk + JOIN item i ON i.id = p.itemFk + JOIN ticket t ON t.id = e.ticketFk + JOIN productionConfig pc + WHERE e.id = vSelf; + + IF vClientFk IS NULL OR vAddressFk IS NULL THEN + CALL util.throw('Some config parameters are not set'); + END IF; + + SET vCreated = DATE(vCreated); + + SELECT id INTO vTicketFk + FROM ticket + WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated) + AND clientFk = vClientFk + AND addressFk = vAddressFk + AND warehouseFk = vWarehouseFk; + + IF vTicketFk IS NULL AND vAction = 'add' THEN + INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk) + VALUES (vClientFk, vWarehouseFk, vCreated, 'CAJAS AUTOCONSUMO', vAddressFk); + + SET vTicketFk = LAST_INSERT_ID(); + END IF; + + SELECT id, quantity INTO vSaleFk, vQuantity + FROM sale + WHERE itemFk = vItemFk + AND ticketFk = vTicketFk + LIMIT 1; + + IF vAction = 'add' THEN + IF vSaleFk IS NOT NULL THEN + UPDATE sale + SET quantity = quantity + 1 + WHERE id = vSaleFk; + ELSE + INSERT INTO sale(itemFk, ticketFk, concept, quantity) + VALUES (vItemFk, vTicketFk, vItemName, 1); + END IF; + ELSE + IF vSaleFk IS NOT NULL THEN + IF vQuantity > 1 THEN + UPDATE sale + SET quantity = quantity - 1 + WHERE id = vSaleFk; + ELSE + DELETE FROM sale WHERE id = vSaleFk; + END IF; + END IF; + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/expedition_afterDelete.sql b/db/routines/vn/triggers/expedition_afterDelete.sql index 5d74a71e5..0a9a37375 100644 --- a/db/routines/vn/triggers/expedition_afterDelete.sql +++ b/db/routines/vn/triggers/expedition_afterDelete.sql @@ -8,5 +8,7 @@ BEGIN `changedModel` = 'Expedition', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); + + CALL expedition_selfConsumptionPackaging(OLD.id, 'remove'); END$$ DELIMITER ;