diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAproveitamentoFinanceiro.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAproveitamentoFinanceiro.java index 552a51d7d..6f3b73ac6 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAproveitamentoFinanceiro.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioAproveitamentoFinanceiro.java @@ -41,7 +41,7 @@ public class RelatorioAproveitamentoFinanceiro extends Relatorio { sql.append(" count( c.caja_id) as passageiros, "); sql.append(" sum( c.PRECIOPAGADO )as valor, "); sql.append(" to_char( c.FECHORVENTA, 'DY') as dia, "); - sql.append(" count(DISTINCT to_char( c.FECHORVENTA, 'WW')) as qtde, "); + sql.append(" coalesce(count(DISTINCT to_char( c.FECHORVENTA, 'WW')), 0) as qtde, "); sql.append(" r.indsentidoida as sentido, "); sql.append(" da.cantasientos as assentos, "); sql.append(" TO_CHAR(co.fechorsalidaoriginal ,'HH24:mi') as horario, "); @@ -109,96 +109,95 @@ public class RelatorioAproveitamentoFinanceiro extends Relatorio { BigDecimal tarifa = limpaNulo(rset.getBigDecimal("tarifa")); BigDecimal totPassageiros = BigDecimal.ZERO; BigDecimal totReceita = BigDecimal.ZERO; - BigDecimal viagens = BigDecimal.ZERO; + Integer viagens =0; BigDecimal segReceitaOpe = limpaNulo(rset.getBigDecimal("'SEG'_RECEITA_OPE")); - BigDecimal segQtde = limpaNulo(rset.getBigDecimal("'SEG'_QTDE")); + Integer segQtde = rset.getInt("'SEG'_QTDE"); BigDecimal segTot = limpaNulo(rset.getBigDecimal("'SEG'_TOT")); totPassageiros = totPassageiros.add(segTot); totReceita = totReceita.add(segReceitaOpe); - viagens = viagens.add(segQtde); + viagens = viagens + segQtde; BigDecimal terReceitaOpe = limpaNulo(rset.getBigDecimal("'TER'_RECEITA_OPE")); - BigDecimal terQtde = limpaNulo(rset.getBigDecimal("'TER'_QTDE")); + Integer terQtde = rset.getInt("'TER'_QTDE"); BigDecimal terTot = limpaNulo(rset.getBigDecimal("'TER'_TOT")); totPassageiros = totPassageiros.add(terTot); totReceita = totReceita.add(terReceitaOpe); - viagens = viagens.add(terQtde); + viagens = viagens .intValue() + terQtde.intValue(); BigDecimal quaReceitaOpe = limpaNulo(rset.getBigDecimal("'QUA'_RECEITA_OPE")); - BigDecimal quaQtde = limpaNulo(rset.getBigDecimal("'QUA'_QTDE")); + Integer quaQtde = rset.getInt("'QUA'_QTDE"); BigDecimal quaTot = limpaNulo(rset.getBigDecimal("'QUA'_TOT")); totPassageiros = totPassageiros.add(quaTot); totReceita = totReceita.add(quaReceitaOpe); - viagens = viagens.add(quaQtde); + viagens = viagens.intValue() + quaQtde.intValue(); BigDecimal quiReceitaOpe = limpaNulo(rset.getBigDecimal("'QUI'_RECEITA_OPE")); - BigDecimal quiQtde = limpaNulo(rset.getBigDecimal("'QUI'_QTDE")); + Integer quiQtde = rset.getInt("'QUI'_QTDE"); BigDecimal quiTot = limpaNulo(rset.getBigDecimal("'QUI'_TOT")); totPassageiros = totPassageiros.add(quiTot); totReceita = totReceita.add(quiReceitaOpe); - viagens = viagens.add(quiQtde); + viagens = viagens.intValue() + quiQtde.intValue(); BigDecimal sexReceitaOpe = limpaNulo(rset.getBigDecimal("'SEX'_RECEITA_OPE")); - BigDecimal sexQtde = limpaNulo(rset.getBigDecimal("'SEX'_QTDE")); + Integer sexQtde = rset.getInt("'SEX'_QTDE"); BigDecimal sexTot = limpaNulo(rset.getBigDecimal("'SEX'_TOT")); totPassageiros = totPassageiros.add(sexTot); totReceita = totReceita.add(sexReceitaOpe); - viagens = viagens.add(sexQtde); + viagens = viagens.intValue() + sexQtde.intValue(); BigDecimal sabReceitaOpe = limpaNulo(rset.getBigDecimal("'SAB'_RECEITA_OPE")); - BigDecimal sabQtde = limpaNulo(rset.getBigDecimal("'SAB'_QTDE")); + Integer sabQtde = rset.getInt("'SAB'_QTDE"); BigDecimal sabTot = limpaNulo(rset.getBigDecimal("'SAB'_TOT")); totPassageiros = totPassageiros.add(sabTot); totReceita = totReceita.add(sabReceitaOpe); - viagens = viagens.add(sabQtde); + viagens = viagens.intValue() + sabQtde.intValue(); BigDecimal domReceitaOpe = limpaNulo(rset.getBigDecimal("'DOM'_RECEITA_OPE")); - BigDecimal domQtde = limpaNulo(rset.getBigDecimal("'DOM'_QTDE")); + Integer domQtde = rset.getInt("'DOM'_QTDE"); BigDecimal domTot = limpaNulo(rset.getBigDecimal("'DOM'_TOT")); totPassageiros = totPassageiros.add(domTot); totReceita = totReceita.add(domReceitaOpe); - viagens = viagens.add(domQtde); - - dataResult.put("VIAGENS", viagens); - log.info("VIAGENS: " + viagens.toString() ); + viagens = viagens.intValue() + domQtde.intValue(); + dataResult.put("VIAGENS", new BigDecimal(viagens)); + log.info("VIAGENS: " + viagens ); dataResult.put("ASSENTOS", assentos); dataResult.put("TARIFA", tarifa); dataResult.put("TOT_PASSAGEIROS", totPassageiros); dataResult.put("TOT_RECEITA", totReceita); dataResult.put("SEG_RECEITA_OPE", segReceitaOpe); - dataResult.put("SEG_QTDE", segQtde); + dataResult.put("SEG_QTDE", new BigDecimal(segQtde)); dataResult.put("SEG_TOT", segTot); dataResult.put("SEG_FIN", calculaMedia(segReceitaOpe, tarifa, segQtde, segTot)); dataResult.put("TER_RECEITA_OPE", terReceitaOpe); - dataResult.put("TER_QTDE", terQtde); + dataResult.put("TER_QTDE", new BigDecimal(terQtde)); dataResult.put("TER_TOT", terTot); dataResult.put("TER_FIN", calculaMedia(terReceitaOpe, tarifa, terQtde, terTot)); dataResult.put("QUA_RECEITA_OPE", quaReceitaOpe); - dataResult.put("QUA_QTDE", quaQtde); + dataResult.put("QUA_QTDE", new BigDecimal(quaQtde)); dataResult.put("QUA_TOT", quaTot); dataResult.put("QUA_FIN", calculaMedia(quaReceitaOpe, tarifa, quaQtde, quaTot)); dataResult.put("QUI_RECEITA_OPE", quiReceitaOpe); - dataResult.put("QUI_QTDE", quiQtde); + dataResult.put("QUI_QTDE", new BigDecimal(quiQtde)); dataResult.put("QUI_TOT", quiTot); dataResult.put("QUI_FIN", calculaMedia(quiReceitaOpe, tarifa, quiQtde, quiTot)); dataResult.put("SEX_RECEITA_OPE", sexReceitaOpe); - dataResult.put("SEX_QTDE", sexQtde); + dataResult.put("SEX_QTDE", new BigDecimal(sexQtde)); dataResult.put("SEX_TOT", sexTot); dataResult.put("SEX_FIN", calculaMedia(sexReceitaOpe, tarifa, sexQtde, sexTot)); dataResult.put("SAB_RECEITA_OPE", sabReceitaOpe); - dataResult.put("SAB_QTDE", sabQtde); + dataResult.put("SAB_QTDE", new BigDecimal(sabQtde)); dataResult.put("SAB_TOT", sabTot); dataResult.put("SAB_FIN", calculaMedia(sabReceitaOpe, tarifa, sabQtde, sabTot)); dataResult.put("DOM_RECEITA_OPE", domReceitaOpe); - dataResult.put("DOM_QTDE", domQtde); + dataResult.put("DOM_QTDE", new BigDecimal(domQtde)); dataResult.put("DOM_TOT", domTot); dataResult.put("DOM_FIN", calculaMedia(domReceitaOpe, tarifa, domQtde, domTot)); @@ -223,9 +222,9 @@ public class RelatorioAproveitamentoFinanceiro extends Relatorio { } } - private BigDecimal calculaMedia(BigDecimal totReceita, BigDecimal tarifa, BigDecimal qtde, BigDecimal tot) { + private BigDecimal calculaMedia(BigDecimal totReceita, BigDecimal tarifa, Integer qtde, BigDecimal tot) { if( qtde.intValue() != 0 && tot.intValue() !=0 ) { - BigDecimal dividendo = tarifa.multiply(qtde); + BigDecimal dividendo = tarifa.multiply(new BigDecimal(qtde)); dividendo = dividendo.multiply(tot); if(dividendo.intValue() == 0 ) {