From 30c28cf12e0998283351fe3c4f266d20993cd1b4 Mon Sep 17 00:00:00 2001 From: alberto Date: Mon, 9 Jan 2017 13:30:46 +0000 Subject: [PATCH] =?UTF-8?q?Exporta=C3=A7=C3=A3o=20Fiscal=20:=20ECF=20e=20R?= =?UTF-8?q?MD=20(issue=208120)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@64706 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../dao/hibernate/FiscalHibernateDAO.java | 2 +- .../exportacaofiscal/ExportacaoFiscal.java | 30 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java index dab25b9b8..59076c1ce 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/FiscalHibernateDAO.java @@ -1306,7 +1306,7 @@ public class FiscalHibernateDAO implements FiscalDAO { registro = new ExportacaoECFTipoCFC(); registro.setEstabelecimento(rs.getString("codestabelecimento")); registro.setDataEmissao(rs.getString("datamov")); - registro.setNumeroIdentificacaoECF(rs.getString("numeroidentificacao") == null || rs.getString("numeroidentificacao").isEmpty() ? rs.getString("numserie") : rs.getString("numeroidentificacao")); + registro.setNumeroIdentificacaoECF(rs.getString("numeroidentificacao") == null || rs.getString("numeroidentificacao").isEmpty() ? "0" : rs.getString("numeroidentificacao")); registro.setEcf(rs.getString("ecf")); registro.setCooReducaoZ(Integer.valueOf(rs.getString("coo"))); registro.setCooInicial(Integer.valueOf(rs.getString("cooinicial"))); diff --git a/src/com/rjconsultores/ventaboletos/utilerias/exportacaofiscal/ExportacaoFiscal.java b/src/com/rjconsultores/ventaboletos/utilerias/exportacaofiscal/ExportacaoFiscal.java index f4ec88597..2a9deed39 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/exportacaofiscal/ExportacaoFiscal.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/exportacaofiscal/ExportacaoFiscal.java @@ -247,7 +247,7 @@ public class ExportacaoFiscal { Integer situacaoCOO = item.getSituacaoCOO(); // 0 - Documento Regular; 2 - Documento Cancelado BigDecimal acrescimo = item.getAcrescimo(); String ufOrigem = item.getUfOrigem(); - Integer municipioOrigem = item.getMunicipioOrigem(); + String municipioOrigem = item.getMunicipioOrigem() == null ? null : item.getMunicipioOrigem().toString(); String ufDestino = item.getUfDestino(); Integer cfop = item.getCfop(); // IM=5357; Serviço IE= 6357 Integer codigoSituacaoTribColunaB = item.getCodigoSituacaoTribColunaB(); // 00 - tributação normal; 20 - tributação com redução na base de calculo; 40 - isentos @@ -256,20 +256,24 @@ public class ExportacaoFiscal { BigDecimal valorBaseCalculoICMS = item.getValorBaseCalculoICMS(); BigDecimal aliquotaICMS = item.getAliquotaICMS(); + if (municipioOrigem != null && municipioOrigem.length() > 5) { + municipioOrigem = municipioOrigem.substring(municipioOrigem.length() - 5, municipioOrigem.length()); + } + StringBuilder sb = new StringBuilder(); sb.append("CCF").append(SEPARADOR); sb.append(formataNumerico(coo.toString(), true, 6)).append(SEPARADOR); sb.append(formataValor(valorServico, 15)).append(SEPARADOR); - sb.append(formataValor(descontoGlobal, 15)).append(SEPARADOR); - sb.append(formataNumerico(codigoParticipante, true, 15)).append(SEPARADOR); + sb.append(descontoGlobal == null ? "" : formataValor(descontoGlobal, 15)).append(SEPARADOR); + sb.append(codigoParticipante == null ? "" : formataNumerico(codigoParticipante, true, 15)).append(SEPARADOR); sb.append(formataNumerico(situacaoCOO, true, 1)).append(SEPARADOR); - sb.append(formataValor(acrescimo, 15)).append(SEPARADOR); + sb.append(acrescimo == null ? "" : formataValor(acrescimo, 15)).append(SEPARADOR); sb.append(formataCaracter(ufOrigem, true, 2)).append(SEPARADOR); sb.append(formataNumerico(municipioOrigem, true, 5)).append(SEPARADOR); sb.append(formataCaracter(ufDestino, true, 2)).append(SEPARADOR); sb.append(formataNumerico(cfop, true, 4)).append(SEPARADOR); sb.append("0").append(SEPARADOR); - sb.append(formataNumerico(codigoSituacaoTribColunaB, true, 2)).append(SEPARADOR); + sb.append(codigoSituacaoTribColunaB == 0 ? "00" : formataNumerico(codigoSituacaoTribColunaB, true, 2)).append(SEPARADOR); sb.append(formataCaracter(VAZIO, false, 1)).append(SEPARADOR); // Posição 14 sb.append(formataCaracter(VAZIO, false, 1)).append(SEPARADOR); // Posição 15 sb.append(formataValor(valorTotal, 15)).append(SEPARADOR); @@ -301,8 +305,12 @@ public class ExportacaoFiscal { BigDecimal valorICMSOutros = item.getValorICMSOutros(); Integer codigoSituacaoTribColunaB = item.getCodigoSituacaoTribColunaB(); // 00 - tributação normal; 20 - tributação com redução na base de calculo; 40 - isentos String ufOrigem = item.getUfOrigem(); - Integer municipioOrigem = item.getMunicipioOrigem(); + String municipioOrigem = item.getMunicipioOrigem() == null ? null : item.getMunicipioOrigem().toString(); + if (municipioOrigem != null && municipioOrigem.length() > 5) { + municipioOrigem = municipioOrigem.substring(municipioOrigem.length() - 5, municipioOrigem.length()); + } + StringBuilder sb = new StringBuilder(); sb.append("ICF").append(SEPARADOR); sb.append(formataValor(valorTotal, 15)).append(SEPARADOR); @@ -317,7 +325,7 @@ public class ExportacaoFiscal { sb.append("N").append(SEPARADOR); sb.append("N").append(SEPARADOR); sb.append("0").append(SEPARADOR); - sb.append(formataNumerico(codigoSituacaoTribColunaB, true, 2)).append(SEPARADOR); + sb.append(codigoSituacaoTribColunaB == 0 ? "00" : formataNumerico(codigoSituacaoTribColunaB, true, 2)).append(SEPARADOR); sb.append(formataCaracter(VAZIO, false, 1)).append(SEPARADOR); // Posição 15 sb.append(formataCaracter(VAZIO, false, 3)).append(SEPARADOR); // Posição 16 sb.append("N").append(SEPARADOR); @@ -330,11 +338,15 @@ public class ExportacaoFiscal { private void adicionarLinhaPRC(PrintWriter writer, ExportacaoECFTipoPRC item) { String ufOrigem = item.getUfOrigem(); - Integer municipioOrigem = item.getMunicipioOrigem(); + String municipioOrigem = item.getMunicipioOrigem() == null ? null : item.getMunicipioOrigem().toString(); BigDecimal valorTotal = item.getValorTotal(); BigDecimal valorBaseCalculoICMS = item.getValorBaseCalculoICMS(); BigDecimal valorICMS = item.getValorICMS(); + if (municipioOrigem != null && municipioOrigem.length() > 5) { + municipioOrigem = municipioOrigem.substring(municipioOrigem.length() - 5, municipioOrigem.length()); + } + StringBuilder sb = new StringBuilder(); sb.append("PRC").append(SEPARADOR); sb.append(formataCaracter(ufOrigem, true, 2)).append(SEPARADOR); @@ -575,7 +587,7 @@ public class ExportacaoFiscal { sb.append(formataValor(valorICMS, 15)).append(SEPARADOR); sb.append(formataValor(valorICMSIsento, 15)).append(SEPARADOR); sb.append(formataValor(valorICMSOutros, 15)).append(SEPARADOR); - sb.append(formataNumerico(codigoSituacaoTribColunaB, true, 2)).append(SEPARADOR); + sb.append(codigoSituacaoTribColunaB == 0 ? "00" : formataNumerico(codigoSituacaoTribColunaB, true, 2)).append(SEPARADOR); sb.append(formataCaracter(ufOrigem, true, 2)).append(SEPARADOR); sb.append(formataNumerico(municipioOrigem, true, 5)).append(SEPARADOR); sb.append(formataCaracter(VAZIO, false, 3)); // Posição 13