fixes #6127
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@42609 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
b4361d4079
commit
15920c98f4
|
@ -7,6 +7,7 @@ package com.rjconsultores.ventaboletos.service.impl;
|
|||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -26,7 +27,8 @@ import com.rjconsultores.ventaboletos.service.ConstanteService;
|
|||
import com.rjconsultores.ventaboletos.service.PuntoVentaService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
import com.rjconsultores.ws.totvs.fornecedor.Tipo;
|
||||
import com.rjconsultores.ws.totvs.fornecedor.TipoCliente;
|
||||
import com.rjconsultores.ws.totvs.fornecedor.TipoPessoa;
|
||||
import com.rjconsultores.ws.totvs.service.TotvsService;
|
||||
|
||||
/**
|
||||
|
@ -164,21 +166,26 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
String endpointFornecedor = getEndpointFornecedor();
|
||||
String endpointCliente = getEndpointCliente();
|
||||
|
||||
Integer xidsvp = puntoVenta.getEmpresa().getEmpresaId();
|
||||
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');
|
||||
String est = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getCveestado();
|
||||
String codpais = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getPais().getPaisId().toString();
|
||||
//O código do país no banco central
|
||||
//brasil - 01058
|
||||
String codpais = "01058";
|
||||
String cep = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCodpostal();
|
||||
|
||||
String pais = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getPais().getNombpais();
|
||||
|
||||
String tel = puntoVenta.getNumtelefonouno();
|
||||
|
@ -193,38 +200,75 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
|
||||
String email = puntoVenta.getDescCorreo();
|
||||
String fax = puntoVenta.getNumfax();
|
||||
String inscr = puntoVenta.getNumIEPuntoVenta();
|
||||
String inscr = puntoVenta.getNumIEPuntoVenta(); //esse campo é validado na totvs. Tem que ser o mesmo do estado enviado
|
||||
String nreduz = puntoVenta.getNombpuntoventa();
|
||||
String tipo = Tipo.F.name();
|
||||
String tpessoa = "";//puntoVenta.getNumDoCPuntoVenta();
|
||||
String obs = puntoVenta.getComentarios();
|
||||
String tipoCliente = TipoCliente.F.name();
|
||||
|
||||
String conta = "";//puntoVenta.getAgenciaId() == null ? null : puntoVenta.getAgenciaId().getNumconta() + "-" + puntoVenta.getAgenciaId().getDigito();
|
||||
String tipoPessoa = TipoPessoa.F.name();
|
||||
|
||||
if (isCNPJ(cgc)){
|
||||
tipoPessoa = TipoPessoa.J.name();
|
||||
}
|
||||
|
||||
String obs = puntoVenta.getComentarios();
|
||||
obs = StringUtils.isBlank(obs)?"sem obs.":obs;
|
||||
|
||||
String conta = "1110101001001";//DEVE SER REVISADO COM A GUANABARA
|
||||
String cnae = "";
|
||||
String inscrm = "";
|
||||
|
||||
|
||||
String inscrm = "ISENTO";//DEVE SER REVISADO COM A GUANABARA
|
||||
String naturez = "";
|
||||
String simpnac = "";
|
||||
String contrib = "";
|
||||
String entid = "";
|
||||
//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, tipo, tpessoa, cnpjEmpresaProtheus,xidsvp);
|
||||
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
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
String entid = "04";
|
||||
try {
|
||||
log.info(" ------------- INICIO INTEGRACION CLIENTE TOTVS ------------- ");
|
||||
|
||||
TotvsService.cadastrarCliente(endpointCliente, bairro, cep, cgc, codmun, codpais, complemen, conta, contrib, ddd, email, nomeEmpresa,
|
||||
endereco, entid, fator, fax, inscr, inscrm, naturez, nome, nreduz, obs, pais, tpessoa, tel, tipo, est, xidsvp);
|
||||
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);
|
||||
respEx = e;
|
||||
|
@ -252,5 +296,18 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
}
|
||||
return constante.getValorconstante();
|
||||
}
|
||||
private String somenteNumeros(String s) {
|
||||
if (s == null || StringUtils.isBlank(s) ){
|
||||
return "";
|
||||
}
|
||||
|
||||
s = StringUtils.trim(s);
|
||||
|
||||
return s.replaceAll("[^0-9]", "");
|
||||
}
|
||||
private boolean isCNPJ(String vlr){
|
||||
vlr = somenteNumeros(vlr);
|
||||
return vlr.length() > 11;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue