fix: refs #7018 Fix invoiceInTax_recalc #2192
|
@ -10,20 +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 vExpenseFk VARCHAR(10);
|
DECLARE vExpenseFk VARCHAR(10);
|
||||||
|
|
||||||
SELECT MAX(rr.dated) INTO vDated
|
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 THEN
|
LIMIT 1;
|
||||||
SELECT `value` INTO vRate
|
|
||||||
FROM referenceRate
|
|
||||||
WHERE dated = vDated;
|
|
||||||
END IF;
|
|
||||||
|
|
||||||
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
|
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue