From cb539624056c6d88d182b27745daec7334c40eb9 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 17 Oct 2024 13:58:21 +0200 Subject: [PATCH] fix: refs #6861 saleTrackingAdd --- ...saleTracking_sectorCollectionAddPrevOK.sql | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql diff --git a/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql new file mode 100644 index 000000000..3ac31752a --- /dev/null +++ b/db/routines/vn/procedures/saleTracking_sectorCollectionAddPrevOK.sql @@ -0,0 +1,26 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`saleTracking_sectorCollectionAddPrevOK`(vSectorCollectionFk INT) +BEGIN +/** + * Inserta los registros de sectorCollection con el estado PREVIA OK si la reserva está picked + * + * @param vSectorCollectionFk Identificador de vn.sectorCollection + */ + REPLACE saleTracking( + saleFk, + isChecked, + workerFk, + stateFk + ) + SELECT sgd.saleFk, + TRUE, + sc.userFk, + s.id + FROM vn.sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk + WHERE sc.id = vSectorCollectionFk AND iss.isPicked; +END$$ +DELIMITER ;