Tarea #1300 -> Revisar los informes comparativos entre años porque los importes salen con IVA
git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@1089 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
parent
e7f72e71ac
commit
e27a8aa271
@ -3570,6 +3570,7 @@ CREATE VIEW V_INF_FAC_CLIENTE(
|
||||
ID_CLIENTE,
|
||||
NOMBRE,
|
||||
IMPORTE_DESCUENTO,
|
||||
BASE_IMPONIBLE,
|
||||
IMPORTE_TOTAL,
|
||||
IMPORTE_TOTAL_ANO)
|
||||
AS
|
||||
@ -3577,7 +3578,7 @@ select f.ID_EMPRESA, EXTRACT(YEAR FROM f.FECHA_FACTURA) as ANO,
|
||||
CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA),7)+1) AS SMALLINT) as SEMESTRE,
|
||||
CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA)+2,3)) AS SMALLINT) as TRIMESTRE,
|
||||
EXTRACT(MONTH FROM f.FECHA_FACTURA) as MES,
|
||||
f.FECHA_FACTURA, f.ID_CLIENTE, f.NOMBRE, f.IMPORTE_DESCUENTO, f.IMPORTE_TOTAL, v.importe_total as IMPORTE_TOTAL_ANO
|
||||
f.FECHA_FACTURA, f.ID_CLIENTE, f.NOMBRE, f.IMPORTE_DESCUENTO, f.BASE_IMPONIBLE as BASE_IMPONIBLE, f.IMPORTE_TOTAL, v.importe_total as IMPORTE_TOTAL_ANO
|
||||
from FACTURAS_CLIENTE f
|
||||
inner join V_INF_FAC_CLIENTE_TOTAL_ANO v on ((v.id_empresa = f.id_empresa) and (v.Ano = EXTRACT(YEAR FROM f.FECHA_FACTURA)))
|
||||
order by 1,2,3,4,5 asc
|
||||
@ -3593,6 +3594,7 @@ CREATE VIEW V_INF_FAC_PROVEEDOR(
|
||||
ID_PROVEEDOR,
|
||||
NOMBRE,
|
||||
IMPORTE_DESCUENTO,
|
||||
BASE_IMPONIBLE,
|
||||
IMPORTE_TOTAL,
|
||||
IMPORTE_TOTAL_ANO)
|
||||
AS
|
||||
@ -3600,7 +3602,7 @@ select f.ID_EMPRESA, EXTRACT(YEAR FROM f.FECHA_FACTURA) as ANO,
|
||||
CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA),7)+1) AS SMALLINT) as SEMESTRE,
|
||||
CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA)+2,3)) AS SMALLINT) as TRIMESTRE,
|
||||
EXTRACT(MONTH FROM f.FECHA_FACTURA) as MES,
|
||||
f.FECHA_FACTURA, f.ID_PROVEEDOR, f.NOMBRE, f.IMPORTE_DESCUENTO, f.IMPORTE_TOTAL, v.importe_total as IMPORTE_TOTAL_ANO
|
||||
f.FECHA_FACTURA, f.ID_PROVEEDOR, f.NOMBRE, f.IMPORTE_DESCUENTO, f.BASE_IMPONIBLE, f.IMPORTE_TOTAL, v.importe_total as IMPORTE_TOTAL_ANO
|
||||
from FACTURAS_PROVEEDOR f
|
||||
inner join V_INF_FAC_PROVEEDOR_TOTAL_ANO v on ((v.id_empresa = f.id_empresa) and (v.Ano = EXTRACT(YEAR FROM f.FECHA_FACTURA)))
|
||||
order by 1,2,3,4,5 asc
|
||||
|
||||
@ -37,18 +37,17 @@ object RptFacturasCliente: TRptFacturasCliente
|
||||
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
|
||||
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' +
|
||||
'va de A'#241'o1 respecto A'#241'o2*/'#10'case'#10'when (periodo1.IMPORTE_TOTAL = 0' +
|
||||
') then (100 - (periodo2.IMPORTE_TOTAL*100))'#10'else (100 - ((period' +
|
||||
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' +
|
||||
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' +
|
||||
'O, MES as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from ' +
|
||||
'V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO' +
|
||||
' = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 on (VAL' +
|
||||
'OR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, comp2.' +
|
||||
'ANO, MES as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'fro' +
|
||||
'm V_INF_FAC_CLIENTE comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (A' +
|
||||
'NO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (V' +
|
||||
'ALOR = periodo2.NFILA)'#10#10'where periodo= '#39'MENSUAL'#39#10'order by valor ' +
|
||||
'asc'#10#10
|
||||
') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
|
||||
'.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
|
||||
'(select comp1.ID_EMPRESA, comp1.ANO, MES as NFILA, SUM(comp1.BAS' +
|
||||
'E_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp1'#10'where' +
|
||||
' ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'orde' +
|
||||
'r by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'left jo' +
|
||||
'in'#10'(select comp2.ID_EMPRESA, comp2.ANO, MES as NFILA, SUM(comp2.' +
|
||||
'BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp2'#10'wh' +
|
||||
'ere ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'o' +
|
||||
'rder by 1 desc,2 asc) periodo2 on (VALOR = periodo2.NFILA)'#10#10'wher' +
|
||||
'e periodo= '#39'MENSUAL'#39#10'order by valor asc'#10#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
@ -1136,18 +1135,17 @@ object RptFacturasCliente: TRptFacturasCliente
|
||||
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
|
||||
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' +
|
||||
'va de A'#241'o1 respecto A'#241'o2*/'#10'case'#10'when (periodo1.IMPORTE_TOTAL = 0' +
|
||||
') then (100 - (periodo2.IMPORTE_TOTAL*100))'#10'else (100 - ((period' +
|
||||
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' +
|
||||
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' +
|
||||
'O, TRIMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL' +
|
||||
#10'from V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'an' +
|
||||
'd (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 o' +
|
||||
'n (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, ' +
|
||||
'comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPOR' +
|
||||
'TE_TOTAL'#10'from V_INF_FAC_CLIENTE comp2'#10'where ID_EMPRESA = :ID_EMP' +
|
||||
'RESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) pe' +
|
||||
'riodo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'TRIMESTRAL'#39#10 +
|
||||
'order by valor asc'#10#10
|
||||
') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
|
||||
'.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
|
||||
'(select comp1.ID_EMPRESA, comp1.ANO, TRIMESTRE as NFILA, SUM(com' +
|
||||
'p1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp1' +
|
||||
#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,' +
|
||||
'3'#10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'l' +
|
||||
'eft join'#10'(select comp2.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFILA' +
|
||||
', SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIE' +
|
||||
'NTE comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'grou' +
|
||||
'p by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo2.' +
|
||||
'NFILA)'#10#10'where periodo= '#39'TRIMESTRAL'#39#10'order by valor asc'#10#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
@ -1248,18 +1246,17 @@ object RptFacturasCliente: TRptFacturasCliente
|
||||
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
|
||||
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' +
|
||||
'va de A'#241'o1 respecto A'#241'o2*/'#10'case'#10'when (periodo1.IMPORTE_TOTAL = 0' +
|
||||
') then (100 - (periodo2.IMPORTE_TOTAL*100))'#10'else (100 - ((period' +
|
||||
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' +
|
||||
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' +
|
||||
'O, SEMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10 +
|
||||
'from V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and' +
|
||||
' (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 on' +
|
||||
' (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, c' +
|
||||
'omp2.ANO, SEMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPORTE' +
|
||||
'_TOTAL'#10'from V_INF_FAC_CLIENTE comp2'#10'where ID_EMPRESA = :ID_EMPRE' +
|
||||
'SA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) peri' +
|
||||
'odo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'SEMESTRAL'#39#10'ord' +
|
||||
'er by valor asc'#10#10
|
||||
') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
|
||||
'.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
|
||||
'(select comp1.ID_EMPRESA, comp1.ANO, SEMESTRE as NFILA, SUM(comp' +
|
||||
'1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp1'#10 +
|
||||
'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3' +
|
||||
#10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'le' +
|
||||
'ft join'#10'(select comp2.ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA, ' +
|
||||
'SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENT' +
|
||||
'E comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group ' +
|
||||
'by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo2.NF' +
|
||||
'ILA)'#10#10'where periodo= '#39'SEMESTRAL'#39#10'order by valor asc'#10#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
@ -1493,24 +1490,24 @@ object RptFacturasCliente: TRptFacturasCliente
|
||||
'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' +
|
||||
'ORTE_TOTAL, 0))))'#10'end'#10'end as Porcentaje_Aumento_Beneficios'#10#10#10'FRO' +
|
||||
'M'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.ANO, TR' +
|
||||
'IMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from' +
|
||||
' V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (AN' +
|
||||
'O = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingreso' +
|
||||
's1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2' +
|
||||
'.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.IMPORTE_TO' +
|
||||
'TAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EM' +
|
||||
'PRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1' +
|
||||
' desc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10 +
|
||||
#10'left join'#10'(select comp3.ID_EMPRESA, comp3.ANO, TRIMESTRE as NFI' +
|
||||
'LA, SUM(comp3.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLI' +
|
||||
'ENTE comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'gro' +
|
||||
'up by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALOR =' +
|
||||
' periodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, c' +
|
||||
'omp4.ANO, TRIMESTRE as NFILA, SUM(comp4.IMPORTE_TOTAL) as IMPORT' +
|
||||
'E_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EM' +
|
||||
'PRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) p' +
|
||||
'eriodo_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where period' +
|
||||
'o= '#39'TRIMESTRAL'#39#10'order by valor asc'#10
|
||||
'IMESTRE as NFILA, SUM(comp1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'fro' +
|
||||
'm V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (A' +
|
||||
'NO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingres' +
|
||||
'os1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp' +
|
||||
'2.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.BASE_IMPO' +
|
||||
'NIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_' +
|
||||
'EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by' +
|
||||
' 1 desc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA' +
|
||||
')'#10#10'left join'#10'(select comp3.ID_EMPRESA, comp3.ANO, TRIMESTRE as N' +
|
||||
'FILA, SUM(comp3.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_' +
|
||||
'CLIENTE comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10 +
|
||||
'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALO' +
|
||||
'R = periodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA' +
|
||||
', comp4.ANO, TRIMESTRE as NFILA, SUM(comp4.BASE_IMPONIBLE) as IM' +
|
||||
'PORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :I' +
|
||||
'D_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 as' +
|
||||
'c) periodo_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where pe' +
|
||||
'riodo= '#39'TRIMESTRAL'#39#10'order by valor asc'#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
@ -1749,24 +1746,24 @@ object RptFacturasCliente: TRptFacturasCliente
|
||||
'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' +
|
||||
'ORTE_TOTAL, 0))))'#10'end'#10'end as Porcentaje_Aumento_Beneficios'#10#10'FROM' +
|
||||
#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.ANO, MES' +
|
||||
' as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_' +
|
||||
'FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :AN' +
|
||||
'O1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos1 on (' +
|
||||
'VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMP' +
|
||||
'RESA, comp2.ANO, MES as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPOR' +
|
||||
'TE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID_E' +
|
||||
'MPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) ' +
|
||||
'periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10#10'left join'#10'(s' +
|
||||
'elect comp3.ID_EMPRESA, comp3.ANO, MES as NFILA, SUM(comp3.IMPOR' +
|
||||
'TE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp3'#10'where ID' +
|
||||
'_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order b' +
|
||||
'y 1 desc,2 asc) periodo_ingresos2 on (VALOR = periodo_ingresos2.' +
|
||||
'NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, comp4.ANO, MES as NF' +
|
||||
'ILA, SUM(comp4.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_PR' +
|
||||
'OVEEDOR comp4'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10 +
|
||||
'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_gastos2 on (VALOR ' +
|
||||
'= periodo_gastos2.NFILA)'#10#10#10'where periodo= '#39'MENSUAL'#39#10'order by val' +
|
||||
'or asc'#10
|
||||
' as NFILA, SUM(comp1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF' +
|
||||
'_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :A' +
|
||||
'NO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos1 on ' +
|
||||
'(VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2.ID_EM' +
|
||||
'PRESA, comp2.ANO, MES as NFILA, SUM(comp2.BASE_IMPONIBLE) as IMP' +
|
||||
'ORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID' +
|
||||
'_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc' +
|
||||
') periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10#10'left join'#10 +
|
||||
'(select comp3.ID_EMPRESA, comp3.ANO, MES as NFILA, SUM(comp3.BAS' +
|
||||
'E_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp3'#10'where' +
|
||||
' ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'orde' +
|
||||
'r by 1 desc,2 asc) periodo_ingresos2 on (VALOR = periodo_ingreso' +
|
||||
's2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, comp4.ANO, MES as' +
|
||||
' NFILA, SUM(comp4.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FA' +
|
||||
'C_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :AN' +
|
||||
'O2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_gastos2 on (VA' +
|
||||
'LOR = periodo_gastos2.NFILA)'#10#10#10'where periodo= '#39'MENSUAL'#39#10'order by' +
|
||||
' valor asc'#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
@ -2005,24 +2002,24 @@ object RptFacturasCliente: TRptFacturasCliente
|
||||
'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' +
|
||||
'ORTE_TOTAL, 0))))'#10'end'#10'end as Porcentaje_Aumento_Beneficios'#10#10#10'FRO' +
|
||||
'M'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.ANO, SE' +
|
||||
'MESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from ' +
|
||||
'V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO' +
|
||||
' = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos' +
|
||||
'1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2.' +
|
||||
'ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA, SUM(comp2.IMPORTE_TOTA' +
|
||||
'L) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPR' +
|
||||
'ESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 d' +
|
||||
'esc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10#10'l' +
|
||||
'eft join'#10'(select comp3.ID_EMPRESA, comp3.ANO, SEMESTRE as NFILA,' +
|
||||
' SUM(comp3.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENT' +
|
||||
'E comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group ' +
|
||||
'by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALOR = pe' +
|
||||
'riodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, comp' +
|
||||
'4.ANO, SEMESTRE as NFILA, SUM(comp4.IMPORTE_TOTAL) as IMPORTE_TO' +
|
||||
'TAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EMPRES' +
|
||||
'A2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) perio' +
|
||||
'do_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where periodo= '#39 +
|
||||
'SEMESTRAL'#39#10'order by valor asc'#10
|
||||
'MESTRE as NFILA, SUM(comp1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from' +
|
||||
' V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (AN' +
|
||||
'O = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingreso' +
|
||||
's1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2' +
|
||||
'.ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA, SUM(comp2.BASE_IMPONI' +
|
||||
'BLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EM' +
|
||||
'PRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1' +
|
||||
' desc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10 +
|
||||
#10'left join'#10'(select comp3.ID_EMPRESA, comp3.ANO, SEMESTRE as NFIL' +
|
||||
'A, SUM(comp3.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLI' +
|
||||
'ENTE comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'gro' +
|
||||
'up by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALOR =' +
|
||||
' periodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, c' +
|
||||
'omp4.ANO, SEMESTRE as NFILA, SUM(comp4.BASE_IMPONIBLE) as IMPORT' +
|
||||
'E_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EM' +
|
||||
'PRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) p' +
|
||||
'eriodo_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where period' +
|
||||
'o= '#39'SEMESTRAL'#39#10'order by valor asc'#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
|
||||
@ -963,18 +963,17 @@ object RptFacturasProveedor: TRptFacturasProveedor
|
||||
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
|
||||
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' +
|
||||
'va de A'#241'o1 respecto A'#241'o2*/'#10'case'#10'when (periodo1.IMPORTE_TOTAL = 0' +
|
||||
') then (100 - (periodo2.IMPORTE_TOTAL*100))'#10'else (100 - ((period' +
|
||||
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' +
|
||||
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' +
|
||||
'O, MES as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from ' +
|
||||
'V_INF_FAC_PROVEEDOR comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (A' +
|
||||
'NO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 on (V' +
|
||||
'ALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, comp' +
|
||||
'2.ANO, MES as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'f' +
|
||||
'rom V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'an' +
|
||||
'd (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo2 o' +
|
||||
'n (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'MENSUAL'#39#10'order by va' +
|
||||
'lor asc'#10#10#10
|
||||
') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
|
||||
'.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
|
||||
'(select comp1.ID_EMPRESA, comp1.ANO, MES as NFILA, SUM(comp1.BAS' +
|
||||
'E_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp1'#10'whe' +
|
||||
're ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'or' +
|
||||
'der by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'left ' +
|
||||
'join'#10'(select comp2.ID_EMPRESA, comp2.ANO, MES as NFILA, SUM(comp' +
|
||||
'2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp' +
|
||||
'2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2' +
|
||||
',3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo2.NFILA)'#10#10 +
|
||||
'where periodo= '#39'MENSUAL'#39#10'order by valor asc'#10#10#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
@ -1073,18 +1072,17 @@ object RptFacturasProveedor: TRptFacturasProveedor
|
||||
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
|
||||
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' +
|
||||
'va de A'#241'o1 respecto A'#241'o2*/'#10'case'#10'when (periodo1.IMPORTE_TOTAL = 0' +
|
||||
') then (100 - (periodo2.IMPORTE_TOTAL*100))'#10'else (100 - ((period' +
|
||||
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' +
|
||||
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' +
|
||||
'O, TRIMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL' +
|
||||
#10'from V_INF_FAC_PROVEEDOR comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10 +
|
||||
'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1' +
|
||||
' on (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA' +
|
||||
', comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMP' +
|
||||
'ORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID' +
|
||||
'_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc' +
|
||||
') periodo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'TRIMESTR' +
|
||||
'AL'#39#10'order by valor asc'#10#10#10
|
||||
') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
|
||||
'.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
|
||||
'(select comp1.ID_EMPRESA, comp1.ANO, TRIMESTRE as NFILA, SUM(com' +
|
||||
'p1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR com' +
|
||||
'p1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,' +
|
||||
'2,3'#10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10 +
|
||||
#10'left join'#10'(select comp2.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFI' +
|
||||
'LA, SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PR' +
|
||||
'OVEEDOR comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10 +
|
||||
'group by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = perio' +
|
||||
'do2.NFILA)'#10#10'where periodo= '#39'TRIMESTRAL'#39#10'order by valor asc'#10#10#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
@ -1183,18 +1181,17 @@ object RptFacturasProveedor: TRptFacturasProveedor
|
||||
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
|
||||
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' +
|
||||
'va de A'#241'o1 respecto A'#241'o2*/'#10'case'#10'when (periodo1.IMPORTE_TOTAL = 0' +
|
||||
') then (100 - (periodo2.IMPORTE_TOTAL*100))'#10'else (100 - ((period' +
|
||||
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' +
|
||||
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' +
|
||||
'O, SEMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10 +
|
||||
'from V_INF_FAC_PROVEEDOR comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'a' +
|
||||
'nd (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 ' +
|
||||
'on (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA,' +
|
||||
' comp2.ANO, SEMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPOR' +
|
||||
'TE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID_E' +
|
||||
'MPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) ' +
|
||||
'periodo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'SEMESTRAL'#39 +
|
||||
#10'order by valor asc'#10#10#10
|
||||
') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
|
||||
'.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
|
||||
'(select comp1.ID_EMPRESA, comp1.ANO, SEMESTRE as NFILA, SUM(comp' +
|
||||
'1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp' +
|
||||
'1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2' +
|
||||
',3'#10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10 +
|
||||
'left join'#10'(select comp2.ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA' +
|
||||
', SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROV' +
|
||||
'EEDOR comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'gr' +
|
||||
'oup by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo' +
|
||||
'2.NFILA)'#10#10'where periodo= '#39'SEMESTRAL'#39#10'order by valor asc'#10#10#10
|
||||
StatementType = stSQL
|
||||
ColumnMappings = <
|
||||
item
|
||||
|
||||
Loading…
Reference in New Issue
Block a user