0012411: [BPe] - [PP0037EC] - Exigir CPF com validação no Call Center
fixes bug#12411 dev:valdevir qua:Wallysson Validando o CPF na ADM git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@87024 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
b1eb34cd1f
commit
04f66c8cb0
|
@ -9,6 +9,8 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.brazilutils.br.cpfcnpj.Cpf;
|
||||||
|
import org.brazilutils.validation.ValidationException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -75,6 +77,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.render.RenderCurso;
|
||||||
@Scope("prototype")
|
@Scope("prototype")
|
||||||
public class EditarClienteController extends MyGenericForwardComposer {
|
public class EditarClienteController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
|
private static final String CPF = "CPF";
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static Logger log = Logger.getLogger(EditarClienteController.class);
|
private static Logger log = Logger.getLogger(EditarClienteController.class);
|
||||||
|
|
||||||
|
@ -321,7 +324,7 @@ public class EditarClienteController extends MyGenericForwardComposer {
|
||||||
cliente = clienteService.obtenerID(cliente.getClienteId());
|
cliente = clienteService.obtenerID(cliente.getClienteId());
|
||||||
lsClienteFidelidad = cliente.getListClienteFidelidadActivos();
|
lsClienteFidelidad = cliente.getListClienteFidelidadActivos();
|
||||||
|
|
||||||
if (cliente.getTipoIdentificacionUno() != null && cliente.getTipoIdentificacionUno().getDesctipo().equals("CPF")) {
|
if (cliente.getTipoIdentificacionUno() != null && cliente.getTipoIdentificacionUno().getDesctipo().equals(CPF)) {
|
||||||
txtNumFidelidade.setText(cliente.getNumIdentificaUno().toString());
|
txtNumFidelidade.setText(cliente.getNumIdentificaUno().toString());
|
||||||
setValidadoresCPF();
|
setValidadoresCPF();
|
||||||
}
|
}
|
||||||
|
@ -489,10 +492,15 @@ public class EditarClienteController extends MyGenericForwardComposer {
|
||||||
txtNumRfc.setMaxlength(11);
|
txtNumRfc.setMaxlength(11);
|
||||||
txtNumRfc.setConstraint("/[0-9]{11}/ : " + Labels.getLabel("editarClienteController.MSG.validacaoCPF"));
|
txtNumRfc.setConstraint("/[0-9]{11}/ : " + Labels.getLabel("editarClienteController.MSG.validacaoCPF"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setValidadoresCPF2() {
|
||||||
|
txtNumRfc2.setMaxlength(11);
|
||||||
|
txtNumRfc2.setConstraint("/[0-9]{11}/ : " + Labels.getLabel("editarClienteController.MSG.validacaoCPF"));
|
||||||
|
}
|
||||||
|
|
||||||
private TipoIdentificacion getTipoIdentificacionCPF(List<TipoIdentificacion> tipos) {
|
private TipoIdentificacion getTipoIdentificacionCPF(List<TipoIdentificacion> tipos) {
|
||||||
for (TipoIdentificacion t : tipos) {
|
for (TipoIdentificacion t : tipos) {
|
||||||
if (t.getDesctipo().equals("CPF")) {
|
if (t.getDesctipo().equals(CPF)) {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -517,7 +525,7 @@ public class EditarClienteController extends MyGenericForwardComposer {
|
||||||
public void onSelect$cmbTipoIdentificacion(Event ev) throws InterruptedException {
|
public void onSelect$cmbTipoIdentificacion(Event ev) throws InterruptedException {
|
||||||
txtNumRfc.setConstraint("");
|
txtNumRfc.setConstraint("");
|
||||||
txtNumRfc.setValue("");
|
txtNumRfc.setValue("");
|
||||||
if (cmbTipoIdentificacion.getSelectedItem().getValue().toString().equals("CPF")) {
|
if (cmbTipoIdentificacion.getSelectedItem().getValue().toString().equals(CPF)) {
|
||||||
setValidadoresCPF();
|
setValidadoresCPF();
|
||||||
} else {
|
} else {
|
||||||
txtNumRfc.setMaxlength(20);
|
txtNumRfc.setMaxlength(20);
|
||||||
|
@ -526,11 +534,21 @@ public class EditarClienteController extends MyGenericForwardComposer {
|
||||||
txtNumFidelidade.setText("");
|
txtNumFidelidade.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSelect$cmbTipoIdentificacion2(Event ev) throws InterruptedException {
|
||||||
|
txtNumRfc2.setConstraint("");
|
||||||
|
txtNumRfc2.setValue("");
|
||||||
|
if (cmbTipoIdentificacion2.getSelectedItem().getValue().toString().equals(CPF)) {
|
||||||
|
setValidadoresCPF2();
|
||||||
|
} else {
|
||||||
|
txtNumRfc2.setMaxlength(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onChange$txtNumRfc(Event ev) throws InterruptedException {
|
public void onChange$txtNumRfc(Event ev) throws InterruptedException {
|
||||||
if (usaCPFComoFidelidade
|
if (usaCPFComoFidelidade
|
||||||
&& cmbTipoIdentificacion.getSelectedItem() != null
|
&& cmbTipoIdentificacion.getSelectedItem() != null
|
||||||
&& cmbTipoIdentificacion.getSelectedItem().getValue().toString().equals("CPF")) {
|
&& cmbTipoIdentificacion.getSelectedItem().getValue().toString().equals(CPF)) {
|
||||||
txtNumFidelidade.setText(txtNumRfc.getText());
|
txtNumFidelidade.setText(txtNumRfc.getText());
|
||||||
} else {
|
} else {
|
||||||
txtNumFidelidade.setText("");
|
txtNumFidelidade.setText("");
|
||||||
|
@ -807,6 +825,37 @@ public class EditarClienteController extends MyGenericForwardComposer {
|
||||||
cmbMotivacionViaje.getValue();
|
cmbMotivacionViaje.getValue();
|
||||||
cmbOcupacion.getValue();
|
cmbOcupacion.getValue();
|
||||||
|
|
||||||
|
if (txtNumRfc.getText() != null && !txtNumRfc.getText().isEmpty()) {
|
||||||
|
if ( cmbTipoIdentificacion != null
|
||||||
|
&& cmbTipoIdentificacion.getSelectedItem() != null
|
||||||
|
&& cmbTipoIdentificacion.getSelectedItem().getValue() != null
|
||||||
|
&& CPF.equals(cmbTipoIdentificacion.getSelectedItem().getValue().toString())) {
|
||||||
|
String numDoc = txtNumRfc.getText();
|
||||||
|
if(!validarCPF(numDoc)) {
|
||||||
|
Messagebox.show(Labels.getLabel("editarClienteController.MSG.validacaoCPFInvalido"),
|
||||||
|
Labels.getLabel("editarClienteController.window.title"), Messagebox.OK,
|
||||||
|
Messagebox.EXCLAMATION);
|
||||||
|
txtNumRfc.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (txtNumRfc2.getText() != null && !txtNumRfc2.getText().isEmpty()) {
|
||||||
|
if ( cmbTipoIdentificacion2 != null
|
||||||
|
&& cmbTipoIdentificacion2.getSelectedItem() != null
|
||||||
|
&& cmbTipoIdentificacion2.getSelectedItem().getValue() != null
|
||||||
|
&& CPF.equals(cmbTipoIdentificacion2.getSelectedItem().getValue().toString())) {
|
||||||
|
String numDoc = txtNumRfc2.getText();
|
||||||
|
if(!validarCPF(numDoc)) {
|
||||||
|
Messagebox.show(Labels.getLabel("editarClienteController.MSG.validacaoCPFInvalido"),
|
||||||
|
Labels.getLabel("editarClienteController.window.title"), Messagebox.OK,
|
||||||
|
Messagebox.EXCLAMATION);
|
||||||
|
txtNumRfc2.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Cliente> lsCliente = clienteService.buscarPorDocumento(txtNumRfc.getValue());
|
List<Cliente> lsCliente = clienteService.buscarPorDocumento(txtNumRfc.getValue());
|
||||||
if (lsCliente.size() > 1
|
if (lsCliente.size() > 1
|
||||||
|
@ -904,6 +953,24 @@ public class EditarClienteController extends MyGenericForwardComposer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param numDoc
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
private Boolean validarCPF(String numDoc) {
|
||||||
|
try {
|
||||||
|
Cpf cpf = new Cpf(numDoc);
|
||||||
|
if(!cpf.isValid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (ValidationException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private List<ClienteFidelidad> criarFidelidadesTodasEmpresas(List<ClienteFidelidad> fidelidades, List<Empresa> empresas) {
|
private List<ClienteFidelidad> criarFidelidadesTodasEmpresas(List<ClienteFidelidad> fidelidades, List<Empresa> empresas) {
|
||||||
|
|
||||||
List<ClienteFidelidad> result = new ArrayList<ClienteFidelidad>();
|
List<ClienteFidelidad> result = new ArrayList<ClienteFidelidad>();
|
||||||
|
|
Loading…
Reference in New Issue