gleimar 2015-05-28 15:03:37 +00:00
parent 096bc11ec1
commit e3fe4db4c5
1 changed files with 30 additions and 6 deletions

View File

@ -330,18 +330,18 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
String cnpjEmpresaProtheus = Atributos.CNPJ_EMPRESA_PROTHEUS;
String nome = puntoVenta.getNombpuntoventa();
nome = removerAcentosCaracteresEspeciais(nome);
nome = removerAcentosCaracteresEspeciaisTotvs(nome);
String cgc = puntoVenta.getNumDoCPuntoVenta();
String endereco = puntoVenta.getDireccioncalle() + "," + ((puntoVenta.getDireccionnumero() == null) ? "" : puntoVenta.getDireccionnumero());
endereco = removerAcentosCaracteresEspeciais(endereco);
endereco = removerAcentosCaracteresEspeciaisTotvs(endereco);
String complemen = puntoVenta.getCompl() == null ? "" : puntoVenta.getCompl();
complemen = removerAcentosCaracteresEspeciais(complemen);
complemen = removerAcentosCaracteresEspeciaisTotvs(complemen);
String bairro = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getDesccolonia();
bairro = removerAcentosCaracteresEspeciais(bairro);
bairro = removerAcentosCaracteresEspeciaisTotvs(bairro);
String codmun = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getCodmunicipio().toString();
codmun = (codmun == null) ? "" : StringUtils.leftPad(codmun, 5, '0');
@ -362,12 +362,14 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
}
String email = puntoVenta.getDescCorreo() == null ? "" : puntoVenta.getDescCorreo();
email = removerCaracteresInvalidosXml(email);
String fax = puntoVenta.getNumfax() == null ? "" : puntoVenta.getNumfax();
String inscr = puntoVenta.getNumIEPuntoVenta();
String inscrm = InscricaoMunicipal.ISENTO.name();
String nreduz = puntoVenta.getRazonSocial() != null ? puntoVenta.getRazonSocial() : puntoVenta.getNombpuntoventa();
nreduz = removerAcentosCaracteresEspeciais(nreduz);
nreduz = removerAcentosCaracteresEspeciaisTotvs(nreduz);
String simpnac = ContribuinteSimplesNacional.NAO.getValor();
@ -466,11 +468,33 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
vlr = somenteNumeros(vlr);
return vlr.length() > 11;
}
private String removerAcentosCaracteresEspeciais(String s){
/**
* From xml spec valid chars:<br>
* #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]<br>
* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.<br>
*
* link artigo:http://stackoverflow.com/questions/9710185/how-to-deal-with-invalid-characters-in-a-ws-output-when-using-cxf
*
* @param text The String to clean
* @param replacement The string to be substituted for each match
* @return The resulting String
*/
private String removerCaracteresInvalidosXml(String s){
if (s == null){
return s;
}
String re = "[^\\x09\\x0A\\x0D\\x20-\\xD7FF\\xE000-\\xFFFD\\x10000-x10FFFF]";
return s.replaceAll(re, "");
}
private String removerAcentosCaracteresEspeciaisTotvs(String s){
if (StringUtils.isBlank(s)){
return s;
}
s = StringUtils.trim(s);
s = removerCaracteresInvalidosXml(s);
return Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "").replaceAll("\\W", " ");
}