feat: refs #7531 Added address_hasDelivery
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Guillermo Bonet 2025-01-15 12:26:16 +01:00
parent d95482ea54
commit c2ca9cfbe5
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,24 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`(vSelf INT, vLanded DATE)
RETURNS BOOL
DETERMINISTIC
BEGIN
/**
* Retorna si hay reparto disponible para
* la dirección y fecha solicitada.
*
* @param vSelf Id de dirección de envío
* @param vLanded Fecha de entrega
* @return true|false
*/
DECLARE vHasDelivery BOOL;
CALL zone_getAgency(vSelf, vLanded);
SELECT EXISTS (SELECT TRUE FROM tmp.zoneGetAgency) INTO vHasDelivery;
RETURN vHasDelivery;
DROP TEMPORARY TABLE tmp.zoneGetAgency;
END$$
DELIMITER ;

View File

@ -21,6 +21,7 @@ BEGIN
SELECT clientFk SELECT clientFk
FROM vn.ticket FROM vn.ticket
WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped) WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped)
AND NOT isDeleted
) )
SELECT c.id, SELECT c.id,
c.name, c.name,
@ -50,7 +51,8 @@ BEGIN
AND c.isActive AND c.isActive
AND ct.code = 'normal' AND ct.code = 'normal'
AND bt.code <> 'worker' AND bt.code <> 'worker'
AND (d.id = vDepartmentFk OR NOT vDepartmentFk) AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL)
AND vn.address_hasDelivery(c.defaultAddressFk, vShipped)
GROUP BY c.id; GROUP BY c.id;
DROP TEMPORARY TABLE tmp.zoneNodes; DROP TEMPORARY TABLE tmp.zoneNodes;