diff --git a/db/routines/vn/procedures/ticket_doSelfConsumptionPackaging.sql b/db/routines/vn/procedures/ticket_doSelfConsumptionPackaging.sql index 0866118f3..4f2dc1401 100644 --- a/db/routines/vn/procedures/ticket_doSelfConsumptionPackaging.sql +++ b/db/routines/vn/procedures/ticket_doSelfConsumptionPackaging.sql @@ -15,16 +15,13 @@ BEGIN DECLARE vTicketFk INT; DECLARE vWarehouseFk INT; - SELECT clientSelfConsumptionFk, addressSelfConsumptionFk - INTO vClientFk, vAddressFk - FROM productionConfig; - - SELECT id INTO vWarehouseFk - FROM warehouse - WHERE code = 'alg'; + SELECT pc.clientSelfConsumptionFk, pc.addressSelfConsumptionFk, w.id + INTO vClientFk, vAddressFk, vWarehouseFk + FROM productionConfig pc + JOIN warehouse w ON w.code = 'alg'; INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk) - SELECT vClientFk, vWarehouseFk, vDateFrom, 'AUTOCONSUMO CAJAS', vAddressFk; + SELECT vClientFk, vWarehouseFk, vDateFrom, 'CAJAS AUTOCONSUMO', vAddressFk; SET vTicketFk = LAST_INSERT_ID();