feat: refs #7774 #7774 Changes ticket_cloneWeekly
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-08-12 09:02:38 +02:00
parent c4e8202261
commit 3cf2cec946
1 changed files with 22 additions and 30 deletions

View File

@ -4,7 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_cloneWeekly`
vDateTo DATE
)
BEGIN
DECLARE vIsDone BOOL;
DECLARE vLanding DATE;
DECLARE vShipment DATE;
DECLARE vWarehouseFk INT;
@ -15,12 +14,15 @@ BEGIN
DECLARE vAgencyModeFk INT;
DECLARE vNewTicket INT;
DECLARE vYear INT;
DECLARE vSalesPersonFK INT;
DECLARE vItemPicker INT;
DECLARE vEmail VARCHAR(150);
DECLARE vObservationSalesPersonFk INT
DEFAULT (SELECT id FROM observationType WHERE code = 'salesPerson');
DECLARE vObservationItemPickerFk INT
DEFAULT (SELECT id FROM observationType WHERE code = 'itemPicker');
DECLARE vEmail VARCHAR(255);
DECLARE vIsDuplicateMail BOOL;
DECLARE vSubject VARCHAR(150);
DECLARE vSubject VARCHAR(100);
DECLARE vMessage TEXT;
DECLARE vDone BOOL;
DECLARE vTickets CURSOR FOR
SELECT tt.ticketFk,
@ -35,14 +37,13 @@ BEGIN
JOIN tmp.time ti
WHERE WEEKDAY(ti.dated) = tt.weekDay;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
CALL `util`.`time_generate`(vDateFrom, vDateTo);
OPEN vTickets;
l: LOOP
SET vIsDone = FALSE;
SET vDone = FALSE;
FETCH vTickets INTO
vTicketFk,
vClientFk,
@ -52,7 +53,7 @@ BEGIN
vAgencyModeFk,
vShipment;
IF vIsDone THEN
IF vDone THEN
LEAVE l;
END IF;
@ -106,15 +107,15 @@ BEGIN
priceFixed,
isPriceFixed)
SELECT vNewTicket,
saleOrig.itemFk,
saleOrig.concept,
saleOrig.quantity,
saleOrig.price,
saleOrig.discount,
saleOrig.priceFixed,
saleOrig.isPriceFixed
FROM sale saleOrig
WHERE saleOrig.ticketFk = vTicketFk;
itemFk,
concept,
quantity,
price,
discount,
priceFixed,
isPriceFixed
FROM sale
WHERE ticketFk = vTicketFk;
INSERT IGNORE INTO saleCloned(saleOriginalFk, saleClonedFk)
SELECT saleOriginal.id, saleClon.id
@ -151,15 +152,7 @@ BEGIN
attenderFk,
vNewTicket
FROM ticketRequest
WHERE ticketFk =vTicketFk;
SELECT id INTO vSalesPersonFK
FROM observationType
WHERE code = 'salesPerson';
SELECT id INTO vItemPicker
FROM observationType
WHERE code = 'itemPicker';
WHERE ticketFk = vTicketFk;
INSERT INTO ticketObservation(
ticketFk,
@ -167,7 +160,7 @@ BEGIN
description)
VALUES(
vNewTicket,
vSalesPersonFK,
vObservationSalesPersonFk,
CONCAT('turno desde ticket: ',vTicketFk))
ON DUPLICATE KEY UPDATE description =
CONCAT(ticketObservation.description,VALUES(description),' ');
@ -177,13 +170,12 @@ BEGIN
description)
VALUES(
vNewTicket,
vItemPicker,
vObservationItemPickerFk,
'ATENCION: Contiene lineas de TURNO')
ON DUPLICATE KEY UPDATE description =
CONCAT(ticketObservation.description,VALUES(description),' ');
IF vLanding IS NULL THEN
SELECT IFNULL(d.notificationEmail, e.email) INTO vEmail
FROM client c
JOIN worker w ON w.id = c.salesPersonFk