7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
1 changed files with 4 additions and 11 deletions
Showing only changes of commit ee67820c20 - Show all commits

View File

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