fix: refs #7018 Fix invoiceInTax_recalc
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-03-21 12:06:59 +01:00
parent 268c63ce8f
commit 535dd40625
1 changed files with 6 additions and 4 deletions

View File

@ -11,18 +11,20 @@ BEGIN
*/
DECLARE vRate DOUBLE DEFAULT 1;
DECLARE vDated DATE;
DECLARE vExpenseFk INT;
DECLARE vCurrencyFk INT;
DECLARE vExpenseFk VARCHAR(10);
SELECT MAX(rr.dated) INTO vDated
SELECT MAX(rr.dated), ii.currencyFk INTO vDated, vCurrencyFk
FROM referenceRate rr
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
WHERE rr.dated <= ii.issued
AND rr.currencyFk = ii.currencyFk;
IF vDated THEN
IF vDated AND vCurrencyFk THEN
SELECT `value` INTO vRate
FROM referenceRate
WHERE dated = vDated;
WHERE dated = vDated
AND currencyFk = vCurrencyFk;
END IF;
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;