fix: refs #7018 Fix invoiceInTax_recalc #2192

Merged
guillermo merged 3 commits from 7018-invoiceInTax_rec into dev 2024-03-22 06:38:51 +00:00
1 changed files with 4 additions and 9 deletions

View File

@ -10,20 +10,15 @@ BEGIN
* @param vInvoiceInFk Id de factura recibida
*/
DECLARE vRate DOUBLE DEFAULT 1;
DECLARE vDated DATE;
DECLARE vExpenseFk VARCHAR(10);
SELECT MAX(rr.dated) INTO vDated
SELECT `value` INTO vRate
FROM referenceRate rr
JOIN invoiceIn ii ON ii.id = vInvoiceInFk
WHERE rr.dated <= ii.issued
AND rr.currencyFk = ii.currencyFk;
IF vDated THEN
SELECT `value` INTO vRate
FROM referenceRate
WHERE dated = vDated;
END IF;
AND rr.currencyFk = ii.currencyFk
ORDER BY dated DESC
LIMIT 1;
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;