feat: refs #7531 Added address_hasDelivery
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
1aa1fbda6c
commit
a666cfa4cd
|
@ -1,7 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`address_hasDelivery`(
|
||||||
vSelf INT,
|
vSelf INT,
|
||||||
vAgencyModeFk INT,
|
vZoneFk INT,
|
||||||
vLanded DATE
|
vLanded DATE
|
||||||
)
|
)
|
||||||
RETURNS BOOL
|
RETURNS BOOL
|
||||||
|
@ -12,10 +12,16 @@ BEGIN
|
||||||
* la dirección y fecha solicitada.
|
* la dirección y fecha solicitada.
|
||||||
*
|
*
|
||||||
* @param vSelf Id de dirección de envío
|
* @param vSelf Id de dirección de envío
|
||||||
|
* @param vZoneFk Id de zona
|
||||||
* @param vLanded Fecha de entrega
|
* @param vLanded Fecha de entrega
|
||||||
* @return true|false
|
* @return true|false
|
||||||
*/
|
*/
|
||||||
DECLARE vHasDelivery BOOL;
|
DECLARE vHasDelivery BOOL;
|
||||||
|
DECLARE vAgencyModeFk INT;
|
||||||
|
|
||||||
|
SELECT agencyModeFk INTO vAgencyModeFk
|
||||||
|
FROM `zone`
|
||||||
|
WHERE id = vZoneFk;
|
||||||
|
|
||||||
CALL zone_getAgency(vSelf, vLanded);
|
CALL zone_getAgency(vSelf, vLanded);
|
||||||
|
|
||||||
|
@ -23,6 +29,7 @@ BEGIN
|
||||||
SELECT TRUE
|
SELECT TRUE
|
||||||
FROM tmp.zoneGetAgency
|
FROM tmp.zoneGetAgency
|
||||||
WHERE agencyModeFk = vAgencyModeFk
|
WHERE agencyModeFk = vAgencyModeFk
|
||||||
|
AND zoneFk = vZoneFk
|
||||||
) INTO vHasDelivery;
|
) INTO vHasDelivery;
|
||||||
|
|
||||||
RETURN vHasDelivery;
|
RETURN vHasDelivery;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`(
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`zone_getAddresses`(
|
||||||
vSelf INT,
|
vSelf INT,
|
||||||
vShipped DATE,
|
vLanded DATE,
|
||||||
vDepartmentFk INT
|
vDepartmentFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
|
@ -11,22 +11,16 @@ BEGIN
|
||||||
* vender producto para esa zona.
|
* vender producto para esa zona.
|
||||||
*
|
*
|
||||||
* @param vSelf Id de zona
|
* @param vSelf Id de zona
|
||||||
* @param vShipped Fecha de envio
|
* @param vLanded Fecha de entrega
|
||||||
* @param vDepartmentFk Id de departamento
|
* @param vDepartmentFk Id de departamento
|
||||||
* @return Un select
|
* @return Un select
|
||||||
*/
|
*/
|
||||||
DECLARE vAgencyModeFk INT;
|
|
||||||
|
|
||||||
SELECT agencyModeFk INTO vAgencyModeFk
|
|
||||||
FROM `zone`
|
|
||||||
WHERE id = vSelf;
|
|
||||||
|
|
||||||
CALL zone_getPostalCode(vSelf);
|
CALL zone_getPostalCode(vSelf);
|
||||||
|
|
||||||
WITH clientWithTicket AS (
|
WITH clientWithTicket AS (
|
||||||
SELECT clientFk
|
SELECT DISTINCT clientFk
|
||||||
FROM vn.ticket
|
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
|
AND NOT isDeleted
|
||||||
)
|
)
|
||||||
SELECT c.id,
|
SELECT c.id,
|
||||||
|
@ -37,7 +31,7 @@ BEGIN
|
||||||
u.name username,
|
u.name username,
|
||||||
aai.invoiced,
|
aai.invoiced,
|
||||||
cnb.lastShipped,
|
cnb.lastShipped,
|
||||||
cwt.clientFk
|
IF(cwt.clientFk, TRUE, FALSE) hasTicket
|
||||||
FROM vn.client c
|
FROM vn.client c
|
||||||
JOIN vn.worker w ON w.id = c.salesPersonFk
|
JOIN vn.worker w ON w.id = c.salesPersonFk
|
||||||
JOIN vn.workerDepartment wd ON wd.workerFk = w.id
|
JOIN vn.workerDepartment wd ON wd.workerFk = w.id
|
||||||
|
@ -58,7 +52,7 @@ BEGIN
|
||||||
AND ct.code = 'normal'
|
AND ct.code = 'normal'
|
||||||
AND bt.code <> 'worker'
|
AND bt.code <> 'worker'
|
||||||
AND (d.id = vDepartmentFk OR vDepartmentFk IS NULL)
|
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;
|
GROUP BY c.id;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.zoneNodes;
|
DROP TEMPORARY TABLE tmp.zoneNodes;
|
||||||
|
|
Loading…
Reference in New Issue