refs #6493 refactorizar-procedimientos-vn2008-parte_2 #2235

Merged
jbreso merged 39 commits from 6493-refactorizar-procedimientos-vn2008-parte_2 into dev 2024-04-24 05:18:59 +00:00
1 changed files with 13 additions and 4 deletions
Showing only changes of commit f4b50dec3e - Show all commits

View File

@ -6,6 +6,15 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`(
IN vIsConsolidated BOOLEAN,
IN vInterGroupSalesIncluded BOOLEAN)
BEGIN
/**
* Crea un balance financiero para una empresa durante un período de tiempo determinado
jbreso marked this conversation as resolved Outdated

Sobrepasa los carácteres máximos x linea, a parte que al final va un punto

Sobrepasa los carácteres máximos x linea, a parte que al final va un punto
*
* @param vStartingMonth Mes de inicio del período
* @param vEndingMonth Mes de finalización del período
* @param vCompany Identificador de la empresa
* @param vIsConsolidated Indica si se trata de un balance consolidado
* @param vInterGroupSalesIncluded Indica si se incluyen las ventas dentro del grupo
jbreso marked this conversation as resolved
Review

Sobrepasa los caracteres máximos, acortar

Sobrepasa los caracteres máximos, acortar
*/
DECLARE intGAP INT DEFAULT 7;
DECLARE vYears INT DEFAULT 2;
DECLARE vYear TEXT;
@ -71,8 +80,8 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.balanceDetail
SELECT cr.companyId receivingId,
ci.companyId issuingId,
year(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`,
month(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`,
YEAR(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`,
MONTH(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`,
expenseFk,
SUM(taxableBase) amount
FROM invoiceIn r
@ -129,7 +138,7 @@ BEGIN
SET vQuery = CONCAT(
'UPDATE tmp.balance b
JOIN
(SELECT expenseFk, SUM(amount) as amount
(SELECT expenseFk, SUM(amount)
FROM tmp.balanceDetail
WHERE year = ?
GROUP BY expenseFk
@ -151,7 +160,7 @@ BEGIN
SUM(IF(year = ?, venta, 0)) y0,
c.Gasto
FROM bs.ventas_contables c
JOIN tCompanyReceiving cr on cr.companyId = c.empresa_id
JOIN tCompanyReceiving cr ON cr.companyId = c.empresa_id
WHERE month BETWEEN ? AND ?
GROUP BY c.Gasto
) sub ON sub.gasto = b.expenseFk COLLATE utf8_general_ci