7152-devToTest_2414 #2228
|
@ -29,7 +29,7 @@ BEGIN
|
||||||
LEAVE l;
|
LEAVE l;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL invoiceInTax_insert(vInvoiceInFk);
|
CALL invoiceInTax_recalc(vInvoiceInFk);
|
||||||
CALL invoiceInDueDay_recalc(vInvoiceInFk);
|
CALL invoiceInDueDay_recalc(vInvoiceInFk);
|
||||||
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_insert`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceInTax_recalc`(
|
||||||
vSelf INT
|
vInvoiceInFk INT
|
||||||
)
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Inserta los impuestos de una factura, ajustando por
|
* Recalcula y actualiza los impuestos de la factura
|
||||||
* tasa de cambio y detalles de compra.
|
* usando la última tasa de cambio y detalles de compra.
|
||||||
*
|
*
|
||||||
* @param vSelf Id de invoiceInTax
|
* @param vInvoiceInFk Id de factura recibida
|
||||||
*/
|
*/
|
||||||
DECLARE vRate DOUBLE DEFAULT 1;
|
DECLARE vRate DOUBLE DEFAULT 1;
|
||||||
DECLARE vDated DATE;
|
DECLARE vDated DATE;
|
||||||
|
@ -15,7 +15,7 @@ BEGIN
|
||||||
|
|
||||||
SELECT MAX(rr.dated) INTO vDated
|
SELECT MAX(rr.dated) INTO vDated
|
||||||
FROM referenceRate rr
|
FROM referenceRate rr
|
||||||
JOIN invoiceIn ii ON ii.id = vSelf
|
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;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ BEGIN
|
||||||
WHERE dated = vDated;
|
WHERE dated = vDated;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
DELETE FROM invoiceInTax WHERE invoiceInFk = vSelf;
|
DELETE FROM invoiceInTax WHERE invoiceInFk = vInvoiceInFk;
|
||||||
|
|
||||||
SELECT id INTO vExpenseFk
|
SELECT id INTO vExpenseFk
|
||||||
FROM expense
|
FROM expense
|
||||||
|
@ -56,7 +56,7 @@ BEGIN
|
||||||
JOIN buy b ON b.entryFk = e.id
|
JOIN buy b ON b.entryFk = e.id
|
||||||
LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
|
LEFT JOIN referenceRate rr ON rr.currencyFk = ii.currencyFk
|
||||||
AND rr.dated = ii.issued
|
AND rr.dated = ii.issued
|
||||||
WHERE ii.id = vSelf
|
WHERE ii.id = vInvoiceInFk
|
||||||
HAVING bi IS NOT NULL;
|
HAVING bi IS NOT NULL;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
Loading…
Reference in New Issue