feat: #6392 migrado de database
This commit is contained in:
parent
6d01164fb3
commit
6f4c0f655d
|
@ -1,7 +1,7 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`ventas_contables_add`(IN vYear INT, IN vMonth INT)
|
||||
BEGIN
|
||||
|
||||
|
||||
/**
|
||||
* Reemplaza las ventas contables del último año.
|
||||
* Es el origen de datos para el balance de Entradas
|
||||
|
@ -13,8 +13,8 @@ BEGIN
|
|||
|
||||
DECLARE TIPO_PATRIMONIAL INT DEFAULT 188;
|
||||
|
||||
DELETE FROM bs.ventas_contables
|
||||
WHERE year = vYear
|
||||
DELETE FROM bs.ventas_contables
|
||||
WHERE year = vYear
|
||||
AND month = vMonth;
|
||||
|
||||
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list;
|
||||
|
@ -25,7 +25,7 @@ BEGIN
|
|||
FROM vn2008.Tickets t
|
||||
JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura
|
||||
WHERE year(f.Fecha) = vYear
|
||||
AND month(f.Fecha) = vMonth;
|
||||
AND month(f.Fecha) = vMonth;
|
||||
|
||||
INSERT INTO bs.ventas_contables(year
|
||||
, month
|
||||
|
@ -35,7 +35,7 @@ BEGIN
|
|||
, tipo_id
|
||||
, empresa_id
|
||||
, gasto)
|
||||
|
||||
|
||||
SELECT vYear
|
||||
, vMonth
|
||||
, round(sum(Cantidad * Preu * (100 - m.Descuento)/100))
|
||||
|
@ -47,13 +47,13 @@ BEGIN
|
|||
, tp.reino_id
|
||||
, a.tipo_id
|
||||
, t.empresa_id
|
||||
, 7000000000
|
||||
, a.expenseFk
|
||||
+ IF(e.empresa_grupo = e2.empresa_grupo
|
||||
,1
|
||||
,IF(e2.empresa_grupo,2,0)
|
||||
) * 1000000
|
||||
+ tp.reino_id * 10000 as Gasto
|
||||
FROM vn2008.Movimientos m
|
||||
) * 100000
|
||||
+ tp.reino_id * 1000 as Gasto
|
||||
FROM vn2008.Movimientos m
|
||||
JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket
|
||||
JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna
|
||||
JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente
|
||||
|
@ -67,7 +67,7 @@ BEGIN
|
|||
AND m.Descuento <> 100
|
||||
AND a.tipo_id != TIPO_PATRIMONIAL
|
||||
GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto;
|
||||
|
||||
|
||||
INSERT INTO bs.ventas_contables(year
|
||||
, month
|
||||
, venta
|
||||
|
@ -86,17 +86,17 @@ BEGIN
|
|||
) as grupo
|
||||
, NULL
|
||||
, NULL
|
||||
, t.companyFk
|
||||
, t.companyFk
|
||||
, 7050000000
|
||||
FROM vn.ticketService ts
|
||||
FROM vn.ticketService ts
|
||||
JOIN vn.ticket t ON ts.ticketFk = t.id
|
||||
JOIN vn.address a on a.id = t.addressFk
|
||||
JOIN vn.client cl on cl.id = a.clientFk
|
||||
JOIN vn.address a on a.id = t.addressFk
|
||||
JOIN vn.client cl on cl.id = a.clientFk
|
||||
JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id
|
||||
JOIN vn.company c on c.id = t.companyFk
|
||||
JOIN vn.company c on c.id = t.companyFk
|
||||
LEFT JOIN vn.company c2 on c2.clientFk = cl.id
|
||||
GROUP BY grupo, t.companyFk ;
|
||||
|
||||
GROUP BY grupo, t.companyFk ;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.ticket_list;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
DELETE FROM vn2008.Gastos
|
||||
WHERE Id_Gasto='' AND Gasto IS NULL AND isWithheld=FALSE;
|
||||
UPDATE vn.expense
|
||||
SET id='7002090000'
|
||||
WHERE id='7002009000';
|
||||
UPDATE vn.expense
|
||||
SET id='7001090000'
|
||||
WHERE id='7001009000';
|
||||
UPDATE vn2008.balance_nest_tree
|
||||
SET Id_Gasto='7001090000'
|
||||
WHERE Id_Gasto='7001009000';
|
|
@ -0,0 +1,5 @@
|
|||
-- Eliminar la clave primaria actual
|
||||
ALTER TABLE bs.ventas_contables DROP PRIMARY KEY;
|
||||
|
||||
-- Agregar la nueva clave primaria incluyendo el campo `gasto`
|
||||
ALTER TABLE bs.ventas_contables ADD PRIMARY KEY (`year`, `month`, `grupo`, `reino_id`, `tipo_id`, `empresa_id`, `gasto`);
|
|
@ -0,0 +1,45 @@
|
|||
UPDATE vn2008.balance_nest_tree
|
||||
SET Id_Gasto = CASE Id_Gasto
|
||||
WHEN 7000010000 THEN 7001001000
|
||||
WHEN 7000020000 THEN 7001002000
|
||||
WHEN 7000030000 THEN 7001003000
|
||||
WHEN 7000040000 THEN 7001004000
|
||||
WHEN 7000050000 THEN 7001005000
|
||||
WHEN 7000060000 THEN 7001006000
|
||||
WHEN 7000070000 THEN 7001007000
|
||||
WHEN 7002060000 THEN 7001206000
|
||||
WHEN 7002070000 THEN 7001207000
|
||||
WHEN 7002030000 THEN 7001203000
|
||||
WHEN 7002040000 THEN 7001204000
|
||||
WHEN 7002050000 THEN 7001205000
|
||||
WHEN 7002020000 THEN 7001202000
|
||||
WHEN 7002010000 THEN 7001201000
|
||||
WHEN 7001060000 THEN 7001106000
|
||||
WHEN 7001070000 THEN 7001107000
|
||||
WHEN 7001030000 THEN 7001103000
|
||||
WHEN 7001040000 THEN 7001104000
|
||||
WHEN 7001050000 THEN 7001105000
|
||||
WHEN 7001020000 THEN 7001102000
|
||||
WHEN 7001010000 THEN 7001101000
|
||||
WHEN 7000080000 THEN 7000008000
|
||||
WHEN 7001080000 THEN 7000108000
|
||||
WHEN 7002080000 THEN 7000208000
|
||||
WHEN 7000090000 THEN 7000009000
|
||||
WHEN 7000100000 THEN 7000010000
|
||||
WHEN 7002090000 THEN 7000209000
|
||||
WHEN 7002100000 THEN 7000210000
|
||||
WHEN 7001090000 THEN 7000109000
|
||||
WHEN 7001100000 THEN 7000110000
|
||||
WHEN 7000120000 THEN 7000012000
|
||||
WHEN 7002120000 THEN 7000212000
|
||||
WHEN 7000130000 THEN 7000013000
|
||||
WHEN 7000140000 THEN 7000014000
|
||||
ELSE Id_Gasto
|
||||
END
|
||||
WHERE Id_Gasto IN (7000010000, 7000020000, 7000030000, 7000040000, 7000050000,
|
||||
7000060000, 7000070000, 7002060000, 7002070000, 7002030000,
|
||||
7002040000, 7002050000, 7002020000, 7002010000, 7001060000,
|
||||
7001070000, 7001030000, 7001040000, 7001050000, 7001020000,
|
||||
7001010000, 7000080000, 7001080000, 7002080000, 7000090000,
|
||||
7000100000, 7002090000, 7002100000, 7001090000, 7001100000,
|
||||
7000120000, 7002120000, 7000130000, 7000140000);
|
|
@ -0,0 +1,46 @@
|
|||
/*UPDATE vn.expense
|
||||
SET id = CASE id
|
||||
WHEN 7000010000 THEN 7001001000
|
||||
WHEN 7000020000 THEN 7001002000
|
||||
WHEN 7000030000 THEN 7001003000
|
||||
WHEN 7000040000 THEN 7001004000
|
||||
WHEN 7000050000 THEN 7001005000
|
||||
WHEN 7000060000 THEN 7001006000
|
||||
WHEN 7000070000 THEN 7001007000
|
||||
WHEN 7002060000 THEN 7001206000
|
||||
WHEN 7002070000 THEN 7001207000
|
||||
WHEN 7002030000 THEN 7001203000
|
||||
WHEN 7002040000 THEN 7001204000
|
||||
WHEN 7002050000 THEN 7001205000
|
||||
WHEN 7002020000 THEN 7001202000
|
||||
WHEN 7002010000 THEN 7001201000
|
||||
WHEN 7001060000 THEN 7001106000
|
||||
WHEN 7001070000 THEN 7001107000
|
||||
WHEN 7001030000 THEN 7001103000
|
||||
WHEN 7001040000 THEN 7001104000
|
||||
WHEN 7001050000 THEN 7001105000
|
||||
WHEN 7001020000 THEN 7001102000
|
||||
WHEN 7001010000 THEN 7001101000
|
||||
WHEN 7000080000 THEN 7000008000
|
||||
WHEN 7001080000 THEN 7000108000
|
||||
WHEN 7002080000 THEN 7000208000
|
||||
WHEN 7000090000 THEN 7000009000
|
||||
WHEN 7000100000 THEN 7000010000
|
||||
WHEN 7002090000 THEN 7000209000
|
||||
WHEN 7002100000 THEN 7000210000
|
||||
WHEN 7001090000 THEN 7000109000
|
||||
WHEN 7001100000 THEN 7000110000
|
||||
WHEN 7000120000 THEN 7000012000
|
||||
WHEN 7002120000 THEN 7000212000
|
||||
WHEN 7000130000 THEN 7000013000
|
||||
WHEN 7000140000 THEN 7000014000
|
||||
ELSE id
|
||||
END
|
||||
WHERE id IN (7000010000, 7000020000, 7000030000, 7000040000, 7000050000,
|
||||
7000060000, 7000070000, 7002060000, 7002070000, 7002030000,
|
||||
7002040000, 7002050000, 7002020000, 7002010000, 7001060000,
|
||||
7001070000, 7001030000, 7001040000, 7001050000, 7001020000,
|
||||
7001010000, 7000080000, 7001080000, 7002080000, 7000090000,
|
||||
7000100000, 7002090000, 7002100000, 7001090000, 7001100000,
|
||||
7000120000, 7002120000, 7000130000, 7000140000);
|
||||
*/
|
|
@ -0,0 +1,2 @@
|
|||
-- Actualizar los item.expenseFk de produccion propia
|
||||
-- Tot lo de producció propia porta el productor o *Polpiser o Santa Dorotea*
|
|
@ -0,0 +1,46 @@
|
|||
/*UPDATE vn2008.gastos_resumen
|
||||
SET Id_Gasto = CASE Id_Gastos
|
||||
WHEN 7000010000 THEN 7001001000
|
||||
WHEN 7000020000 THEN 7001002000
|
||||
WHEN 7000030000 THEN 7001003000
|
||||
WHEN 7000040000 THEN 7001004000
|
||||
WHEN 7000050000 THEN 7001005000
|
||||
WHEN 7000060000 THEN 7001006000
|
||||
WHEN 7000070000 THEN 7001007000
|
||||
WHEN 7002060000 THEN 7001206000
|
||||
WHEN 7002070000 THEN 7001207000
|
||||
WHEN 7002030000 THEN 7001203000
|
||||
WHEN 7002040000 THEN 7001204000
|
||||
WHEN 7002050000 THEN 7001205000
|
||||
WHEN 7002020000 THEN 7001202000
|
||||
WHEN 7002010000 THEN 7001201000
|
||||
WHEN 7001060000 THEN 7001106000
|
||||
WHEN 7001070000 THEN 7001107000
|
||||
WHEN 7001030000 THEN 7001103000
|
||||
WHEN 7001040000 THEN 7001104000
|
||||
WHEN 7001050000 THEN 7001105000
|
||||
WHEN 7001020000 THEN 7001102000
|
||||
WHEN 7001010000 THEN 7001101000
|
||||
WHEN 7000080000 THEN 7000008000
|
||||
WHEN 7001080000 THEN 7000108000
|
||||
WHEN 7002080000 THEN 7000208000
|
||||
WHEN 7000090000 THEN 7000009000
|
||||
WHEN 7000100000 THEN 7000010000
|
||||
WHEN 7002090000 THEN 7000209000
|
||||
WHEN 7002100000 THEN 7000210000
|
||||
WHEN 7001090000 THEN 7000109000
|
||||
WHEN 7001100000 THEN 7000110000
|
||||
WHEN 7000120000 THEN 7000012000
|
||||
WHEN 7002120000 THEN 7000212000
|
||||
WHEN 7000130000 THEN 7000013000
|
||||
WHEN 7000140000 THEN 7000014000
|
||||
ELSE Id_Gastos
|
||||
END
|
||||
WHERE Id_Gastos IN (7000010000, 7000020000, 7000030000, 7000040000, 7000050000,
|
||||
7000060000, 7000070000, 7002060000, 7002070000, 7002030000,
|
||||
7002040000, 7002050000, 7002020000, 7002010000, 7001060000,
|
||||
7001070000, 7001030000, 7001040000, 7001050000, 7001020000,
|
||||
7001010000, 7000080000, 7001080000, 7002080000, 7000090000,
|
||||
7000100000, 7002090000, 7002100000, 7001090000, 7001100000,
|
||||
7000120000, 7002120000, 7000130000, 7000140000);
|
||||
*/
|
|
@ -0,0 +1,38 @@
|
|||
/*CALL bs.ventas_contables_add(2021, 1);
|
||||
CALL bs.ventas_contables_add(2021, 2);
|
||||
CALL bs.ventas_contables_add(2021, 3);
|
||||
CALL bs.ventas_contables_add(2021, 4);
|
||||
CALL bs.ventas_contables_add(2021, 5);
|
||||
CALL bs.ventas_contables_add(2021, 6);
|
||||
CALL bs.ventas_contables_add(2021, 7);
|
||||
CALL bs.ventas_contables_add(2021, 8);
|
||||
CALL bs.ventas_contables_add(2021, 9);
|
||||
CALL bs.ventas_contables_add(2021, 10);
|
||||
CALL bs.ventas_contables_add(2021, 11);
|
||||
CALL bs.ventas_contables_add(2021, 12);
|
||||
CALL bs.ventas_contables_add(2022, 1);
|
||||
CALL bs.ventas_contables_add(2022, 2);
|
||||
CALL bs.ventas_contables_add(2022, 3);
|
||||
CALL bs.ventas_contables_add(2022, 4);
|
||||
CALL bs.ventas_contables_add(2022, 5);
|
||||
CALL bs.ventas_contables_add(2022, 6);
|
||||
CALL bs.ventas_contables_add(2022, 7);
|
||||
CALL bs.ventas_contables_add(2022, 8);
|
||||
CALL bs.ventas_contables_add(2022, 9);
|
||||
CALL bs.ventas_contables_add(2022, 10);
|
||||
CALL bs.ventas_contables_add(2022, 11);
|
||||
CALL bs.ventas_contables_add(2022, 12);
|
||||
CALL bs.ventas_contables_add(2023, 1);
|
||||
CALL bs.ventas_contables_add(2023, 2);
|
||||
CALL bs.ventas_contables_add(2023, 3);
|
||||
CALL bs.ventas_contables_add(2023, 4);
|
||||
CALL bs.ventas_contables_add(2023, 5);
|
||||
CALL bs.ventas_contables_add(2023, 6);
|
||||
CALL bs.ventas_contables_add(2023, 7);
|
||||
CALL bs.ventas_contables_add(2023, 8);
|
||||
CALL bs.ventas_contables_add(2023, 9);
|
||||
CALL bs.ventas_contables_add(2023, 10);
|
||||
CALL bs.ventas_contables_add(2023, 11);
|
||||
CALL bs.ventas_contables_add(2023, 12);
|
||||
CALL bs.ventas_contables_add(2024, 1);
|
||||
*/
|
Loading…
Reference in New Issue