7383-testToMaster #2445
|
@ -6,6 +6,15 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`balance_create`(
|
||||||
IN vIsConsolidated BOOLEAN,
|
IN vIsConsolidated BOOLEAN,
|
||||||
IN vInterGroupSalesIncluded BOOLEAN)
|
IN vInterGroupSalesIncluded BOOLEAN)
|
||||||
BEGIN
|
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 intGAP INT DEFAULT 7;
|
||||||
DECLARE vYears INT DEFAULT 2;
|
DECLARE vYears INT DEFAULT 2;
|
||||||
DECLARE vYear TEXT;
|
DECLARE vYear TEXT;
|
||||||
|
@ -71,8 +80,8 @@ BEGIN
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.balanceDetail
|
CREATE OR REPLACE TEMPORARY TABLE tmp.balanceDetail
|
||||||
SELECT cr.companyId receivingId,
|
SELECT cr.companyId receivingId,
|
||||||
ci.companyId issuingId,
|
ci.companyId issuingId,
|
||||||
year(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`,
|
YEAR(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `year`,
|
||||||
month(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`,
|
MONTH(IFNULL(r.bookEntried,IFNULL(r.booked, r.issued))) `month`,
|
||||||
expenseFk,
|
expenseFk,
|
||||||
SUM(taxableBase) amount
|
SUM(taxableBase) amount
|
||||||
FROM invoiceIn r
|
FROM invoiceIn r
|
||||||
|
@ -129,7 +138,7 @@ BEGIN
|
||||||
SET vQuery = CONCAT(
|
SET vQuery = CONCAT(
|
||||||
'UPDATE tmp.balance b
|
'UPDATE tmp.balance b
|
||||||
JOIN
|
JOIN
|
||||||
(SELECT expenseFk, SUM(amount) as amount
|
(SELECT expenseFk, SUM(amount)
|
||||||
FROM tmp.balanceDetail
|
FROM tmp.balanceDetail
|
||||||
WHERE year = ?
|
WHERE year = ?
|
||||||
GROUP BY expenseFk
|
GROUP BY expenseFk
|
||||||
|
@ -151,7 +160,7 @@ BEGIN
|
||||||
SUM(IF(year = ?, venta, 0)) y0,
|
SUM(IF(year = ?, venta, 0)) y0,
|
||||||
c.Gasto
|
c.Gasto
|
||||||
FROM bs.ventas_contables c
|
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 ?
|
WHERE month BETWEEN ? AND ?
|
||||||
GROUP BY c.Gasto
|
GROUP BY c.Gasto
|
||||||
) sub ON sub.gasto = b.expenseFk COLLATE utf8_general_ci
|
) sub ON sub.gasto = b.expenseFk COLLATE utf8_general_ci
|
||||||
|
|
Loading…
Reference in New Issue