bug#11600

dev: julio
qua:

git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@84314 d1611594-4594-4d17-8e1d-87c2c4800839
master
julio 2018-08-16 17:56:01 +00:00
parent 95fb18fce2
commit cf360ab445
2 changed files with 39 additions and 17 deletions

View File

@ -54,9 +54,9 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
sql.append(" c.numfoliosistema as numfoliosistema, "); sql.append(" c.numfoliosistema as numfoliosistema, ");
sql.append(" coalesce(c.preciopagado,0) + coalesce(c.importetaxaembarque,0) + coalesce(c.importeseguro,0) + coalesce(c.importepedagio,0) + coalesce(c.importeoutros,0) as valortotal, "); sql.append(" coalesce(c.preciopagado,0) + coalesce(c.importetaxaembarque,0) + coalesce(c.importeseguro,0) + coalesce(c.importepedagio,0) + coalesce(c.importeoutros,0) as valortotal, ");
sql.append(" bpe.codstat as codstatus, "); sql.append(" bpe.codstat as codstatus, ");
sql.append(" DBMS_LOB.substr(bpe.xmlregular, 3000) as xml_bpe, "); sql.append(" DBMS_LOB.substr(coalesce(bpe.xmlregular, bpe.xmlcontingencia), 3000) as xml_bpe, ");
sql.append(" DBMS_LOB.substr(bpe.xmlregular, 3000, 3001) as xml_bpe_2, "); sql.append(" DBMS_LOB.substr(coalesce(bpe.xmlregular, bpe.xmlcontingencia), 3000, 3001) as xml_bpe_2, ");
sql.append(" DBMS_LOB.substr(bpe.xmlregular, 3000, 6001) as xml_bpe_3, "); sql.append(" DBMS_LOB.substr(coalesce(bpe.xmlregular, bpe.xmlcontingencia), 3000, 6001) as xml_bpe_3, ");
sql.append(" bpe.tipoevento as tipoevento, "); sql.append(" bpe.tipoevento as tipoevento, ");
sql.append(" bpe.desconto as v_desconto, "); sql.append(" bpe.desconto as v_desconto, ");
sql.append(" bpe.chbpe, "); sql.append(" bpe.chbpe, ");
@ -99,7 +99,7 @@ public class BpeHibernateDAO extends HibernateDaoSupport implements BpeDAO {
sql.append(" left join empresa_imposto ei on ei.empresa_id = ep.empresa_id and ei.estado_id = e.estado_id "); sql.append(" left join empresa_imposto ei on ei.empresa_id = ep.empresa_id and ei.estado_id = e.estado_id ");
sql.append("where c.activo = 1 and e.activo = 1 and ei.activo = 1 "); sql.append("where c.activo = 1 and e.activo = 1 and ei.activo = 1 ");
sql.append(" and bpe.tipoamb = 1 and ep.activo = 1 "); sql.append(" and bpe.tipoamb = 1 and ep.activo = 1 ");
sql.append(" and bpe.errocontingencia is null "); // sql.append(" and bpe.errocontingencia is null ");
//sql.append(" and bpe.codstat <> 150 "); // não deve ser enviados os registros de contigencia //sql.append(" and bpe.codstat <> 150 "); // não deve ser enviados os registros de contigencia
sql.append(" and (tipoevento <> 110115 or tipoevento is null) "); sql.append(" and (tipoevento <> 110115 or 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 (case when ei.indtribviagem = 1 then c.fechorviaje else c.feccreacion end) >= to_date(?,'DD/MM/YYYY HH24:MI:SS') ");

View File

@ -97,6 +97,7 @@ public class ExportacaoBPEVo {
String pICMS = null; String pICMS = null;
String vICMS = null; String vICMS = null;
String cst = null; String cst = null;
String pRedBC = null;
String vBP = null; String vBP = null;
String vDesconto = null; String vDesconto = null;
@ -106,13 +107,31 @@ public class ExportacaoBPEVo {
vBC = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVBC(); vBC = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVBC();
pICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getPICMS(); pICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getPICMS();
vICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVICMS(); vICMS = tbpe.getInfBPe().getImp().getICMS().getICMS00().getVICMS();
cst = tbpe.getInfBPe().getImp().getICMS().getICMS00().getCST(); } else if (tbpe.getInfBPe().getImp().getICMS().getICMS20() != null) {
vBC = tbpe.getInfBPe().getImp().getICMS().getICMS20().getVBC();
pICMS = tbpe.getInfBPe().getImp().getICMS().getICMS20().getPICMS();
vICMS = tbpe.getInfBPe().getImp().getICMS().getICMS20().getVICMS();
pRedBC = tbpe.getInfBPe().getImp().getICMS().getICMS20().getPRedBC();
} }
if (tbpe.getInfBPe().getInfValorBPe() != null) { if (tbpe.getInfBPe().getInfValorBPe() != null) {
vBP = tbpe.getInfBPe().getInfValorBPe().getVBP(); vBP = tbpe.getInfBPe().getInfValorBPe().getVBP();
vDesconto = tbpe.getInfBPe().getInfValorBPe().getVDesconto(); vDesconto = tbpe.getInfBPe().getInfValorBPe().getVDesconto();
} }
// validar cst enviado
if (tbpe.getInfBPe().getImp().getICMS().getICMS00() != null)
cst = tbpe.getInfBPe().getImp().getICMS().getICMS00().getCST();
else if (tbpe.getInfBPe().getImp().getICMS().getICMS20() != null)
cst = tbpe.getInfBPe().getImp().getICMS().getICMS20().getCST();
else if (tbpe.getInfBPe().getImp().getICMS().getICMS45() != null)
cst = tbpe.getInfBPe().getImp().getICMS().getICMS45().getCST();
else if (tbpe.getInfBPe().getImp().getICMS().getICMS90() != null)
cst = tbpe.getInfBPe().getImp().getICMS().getICMS90().getCST();
else if (tbpe.getInfBPe().getImp().getICMS().getICMSOutraUF() != null)
cst = tbpe.getInfBPe().getImp().getICMS().getICMSOutraUF().getCST();
else if (tbpe.getInfBPe().getImp().getICMS().getICMSSN() != null)
cst = tbpe.getInfBPe().getImp().getICMS().getICMSSN().getCST();
} }
String cstCofins = "01"; String cstCofins = "01";
@ -133,8 +152,10 @@ public class ExportacaoBPEVo {
registro.getListaRegistroBPE().add(tipoBPE); registro.getListaRegistroBPE().add(tipoBPE);
String cfop = isInterMunicipal ? "5357" : "6357"; String cfop = isInterMunicipal ? "5357" : "6357";
String cstb = isInterMunicipal ? (registro.getRedBaseCalcEstadual() == null || registro.getRedBaseCalcEstadual().equals(ZERO)) ? "00" : "20"
: (registro.getRedBaseCalcMunicipal() == null || registro.getRedBaseCalcMunicipal().equals(ZERO)) ? "00" : "20"; // 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 = ""; String csosnb = "";
if (registro.getCrt().equals(CrtBpe.SIMPLES_NACIONAL)) { if (registro.getCrt().equals(CrtBpe.SIMPLES_NACIONAL)) {
@ -149,9 +170,10 @@ public class ExportacaoBPEVo {
BigDecimal aliquotaICMS = new BigDecimal(pICMS == null ? "0.0" : pICMS); BigDecimal aliquotaICMS = new BigDecimal(pICMS == null ? "0.0" : pICMS);
BigDecimal icms = new BigDecimal(vICMS == null ? "0.0" : vICMS); BigDecimal icms = new BigDecimal(vICMS == null ? "0.0" : vICMS);
BigDecimal isentas = registro.getValortotal().subtract(baseCalculoICMS); BigDecimal isentas = registro.getValortotal().subtract(baseCalculoICMS);
BigDecimal outras = new BigDecimal(cst == null ? "0.0" : cst);
ExportacaoBPETipoDPE tipoDPE = new ExportacaoBPETipoDPE(registro.getValortotal(), cfop, cstb, csosnb, BigDecimal outras = new BigDecimal(pRedBC == null ? "0.0" : pRedBC);
ExportacaoBPETipoDPE tipoDPE = new ExportacaoBPETipoDPE(registro.getValortotal(), cfop, cst, csosnb,
baseCalculoICMS, aliquotaICMS, icms, isentas, outras); baseCalculoICMS, aliquotaICMS, icms, isentas, outras);
registro.getListaRegistroDPE().add(tipoDPE); registro.getListaRegistroDPE().add(tipoDPE);
@ -178,7 +200,7 @@ public class ExportacaoBPEVo {
this.getListaRegistroBaseBPE().add(registro); this.getListaRegistroBaseBPE().add(registro);
} }
private TBPe convertXmlToBpe(String xml) { public TBPe convertXmlToBpe(String xml) {
TBPe objeto = null; TBPe objeto = null;
if (xml != null) { if (xml != null) {
try { try {