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

This commit is contained in:
Guillermo Bonet 2024-06-12 14:26:26 +02:00
parent 317f898c2e
commit d0b926b2c5
1 changed files with 18 additions and 8 deletions

View File

@ -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;