refs #7531 Modify zone_getAddresses #2675

Merged
guillermo merged 5 commits from 7531-Modify-zone_getAddresses into dev 2024-07-30 10:02:12 +00:00
1 changed files with 39 additions and 37 deletions

View File

@ -1,40 +1,41 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAddresses`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getAddresses`(
vSelf INT, vSelf INT,
vLanded DATE vShipped DATE,
vDepartmentFk INT
ivanm marked this conversation as resolved Outdated

vDepartmentFk

vDepartmentFk
) )
BEGIN BEGIN
/** /**
* Devuelve un listado de todos los clientes activos * Devuelve un listado de todos los clientes activos
* con consignatarios a los que se les puede * con consignatarios a los que se les puede
* vender producto para esa zona y no tiene un ticket * vender producto para esa zona.
* para ese día.
* *
* @param vSelf Id de zona * @param vSelf Id de zona
* @param vDated Fecha de entrega * @param vShipped Fecha de envio
* @param vDepartmentFk Id de departamento
* @return Un select * @return Un select
ivanm marked this conversation as resolved Outdated

vDepartmentFk Id de departamento

vDepartmentFk Id de departamento
*/ */
CALL zone_getPostalCode(vSelf); CALL zone_getPostalCode(vSelf);
WITH notHasTicket AS ( WITH clientWithTicket AS (
SELECT id
FROM vn.client
WHERE id NOT IN (
SELECT clientFk SELECT clientFk
FROM vn.ticket FROM vn.ticket
WHERE landed BETWEEN vLanded AND util.dayEnd(vLanded) WHERE shipped BETWEEN vShipped AND util.dayEnd(vShipped)
) )
ivanm marked this conversation as resolved
Review

notHasTicket crec que te sobra

notHasTicket crec que te sobra
) SELECT c.id,
SELECT c.id clientFk,
c.name, c.name,
c.phone, c.phone,
bt.description, bt.description,
c.salesPersonFk, c.salesPersonFk,
u.name username, u.name username,
ivanm marked this conversation as resolved
Review

hasTickets (today no es correcte perque li pots pasar una altra fetxa que no siga hui)

hasTickets (today no es correcte perque li pots pasar una altra fetxa que no siga hui)
aai.invoiced, aai.invoiced,
ivanm marked this conversation as resolved
Review

Aço queda mes net aixina:

		SELECT DISTINCT clientFk
			FROM vn.ticket
			WHERE shipped BETWEEN vDated AND util.dayEnd(vDated)
Aço queda mes net aixina: ``` SELECT DISTINCT clientFk FROM vn.ticket WHERE shipped BETWEEN vDated AND util.dayEnd(vDated) ```
cnb.lastShipped cnb.lastShipped,
cwt.clientFk
FROM vn.client c FROM vn.client c
ivanm marked this conversation as resolved
Review

Si li preguntares i volia per shipped ok

Si li preguntares i volia per shipped ok
JOIN notHasTicket ON notHasTicket.id = c.id JOIN vn.worker w ON w.id = c.salesPersonFk
JOIN vn.workerDepartment wd ON wd.workerFk = w.id
JOIN vn.department d ON d.id = wd.departmentFk
LEFT JOIN clientWithTicket cwt ON cwt.clientFk = c.id
LEFT JOIN account.`user` u ON u.id = c.salesPersonFk LEFT JOIN account.`user` u ON u.id = c.salesPersonFk
JOIN vn.`address` a ON a.clientFk = c.id JOIN vn.`address` a ON a.clientFk = c.id
JOIN vn.postCode pc ON pc.code = a.postalCode JOIN vn.postCode pc ON pc.code = a.postalCode
@ -49,6 +50,7 @@ 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)
ivanm marked this conversation as resolved Outdated

Soporta que pueda ser null:
(d.id = vDepartmentFk OR NOT vDepartmentFk)

Soporta que pueda ser null: `(d.id = vDepartmentFk OR NOT vDepartmentFk)`
Outdated
Review

Cert, també demana els que no tinguen comercial/departament assignat. Ho modifique.

Cert, també demana els que no tinguen comercial/departament assignat. Ho modifique.
GROUP BY c.id; GROUP BY c.id;
DROP TEMPORARY TABLE tmp.zoneNodes; DROP TEMPORARY TABLE tmp.zoneNodes;