7691-testToMaster #2703

Merged
alexm merged 268 commits from 7691-testToMaster into master 2024-07-09 05:38:28 +00:00
1 changed files with 28 additions and 5 deletions
Showing only changes of commit fb4be69cf1 - Show all commits

View File

@ -29,7 +29,7 @@ BEGIN
IF vBookEntry IS NULL THEN IF vBookEntry IS NULL THEN
SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear SELECT YEAR(IFNULL(ii.bookEntried, d.bookEntried)) INTO vFiscalYear
FROM invoiceIn ii FROM invoiceIn ii
JOIN entry e ON e.invoiceInFk = ii.id JOIN `entry` e ON e.invoiceInFk = ii.id
JOIN duaEntry de ON de.entryFk = e.id JOIN duaEntry de ON de.entryFk = e.id
JOIN dua d ON d.id = de.duaFk JOIN dua d ON d.id = de.duaFk
WHERE d.id = vDuaFk WHERE d.id = vDuaFk
@ -60,5 +60,28 @@ l: LOOP
JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id JOIN duaInvoiceIn dii ON dii.invoiceInFk = ii.id
SET ii.isBooked = TRUE SET ii.isBooked = TRUE
WHERE dii.duaFk = vDuaFk; WHERE dii.duaFk = vDuaFk;
UPDATE `entry` e
JOIN (
WITH entries AS (
SELECT e.id, de.duaFk
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 entries e
LEFT JOIN notBookedEntries nbe ON nbe.id = e.id
WHERE nbe.id IS NULL
) sub ON sub.id = e.id
SET e.isBooked = TRUE,
e.isConfirmed = TRUE;
END$$ END$$
DELIMITER ; DELIMITER ;