7863-devToTest_2434 #2852

Merged
alexm merged 129 commits from 7863-devToTest_2434 into test 2024-08-13 06:50:25 +00:00
1 changed files with 33 additions and 35 deletions
Showing only changes of commit c4e8202261 - Show all commits

View File

@ -17,9 +17,12 @@ BEGIN
DECLARE vYear INT; DECLARE vYear INT;
DECLARE vSalesPersonFK INT; DECLARE vSalesPersonFK INT;
DECLARE vItemPicker INT; DECLARE vItemPicker INT;
DECLARE vTicketfailed INT; DECLARE vEmail VARCHAR(150);
DECLARE vIsDuplicateMail BOOL;
DECLARE vSubject VARCHAR(150);
DECLARE vMessage TEXT;
DECLARE rsTicket CURSOR FOR DECLARE vTickets CURSOR FOR
SELECT tt.ticketFk, SELECT tt.ticketFk,
t.clientFk, t.clientFk,
t.warehouseFk, t.warehouseFk,
@ -36,16 +39,11 @@ BEGIN
CALL `util`.`time_generate`(vDateFrom, vDateTo); CALL `util`.`time_generate`(vDateFrom, vDateTo);
OPEN rsTicket; OPEN vTickets;
myLoop: LOOP l: LOOP
BEGIN
DECLARE vSalesPersonEmail VARCHAR(150);
DECLARE vIsDuplicateMail BOOL;
DECLARE vSubject VARCHAR(150);
DECLARE vMessage TEXT;
SET vIsDone = FALSE; SET vIsDone = FALSE;
FETCH rsTicket INTO FETCH vTickets INTO
vTicketFk, vTicketFk,
vClientFk, vClientFk,
vWarehouseFk, vWarehouseFk,
@ -55,10 +53,10 @@ BEGIN
vShipment; vShipment;
IF vIsDone THEN IF vIsDone THEN
LEAVE myLoop; LEAVE l;
END IF; END IF;
-- busca si el ticket ya ha sido clonado -- Busca si el ticket ya ha sido clonado
IF EXISTS (SELECT TRUE FROM ticket tOrig IF EXISTS (SELECT TRUE FROM ticket tOrig
JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk JOIN sale saleOrig ON tOrig.id = saleOrig.ticketFk
JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id JOIN saleCloned sc ON sc.saleOriginalFk = saleOrig.id
@ -68,7 +66,7 @@ BEGIN
AND tClon.isDeleted = FALSE AND tClon.isDeleted = FALSE
AND DATE(tClon.shipped) = vShipment) AND DATE(tClon.shipped) = vShipment)
THEN THEN
ITERATE myLoop; ITERATE l;
END IF; END IF;
IF vAgencyModeFk IS NULL THEN IF vAgencyModeFk IS NULL THEN
@ -184,9 +182,9 @@ BEGIN
ON DUPLICATE KEY UPDATE description = ON DUPLICATE KEY UPDATE description =
CONCAT(ticketObservation.description,VALUES(description),' '); CONCAT(ticketObservation.description,VALUES(description),' ');
IF (vLanding IS NULL) THEN IF vLanding IS NULL THEN
SELECT IFNULL(d.notificationEmail,e.email) INTO vSalesPersonEmail SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail
FROM client c FROM client c
JOIN worker w ON w.id = c.salesPersonFk JOIN worker w ON w.id = c.salesPersonFk
JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk
@ -203,21 +201,21 @@ BEGIN
SELECT COUNT(*) INTO vIsDuplicateMail SELECT COUNT(*) INTO vIsDuplicateMail
FROM mail FROM mail
WHERE receiver = vSalesPersonEmail WHERE receiver = vEmail
AND subject = vSubject; AND subject = vSubject;
IF NOT vIsDuplicateMail THEN IF NOT vIsDuplicateMail THEN
CALL mail_insert(vSalesPersonEmail, NULL, vSubject, vMessage); CALL mail_insert(vEmail, NULL, vSubject, vMessage);
END IF; END IF;
CALL ticket_setState(vNewTicket, 'FIXING'); CALL ticket_setState(vNewTicket, 'FIXING');
ELSE ELSE
CALL ticketCalculateClon(vNewTicket, vTicketFk); CALL ticketCalculateClon(vNewTicket, vTicketFk);
END IF; END IF;
END;
END LOOP; END LOOP;
CLOSE rsTicket; CLOSE vTickets;
DROP TEMPORARY TABLE IF EXISTS tmp.time, tmp.zoneGetLanded; DROP TEMPORARY TABLE IF EXISTS
tmp.time,
tmp.zoneGetLanded;
END$$ END$$
DELIMITER ; DELIMITER ;