feat: refs#6493 modificar procedimiento balance_create
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Juanjo Breso 2024-03-25 09:41:16 +01:00
parent f2a1d401ca
commit f4b50dec3e
1 changed files with 13 additions and 4 deletions

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
*
* @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
*/
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