fixes bug#14368

dev:julio
qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@93341 d1611594-4594-4d17-8e1d-87c2c4800839
master
julio 2019-05-15 21:02:30 +00:00
parent 1ae57ab26e
commit 032448c957
2 changed files with 19 additions and 9 deletions

View File

@ -45,6 +45,9 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
@Override @Override
public ExportacaoBPEVo buscarRegistroExportacaoBpe(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado) { public ExportacaoBPEVo buscarRegistroExportacaoBpe(Connection connection, Date inicio, Date fim, Integer empresaId, String cveestado) {
log.info("Inicio da consulta buscarRegistroExportacaoBpe: " + new Date());
ExportacaoBPEVo exportacaoBPEVo = new ExportacaoBPEVo(); ExportacaoBPEVo exportacaoBPEVo = new ExportacaoBPEVo();
List<ExportacaoBPEBase> registros = new ArrayList<ExportacaoBPEBase>(); List<ExportacaoBPEBase> registros = new ArrayList<ExportacaoBPEBase>();
@ -111,8 +114,8 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
sql.append(" and bpe.tipoamb = 1 and ep.activo = 1 "); sql.append(" and bpe.tipoamb = 1 and ep.activo = 1 ");
sql.append(" and bpe.codstat in (100,101,102,135,150) "); sql.append(" and bpe.codstat in (100,101,102,135,150) ");
sql.append(" and (bpe.tipoevento <> 110115 or bpe.tipoevento is null) "); sql.append(" and (bpe.tipoevento <> 110115 or bpe.tipoevento is null) ");
sql.append(" and (case when ei.indtribviagem = 1 then c.fechorviaje else c.feccreacion end) >= to_date(?,'DD/MM/YYYY HH24:MI:SS') "); sql.append(" and c.feccreacion >= to_date(?,'DD/MM/YYYY HH24:MI:SS') ");
sql.append(" and (case when ei.indtribviagem = 1 then c.fechorviaje else c.feccreacion end) <= to_date(?,'DD/MM/YYYY HH24:MI:SS')"); sql.append(" and c.feccreacion <= to_date(?,'DD/MM/YYYY HH24:MI:SS') ");
sql.append(" and ep.empresa_id = ? "); sql.append(" and ep.empresa_id = ? ");
sql.append(" and e.cveestado = ? "); sql.append(" and e.cveestado = ? ");
sql.append("order by to_number(c.numfoliosistema), to_number(num_bpe), dh_emisao "); sql.append("order by to_number(c.numfoliosistema), to_number(num_bpe), dh_emisao ");
@ -123,7 +126,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
ps.setString(2, DateUtil.getStringDate(fim, DATE_FORMAT_DMY) + " 23:59:59"); ps.setString(2, DateUtil.getStringDate(fim, DATE_FORMAT_DMY) + " 23:59:59");
ps.setLong(3, Long.valueOf(empresaId)); ps.setLong(3, Long.valueOf(empresaId));
ps.setString(4, cveestado); ps.setString(4, cveestado);
ResultSet rs = ps.executeQuery(); ResultSet rs = ps.executeQuery();
while (rs.next()) { while (rs.next()) {
@ -194,6 +197,8 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
rs.close(); rs.close();
ps.close(); ps.close();
log.info("Fim buscarRegistroExportacaoBpe: " + new Date());
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
@ -622,8 +627,10 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
sql.append("where c.activo = 1 and bpe.tipoamb = 1 and bpe.codstat in (100,102,150) "); sql.append("where c.activo = 1 and bpe.tipoamb = 1 and bpe.codstat in (100,102,150) ");
sql.append(" and (bpe.fecmodif < (case when (to_char(bpe.fecmodif, 'mm/yyyy') <> to_char(bpecan.fecmodif, 'mm/yyyy') ) "); sql.append(" and (bpe.fecmodif < (case when (to_char(bpe.fecmodif, 'mm/yyyy') <> to_char(bpecan.fecmodif, 'mm/yyyy') ) ");
sql.append(" then bpecan.fecmodif else bpe.fecmodif end) or bpecan.fecmodif is null) "); sql.append(" then bpecan.fecmodif else bpe.fecmodif end) or bpecan.fecmodif is null) ");
sql.append(" and (case when ei.indtribviagem = 1 then c.fechorviaje else c.feccreacion end) >= :DATE_INICIO "); // sql.append(" and (case when ei.indtribviagem = 1 then c.fechorviaje else c.feccreacion end) >= :DATE_INICIO ");
sql.append(" and (case when ei.indtribviagem = 1 then c.fechorviaje else c.feccreacion end) <= :DATE_FIM "); // sql.append(" and (case when ei.indtribviagem = 1 then c.fechorviaje else c.feccreacion end) <= :DATE_FIM ");
sql.append(" and c.feccreacion >= :DATE_INICIO ");
sql.append(" and c.feccreacion <= :DATE_FIM ");
sql.append(" and ep.empresa_id = :EMPRESA_ID "); sql.append(" and ep.empresa_id = :EMPRESA_ID ");
sql.append(" and e.cveestado in ( ").append(ufs).append(" ) "); sql.append(" and e.cveestado in ( ").append(ufs).append(" ) ");

View File

@ -133,17 +133,20 @@ public class ExportacaoBPEVo {
if (comp.getTpComp().equals(TipoComp.PEDAGIO)) { if (comp.getTpComp().equals(TipoComp.PEDAGIO)) {
vPedagio = (isInterMunicipal && !registro.getIndPedadioEstdual()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0"; vPedagio = (isInterMunicipal && !registro.getIndPedadioEstdual()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0";
vPedagio = (!isInterMunicipal && !registro.getIndPedagioMunicipal()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0"; if (vPedagio.equals("0.0"))
vPedagio = (!isInterMunicipal && !registro.getIndPedagioMunicipal()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0";
} }
if (comp.getTpComp().equals(TipoComp.TAXA_EMBARQUE)) { if (comp.getTpComp().equals(TipoComp.TAXA_EMBARQUE)) {
vTxEmbarque = (isInterMunicipal && !registro.getIndTxEmbarqueEstadual()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0"; vTxEmbarque = (isInterMunicipal && !registro.getIndTxEmbarqueEstadual()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0";
vTxEmbarque = (!isInterMunicipal && !registro.getIndTxEmbarqueMunicipal()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0"; if (vTxEmbarque.equals("0.0"))
vTxEmbarque = (!isInterMunicipal && !registro.getIndTxEmbarqueMunicipal()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0";
} }
if (comp.getTpComp().equals(TipoComp.SEGURO)) { if (comp.getTpComp().equals(TipoComp.SEGURO)) {
vSeguro = (isInterMunicipal && !registro.getIndSeguroEstadual()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0"; vSeguro = (isInterMunicipal && !registro.getIndSeguroEstadual()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0";
vSeguro = (!isInterMunicipal && !registro.getIndSeguroMunicipal()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0"; if (vSeguro.equals("0.0"))
vSeguro = (!isInterMunicipal && !registro.getIndSeguroMunicipal()) ? (comp.getVComp() == null ? "0.0" : comp.getVComp()) : "0.0";
} }
} }
} }
@ -209,7 +212,7 @@ public class ExportacaoBPEVo {
BigDecimal isentas = registro.getValortotal().subtract(baseCalculoICMS); BigDecimal isentas = registro.getValortotal().subtract(baseCalculoICMS);
if (pRedBC != null) { if (pRedBC != null) {
isentas = txEmbarque.add(pedagio).add(pedagio).add(seguro); isentas = txEmbarque.add(pedagio).add(seguro);
} }
BigDecimal outras = new BigDecimal(pRedBC == null ? "0.0" : pRedBC); BigDecimal outras = new BigDecimal(pRedBC == null ? "0.0" : pRedBC);