Totvs - WS Fornecedor / WS Cliente / WS Pedido Compra (bug #6127)
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@42707 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
14bebcc175
commit
a903a30c2e
|
@ -30,6 +30,7 @@ import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
import com.rjconsultores.ws.totvs.service.TotvsService;
|
import com.rjconsultores.ws.totvs.service.TotvsService;
|
||||||
import com.rjconsultores.ws.utileria.Atributos.CodPaisBanco;
|
import com.rjconsultores.ws.utileria.Atributos.CodPaisBanco;
|
||||||
import com.rjconsultores.ws.utileria.Atributos.ContribuinteICMS;
|
import com.rjconsultores.ws.utileria.Atributos.ContribuinteICMS;
|
||||||
|
import com.rjconsultores.ws.utileria.Atributos.ContribuinteSimplesNacional;
|
||||||
import com.rjconsultores.ws.utileria.Atributos.TipoCliente;
|
import com.rjconsultores.ws.utileria.Atributos.TipoCliente;
|
||||||
import com.rjconsultores.ws.utileria.Atributos.TipoEntidade;
|
import com.rjconsultores.ws.utileria.Atributos.TipoEntidade;
|
||||||
import com.rjconsultores.ws.utileria.Atributos.TipoFornecedor;
|
import com.rjconsultores.ws.utileria.Atributos.TipoFornecedor;
|
||||||
|
@ -164,9 +165,43 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
||||||
return puntosVenta;
|
return puntosVenta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean validaCanalVenta(Short tipoptovtaId) {
|
||||||
|
|
||||||
|
boolean resp = false;
|
||||||
|
|
||||||
|
switch (tipoptovtaId) {
|
||||||
|
// PROPRIAS
|
||||||
|
case 11:
|
||||||
|
resp = true;
|
||||||
|
break;
|
||||||
|
// FRANQUEADAS
|
||||||
|
case 12:
|
||||||
|
resp = true;
|
||||||
|
break;
|
||||||
|
// COBRADOR
|
||||||
|
case 15:
|
||||||
|
resp = true;
|
||||||
|
break;
|
||||||
|
// MOTORISTA
|
||||||
|
case 14:
|
||||||
|
resp = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
private void integracionTotvs(PuntoVenta puntoVenta) throws IntegracionException {
|
private void integracionTotvs(PuntoVenta puntoVenta) throws IntegracionException {
|
||||||
if (ApplicationProperties.getInstance().integracionTotvs()) {
|
if (ApplicationProperties.getInstance().integracionTotvs()) {
|
||||||
|
|
||||||
|
boolean clienteValido = validaCanalVenta(puntoVenta.getTipoPuntoVenta().getTipoptovtaId());
|
||||||
|
boolean fornecedorValido = (puntoVenta.getTipoPuntoVenta().getTipoptovtaId() == 13);
|
||||||
|
|
||||||
|
if (fornecedorValido)
|
||||||
|
clienteValido = true;
|
||||||
|
|
||||||
String endpointFornecedor = getEndpointFornecedor();
|
String endpointFornecedor = getEndpointFornecedor();
|
||||||
String endpointCliente = getEndpointCliente();
|
String endpointCliente = getEndpointCliente();
|
||||||
|
|
||||||
|
@ -189,8 +224,6 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
||||||
|
|
||||||
String cep = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCodpostal();
|
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();
|
String tel = puntoVenta.getNumtelefonouno();
|
||||||
String ddd = null;
|
String ddd = null;
|
||||||
try {
|
try {
|
||||||
|
@ -207,6 +240,8 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
||||||
|
|
||||||
String nreduz = puntoVenta.getRazonSocial() != null ? puntoVenta.getRazonSocial() : puntoVenta.getNombpuntoventa();
|
String nreduz = puntoVenta.getRazonSocial() != null ? puntoVenta.getRazonSocial() : puntoVenta.getNombpuntoventa();
|
||||||
|
|
||||||
|
String simpnac = ContribuinteSimplesNacional.NAO.getValor();
|
||||||
|
|
||||||
String tppessoa = TipoFornecedor.OS.name();
|
String tppessoa = TipoFornecedor.OS.name();
|
||||||
String tppessoaCliente = TipoCliente.F.name();
|
String tppessoaCliente = TipoCliente.F.name();
|
||||||
|
|
||||||
|
@ -219,16 +254,12 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
||||||
String obs = puntoVenta.getComentarios();
|
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 cnae = "";
|
||||||
|
|
||||||
String inscrm = "ISENTO";// DEVE SER REVISADO COM A GUANABARA
|
String inscrm = "ISENTO"; // DEVE SER REVISADO COM A GUANABARA
|
||||||
String naturez = "";
|
String naturez = "";
|
||||||
|
|
||||||
// 1 = SIM
|
|
||||||
// 2 = Não
|
|
||||||
String simpnac = "1";// deve ser revisado com a guanabara
|
|
||||||
|
|
||||||
String fator = "";
|
String fator = "";
|
||||||
|
|
||||||
String agencia = puntoVenta.getAgenciaId() == null ? "" : puntoVenta.getAgenciaId().getNumagencia();
|
String agencia = puntoVenta.getAgenciaId() == null ? "" : puntoVenta.getAgenciaId().getNumagencia();
|
||||||
|
@ -247,33 +278,40 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
||||||
|
|
||||||
Exception respEx = null;
|
Exception respEx = null;
|
||||||
|
|
||||||
try {
|
if (clienteValido) {
|
||||||
log.info(" ------------- INICIO INTEGRACION FORNECEDOR TOTVS ------------- ");
|
try {
|
||||||
|
log.info(" ------------- INICIO INTEGRACION FORNECEDOR TOTVS ------------- ");
|
||||||
|
|
||||||
TotvsService.cadastrarFornecedor(endpointFornecedor, bairro, cep, cgc, cnae, codmun, codpais, complemen, conta, ddd, email, endereco,
|
TotvsService.cadastrarFornecedor(endpointFornecedor, bairro, cep, cgc, cnae, codmun, codpais, complemen, conta, ddd, email, endereco,
|
||||||
est, inscr, inscrm, naturez, nome, nreduz, simpnac, tel, tipoPessoa, tppessoa, cnpjEmpresaProtheus, xidsvp, agencia, banco,
|
est, inscr, inscrm, naturez, nome, nreduz, simpnac, tel, tipoPessoa, tppessoa, cnpjEmpresaProtheus, xidsvp, agencia, banco,
|
||||||
dgverag, ctacorr, dgverct);
|
dgverag, ctacorr, dgverct);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("", e);
|
log.error("", e);
|
||||||
respEx = e;
|
respEx = e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String contrib = ContribuinteICMS.NAO.getValor();// deve ser revisado com a guanabara
|
String contrib = ContribuinteICMS.NAO.getValor();
|
||||||
String entid = TipoEntidade.TRANSPORTE_PASSAGEIRO.getValor();
|
String entid = TipoEntidade.TRANSPORTE_PASSAGEIRO.getValor();
|
||||||
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,
|
|
||||||
endereco, entid, fator, fax, inscr, inscrm, naturez, nome, nreduz, obs, pais, tppessoaCliente, tel, tipoPessoa, est, xidsvp);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("", e);
|
|
||||||
respEx = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (respEx != null) {
|
String pais = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getPais().getNombpais();
|
||||||
throw new IntegracionException("integracion.totvs");
|
pais = "";// segundo mateus, passar em branco, segundo orientação do mateus da totvs
|
||||||
}
|
|
||||||
|
|
||||||
|
if (fornecedorValido) {
|
||||||
|
try {
|
||||||
|
log.info(" ------------- INICIO INTEGRACION CLIENTE 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, tppessoaCliente, tel, tipoPessoa, est, xidsvp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("", e);
|
||||||
|
respEx = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (respEx != null) {
|
||||||
|
throw new IntegracionException("integracion.totvs");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue