This commit is contained in:
parent
268c63ce8f
commit
535dd40625
|
@ -11,18 +11,20 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vRate DOUBLE DEFAULT 1;
|
DECLARE vRate DOUBLE DEFAULT 1;
|
||||||
DECLARE vDated DATE;
|
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
|
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;
|
||||||
|
|
||||||
IF vDated THEN
|
IF vDated AND vCurrencyFk THEN
|
||||||
SELECT `value` INTO vRate
|
SELECT `value` INTO vRate
|
||||||
FROM referenceRate
|
FROM referenceRate
|
||||||
WHERE dated = vDated;
|
WHERE dated = vDated
|
||||||
|
AND currencyFk = vCurrencyFk;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
|
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
|
||||||
|
|
Loading…
Reference in New Issue