feat: refs #6500 procRefactor8 #2131

Merged
robert merged 28 commits from 6500-procRefactor8 into dev 2024-04-17 11:32:54 +00:00
1 changed files with 14 additions and 20 deletions
Showing only changes of commit e83b0622cf - Show all commits

View File

@ -2,9 +2,7 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`()
BEGIN
robert marked this conversation as resolved Outdated

falta descripción

falta descripción
DECLARE v10Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 10 YEAR;
SELECT
SELECT
t.year,
t.month,
pagos.dollars,
@ -15,28 +13,24 @@ BEGIN
JOIN time t ON t.dated = ii.issued
JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk
JOIN
(
SELECT
t.year,
t.month,
CAST(SUM(divisa) AS DECIMAL(10,2)) dollars,
CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical,
CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial
FROM payment p
JOIN time t ON t.dated = p.received
JOIN referenceRate rr ON rr.dated = p.received
JOIN currency c ON c.id = rr.currencyFk
WHERE divisa
AND p.received >= v10Years
AND c.code = 'USD'
GROUP BY t.year, t.month
( SELECT
t.year,
t.month,
CAST(SUM(divisa) AS DECIMAL(10,2)) dollars,
CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical,
CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial
robert marked this conversation as resolved Outdated

faltan alias, no se sabe de que tablas vienen los campos

faltan alias, no se sabe de que tablas vienen los campos
FROM payment p
JOIN time t ON t.dated = p.received
JOIN referenceRate rr ON rr.dated = p.received
JOIN currency c ON c.id = rr.currencyFk
WHERE divisa
AND c.code = 'USD'
GROUP BY t.year, t.month
) pagos ON t.year = pagos.year AND t.month = pagos.MONTH
JOIN currency c ON c.id = ii.currencyFk
WHERE c.code = 'USD'
robert marked this conversation as resolved Outdated

En la medida de lo posible no se debe de escribir en español, en este caso el nombre de la subconsulta es totalmente evitable que este en español, traducir

En la medida de lo posible no se debe de escribir en español, en este caso el nombre de la subconsulta es totalmente evitable que este en español, traducir
AND ii.issued >= v10Years
AND iit.foreignValue
AND iit.taxableBase
GROUP BY t.year, t.month;
END$$
DELIMITER ;