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:
David Arranz 2014-01-24 14:28:37 +00:00
parent e7f72e71ac
commit e27a8aa271
3 changed files with 124 additions and 128 deletions

View File

@ -3570,6 +3570,7 @@ CREATE VIEW V_INF_FAC_CLIENTE(
ID_CLIENTE, ID_CLIENTE,
NOMBRE, NOMBRE,
IMPORTE_DESCUENTO, IMPORTE_DESCUENTO,
BASE_IMPONIBLE,
IMPORTE_TOTAL, IMPORTE_TOTAL,
IMPORTE_TOTAL_ANO) IMPORTE_TOTAL_ANO)
AS 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),7)+1) AS SMALLINT) as SEMESTRE,
CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA)+2,3)) AS SMALLINT) as TRIMESTRE, CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA)+2,3)) AS SMALLINT) as TRIMESTRE,
EXTRACT(MONTH FROM f.FECHA_FACTURA) as MES, 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 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))) 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 order by 1,2,3,4,5 asc
@ -3593,6 +3594,7 @@ CREATE VIEW V_INF_FAC_PROVEEDOR(
ID_PROVEEDOR, ID_PROVEEDOR,
NOMBRE, NOMBRE,
IMPORTE_DESCUENTO, IMPORTE_DESCUENTO,
BASE_IMPONIBLE,
IMPORTE_TOTAL, IMPORTE_TOTAL,
IMPORTE_TOTAL_ANO) IMPORTE_TOTAL_ANO)
AS 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),7)+1) AS SMALLINT) as SEMESTRE,
CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA)+2,3)) AS SMALLINT) as TRIMESTRE, CAST((DIV(EXTRACT(MONTH FROM f.FECHA_FACTURA)+2,3)) AS SMALLINT) as TRIMESTRE,
EXTRACT(MONTH FROM f.FECHA_FACTURA) as MES, 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 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))) 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 order by 1,2,3,4,5 asc

View File

@ -37,18 +37,17 @@ object RptFacturasCliente: TRptFacturasCliente
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' + '1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' + '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' + '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' + ') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' + '.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' + '(select comp1.ID_EMPRESA, comp1.ANO, MES as NFILA, SUM(comp1.BAS' +
'O, MES as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from ' + 'E_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp1'#10'where' +
'V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO' + ' ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'orde' +
' = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 on (VAL' + 'r by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'left jo' +
'OR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, comp2.' + 'in'#10'(select comp2.ID_EMPRESA, comp2.ANO, MES as NFILA, SUM(comp2.' +
'ANO, MES as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'fro' + 'BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp2'#10'wh' +
'm V_INF_FAC_CLIENTE comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (A' + 'ere ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'o' +
'NO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (V' + 'rder by 1 desc,2 asc) periodo2 on (VALOR = periodo2.NFILA)'#10#10'wher' +
'ALOR = periodo2.NFILA)'#10#10'where periodo= '#39'MENSUAL'#39#10'order by valor ' + 'e periodo= '#39'MENSUAL'#39#10'order by valor asc'#10#10
'asc'#10#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item
@ -1136,18 +1135,17 @@ object RptFacturasCliente: TRptFacturasCliente
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' + '1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' + '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' + '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' + ') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' + '.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' + '(select comp1.ID_EMPRESA, comp1.ANO, TRIMESTRE as NFILA, SUM(com' +
'O, TRIMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL' + 'p1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp1' +
#10'from V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'an' + #10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,' +
'd (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 o' + '3'#10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'l' +
'n (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, ' + 'eft join'#10'(select comp2.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFILA' +
'comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPOR' + ', SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIE' +
'TE_TOTAL'#10'from V_INF_FAC_CLIENTE comp2'#10'where ID_EMPRESA = :ID_EMP' + 'NTE comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'grou' +
'RESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) pe' + 'p by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo2.' +
'riodo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'TRIMESTRAL'#39#10 + 'NFILA)'#10#10'where periodo= '#39'TRIMESTRAL'#39#10'order by valor asc'#10#10
'order by valor asc'#10#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item
@ -1248,18 +1246,17 @@ object RptFacturasCliente: TRptFacturasCliente
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' + '1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' + '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' + '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' + ') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' + '.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' + '(select comp1.ID_EMPRESA, comp1.ANO, SEMESTRE as NFILA, SUM(comp' +
'O, SEMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10 + '1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp1'#10 +
'from V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and' + 'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3' +
' (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 on' + #10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'le' +
' (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, c' + 'ft join'#10'(select comp2.ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA, ' +
'omp2.ANO, SEMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPORTE' + 'SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENT' +
'_TOTAL'#10'from V_INF_FAC_CLIENTE comp2'#10'where ID_EMPRESA = :ID_EMPRE' + 'E comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group ' +
'SA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) peri' + 'by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo2.NF' +
'odo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'SEMESTRAL'#39#10'ord' + 'ILA)'#10#10'where periodo= '#39'SEMESTRAL'#39#10'order by valor asc'#10#10
'er by valor asc'#10#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item
@ -1493,24 +1490,24 @@ object RptFacturasCliente: TRptFacturasCliente
'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' + 'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' +
'ORTE_TOTAL, 0))))'#10'end'#10'end as Porcentaje_Aumento_Beneficios'#10#10#10'FRO' + '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' + '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' + 'IMESTRE as NFILA, SUM(comp1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'fro' +
' V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (AN' + 'm V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (A' +
'O = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingreso' + 'NO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingres' +
's1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2' + 'os1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp' +
'.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.IMPORTE_TO' + '2.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.BASE_IMPO' +
'TAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EM' + 'NIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_' +
'PRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1' + 'EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by' +
' desc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10 + ' 1 desc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA' +
#10'left join'#10'(select comp3.ID_EMPRESA, comp3.ANO, TRIMESTRE as NFI' + ')'#10#10'left join'#10'(select comp3.ID_EMPRESA, comp3.ANO, TRIMESTRE as N' +
'LA, SUM(comp3.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLI' + 'FILA, SUM(comp3.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_' +
'ENTE comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'gro' + 'CLIENTE comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10 +
'up by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALOR =' + 'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALO' +
' periodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, c' + 'R = periodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA' +
'omp4.ANO, TRIMESTRE as NFILA, SUM(comp4.IMPORTE_TOTAL) as IMPORT' + ', comp4.ANO, TRIMESTRE as NFILA, SUM(comp4.BASE_IMPONIBLE) as IM' +
'E_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EM' + 'PORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :I' +
'PRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) p' + 'D_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 as' +
'eriodo_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where period' + 'c) periodo_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where pe' +
'o= '#39'TRIMESTRAL'#39#10'order by valor asc'#10 'riodo= '#39'TRIMESTRAL'#39#10'order by valor asc'#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item
@ -1749,24 +1746,24 @@ object RptFacturasCliente: TRptFacturasCliente
'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' + 'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' +
'ORTE_TOTAL, 0))))'#10'end'#10'end as Porcentaje_Aumento_Beneficios'#10#10'FROM' + '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' + #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_' + ' 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 = :AN' + '_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :A' +
'O1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos1 on (' + '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_EMP' + '(VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2.ID_EM' +
'RESA, comp2.ANO, MES as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPOR' + 'PRESA, comp2.ANO, MES as NFILA, SUM(comp2.BASE_IMPONIBLE) as IMP' +
'TE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID_E' + 'ORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID' +
'MPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) ' + '_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'(s' + ') periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10#10'left join'#10 +
'elect comp3.ID_EMPRESA, comp3.ANO, MES as NFILA, SUM(comp3.IMPOR' + '(select comp3.ID_EMPRESA, comp3.ANO, MES as NFILA, SUM(comp3.BAS' +
'TE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp3'#10'where ID' + 'E_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENTE comp3'#10'where' +
'_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order b' + ' ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'orde' +
'y 1 desc,2 asc) periodo_ingresos2 on (VALOR = periodo_ingresos2.' + 'r by 1 desc,2 asc) periodo_ingresos2 on (VALOR = periodo_ingreso' +
'NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, comp4.ANO, MES as NF' + 's2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, comp4.ANO, MES as' +
'ILA, SUM(comp4.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_PR' + ' NFILA, SUM(comp4.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FA' +
'OVEEDOR comp4'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10 + 'C_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :AN' +
'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_gastos2 on (VALOR ' + 'O2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_gastos2 on (VA' +
'= periodo_gastos2.NFILA)'#10#10#10'where periodo= '#39'MENSUAL'#39#10'order by val' + 'LOR = periodo_gastos2.NFILA)'#10#10#10'where periodo= '#39'MENSUAL'#39#10'order by' +
'or asc'#10 ' valor asc'#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item
@ -2005,24 +2002,24 @@ object RptFacturasCliente: TRptFacturasCliente
'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' + 'riodo_ingresos2.IMPORTE_TOTAL, 0) - coalesce(periodo_gastos2.IMP' +
'ORTE_TOTAL, 0))))'#10'end'#10'end as Porcentaje_Aumento_Beneficios'#10#10#10'FRO' + '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' + '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 ' + '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 (ANO' + ' V_INF_FAC_CLIENTE comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (AN' +
' = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos' + 'O = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingreso' +
'1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2.' + 's1 on (VALOR = periodo_ingresos1.NFILA)'#10#10'left join'#10'(select comp2' +
'ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA, SUM(comp2.IMPORTE_TOTA' + '.ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA, SUM(comp2.BASE_IMPONI' +
'L) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPR' + 'BLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EM' +
'ESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 d' + 'PRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1' +
'esc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10#10'l' + ' desc,2 asc) periodo_gastos1 on (VALOR = periodo_gastos1.NFILA)'#10 +
'eft join'#10'(select comp3.ID_EMPRESA, comp3.ANO, SEMESTRE as NFILA,' + #10'left join'#10'(select comp3.ID_EMPRESA, comp3.ANO, SEMESTRE as NFIL' +
' SUM(comp3.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLIENT' + 'A, SUM(comp3.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_CLI' +
'E comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group ' + 'ENTE comp3'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'gro' +
'by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALOR = pe' + 'up by 1,2,3'#10'order by 1 desc,2 asc) periodo_ingresos2 on (VALOR =' +
'riodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, comp' + ' periodo_ingresos2.NFILA)'#10#10'left join'#10'(select comp4.ID_EMPRESA, c' +
'4.ANO, SEMESTRE as NFILA, SUM(comp4.IMPORTE_TOTAL) as IMPORTE_TO' + 'omp4.ANO, SEMESTRE as NFILA, SUM(comp4.BASE_IMPONIBLE) as IMPORT' +
'TAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EMPRES' + 'E_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp4'#10'where ID_EMPRESA = :ID_EM' +
'A2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) perio' + 'PRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) p' +
'do_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where periodo= '#39 + 'eriodo_gastos2 on (VALOR = periodo_gastos2.NFILA)'#10#10#10'where period' +
'SEMESTRAL'#39#10'order by valor asc'#10 'o= '#39'SEMESTRAL'#39#10'order by valor asc'#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item

View File

@ -963,18 +963,17 @@ object RptFacturasProveedor: TRptFacturasProveedor
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' + '1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' + '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' + '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' + ') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' + '.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' + '(select comp1.ID_EMPRESA, comp1.ANO, MES as NFILA, SUM(comp1.BAS' +
'O, MES as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'from ' + 'E_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp1'#10'whe' +
'V_INF_FAC_PROVEEDOR comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (A' + 're ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2,3'#10'or' +
'NO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 on (V' + 'der by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10'left ' +
'ALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA, comp' + 'join'#10'(select comp2.ID_EMPRESA, comp2.ANO, MES as NFILA, SUM(comp' +
'2.ANO, MES as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10'f' + '2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp' +
'rom V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'an' + '2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2' +
'd (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo2 o' + ',3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo2.NFILA)'#10#10 +
'n (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'MENSUAL'#39#10'order by va' + 'where periodo= '#39'MENSUAL'#39#10'order by valor asc'#10#10#10
'lor asc'#10#10#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item
@ -1073,18 +1072,17 @@ object RptFacturasProveedor: TRptFacturasProveedor
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' + '1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' + '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' + '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' + ') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' + '.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' + '(select comp1.ID_EMPRESA, comp1.ANO, TRIMESTRE as NFILA, SUM(com' +
'O, TRIMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL' + 'p1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR com' +
#10'from V_INF_FAC_PROVEEDOR comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10 + 'p1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,' +
'and (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1' + '2,3'#10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10 +
' on (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA' + #10'left join'#10'(select comp2.ID_EMPRESA, comp2.ANO, TRIMESTRE as NFI' +
', comp2.ANO, TRIMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMP' + 'LA, SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PR' +
'ORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID' + 'OVEEDOR comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10 +
'_EMPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc' + 'group by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = perio' +
') periodo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'TRIMESTR' + 'do2.NFILA)'#10#10'where periodo= '#39'TRIMESTRAL'#39#10'order by valor asc'#10#10#10
'AL'#39#10'order by valor asc'#10#10#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item
@ -1183,18 +1181,17 @@ object RptFacturasProveedor: TRptFacturasProveedor
'1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' + '1.IMPORTE_TOTAL - periodo2.IMPORTE_TOTAL) as Diferencia,'#10'/*SOLO ' +
'COMPARAREMOS CUANDO EL SEGUNDO A'#209'O SEA DIFERENTE DE 0, comparati' + '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' + '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' + ') then (NULL)'#10'else (100 - ((periodo2.IMPORTE_TOTAL*100)/periodo1' +
'o2.IMPORTE_TOTAL*100)/periodo1.IMPORTE_TOTAL))'#10'end as Porcentaje' + '.IMPORTE_TOTAL))'#10'end as Porcentaje'#10#10'FROM'#10'periodos_aux'#10'left join'#10 +
#10#10'FROM'#10'periodos_aux'#10'left join'#10'(select comp1.ID_EMPRESA, comp1.AN' + '(select comp1.ID_EMPRESA, comp1.ANO, SEMESTRE as NFILA, SUM(comp' +
'O, SEMESTRE as NFILA, SUM(comp1.IMPORTE_TOTAL) as IMPORTE_TOTAL'#10 + '1.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp' +
'from V_INF_FAC_PROVEEDOR comp1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'a' + '1'#10'where ID_EMPRESA = :ID_EMPRESA1'#10'and (ANO = :ANO1)'#10'group by 1,2' +
'nd (ANO = :ANO1)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) periodo1 ' + ',3'#10'order by 1 desc,2 asc) periodo1 on (VALOR = periodo1.NFILA)'#10#10 +
'on (VALOR = periodo1.NFILA)'#10#10'left join'#10'(select comp2.ID_EMPRESA,' + 'left join'#10'(select comp2.ID_EMPRESA, comp2.ANO, SEMESTRE as NFILA' +
' comp2.ANO, SEMESTRE as NFILA, SUM(comp2.IMPORTE_TOTAL) as IMPOR' + ', SUM(comp2.BASE_IMPONIBLE) as IMPORTE_TOTAL'#10'from V_INF_FAC_PROV' +
'TE_TOTAL'#10'from V_INF_FAC_PROVEEDOR comp2'#10'where ID_EMPRESA = :ID_E' + 'EEDOR comp2'#10'where ID_EMPRESA = :ID_EMPRESA2'#10'and (ANO = :ANO2)'#10'gr' +
'MPRESA2'#10'and (ANO = :ANO2)'#10'group by 1,2,3'#10'order by 1 desc,2 asc) ' + 'oup by 1,2,3'#10'order by 1 desc,2 asc) periodo2 on (VALOR = periodo' +
'periodo2 on (VALOR = periodo2.NFILA)'#10#10'where periodo= '#39'SEMESTRAL'#39 + '2.NFILA)'#10#10'where periodo= '#39'SEMESTRAL'#39#10'order by valor asc'#10#10#10
#10'order by valor asc'#10#10#10
StatementType = stSQL StatementType = stSQL
ColumnMappings = < ColumnMappings = <
item item