From 934bd39286f7ec66603ba4ab41d7b41db64d5e2d Mon Sep 17 00:00:00 2001 From: julio Date: Wed, 28 Oct 2015 13:40:20 +0000 Subject: [PATCH] fixes bug #6778 git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@49530 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../relatorios/impl/RelatorioTaxasLinha.java | 58 +++++++++++-------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTaxasLinha.java b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTaxasLinha.java index c80021eab..749c9a808 100644 --- a/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTaxasLinha.java +++ b/src/java/com/rjconsultores/ventaboletos/relatorios/impl/RelatorioTaxasLinha.java @@ -33,7 +33,7 @@ public class RelatorioTaxasLinha extends Relatorio { super(parametros, conexao); CalculoImposto.limpaCache(); - this.setCustomDataSource(false,new DataSource(this) { + this.setCustomDataSource(false, new DataSource(this) { public void initDados() throws Exception { Connection conexao = this.relatorio.getConexao(); @@ -76,31 +76,41 @@ public class RelatorioTaxasLinha extends Relatorio { BigDecimal valorIcms = BigDecimal.ZERO; String indInterestadual = this.resultSet.getString("INTERESTADUAL"); Integer idEstado = this.resultSet.getInt("ORIGEM_ESTADO_ID"); + Integer empresaId = this.resultSet.getInt("EMPRESA_ID"); try { - if (fieldName.equals("IMPORTETAXAEMBARQUE") && this.resultSet.getBigDecimal("IMPORTETAXAEMBARQUE") != null && !this.resultSet.getBigDecimal("IMPORTETAXAEMBARQUE").equals(BigDecimal.ZERO)) { - valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, this.resultSet.getInt("EMPRESA_ID"), indInterestadual, BigDecimal.ZERO, BigDecimal.ZERO, this.resultSet.getBigDecimal("IMPORTETAXAEMBARQUE"), BigDecimal.ZERO); - return this.resultSet.getBigDecimal("IMPORTETAXAEMBARQUE").subtract(valorIcms); - } - else if (fieldName.equals("IMPORTEPEDAGIO") && this.resultSet.getBigDecimal("IMPORTEPEDAGIO") != null && !this.resultSet.getBigDecimal("IMPORTEPEDAGIO").equals(BigDecimal.ZERO)) { - valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, this.resultSet.getInt("EMPRESA_ID"), indInterestadual, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, this.resultSet.getBigDecimal("IMPORTEPEDAGIO")); - return this.resultSet.getBigDecimal("IMPORTEPEDAGIO").subtract(valorIcms); - } - else if (fieldName.equals("IMPORTESEGURO") && this.resultSet.getBigDecimal("IMPORTESEGURO") != null && !this.resultSet.getBigDecimal("IMPORTESEGURO").equals(BigDecimal.ZERO)) { - valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, this.resultSet.getInt("EMPRESA_ID"), indInterestadual, BigDecimal.ZERO, this.resultSet.getBigDecimal("IMPORTESEGURO"), BigDecimal.ZERO, BigDecimal.ZERO); - return this.resultSet.getBigDecimal("IMPORTESEGURO").subtract(valorIcms); - } - else if (fieldName.equals("TOTAL_EMBARQUE") && !this.resultSet.getBigDecimal("TOTAL_EMBARQUE").equals(BigDecimal.ZERO)) { - valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, this.resultSet.getInt("EMPRESA_ID"), indInterestadual, BigDecimal.ZERO, this.resultSet.getBigDecimal("TOTAL_EMBARQUE"), BigDecimal.ZERO, BigDecimal.ZERO); - return this.resultSet.getBigDecimal("TOTAL_EMBARQUE").subtract(valorIcms); - } - else if (fieldName.equals("TOTAL_PEDAGIO") && !this.resultSet.getBigDecimal("TOTAL_PEDAGIO").equals(BigDecimal.ZERO)) { - valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, this.resultSet.getInt("EMPRESA_ID"), indInterestadual, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, this.resultSet.getBigDecimal("TOTAL_PEDAGIO")); - return this.resultSet.getBigDecimal("TOTAL_PEDAGIO").subtract(valorIcms); - } - else if (fieldName.equals("TOTAL_SEGURO") && !this.resultSet.getBigDecimal("TOTAL_SEGURO").equals(BigDecimal.ZERO)) { - valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, this.resultSet.getInt("EMPRESA_ID"), indInterestadual, BigDecimal.ZERO, this.resultSet.getBigDecimal("TOTAL_SEGURO"), BigDecimal.ZERO, BigDecimal.ZERO); - return this.resultSet.getBigDecimal("TOTAL_SEGURO").subtract(valorIcms); + BigDecimal importeTaxaEmbarque = resultSet.getBigDecimal("IMPORTETAXAEMBARQUE") == null ? BigDecimal.ZERO : resultSet.getBigDecimal("IMPORTETAXAEMBARQUE"); + BigDecimal importePedagio = resultSet.getBigDecimal("IMPORTEPEDAGIO") == null ? BigDecimal.ZERO : resultSet.getBigDecimal("IMPORTEPEDAGIO"); + BigDecimal importeSeguro = resultSet.getBigDecimal("IMPORTESEGURO") == null ? BigDecimal.ZERO : resultSet.getBigDecimal("IMPORTESEGURO"); + + BigDecimal totalEmbarque = resultSet.getBigDecimal("TOTAL_EMBARQUE") == null ? BigDecimal.ZERO : resultSet.getBigDecimal("TOTAL_EMBARQUE"); + BigDecimal totalPedagio = resultSet.getBigDecimal("TOTAL_PEDAGIO") == null ? BigDecimal.ZERO : resultSet.getBigDecimal("TOTAL_PEDAGIO"); + BigDecimal totalSeguro = resultSet.getBigDecimal("TOTAL_SEGURO") == null ? BigDecimal.ZERO : resultSet.getBigDecimal("TOTAL_SEGURO"); + + if (fieldName.equals("IMPORTETAXAEMBARQUE") && !!importeTaxaEmbarque.equals(BigDecimal.ZERO)) { + valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, empresaId, indInterestadual, BigDecimal.ZERO, BigDecimal.ZERO, importeTaxaEmbarque, BigDecimal.ZERO); + return importeTaxaEmbarque.subtract(valorIcms); + + } else if (fieldName.equals("IMPORTEPEDAGIO") && !importePedagio.equals(BigDecimal.ZERO)) { + valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, empresaId, indInterestadual, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, importePedagio); + return importePedagio.subtract(valorIcms); + + } else if (fieldName.equals("IMPORTESEGURO") && !importeSeguro.equals(BigDecimal.ZERO)) { + valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, empresaId, indInterestadual, BigDecimal.ZERO, importeSeguro, BigDecimal.ZERO, BigDecimal.ZERO); + return importeSeguro.subtract(valorIcms); + + } else if (fieldName.equals("TOTAL_EMBARQUE") && !totalEmbarque.equals(BigDecimal.ZERO)) { + valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, empresaId, indInterestadual, BigDecimal.ZERO, totalEmbarque, BigDecimal.ZERO, BigDecimal.ZERO); + return totalEmbarque.subtract(valorIcms); + + } else if (fieldName.equals("TOTAL_PEDAGIO") && !totalPedagio.equals(BigDecimal.ZERO)) { + valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, empresaId, indInterestadual, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, totalPedagio); + return totalPedagio.subtract(valorIcms); + + } else if (fieldName.equals("TOTAL_SEGURO") && !totalSeguro.equals(BigDecimal.ZERO)) { + valorIcms = CalculoImposto.getValorImposto(this.relatorio.getConexao(), idEstado, empresaId, indInterestadual, BigDecimal.ZERO, totalSeguro, BigDecimal.ZERO, BigDecimal.ZERO); + return totalSeguro.subtract(valorIcms); + } } catch (Exception e) { if (e instanceof ExceptionConfiguracao)