This commit is contained in:
parent
317f898c2e
commit
d0b926b2c5
|
@ -24,6 +24,16 @@ BEGIN
|
|||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
UPDATE invoiceIn ii
|
||||
JOIN entry e ON e.invoiceInFk = ii.id
|
||||
JOIN duaEntry de ON de.entryFk = e.id
|
||||
JOIN dua d ON d.id = de.duaFk
|
||||
SET ii.booked = IFNULL(ii.booked, d.booked),
|
||||
ii.operated = IFNULL(ii.operated, d.operated),
|
||||
ii.issued = IFNULL(ii.issued, d.issued),
|
||||
ii.bookEntried = IFNULL(ii.bookEntried, d.bookEntried)
|
||||
WHERE d.id = vDuaFk;
|
||||
|
||||
SELECT ASIEN INTO vBookEntry FROM dua WHERE id = vDuaFk;
|
||||
|
||||
IF vBookEntry IS NULL THEN
|
||||
|
@ -65,21 +75,21 @@ BEGIN
|
|||
JOIN (
|
||||
WITH entries AS (
|
||||
SELECT e.id, de.duaFk
|
||||
FROM `entry` e
|
||||
FROM `entry` e
|
||||
JOIN duaEntry de ON de.entryFk = e.id
|
||||
WHERE de.duaFk = vDuaFk
|
||||
AND (NOT e.isBooked OR NOT e.isConfirmed)
|
||||
),
|
||||
notBookedEntries AS (
|
||||
SELECT e.id
|
||||
FROM entries e
|
||||
JOIN duaEntry de ON de.entryFk = e.id
|
||||
JOIN dua d ON d.id = de.duaFk
|
||||
WHERE d.ASIEN IS NULL)
|
||||
SELECT e.id
|
||||
FROM duaEntry
|
||||
WHERE duaFk = vDuaFk
|
||||
AND NOT customsValue
|
||||
)
|
||||
SELECT e.id
|
||||
FROM entries e
|
||||
LEFT JOIN notBookedEntries nbe ON nbe.id = e.id
|
||||
WHERE nbe.id IS NULL
|
||||
LEFT JOIN notBookedEntries nbe ON nbe.entryFk = e.id
|
||||
WHERE nbe.entryFk IS NULL
|
||||
) sub ON sub.id = e.id
|
||||
SET e.isBooked = TRUE,
|
||||
e.isConfirmed = TRUE;
|
||||
|
|
Loading…
Reference in New Issue