feat: refs #7531 Added address_hasDelivery #3361

Merged
guillermo merged 9 commits from 7531-addressHasDelivery into master 2025-01-20 06:51:19 +00:00
1 changed files with 9 additions and 8 deletions

View File

@ -1,26 +1,27 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`(
vSelf INT,
vShipped DATE,
vLanded DATE,
vDepartmentFk INT
)
BEGIN
/**
* Devuelve un listado de todos los clientes activos
* con consignatarios a los que se les puede
* vender producto para esa zona.
* entregar producto para esa zona.
*
* @param vSelf Id de zona
* @param vShipped Fecha de envio
* @param vDepartmentFk Id de departamento
* @param vLanded Fecha de entrega
* @param vDepartmentFk Id de departamento | NULL para mostrar todos
* @return Un select
*/
CALL zone_getPostalCode(vSelf);
WITH clientWithTicket AS (
SELECT clientFk
SELECT DISTINCT clientFk
FROM vn.ticket
WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped)
WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded)
AND NOT isDeleted
)
SELECT c.id,
c.name,
@ -30,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
@ -50,7 +51,7 @@ BEGIN
AND c.isActive
AND ct.code = 'normal'
AND bt.code <> 'worker'
AND (d.id = vDepartmentFk OR NOT vDepartmentFk)
AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL)
GROUP BY c.id;
DROP TEMPORARY TABLE tmp.zoneNodes;