diff --git a/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java b/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java index 40f6f931a..b6fc33eaa 100644 --- a/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java +++ b/src/com/rjconsultores/ventaboletos/dao/hibernate/BpeHibernateDAO.java @@ -64,7 +64,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO { sql.append(" bpe.chbpe, "); sql.append(" coalesce(chbpe_substituicao, ' ') as chbpe_sub, "); sql.append(" to_char(c.feccreacion, 'yyyymmdd') as dhrecbto, "); - sql.append(" coalesce(to_char(c.fechorventa, 'yyyymmdd'), to_char(to_timestamp_tz(bpe.dhvalidade, 'YYYY-MM-DD" + "\"T\"" + "HH24:MI:SSTZH:TZM'), 'yyyymmdd')) as dh_emisao, "); + sql.append(" to_char(c.feccreacion, 'yyyymmdd') as dh_emisao, "); sql.append(" coalesce(bpe.tiposubstituicao, '0') as tp_bpe, "); sql.append(" bpe.retorno_id as retorno, "); sql.append(" bpe.nprot, "); diff --git a/src/com/rjconsultores/ventaboletos/utilerias/DateUtil.java b/src/com/rjconsultores/ventaboletos/utilerias/DateUtil.java index de2f24b22..f0db0f5f2 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/DateUtil.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/DateUtil.java @@ -24,6 +24,8 @@ public final class DateUtil { public static String ddMMaaHHmm = "dd/MM/yyyy hh:mm"; public static String ddMMaa = "dd/MM/yyyy"; + public static String formatGMT = "yyyy-MM-dd'T'HH:mm:ss"; + public static String formatExp = "yyyymmdd"; /** * No need for an instance diff --git a/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java b/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java index 16aa6d67f..f73a201db 100644 --- a/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java +++ b/src/com/rjconsultores/ventaboletos/utilerias/exportacao/bpe/ExportacaoBPEVo.java @@ -6,6 +6,7 @@ import java.util.List; import org.apache.commons.lang.StringUtils; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; import com.rjconsultores.ventaboletos.utilerias.UtiliteriasFiscal; import com.rjconsultores.ventaboletos.utilerias.exportacao.bpe.xml.BPeUtil; @@ -59,9 +60,7 @@ public class ExportacaoBPEVo { } public boolean isBpeCancelado(ExportacaoBPEBase registro) { - return (registro.getCodstatus() == null ? false : (registro.getCodstatus().equals(StatusBpe.EVENTOS))) - // && (registro.getTipoevento() == null ? true : (registro.getTipoevento().equals(EventosBpe.CANCELAMENTO))) - ; + return (registro.getCodstatus() == null ? false : (registro.getCodstatus().equals(StatusBpe.EVENTOS))); } public void gerarListas(ExportacaoBPEBase registro) { @@ -86,6 +85,8 @@ public class ExportacaoBPEVo { String tpDoc = isCancelamento ? "1" : (StringUtils.isBlank(registro.getChbpeSub()) ? "0" : "0"); String numBpe = StringUtils.isNotBlank(xml) ? tbpe.getInfBPe().getIde().getNBP() : registro.getNumBpe(); + String dhEmisao = StringUtils.isBlank(xml) ? registro.getDhEmisao() + : DateUtil.changeFormatStringDate(tbpe.getInfBPe().getIde().getDhEmi(), DateUtil.formatGMT, DateUtil.formatExp); if (isCancelamento) { @@ -148,7 +149,7 @@ public class ExportacaoBPEVo { String tpBpe = StringUtils.isBlank(xml) ? "" : (StringUtils.isBlank(tbpe.getInfBPe().getInfBPeSub() == null ? "" : tbpe.getInfBPe().getInfBPeSub().getChBPe()) ? "1" : "2"); ExportacaoBPETipoBPE tipoBPE = new ExportacaoBPETipoBPE(registro.getCodEstabelecimento(), registro.getChbpe(), registro.getNumSerieBpe(), - numBpe, registro.getDhrecbto(), tpDoc, registro.getDhEmisao(), valorBruto, + numBpe, registro.getDhrecbto(), tpDoc, dhEmisao, valorBruto, desconto, estadoOrigem, municipioOrigem, estadoDestino, municipioDestino, cstCofins, receitaTriCofins, tpBpe, chbpeSub, codigoContabil, indContribuicaoPrevidenciaria, registro.getRetorno(), cstPis); @@ -157,10 +158,6 @@ public class ExportacaoBPEVo { String cfop = isInterMunicipal ? "5357" : "6357"; - // String cstb = StringUtils.isNotBlank(xml) ? tbpe.getInfBPe().getImp().getICMS().getICMS45().getCST() : - // isInterMunicipal ? (registro.getRedBaseCalcEstadual() == null || registro.getRedBaseCalcEstadual().equals(ZERO)) ? "00" : "20" - // : (registro.getRedBaseCalcMunicipal() == null || registro.getRedBaseCalcMunicipal().equals(ZERO)) ? "00" : "20"; - String csosnb = ""; if (registro.getCrt().equals(CrtBpe.SIMPLES_NACIONAL)) { csosnb = CrtBpe.SIMPLES_NACIONAL.toString(); @@ -181,24 +178,6 @@ public class ExportacaoBPEVo { baseCalculoICMS, aliquotaICMS, icms, isentas, outras); registro.getListaRegistroDPE().add(tipoDPE); - // BpeBuscaCamposXml buscaCamposXml = BpeBuscaCamposXml.getInstance(registro.getXml()); - // String[] atpComp = buscaCamposXml.buscaCamposXmlArray("tpComp"); - // String[] avComp = buscaCamposXml.buscaCamposXmlArray("vComp"); - // - // for (int i = 0; i < avComp.length; i++) { - // String tpComp = atpComp[i]; - // String vComp = avComp[i]; - // BigDecimal valor = new BigDecimal(vComp == null ? "0.0" : vComp); - // - // ExportacaoBPETipoOBE tipoOBE = new ExportacaoBPETipoOBE(tpComp, valor); - // registro.getListaRegistroOBE().add(tipoOBE); - // } - - // BigDecimal valorBP = new BigDecimal(vBP == null ? "0.0" : vBP); - - // ExportacaoBPETipoPRC tipoPRC = new ExportacaoBPETipoPRC(registro.getEstadoOrigem(), registro.getMunicipioOrigem(), valorBP, baseCalculoICMS, icms); - // registro.getListaRegistroPRC().add(tipoPRC); - } this.getListaRegistroBaseBPE().add(registro);