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-17 09:40:07 +01:00
parent 1aa1fbda6c
commit a666cfa4cd
2 changed files with 14 additions and 13 deletions

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`(
vSelf INT,
vAgencyModeFk INT,
vZoneFk INT,
vLanded DATE
)
RETURNS BOOL
@ -12,10 +12,16 @@ BEGIN
* la dirección y fecha solicitada.
*
* @param vSelf Id de dirección de envío
* @param vZoneFk Id de zona
* @param vLanded Fecha de entrega
* @return true|false
*/
DECLARE vHasDelivery BOOL;
DECLARE vAgencyModeFk INT;
SELECT agencyModeFk INTO vAgencyModeFk
FROM `zone`
WHERE id = vZoneFk;
CALL zone_getAgency(vSelf, vLanded);
@ -23,6 +29,7 @@ BEGIN
SELECT TRUE
FROM tmp.zoneGetAgency
WHERE agencyModeFk = vAgencyModeFk
AND zoneFk = vZoneFk
) INTO vHasDelivery;
RETURN vHasDelivery;

View File

@ -1,7 +1,7 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`(
vSelf INT,
vShipped DATE,
vLanded DATE,
vDepartmentFk INT
)
BEGIN
@ -11,22 +11,16 @@ BEGIN
* vender producto para esa zona.
*
* @param vSelf Id de zona
* @param vShipped Fecha de envio
* @param vLanded Fecha de entrega
* @param vDepartmentFk Id de departamento
* @return Un select
*/
DECLARE vAgencyModeFk INT;
SELECT agencyModeFk INTO vAgencyModeFk
FROM `zone`
WHERE id = vSelf;
CALL zone_getPostalCode(vSelf);
WITH clientWithTicket AS (
SELECT clientFk
SELECT DISTINCT clientFk
FROM vn.ticket
WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped)
WHERE shipped BETWEEN vLanded - INTERVAL 1 DAY AND util.dayEnd(vLanded - INTERVAL 1 DAY)
AND NOT isDeleted
)
SELECT c.id,
@ -37,7 +31,7 @@ BEGIN
u.name username,
aai.invoiced,
cnb.lastShipped,
cwt.clientFk
IF(cwt.clientFk, TRUE, FALSE) hasTicket
FROM vn.client c
JOIN vn.worker w ON w.id = c.salesPersonFk
JOIN vn.workerDepartment wd ON wd.workerFk = w.id
@ -58,7 +52,7 @@ BEGIN
AND ct.code = 'normal'
AND bt.code <> 'worker'
AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL)
AND vn.address_hasDelivery(c.defaultAddressFk, vAgencyModeFk, vShipped)
AND vn.address_hasDelivery(c.defaultAddressFk, vSelf, vLanded)
GROUP BY c.id;
DROP TEMPORARY TABLE tmp.zoneNodes;