Totvs - WS Fornecedor / WS Cliente / WS Pedido Compra (fixes bug #6127)
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@42651 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
15920c98f4
commit
991a260caf
|
@ -162,27 +162,27 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
|
||||
private void integracionTotvs(PuntoVenta puntoVenta) throws IntegracionException {
|
||||
if (ApplicationProperties.getInstance().integracionTotvs()) {
|
||||
|
||||
|
||||
String endpointFornecedor = getEndpointFornecedor();
|
||||
String endpointCliente = getEndpointCliente();
|
||||
|
||||
Integer xidsvp = puntoVenta.getPuntoventaId();
|
||||
String nomeEmpresa = puntoVenta.getRazonSocial();
|
||||
String nomeFilial = puntoVenta.getNumDoCPuntoVenta();
|
||||
|
||||
|
||||
String cnpjEmpresaProtheus = "25634551000138";
|
||||
String nome = puntoVenta.getNombpuntoventa();
|
||||
String cgc =puntoVenta.getNumDoCPuntoVenta();
|
||||
|
||||
String cgc = puntoVenta.getNumDoCPuntoVenta();
|
||||
|
||||
String endereco = puntoVenta.getDireccioncalle() + "," + puntoVenta.getDireccionnumero() == null ? "" : puntoVenta.getDireccionnumero();
|
||||
String complemen = puntoVenta.getCompl() == null ? "" : puntoVenta.getCompl();
|
||||
String bairro = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getDesccolonia();
|
||||
|
||||
String codmun = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getCodmunicipio().toString();
|
||||
codmun = (codmun ==null)?"":StringUtils.leftPad(codmun, 5, '0');
|
||||
codmun = (codmun == null) ? "" : StringUtils.leftPad(codmun, 5, '0');
|
||||
|
||||
String est = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getCveestado();
|
||||
//O código do país no banco central
|
||||
//brasil - 01058
|
||||
|
||||
// O código do país no banco central
|
||||
// brasil - 01058
|
||||
String codpais = "01058";
|
||||
String cep = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCodpostal();
|
||||
|
||||
|
@ -200,74 +200,56 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
|
||||
String email = puntoVenta.getDescCorreo();
|
||||
String fax = puntoVenta.getNumfax();
|
||||
String inscr = puntoVenta.getNumIEPuntoVenta(); //esse campo é validado na totvs. Tem que ser o mesmo do estado enviado
|
||||
String nreduz = puntoVenta.getNombpuntoventa();
|
||||
String inscr = puntoVenta.getNumIEPuntoVenta(); // esse campo é validado na totvs. Tem que ser o mesmo do estado enviado
|
||||
|
||||
String nreduz = puntoVenta.getRazonSocial() != null ? puntoVenta.getRazonSocial() : puntoVenta.getNombpuntoventa();
|
||||
|
||||
String tipoCliente = TipoCliente.F.name();
|
||||
|
||||
String tipoPessoa = TipoPessoa.F.name();
|
||||
|
||||
if (isCNPJ(cgc)){
|
||||
|
||||
if (isCNPJ(cgc)) {
|
||||
tipoPessoa = TipoPessoa.J.name();
|
||||
}
|
||||
|
||||
|
||||
String obs = puntoVenta.getComentarios();
|
||||
obs = StringUtils.isBlank(obs)?"sem obs.":obs;
|
||||
obs = StringUtils.isBlank(obs) ? "sem obs." : obs;
|
||||
|
||||
String conta = "1110101001001";//DEVE SER REVISADO COM A GUANABARA
|
||||
String conta = "1110101001001";// DEVE SER REVISADO COM A GUANABARA
|
||||
String cnae = "";
|
||||
|
||||
|
||||
String inscrm = "ISENTO";//DEVE SER REVISADO COM A GUANABARA
|
||||
String inscrm = "ISENTO";// DEVE SER REVISADO COM A GUANABARA
|
||||
String naturez = "";
|
||||
//1 = SIM
|
||||
//2 = Não
|
||||
String simpnac = "1";//deve ser revisado com a guanabara
|
||||
|
||||
|
||||
// 1 = SIM
|
||||
// 2 = Não
|
||||
String simpnac = "1";// deve ser revisado com a guanabara
|
||||
|
||||
String fator = "";
|
||||
|
||||
|
||||
Exception respEx = null;
|
||||
|
||||
try {
|
||||
log.info(" ------------- INICIO INTEGRACION FORNECEDOR TOTVS ------------- ");
|
||||
|
||||
TotvsService.cadastrarFornecedor(endpointFornecedor, bairro, cep, cgc, cnae, codmun, codpais, complemen, conta, ddd, email, endereco,
|
||||
est, inscr, inscrm, naturez, nome, nreduz, simpnac, tel, tipoPessoa, tipoCliente, cnpjEmpresaProtheus,xidsvp);
|
||||
|
||||
TotvsService.cadastrarFornecedor(endpointFornecedor, bairro, cep, cgc, cnae, codmun, codpais, complemen, conta, ddd, email, endereco,
|
||||
est, inscr, inscrm, naturez, nome, nreduz, simpnac, tel, tipoPessoa, tipoCliente, cnpjEmpresaProtheus, xidsvp);
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
respEx = e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* campo CONTRIB - deve ser passado
|
||||
- 1 = Sim
|
||||
- 2 - Não
|
||||
* campo CONTRIB - deve ser passado - 1 = Sim - 2 - Não
|
||||
*/
|
||||
String contrib = "2";//deve ser revisado com a guanabara
|
||||
|
||||
String contrib = "2";// deve ser revisado com a guanabara
|
||||
|
||||
/**
|
||||
* No campo ENTID - deve ser passado:
|
||||
00-PJ Dir.Priv.;
|
||||
01-Órg.,Autq.;
|
||||
02-Autopec
|
||||
03-Emp.Pub./Soc.Eco.Mis.;
|
||||
04-Trans.Passg.
|
||||
05-Ser.Pres.Fin.;
|
||||
06-Demais Serv.
|
||||
07-Dema is Ent.;
|
||||
08-Assoc.Profis.;
|
||||
09-Combustív.;
|
||||
10-Pgto n .Espec.
|
||||
* No campo ENTID - deve ser passado: 00-PJ Dir.Priv.; 01-Órg.,Autq.; 02-Autopec 03-Emp.Pub./Soc.Eco.Mis.; 04-Trans.Passg. 05-Ser.Pres.Fin.; 06-Demais Serv. 07-Dema is Ent.; 08-Assoc.Profis.; 09-Combustív.; 10-Pgto n .Espec.
|
||||
*/
|
||||
String entid = "04";
|
||||
try {
|
||||
log.info(" ------------- INICIO INTEGRACION CLIENTE TOTVS ------------- ");
|
||||
pais = "";//segundo mateus, passar em branco, segundo orientação do mateus da totvs
|
||||
TotvsService.cadastrarCliente(endpointCliente, bairro, cep, cgc, codmun, codpais, complemen, conta, contrib, ddd, email, cnpjEmpresaProtheus,
|
||||
pais = "";// segundo mateus, passar em branco, segundo orientação do mateus da totvs
|
||||
TotvsService.cadastrarCliente(endpointCliente, bairro, cep, cgc, codmun, codpais, complemen, conta, contrib, ddd, email, cnpjEmpresaProtheus,
|
||||
endereco, entid, fator, fax, inscr, inscrm, naturez, nome, nreduz, obs, pais, tipoCliente, tel, tipoPessoa, est, xidsvp);
|
||||
} catch (Exception e) {
|
||||
log.error("", e);
|
||||
|
@ -296,18 +278,19 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
}
|
||||
return constante.getValorconstante();
|
||||
}
|
||||
|
||||
private String somenteNumeros(String s) {
|
||||
if (s == null || StringUtils.isBlank(s) ){
|
||||
if (s == null || StringUtils.isBlank(s)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
s = StringUtils.trim(s);
|
||||
|
||||
|
||||
return s.replaceAll("[^0-9]", "");
|
||||
}
|
||||
private boolean isCNPJ(String vlr){
|
||||
|
||||
private boolean isCNPJ(String vlr) {
|
||||
vlr = somenteNumeros(vlr);
|
||||
return vlr.length() > 11;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue