From 6769ed8728137e0f7443fc3b2e7488fbad233e3e Mon Sep 17 00:00:00 2001 From: julio Date: Wed, 20 Sep 2017 14:20:42 +0000 Subject: [PATCH] fixes bug #9389 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@74043 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../impl/RelatorioFinanceiroAnalitico.java | 36 ++++++++++--------- .../impl/RelatorioFinanceiroSintetico.java | 29 ++++++++------- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroAnalitico.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroAnalitico.java index 27d020cd5..10909106d 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroAnalitico.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroAnalitico.java @@ -164,20 +164,20 @@ public class RelatorioFinanceiroAnalitico extends Relatorio { sql.append(" cd.puntoventaId, "); sql.append(" cd.empresaId, "); sql.append(" cd.fechorVenta, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V') then cd.pedagio else 0 end) as pedagio, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V') then cd.valorpago else 0 end) as receita_bpr, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32)) then cd.valorpago else 0 end) as receita_devol_bpr, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.numfoliosistema is null) then cd.valorpago else 0 end) as receita_gap, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32) and cd.numfoliosistema is null) then cd.valorpago else 0 end) as receita_devol_gap, "); - sql.append(" sum(case when (cd.indstatusboleto = 'E') then cd.valorpago else 0 end) as entrega_gap, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.pedagio else 0 end) as pedagio, "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.valorpago else 0 end) as receita_bpr, "); + sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37)) then cd.valorpago else 0 end) as receita_devol_bpr, "); + sql.append(" sum(case when (cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_gap, "); + sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37) and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_devol_gap, "); + sql.append(" sum(case when (cd.indreimpresion = 1 and cd.indstatusboleto = 'E' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as entrega_gap, "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, "); + sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, "); + sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred "); sql.append(" "); sql.append("from ( "); sql.append(" select "); - sql.append(" c.caja_id as cajaid, "); + sql.append(" c.boleto_id as cajaid, "); sql.append(" trunc(c.feccreacion) as fechorVenta, "); sql.append(" e.empresa_id as empresaId, "); sql.append(" pv.puntoventa_id as puntoventaId, "); @@ -198,8 +198,8 @@ public class RelatorioFinanceiroAnalitico extends Relatorio { sql.append(" cfp.formapago_id, "); sql.append(" c.motivocancelacion_id as motivocancelacion_id, "); sql.append(" c.tipoventa_id as tipoventa_id "); - sql.append(" from caja c "); - sql.append(" inner join caja_formapago cfp on cfp.caja_id = c.caja_id "); + sql.append(" from boleto c "); + sql.append(" inner join boleto_formapago cfp on cfp.boleto_id = c.boleto_id "); sql.append(" inner join punto_venta pv on pv.puntoventa_id = c.puntoventa_id "); sql.append(" inner join forma_pago fp on cfp.formapago_id = fp.formapago_id "); sql.append(" inner join marca m on c.marca_id = m.marca_id "); @@ -217,18 +217,22 @@ public class RelatorioFinanceiroAnalitico extends Relatorio { sql.append("left join ( "); sql.append(" select ed.puntoventaId, ed.estadoId, ed.empresaId, "); sql.append(" ed.fechorVenta, "); - sql.append(" sum(case when tipoeventoextra_id = 2 and indtipo = 1 then impingreso else 0 end) as taxaEmbarque, "); + sql.append(" sum(case when tipoeventoextra_id = 2 and indtipo = 1 then impingreso else 0 end) as taxaEmbarque, "); sql.append(" sum(case when tipoeventoextra_id = 25 and indtipo = 1 then impingreso else 0 end) as seguro, "); sql.append(" sum(case when tipoeventoextra_id = 82 and indtipo = 1 then impingreso else 0 end) as receita_eb, "); sql.append(" sum(case when tipoeventoextra_id in (41) and indtipo = 1 then impingreso else 0 end) as receita_multa, "); sql.append(" sum(case when tipoeventoextra_id in (103,99978,99999) and indtipo = 1 then impingreso else 0 end) as receita_dif_troca_ocd, "); sql.append(" sum(case when tipoeventoextra_id in (43) and indtipo = 1 then impingreso else 0 end) as receita_dif_dif_tarifa_maior, "); sql.append(" sum(case when tipoeventoextra_id in (44) and indtipo = 0 then impingreso else 0 end) as receita_dif_dif_tarifa_menor, "); - sql.append(" sum(case when tipoeventoextra_id not in (44) and indtipo = 0 then impingreso else 0 end) as despesas "); + sql.append(" sum(case when tipoeventoextra_id not in (44) and indtipo = 0 then impingreso else 0 end) as despesas, "); + sql.append(" sum(case when (formapago_id in (2,25) and tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) "); + sql.append(" and indtipo = 1) then impingreso else 0 end) as cartao_credito_ee, "); + sql.append(" sum(case when (formapago_id in (3,26) and tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) "); + sql.append(" and indtipo = 1) then impingreso else 0 end) as cartao_debito_ee "); sql.append(" from ( "); sql.append(" select ee.tipoeventoextra_id, ee.impingreso, tee.indtipo, "); sql.append(" pv.puntoventa_id as puntoventaId, eo.estado_id as estadoId, ee.empresa_id as empresaId, "); - sql.append(" trunc(ee.fechoringreso) as fechorVenta "); + sql.append(" trunc(ee.fechoringreso) as fechorVenta, ee.formapago_id "); sql.append(" from evento_extra ee "); sql.append(" join tipo_evento_extra tee on ee.tipoeventoextra_id = tee.tipoeventoextra_id "); sql.append(" join punto_venta pv on pv.puntoventa_id = ee.puntoventa_id "); diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroSintetico.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroSintetico.java index e0a6e92a6..a3eaa053e 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroSintetico.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioFinanceiroSintetico.java @@ -169,19 +169,19 @@ public class RelatorioFinanceiroSintetico extends Relatorio { sql.append(" cd.codigo, "); sql.append(" cd.puntoventaId, "); sql.append(" cd.empresaId, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto <> 'E' and cd.numfoliosistema is not null and cd.tipoventa_id not in (5,12,18,49)) then cd.pedagio else 0 end) as pedagio, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto <> 'E' and cd.numfoliosistema is not null) then cd.valorpago else 0 end) as receita_bpr, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32,10,37)) then cd.valorpago else 0 end) as receita_devol_bpr, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_gap, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (31,32,10,37) and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_devol_gap, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'E' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as entrega_gap, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, "); - sql.append(" sum(case when (cd.indcancelacion = 0 and cd.indstatusboleto = 'V' and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, "); - sql.append(" sum(case when (cd.indcancelacion = 1 and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.pedagio else 0 end) as pedagio, "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null) then cd.valorpago else 0 end) as receita_bpr, "); + sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37)) then cd.valorpago else 0 end) as receita_devol_bpr, "); + sql.append(" sum(case when (cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_gap, "); + sql.append(" sum(case when (cd.indstatusboleto in ('C', 'T') and cd.motivocancelacion_id in (31,32,10,37) and cd.numfoliosistema is null and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as receita_devol_gap, "); + sql.append(" sum(case when (cd.indreimpresion = 1 and cd.indstatusboleto = 'E' and cd.tipoventa_id in (5,12,18,49)) then cd.valorpago else 0 end) as entrega_gap, "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (2,25)) then cd.valorpago else 0 end) as cartao_credito, "); + sql.append(" sum(case when (cd.motivocancelacion_id is null and cd.indreimpresion = 0 and cd.indstatusboleto = 'V' and cd.numfoliosistema is not null and cd.formapago_id in (3,26)) then cd.valorpago else 0 end) as cartao_debito, "); + sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (35)) then cd.valorpago else 0 end) as receita_ocd_deb, "); + sql.append(" sum(case when (cd.indstatusboleto = 'C' and cd.motivocancelacion_id in (99) ) then cd.valorpago else 0 end) as receita_ocd_cred "); sql.append("from ( "); sql.append(" select "); - sql.append(" c.caja_id as cajaid, "); + sql.append(" c.boleto_id as cajaid, "); sql.append(" e.empresa_id as empresaId, "); sql.append(" pv.puntoventa_id as puntoventaId, "); sql.append(" pv.numpuntoventa as codigo, "); @@ -193,7 +193,6 @@ public class RelatorioFinanceiroSintetico extends Relatorio { sql.append(" c.numfoliosistema, "); sql.append(" coalesce(cfp.importe, 0) as valorpago, "); sql.append(" coalesce(c.preciobase, 0) as precobase, "); - sql.append(" coalesce(c.preciopagado, 0) as tarifa, "); sql.append(" coalesce(c.importetaxaembarque, 0) as taxaEmbarque, "); sql.append(" coalesce(c.importepedagio, 0) as pedagio, "); sql.append(" coalesce(c.importeseguro, 0) as seguro, "); @@ -201,10 +200,10 @@ public class RelatorioFinanceiroSintetico extends Relatorio { sql.append(" cfp.formapago_id, "); sql.append(" c.motivocancelacion_id as motivocancelacion_id, "); sql.append(" c.tipoventa_id as tipoventa_id "); - sql.append(" from caja c "); - sql.append(" inner join caja_formapago cfp on cfp.caja_id = c.caja_id "); + sql.append(" from boleto c "); + sql.append(" inner join boleto_formapago cfp on cfp.boleto_id = c.boleto_id and cfp.activo = 1 "); sql.append(" inner join punto_venta pv on pv.puntoventa_id = c.puntoventa_id "); - sql.append(" inner join forma_pago fp on cfp.formapago_id = fp.formapago_id "); + sql.append(" inner join forma_pago fp on cfp.formapago_id = fp.formapago_id and fp.activo = 1 "); sql.append(" inner join marca m on c.marca_id = m.marca_id "); sql.append(" inner join empresa e on e.empresa_id = m.empresa_id "); sql.append(" inner join parada po on po.parada_id = pv.parada_id ");