This commit is contained in:
parent
b6abcbe090
commit
b56260af36
|
@ -136,11 +136,11 @@ BEGIN
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN vn.alertLevel al ON al.code = 'FREE'
|
JOIN vn.alertLevel al ON al.code = 'FREE'
|
||||||
LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
|
LEFT JOIN tPrevia tp ON tp.ticketFk = t.id
|
||||||
LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id
|
LEFT JOIN vn.ticketState tls ON tls.ticketFk = t.id
|
||||||
JOIN hedera.`order` o ON o.address_id = t.addressFk
|
JOIN hedera.`order` o ON o.address_id = t.addressFk
|
||||||
|
AND t.shipped BETWEEN vShipment AND vShipmentDayEnd
|
||||||
AND t.warehouseFk = vWarehouseFk
|
AND t.warehouseFk = vWarehouseFk
|
||||||
AND o.date_send = t.landed
|
AND o.date_send = t.landed
|
||||||
AND t.shipped BETWEEN vShipment AND vShipmentDayEnd
|
|
||||||
WHERE o.id = vSelf
|
WHERE o.id = vSelf
|
||||||
AND t.refFk IS NULL
|
AND t.refFk IS NULL
|
||||||
AND tp.ticketFk IS NULL
|
AND tp.ticketFk IS NULL
|
||||||
|
@ -150,7 +150,9 @@ BEGIN
|
||||||
-- Comprobamos si hay un ticket de previa disponible
|
-- Comprobamos si hay un ticket de previa disponible
|
||||||
IF vTicketFk IS NULL THEN
|
IF vTicketFk IS NULL THEN
|
||||||
WITH tItemPackingTypeOrder AS (
|
WITH tItemPackingTypeOrder AS (
|
||||||
SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes,
|
SELECT GROUP_CONCAT(
|
||||||
|
DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk
|
||||||
|
) distinctItemPackingTypes,
|
||||||
o.address_id
|
o.address_id
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
JOIN orderRow oro ON oro.itemFk = i.id
|
JOIN orderRow oro ON oro.itemFk = i.id
|
||||||
|
@ -159,16 +161,20 @@ BEGIN
|
||||||
),
|
),
|
||||||
tItemPackingTypeTicket AS (
|
tItemPackingTypeTicket AS (
|
||||||
SELECT t.id,
|
SELECT t.id,
|
||||||
GROUP_CONCAT(DISTINCT i.itemPackingTypeFk) distinctItemPackingTypes
|
GROUP_CONCAT(
|
||||||
|
DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk
|
||||||
|
) distinctItemPackingTypes
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN vn.alertLevel al ON al.code = 'ON_PREVIOUS'
|
JOIN vn.ticketState tls ON tls.ticketFk = t.id
|
||||||
|
JOIN vn.alertLevel al ON al.id = tls.alertLevel
|
||||||
JOIN vn.sale s ON s.ticketFk = t.id
|
JOIN vn.sale s ON s.ticketFk = t.id
|
||||||
JOIN vn.item i ON i.id = s.itemFk
|
JOIN vn.item i ON i.id = s.itemFk
|
||||||
JOIN tItemPackingTypeOrder ipto
|
JOIN tItemPackingTypeOrder ipto
|
||||||
WHERE t.refFk IS NULL
|
WHERE t.shipped BETWEEN vShipment AND vShipmentDayEnd
|
||||||
AND t.shipped BETWEEN vShipment AND vShipmentDayEnd
|
AND t.refFk IS NULL
|
||||||
AND t.warehouseFk = vWarehouseFk
|
AND t.warehouseFk = vWarehouseFk
|
||||||
AND t.addressFk = ipto.address_id
|
AND t.addressFk = ipto.address_id
|
||||||
|
AND al.code = 'ON_PREVIOUS'
|
||||||
GROUP BY t.id
|
GROUP BY t.id
|
||||||
)
|
)
|
||||||
SELECT iptt.id INTO vTicketFk
|
SELECT iptt.id INTO vTicketFk
|
||||||
|
|
Loading…
Reference in New Issue