From 3d466d7e1a82726c7371ef7b987a813c27b2694e Mon Sep 17 00:00:00 2001 From: valdevir Date: Fri, 12 Feb 2021 13:51:52 +0000 Subject: [PATCH] fixes bug#21352 qua: dev:Fabio git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@105362 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../impl/RelatorioReceitaDiariaAgencia.java | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioReceitaDiariaAgencia.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioReceitaDiariaAgencia.java index 5b8fbba0f..ecc01356d 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioReceitaDiariaAgencia.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioReceitaDiariaAgencia.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -32,7 +33,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.NamedParameterStatement; */ public class RelatorioReceitaDiariaAgencia extends Relatorio { - private Map> mapCacheConfigComissao; + private LinkedHashMap> mapCacheConfigComissao; //Mantis 16390 //As vendas com impressão posterior não estavam sendo exibidas como prévenda pois só estavam sendo validados os tipoVendaId 18 e 39. //Verifiquei a classe RelatorioImpressaoPosterior e adicionei os tipoVendaId faltantes de acordo com sua regra de negócio. @@ -40,23 +41,37 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { private Set pontoVendaConfiguracao; - public RelatorioReceitaDiariaAgencia(Map parametros, Connection conexao) throws Exception { + public RelatorioReceitaDiariaAgencia(final Map parametros, Connection conexao) throws Exception { super(parametros, conexao); CalculoImposto.limpaCache(); - this.mapCacheConfigComissao = new HashMap>(); + this.mapCacheConfigComissao = new LinkedHashMap>(); this.setCustomDataSource(new ArrayDataSource(this) { - protected HashMap> mapDados; + protected LinkedHashMap> mapDados; @Override public Object valueCustomFields(String fieldName) throws Exception { if (fieldName.equals("RECEITA_TOTAL")) { BigDecimal gap = BigDecimal.ZERO; - - gap = ((BigDecimal) this.getByName("RECEITA_TARIFA_GAP")).add((BigDecimal) this.getByName("RECEITA_SEGURO_GAP")).add((BigDecimal) this.getByName("RECEITA_EMBARQUE_GAP")).add((BigDecimal) this.getByName("RECEITA_PEDAGIO_GAP")).subtract((BigDecimal) this.getByName("TOTAL_DEVOL_GAP")); + if( this.getByName("RECZEITA_TARIFA_GAP")!=null) { + gap = ((BigDecimal) this.getByName("RECZEITA_TARIFA_GAP")); + } + if(this.getByName("RECEITA_SEGURO_GAP") !=null) { + gap.add((BigDecimal) this.getByName("RECEITA_SEGURO_GAP")); + } + + if(this.getByName("RECEITA_EMBARQUE_GAP")!=null) { + gap.add((BigDecimal) this.getByName("RECEITA_EMBARQUE_GAP")); + } + if(this.getByName("RECEITA_PEDAGIO_GAP")!=null) { + gap.add((BigDecimal) this.getByName("RECEITA_PEDAGIO_GAP")); + } + if(getByName("TOTAL_DEVOL_GAP") !=null) { + gap.subtract((BigDecimal) this.getByName("TOTAL_DEVOL_GAP")); + } return ((BigDecimal) this.getByName("RECEITA_TARIFA")).add((BigDecimal) this.getByName("RECEITA_SEGURO")).add((BigDecimal) this.getByName("RECEITA_BAGAGEM")).add((BigDecimal) this.getByName("RECEITA_EMBARQUE")).add((BigDecimal) this.getByName("RECEITA_PEDAGIO")).subtract((BigDecimal) this.getByName("TOTAL_DEVOL")).add(gap); } @@ -134,11 +149,11 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { this.resultSet = stmt.executeQuery(); } - public void setRowComissao(Map rowOrigem) throws Exception { - Map rowDestino = rowOrigem; + public void setRowComissao(LinkedHashMap rowOrigem) throws Exception { + LinkedHashMap rowDestino = rowOrigem; // Busca as configurações de comissão - HashMap configComissao = getConfigComissao((Integer) rowOrigem.get("PUNTOVENTA_ID"), (Integer) rowOrigem.get("EMPRESAPUNTOVENTA_ID")); + LinkedHashMap configComissao = getConfigComissao((Integer) rowOrigem.get("PUNTOVENTA_ID"), (Integer) rowOrigem.get("EMPRESAPUNTOVENTA_ID")); if (configComissao == null) { return; } @@ -246,19 +261,19 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { rowDestino.put("ESTADO_ID", configComissao.get("ESTADO_ID")); rowDestino.put("TIPO_AGENCIA", configComissao.get("TIPO_AGENCIA")); - mapDados.put(puntoVentaId + "-" + rowOrigem.get("EMPRESA_ID"), (HashMap) rowDestino); + mapDados.put(puntoVentaId + "-" + rowOrigem.get("EMPRESA_ID"), (LinkedHashMap) rowDestino); } } - protected Map getRow(Integer puntoVentaId, Integer empresaId, ResultSet rs) throws SQLException { + protected LinkedHashMap getRow(Integer puntoVentaId, Integer empresaId, ResultSet rs) throws SQLException { - Map row; + LinkedHashMap row; if (mapDados.containsKey(puntoVentaId.toString() + "-" + empresaId.toString())) { row = mapDados.get(puntoVentaId.toString() + "-" + empresaId.toString()); } else { - row = new HashMap(); + row = new LinkedHashMap(); row.put("TOTAL_BILHETES", BigDecimal.ZERO); row.put("TOTAL_BILHETES_CANC", BigDecimal.ZERO); row.put("TOTAL_BILHETES_GAP", BigDecimal.ZERO); @@ -318,7 +333,7 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { public void initDados() throws Exception { pontoVendaConfiguracao = new HashSet(); this.prepareQuery(); - this.mapDados = new HashMap>(); + this.mapDados = new LinkedHashMap>(); this.resultSet.setFetchSize(1000); while (this.resultSet.next()) { @@ -330,9 +345,9 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { Integer idEstado = this.resultSet.getInt("ORIGEM_ESTADO_ID"); // Inicializa a row atual - Map row = this.getRow(puntoVentaId, empresaId, this.resultSet); + LinkedHashMap row = this.getRow(puntoVentaId, empresaId, this.resultSet); - this.mapDados.put(row.get("PUNTOVENTA_ID") + "-" + empresaId.toString(), (HashMap) row); + this.mapDados.put(row.get("PUNTOVENTA_ID") + "-" + empresaId.toString(), (LinkedHashMap) row); if ((Boolean) getParametros().get("TRANSFERENCIA_PASSAGENS")) { // Utiliza o -1 para retirar as transferências @@ -451,9 +466,9 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { public void processaParametros() throws Exception { } - public HashMap getConfigComissao(Integer puntoVentaId, Integer empresaId) throws Exception { + public LinkedHashMap getConfigComissao(Integer puntoVentaId, Integer empresaId) throws Exception { - HashMap cacheConfig = null; + LinkedHashMap cacheConfig = null; // Verifica se já existe configuração na memoria, caso não exista, realiza busca no banco if (!mapCacheConfigComissao.containsKey(puntoVentaId.toString() + "_" + empresaId.toString())) { @@ -481,7 +496,7 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { ResultSet rs = stmt.executeQuery(); if (rs.next()) { - cacheConfig = new HashMap(); + cacheConfig = new LinkedHashMap(); cacheConfig.put("ISSRETIDO", rs.getBigDecimal("ISSRETIDO")); cacheConfig.put("ROYALTIES", rs.getBigDecimal("ROYALTIES")); @@ -750,7 +765,7 @@ public class RelatorioReceitaDiariaAgencia extends Relatorio { sql.append(" :ISNUMPUNTOVENTATODOS = 'N') OR (:ISNUMPUNTOVENTATODOS = 'S')) "); sql.append(" AND ((INSTR(:ESTADO_ID, ',' || TRIM(ES.ESTADO_ID) || ',') > 0 AND "); sql.append(" :ISESTADOTODOS = 'N') OR (:ISESTADOTODOS = 'S')) "); - sql.append(" ORDER BY to_number(regexp_substr(PV.NUMPUNTOVENTA, '\\d+')), EC.NOMBEMPRESA, ES.CVEESTADO "); + sql.append(" ORDER BY lpad(to_number(regexp_substr(PV.NUMPUNTOVENTA, '\\d+')), 6), EC.NOMBEMPRESA, ES.CVEESTADO "); return sql.toString(); }