bug#10637
dev:julio qua:marcelo git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@79229 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
e47e602882
commit
4c38462d79
|
@ -98,7 +98,7 @@ public class RelatorioFinanceiroAnalitico extends Relatorio {
|
|||
|
||||
fs.setTxEmb(getBigDecimal(rset, "taxaEmbarque"));
|
||||
fs.setPedagio(getBigDecimal(rset, "pedagio"));
|
||||
fs.setSegFacult(getBigDecimal(rset, "seguro"));
|
||||
fs.setSegFacult(getBigDecimal(rset, "segurofac"));
|
||||
|
||||
BigDecimal totalTerceiros = fs.getTxEmb().add(fs.getPedagio()).add(fs.getSegFacult());
|
||||
fs.setTotalTerceiros(totalTerceiros);
|
||||
|
@ -199,7 +199,6 @@ public class RelatorioFinanceiroAnalitico extends Relatorio {
|
|||
sql.append(" c.motivocancelacion_id as motivocancelacion_id, ");
|
||||
sql.append(" c.tipoventa_id as tipoventa_id, ");
|
||||
sql.append(" c.indstatusoperacion ");
|
||||
sql.append(" ");
|
||||
sql.append(" FROM CONTA_CORRENTE_PTOVTA ccp ");
|
||||
sql.append(" INNER JOIN marca ma ");
|
||||
sql.append(" ON ma.empresa_id = ccp.EMPRESA_ID ");
|
||||
|
@ -393,39 +392,42 @@ public class RelatorioFinanceiroAnalitico extends Relatorio {
|
|||
sql.append(" ) cdc ");
|
||||
sql.append(" group by cdc.estadoOrigem, cdc.estadoId, cdc.codigo, cdc.puntoventaId, cdc.empresaId, cdc.fechorVenta ");
|
||||
sql.append(") canc on agrc.empresaId = canc.empresaId and agrc.puntoventaId = canc.puntoventaId and agrc.estadoId = canc.estadoId and agrc.fechorVenta = canc.fechorVenta ");
|
||||
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 = 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 (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, 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 ");
|
||||
sql.append(" join parada po on po.parada_id = pv.parada_id ");
|
||||
sql.append(" join ciudad co on co.ciudad_id = po.ciudad_id ");
|
||||
sql.append(" join estado eo on eo.estado_id = co.estado_id ");
|
||||
sql.append(" where ee.activo = 1 and ee.empresa_id = :EMPRESA_ID ");
|
||||
sql.append(" left join ( ");
|
||||
sql.append(" select ");
|
||||
sql.append(" ee.empresa_id AS empresaId, cd.puntoventa_id AS puntoventaId, eo.estado_id AS estadoId, trunc(ee.fechoringreso) as fechorVenta, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id = 2 and indtipo = 1 then cdp.importe else 0 end) as taxaembarque, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id = 25 and indtipo = 1 then cdp.importe else 0 end) as segurofac, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id = 82 and indtipo = 1 then cdp.importe else 0 end) as receita_eb, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (41) and indtipo = 1 then cdp.importe else 0 end) as receita_multa, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (103,99978,99999) and indtipo = 1 then cdp.importe else 0 end) as receita_dif_troca_ocd, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (43) and indtipo = 1 then cdp.importe else 0 end) as receita_dif_dif_tarifa_maior, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (44) and indtipo = 0 then cdp.importe else 0 end) as receita_dif_dif_tarifa_menor, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id not in (44) and indtipo = 0 then cdp.importe else 0 end) as despesas, ");
|
||||
sql.append(" sum( case when (formapago_id in (2,25) and tee.tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) and indtipo = 1) then cdp.importe else 0 end) as cartao_credito_ee, ");
|
||||
sql.append(" sum( case when (formapago_id in (3,26) and tee.tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) and indtipo = 1) then cdp.importe else 0 end) as cartao_debito_ee ");
|
||||
sql.append(" from caja_diversos cd ");
|
||||
sql.append(" join evento_extra ee on ee.eventoextra_id = cd.eventoextra_id ");
|
||||
sql.append(" join tipo_evento_extra tee on tee.tipoeventoextra_id = ee.tipoeventoextra_id ");
|
||||
sql.append(" join caja_diversos_pago cdp on cdp.cajadiversos_id = cd.cajadiversos_id ");
|
||||
sql.append(" join conta_corrente_ptovta ccp on ccp.empresa_id = ee.empresa_id ");
|
||||
sql.append(" and ccp.puntoventa_id = cd.puntoventa_id ");
|
||||
sql.append(" and ccp.turno_id = cd.turno_id ");
|
||||
sql.append(" and ccp.usuario_id = cd.usuario_id ");
|
||||
sql.append(" and cd.feccorte = ccp.feccorte ");
|
||||
sql.append(" join punto_venta pv on pv.puntoventa_id = ee.puntoventa_id ");
|
||||
sql.append(" left join boleto b on b.boleto_id = ee.boleto_id ");
|
||||
sql.append(" left join parada po on po.parada_id = b.origen_id ");
|
||||
sql.append(" left join ciudad co on co.ciudad_id = po.ciudad_id ");
|
||||
sql.append(" left join estado eo on eo.estado_id = co.estado_id ");
|
||||
sql.append(" where ");
|
||||
sql.append(" ( cd.indreimpresion = 0 or cd.indreimpresion is null ) ");
|
||||
sql.append(" and ee.empresa_id = :EMPRESA_ID ");
|
||||
sql.append(ufs == null ? "" : "and eo.estado_id in ( " + ufs + " ) ");
|
||||
sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) ");
|
||||
sql.append(pdvs == null ? "" : "and ccp.puntoventa_id in ( " + pdvs + " ) ");
|
||||
sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId);
|
||||
sql.append(" and ee.fechoringreso between :DATE_INICIO and :DATE_FIM ");
|
||||
sql.append(" ) ed ");
|
||||
sql.append(" group by ed.puntoventaId, ed.estadoId, ed.empresaId, ed.fechorVenta ");
|
||||
sql.append(" ) eed on agrc.empresaId = eed.empresaId and agrc.puntoventaId = eed.puntoventaId and agrc.estadoId = eed.estadoId and agrc.fechorVenta = eed.fechorVenta ");
|
||||
sql.append(" and ccp.FECCORTE between :DATE_INICIO and :DATE_FIM ");
|
||||
sql.append(" group by ee.empresa_id, cd.puntoventa_id, eo.estado_id, trunc(ee.fechoringreso) ");
|
||||
sql.append(" ) eed on agrc.empresaId = eed.empresaId and agrc.puntoventaId = eed.puntoventaId and agrc.estadoId = eed.estadoId AND agrc.fechorVenta = eed.fechorVenta ");
|
||||
sql.append("left join ( ");
|
||||
sql.append(" select coalesce(sum(fd.valor), 0) as deposito, pv.puntoventa_id as puntoventaId, fcc.empresa_id as empresaId, eo.estado_id as estadoId, ");
|
||||
sql.append(" trunc(fd.feccreacion) as fechorVenta ");
|
||||
|
|
|
@ -97,7 +97,7 @@ public class RelatorioFinanceiroSintetico extends Relatorio {
|
|||
|
||||
fs.setTxEmb(getBigDecimal(rset, "taxaEmbarque"));
|
||||
fs.setPedagio(getBigDecimal(rset, "pedagio"));
|
||||
fs.setSegFacult(getBigDecimal(rset, "seguro"));
|
||||
fs.setSegFacult(getBigDecimal(rset, "segurofac"));
|
||||
|
||||
BigDecimal totalTerceiros = fs.getTxEmb().add(fs.getPedagio()).add(fs.getSegFacult());
|
||||
fs.setTotalTerceiros(totalTerceiros);
|
||||
|
@ -398,39 +398,45 @@ public class RelatorioFinanceiroSintetico extends Relatorio {
|
|||
sql.append(" ) cdc ");
|
||||
sql.append(" group by cdc.estadoOrigem, cdc.estadoId, cdc.codigo, cdc.puntoventaId, cdc.empresaId, cdc.fechorVenta ");
|
||||
sql.append(") canc on agrc.empresaId = canc.empresaId and agrc.puntoventaId = canc.puntoventaId and agrc.estadoId = canc.estadoId and agrc.fechorVenta = canc.fechorVenta ");
|
||||
sql.append("left join ( ");
|
||||
sql.append(" select ed.puntoventaId, ed.estadoId, ed.empresaId, ");
|
||||
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 (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, pv.puntoventa_id as puntoventaId, ");
|
||||
sql.append(" eo.estado_id as estadoId, ee.empresa_id as empresaId, 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 ");
|
||||
sql.append(" join parada po on po.parada_id = pv.parada_id ");
|
||||
sql.append(" join ciudad co on co.ciudad_id = po.ciudad_id ");
|
||||
sql.append(" join estado eo on eo.estado_id = co.estado_id ");
|
||||
sql.append(" where ee.activo = 1 and ee.empresa_id = :EMPRESA_ID ");
|
||||
sql.append(" left join ( ");
|
||||
sql.append(" select ");
|
||||
sql.append(" ee.empresa_id AS empresaId, cd.puntoventa_id AS puntoventaId, eo.estado_id AS estadoId, trunc(ee.fechoringreso) as fechorVenta, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id = 2 and indtipo = 1 then cdp.importe else 0 end) as taxaembarque, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id = 25 and indtipo = 1 then cdp.importe else 0 end) as segurofac, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id = 82 and indtipo = 1 then cdp.importe else 0 end) as receita_eb, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (41) and indtipo = 1 then cdp.importe else 0 end) as receita_multa, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (103,99978,99999) and indtipo = 1 then cdp.importe else 0 end) as receita_dif_troca_ocd, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (43) and indtipo = 1 then cdp.importe else 0 end) as receita_dif_dif_tarifa_maior, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id in (44) and indtipo = 0 then cdp.importe else 0 end) as receita_dif_dif_tarifa_menor, ");
|
||||
sql.append(" sum( case when tee.tipoeventoextra_id not in (44) and indtipo = 0 then cdp.importe else 0 end) as despesas, ");
|
||||
sql.append(" sum( case when (formapago_id in (2,25) and tee.tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) and indtipo = 1) then cdp.importe else 0 end) as cartao_credito_ee, ");
|
||||
sql.append(" sum( case when (formapago_id in (3,26) and tee.tipoeventoextra_id in (2,25,82,41,43,103,99978,99999) and indtipo = 1) then cdp.importe else 0 end) as cartao_debito_ee ");
|
||||
sql.append(" from caja_diversos cd ");
|
||||
sql.append(" join evento_extra ee on ee.eventoextra_id = cd.eventoextra_id ");
|
||||
sql.append(" join tipo_evento_extra tee on tee.tipoeventoextra_id = ee.tipoeventoextra_id ");
|
||||
sql.append(" join caja_diversos_pago cdp on cdp.cajadiversos_id = cd.cajadiversos_id ");
|
||||
sql.append(" join conta_corrente_ptovta ccp on ccp.empresa_id = ee.empresa_id ");
|
||||
sql.append(" and ccp.puntoventa_id = cd.puntoventa_id ");
|
||||
sql.append(" and ccp.turno_id = cd.turno_id ");
|
||||
sql.append(" and ccp.usuario_id = cd.usuario_id ");
|
||||
sql.append(" and cd.feccorte = ccp.feccorte ");
|
||||
sql.append(" join punto_venta pv on pv.puntoventa_id = ee.puntoventa_id ");
|
||||
sql.append(" left join boleto b on b.boleto_id = ee.boleto_id ");
|
||||
sql.append(" left join parada po on po.parada_id = b.origen_id ");
|
||||
sql.append(" left join ciudad co on co.ciudad_id = po.ciudad_id ");
|
||||
sql.append(" left join estado eo on eo.estado_id = co.estado_id ");
|
||||
sql.append(" where ");
|
||||
sql.append(" ( cd.indreimpresion = 0 or cd.indreimpresion is null ) ");
|
||||
sql.append(" and ee.empresa_id = :EMPRESA_ID ");
|
||||
sql.append(ufs == null ? "" : "and eo.estado_id in ( " + ufs + " ) ");
|
||||
sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) ");
|
||||
sql.append(pdvs == null ? "" : "and ccp.puntoventa_id in ( " + pdvs + " ) ");
|
||||
sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId);
|
||||
sql.append(" and ee.fechoringreso between :DATE_INICIO and :DATE_FIM ");
|
||||
sql.append(" ) ed ");
|
||||
sql.append(" group by ed.puntoventaId, ed.estadoId, ed.empresaId ");
|
||||
sql.append(" ) eed on agrc.empresaId = eed.empresaId and agrc.puntoventaId = eed.puntoventaId and agrc.estadoId = eed.estadoId ");
|
||||
sql.append(" and ccp.FECCORTE between :DATE_INICIO and :DATE_FIM ");
|
||||
sql.append(" group by ee.empresa_id, cd.puntoventa_id, eo.estado_id, trunc(ee.fechoringreso) ");
|
||||
sql.append(" ) eed on agrc.empresaId = eed.empresaId and agrc.puntoventaId = eed.puntoventaId and agrc.estadoId = eed.estadoId AND agrc.fechorVenta = eed.fechorVenta ");
|
||||
sql.append("left join ( ");
|
||||
sql.append(" select coalesce(sum(fd.valor), 0) as deposito, pv.puntoventa_id as puntoventaId, fcc.empresa_id as empresaId, eo.estado_id as estadoId ");
|
||||
sql.append(" select coalesce(sum(fd.valor), 0) as deposito, pv.puntoventa_id as puntoventaId, fcc.empresa_id as empresaId, eo.estado_id as estadoId, ");
|
||||
sql.append(" trunc(fd.feccreacion) as fechorVenta ");
|
||||
sql.append(" from fechamento_cntcorrente fcc ");
|
||||
sql.append(" join fechamento_cct_deposito fcd on fcd.fechamentocntcorrente_id = fcc.fechamentocntcorrente_id ");
|
||||
sql.append(" join fechamento_deposito fd on fd.fechamentocntcorrente_id = fcd.fechamentocntcorrente_id ");
|
||||
|
@ -443,10 +449,11 @@ public class RelatorioFinanceiroSintetico extends Relatorio {
|
|||
sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) ");
|
||||
sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId);
|
||||
sql.append(" and fd.feccreacion between :DATE_INICIO and :DATE_FIM ");
|
||||
sql.append(" group by pv.puntoventa_id, fcc.empresa_id, eo.estado_id ");
|
||||
sql.append(" ) depd on agrc.empresaId = depd.empresaId and agrc.puntoventaId = depd.puntoventaId and agrc.estadoId = depd.estadoId ");
|
||||
sql.append(" group by pv.puntoventa_id, fcc.empresa_id, eo.estado_id, trunc(fd.feccreacion) ");
|
||||
sql.append(" ) depd on agrc.empresaId = depd.empresaId and agrc.puntoventaId = depd.puntoventaId and agrc.estadoId = depd.estadoId and agrc.fechorVenta = depd.fechorVenta ");
|
||||
sql.append("left join ( ");
|
||||
sql.append(" select coalesce(sum(fb.valordocumento), 0) as boleto_bnc , pv.puntoventa_id as puntoventaId, fcc.empresa_id as empresaId, eo.estado_id as estadoId ");
|
||||
sql.append(" select coalesce(sum(fb.valordocumento), 0) as boleto_bnc , pv.puntoventa_id as puntoventaId, fcc.empresa_id as empresaId, eo.estado_id as estadoId, ");
|
||||
sql.append(" trunc(fb.fecmodif) as fechorVenta ");
|
||||
sql.append(" from fechamento_cntcorrente fcc ");
|
||||
sql.append(" join fechamento_boleto fb on fb.fechamentocntcorrente_id = fcc.fechamentocntcorrente_id ");
|
||||
sql.append(" join punto_venta pv on pv.puntoventa_id = fcc.puntoventa_id ");
|
||||
|
@ -458,8 +465,8 @@ public class RelatorioFinanceiroSintetico extends Relatorio {
|
|||
sql.append(pdvs == null ? "" : "and pv.puntoventa_id in ( " + pdvs + " ) ");
|
||||
sql.append(tipoptovtaId == -1 ? "" : "and pv.tipoptovta_id = " + tipoptovtaId);
|
||||
sql.append(" and fb.fecmodif between :DATE_INICIO and :DATE_FIM ");
|
||||
sql.append(" group by pv.puntoventa_id, fcc.empresa_id, eo.estado_id ");
|
||||
sql.append(" ) bold on agrc.empresaId = bold.empresaId and agrc.puntoventaId = bold.puntoventaId and agrc.estadoId = bold.estadoId ");
|
||||
sql.append(" group by pv.puntoventa_id, fcc.empresa_id, eo.estado_id, trunc(fb.fecmodif) ");
|
||||
sql.append(" ) bold on agrc.empresaId = bold.empresaId and agrc.puntoventaId = bold.puntoventaId and agrc.estadoId = bold.estadoId and agrc.fechorVenta = bold.fechorVenta ");
|
||||
|
||||
return sql.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue