leonardo 2017-03-13 13:49:55 +00:00
parent ed2b6f1e1f
commit 4d2d0c3a04
1 changed files with 18 additions and 16 deletions

View File

@ -155,18 +155,27 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG");
if (empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) {
log.debug("iniciando integração com AG");
integrarClienteAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
integrarFornecedorAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
integraAG(entidad);
log.debug("fim da integração com AG");
}
return entidad;
}
private void integraAG(PuntoVenta entidad) throws IntegracionException{
String motivoNaoIntegrado = "";
integrarClienteAG(entidad);
if (!entidad.getIndIntegradoAG()){
motivoNaoIntegrado += "Cliente: " + entidad.getMotivoNaoIntegradoAG();
}
integrarFornecedorAG(entidad);
if (!entidad.getIndIntegradoAG()){
motivoNaoIntegrado += "Fornecedor: " + entidad.getMotivoNaoIntegradoAG();
}
if (!motivoNaoIntegrado.isEmpty()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
}
private void integrarFornecedorAG(PuntoVenta entidad) {
@ -417,14 +426,7 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
Constante empresasIntegraAG = constanteService.buscarPorNomeConstante("EMPRESAS_INTEGRACAO_AG");
if (empresasIntegraAG != null && empresasIntegraAG.getValorconstante() != null && empresasIntegraAG.getValorconstante().contains(entidad.getEmpresa().getEmpresaId().toString())) {
log.debug("iniciando integração com AG");
integrarClienteAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
integrarFornecedorAG(entidad);
if (!entidad.getIndIntegradoAG()){
throw new IntegracionException(entidad.getMotivoNaoIntegradoAG());
}
integraAG(entidad);
log.debug("fim da integração com AG");
}