7167-testToMaster_2414 #2244
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue