From 2eed2f00a94a5cab000a8c4c047c31726aa85cab Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 26 Nov 2024 09:01:04 +0100 Subject: [PATCH] fix: refs #4948 ticket_selfConsumptionPackaging --- .../procedures/expedition_selfConsumptionPackaging.sql | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql index 43660f215..330292f62 100644 --- a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql +++ b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`expedition_selfConsum vSelf INT, vAction ENUM('add', 'remove') ) -BEGIN +proc:BEGIN /** * Maneja el consumo de cajas para autoconsumo, permitiendo * añadir o quitar cajas utilizadas según la acción indicada. @@ -37,8 +37,8 @@ BEGIN vWarehouseFk, vCreated FROM expedition e - JOIN packaging p ON p.id = e.packagingFk - JOIN item i ON i.id = p.itemFk + LEFT JOIN packaging p ON p.id = e.packagingFk + LEFT JOIN item i ON i.id = p.itemFk JOIN ticket t ON t.id = e.ticketFk JOIN productionConfig pc WHERE e.id = vSelf; @@ -47,6 +47,10 @@ BEGIN CALL util.throw('Some config parameters are not set'); END IF; + IF vItemFk IS NULL THEN + LEAVE proc; + END IF; + SET vCreated = DATE(vCreated); SELECT id INTO vTicketFk