diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java index 8eb8e8f90..5f0cfee60 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java @@ -107,18 +107,20 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" where c.activo = 1 and po.activo = 1 and co.activo = 1 and eo.activo = 1 and ei.activo = 1 "); sql.append(" and coalesce(case when s.aliasorigen_id is null then ei.activo else eis.activo end, 0) = 1 "); sql.append(" and bpe.tipoamb = 1 "); - sql.append(" and ((c.indreimpresion = 0 and c.motivocancelacion_id is null and c.numfoliosistema is not null) or (c.indstatusboleto = 'E' and c.indreimpresion = 1)) "); - sql.append(" and ((case when coalesce(r.indtribtarifa,0) = 1 then c.preciopagado else 0 end) + (case when coalesce(r.indtribtaxaembarque,0) = 1 then c.importetaxaembarque else 0 end) + (case when coalesce(r.indtribpedagio,0) = 1 then c.importepedagio else 0 end)) > 0 "); - // sql.append(" and c.feccreacion >= to_date(?,'DD/MM/YYYY HH24:MI:SS') and c.feccreacion <= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); + // sql.append(" and ((c.indreimpresion = 0 and c.motivocancelacion_id is null and c.numfoliosistema is not null) or (c.indstatusboleto = 'E' and c.indreimpresion = 1)) "); + // sql.append(" and ((case when coalesce(r.indtribtarifa,0) = 1 then c.preciopagado else 0 end) + (case when coalesce(r.indtribtaxaembarque,0) = 1 then c.importetaxaembarque else 0 end) + (case when coalesce(r.indtribpedagio,0) = 1 then c.importepedagio else 0 end)) > 0 "); + + // sql.append(" and c.feccreacion >= to_date(?,'DD/MM/YYYY HH24:MI:SS') and c.feccreacion <= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); + sql.append(" and (case when (case when s.aliasorigen_id is null then ei.indtribviagem else eis.indtribviagem end) = 1 then "); sql.append(" c.fechorviaje else c.feccreacion end) >= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); sql.append(" and (case when (case when s.aliasorigen_id is null then ei.indtribviagem else eis.indtribviagem end) = 1 then "); sql.append(" c.fechorviaje else c.feccreacion end) <= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); - + sql.append(" and c.empresacorrida_id = ? "); sql.append(" and ((case when s.aliasorigen_id is null then eo.cveestado else eos.cveestado end) = ?) "); - sql.append(" order by dhrecbto, numfoliosistema "); + sql.append(" order by dhrecbto, chbpe, numfoliosistema "); try { PreparedStatement ps = connection.prepareStatement(sql.toString()); @@ -239,9 +241,14 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { String xmlBpe = null; StringBuilder sql = new StringBuilder(); sql.append(" select distinct "); - sql.append(" DBMS_LOB.substr(bpe.xmlregular, 4000) as xml_bpe, "); - sql.append(" DBMS_LOB.substr(bpe.xmlregular, 4000, 4001) as xml_bpe_2, "); - sql.append(" DBMS_LOB.substr(bpe.xmlregular, 4000, 8001) as xml_bpe_3 "); + sql.append(" DBMS_LOB.substr(bpe.xmlregular, 3000) as xml_bpe, "); + sql.append(" DBMS_LOB.substr(bpe.xmlregular, 3000, 3001) as xml_bpe_2, "); + sql.append(" DBMS_LOB.substr(bpe.xmlregular, 3000, 6001) as xml_bpe_3 "); + + // sql.append(" DBMS_LOB.substr(bpe.xmlregular, 4000) as xml_bpe, "); + // sql.append(" DBMS_LOB.substr(bpe.xmlregular, 4000, 4001) as xml_bpe_2, "); + // sql.append(" DBMS_LOB.substr(bpe.xmlregular, 4000, 8001) as xml_bpe_3 "); + sql.append(" from bpe bpe "); sql.append(" where bpe.activo = 1 "); sql.append(" and bpe.tipoamb = 1 "); diff --git a/src/com/rjconsultores/ventaboletos/utilerias/exportacao/ExportacaoBpe.java b/src/com/rjconsultores/ventaboletos/utilerias/exportacao/ExportacaoBpe.java index 1a82ecd9f..d3f966520 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/exportacao/ExportacaoBpe.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/exportacao/ExportacaoBpe.java @@ -103,9 +103,10 @@ public class ExportacaoBpe { String chaveEletrônica = tipoBPE.getChaveEletronica(); String serie = tipoBPE.getSerie(); String numero = tipoBPE.getNumero(); - String dataEmissao = tipoBPE.getDataEmissao(); + String dataPrestacao = StringUtils.isBlank(tipoBPE.getDataPrestacao()) ? VAZIO : tipoBPE.getDataPrestacao(); + String dataEmissao = StringUtils.isBlank(tipoBPE.getDataEmissao()) ? VAZIO : tipoBPE.getDataEmissao(); String situacaoDocumento = tipoBPE.getSituacaoDoc(); - String dataPrestacao = tipoBPE.getDataPrestacao(); + String valorBruto = tipoBPE.getValorBruto() == null ? VAZIO : formataValor(tipoBPE.getValorBruto(), 15); String valorDesconto = tipoBPE.getValorDesconto() == null ? VAZIO : formataValor(tipoBPE.getValorDesconto(), 15); String UFOrigem = tipoBPE.getUFOrigem(); @@ -129,8 +130,7 @@ public class ExportacaoBpe { String receitaIRPJ3 = VAZIO; String receitaIRPJ4 = VAZIO; String tipoBPe = tipoBPE.getTipoBPe(); - String chaveEletRef = VAZIO; - // String chaveEletRef = tipoBPE.getChaveEletronicaReferencia(); + String chaveEletRef = StringUtils.isBlank(tipoBPE.getChaveEletronicaReferencia()) ? VAZIO : tipoBPE.getChaveEletronicaReferencia(); String codigoContabil = StringUtils.isBlank(tipoBPE.getCodigoContabil()) ? VAZIO : tipoBPE.getCodigoContabil(); String codigoPrevidenciaria = tipoBPE.getIndContribuicaoPrevidenciaria(); String codigoComplementar = VAZIO; diff --git a/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java b/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java index cdfb7dd7f..de17bd243 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java @@ -86,10 +86,17 @@ public class ExportacaoBPEVo { registro.getListaRegistroBPE().add(tipoBPE); } else { - String vBC = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVBC(); - String pICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getPICMS(); - String vICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVICMS(); - String vBP = tbpe.getInfBPe().getInfValorBPe().getVBP(); + String vBC = null; + String pICMS = null; + String vICMS = null; + String vBP = null; + + if (tbpe.getInfBPe().getImp().getICMS().getICMS00() != null) { + vBC = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVBC(); + pICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getPICMS(); + vICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVICMS(); + vBP = tbpe.getInfBPe().getInfValorBPe().getVBP(); + } String cstCofins = "01"; String cstPis = "01";