Creacion de number formated text field y implementacion de prueba como campos de efectivo
This commit is contained in:
@@ -90,15 +90,15 @@ public class ArqueoController {
|
||||
*/
|
||||
private void fillEfectivo() {
|
||||
this.efectivo = this.efectivoDAO.findByCaja(this.caja);
|
||||
this.view.getVeinteMilField().setText(String.valueOf(efectivo.getVeinteMil()));
|
||||
this.view.getDiezMilField().setText(String.valueOf(efectivo.getDiezMil()));
|
||||
this.view.getCincoMilField().setText(String.valueOf(efectivo.getCincoMil()));
|
||||
this.view.getDosMilField().setText(String.valueOf(efectivo.getDosMil()));
|
||||
this.view.getMilField().setText(String.valueOf(efectivo.getMil()));
|
||||
this.view.getQuinientosField().setText(String.valueOf(efectivo.getQuinientos()));
|
||||
this.view.getCienField().setText(String.valueOf(efectivo.getCien()));
|
||||
this.view.getCincuentaField().setText(String.valueOf(efectivo.getCincuenta()));
|
||||
this.view.getDiezField().setText(String.valueOf(efectivo.getDiez()));
|
||||
this.view.getVeinteMilField().setValue(efectivo.getVeinteMil());
|
||||
this.view.getDiezMilField().setValue(efectivo.getDiezMil());
|
||||
this.view.getCincoMilField().setValue(efectivo.getCincoMil());
|
||||
this.view.getDosMilField().setValue(efectivo.getDosMil());
|
||||
this.view.getMilField().setValue(efectivo.getMil());
|
||||
this.view.getQuinientosField().setValue(efectivo.getQuinientos());
|
||||
this.view.getCienField().setValue(efectivo.getCien());
|
||||
this.view.getCincuentaField().setValue(efectivo.getCincuenta());
|
||||
this.view.getDiezField().setValue(efectivo.getDiez());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,8 +223,7 @@ public class ArqueoController {
|
||||
* Primero llama a normalizar el input, luego a esconder los mensajes de error, para finalmente llamar a guardar el efectivo
|
||||
*/
|
||||
private void guardarEfectivoActionListener(){
|
||||
this.normalizeEfectivoInput();
|
||||
this.hiddeEfectivoErrorMessages();
|
||||
this.view.getGuardarEfectivoButton().requestFocus();
|
||||
this.guardarEfectivo();
|
||||
}
|
||||
|
||||
@@ -243,31 +242,29 @@ public class ArqueoController {
|
||||
* llama a updateResumenEfectivo y updateResumenArqueo para actualizar los datos en efectivoField y arqueoField
|
||||
*/
|
||||
private void guardarEfectivo() {
|
||||
String diez = this.view.getDiezField().getText();
|
||||
String cincuenta = this.view.getCincuentaField().getText();
|
||||
String cien = this.view.getCienField().getText();
|
||||
String quinientos = this.view.getQuinientosField().getText();
|
||||
String mil = this.view.getMilField().getText();
|
||||
String dosMil = this.view.getDosMilField().getText();
|
||||
String cincoMil = this.view.getCincoMilField().getText();
|
||||
String diezMil = this.view.getDiezMilField().getText();
|
||||
String veinteMil = this.view.getVeinteMilField().getText();
|
||||
int diez = this.view.getDiezField().getValue();
|
||||
int cincuenta = this.view.getCincuentaField().getValue();
|
||||
int cien = this.view.getCienField().getValue();
|
||||
int quinientos = this.view.getQuinientosField().getValue();
|
||||
int mil = this.view.getMilField().getValue();
|
||||
int dosMil = this.view.getDosMilField().getValue();
|
||||
int cincoMil = this.view.getCincoMilField().getValue();
|
||||
int diezMil = this.view.getDiezMilField().getValue();
|
||||
int veinteMil = this.view.getVeinteMilField().getValue();
|
||||
|
||||
if (this.validateEfectivoInput(diez, cincuenta, cien, quinientos, mil, dosMil, cincoMil, diezMil, veinteMil)) {
|
||||
this.efectivo.setDiez(Integer.valueOf(diez));
|
||||
this.efectivo.setCincuenta(Integer.valueOf(cincuenta));
|
||||
this.efectivo.setCien(Integer.valueOf(cien));
|
||||
this.efectivo.setQuinientos(Integer.valueOf(quinientos));
|
||||
this.efectivo.setMil(Integer.valueOf(mil));
|
||||
this.efectivo.setDosMil(Integer.valueOf(dosMil));
|
||||
this.efectivo.setCincoMil(Integer.valueOf(cincoMil));
|
||||
this.efectivo.setDiezMil(Integer.valueOf(diezMil));
|
||||
this.efectivo.setVeinteMil(Integer.valueOf(veinteMil));
|
||||
this.efectivo.setDiez(diez);
|
||||
this.efectivo.setCincuenta(cincuenta);
|
||||
this.efectivo.setCien(cien);
|
||||
this.efectivo.setQuinientos(quinientos);
|
||||
this.efectivo.setMil(mil);
|
||||
this.efectivo.setDosMil(dosMil);
|
||||
this.efectivo.setCincoMil(cincoMil);
|
||||
this.efectivo.setDiezMil(diezMil);
|
||||
this.efectivo.setVeinteMil(veinteMil);
|
||||
this.efectivoDAO.updateEfectivo(efectivo);
|
||||
|
||||
this.updateResumenEfectivo();
|
||||
this.updateResumenArqueo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,25 +285,6 @@ public class ArqueoController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Llama a las validaciones necesarias para el input de Efectivo
|
||||
* @return si es que paso todas las validaciones.
|
||||
*/
|
||||
private boolean validateEfectivoInput(String diez, String cincuenta, String cien, String quinientos, String mil, String dosMil, String cincoMil, String diezMil, String veinteMil) {
|
||||
|
||||
boolean diezValidation = validateEfectivoMoneda(diez, this.view.getErrorDiez());
|
||||
boolean cincuentaValidation = validateEfectivoMoneda(cincuenta, this.view.getErrorCincuenta());
|
||||
boolean cienValidation = validateEfectivoMoneda(cien, this.view.getErrorCien());
|
||||
boolean quinientosValidation = validateEfectivoMoneda(quinientos, this.view.getErrorQuinientos());
|
||||
boolean milValidation = validateEfectivoMoneda(mil, this.view.getErrorMil());
|
||||
boolean dosMilValidation = validateEfectivoMoneda(dosMil, this.view.getErrorDosMil());
|
||||
boolean cincoMilValidation = validateEfectivoMoneda(cincoMil, this.view.getErrorCincoMil());
|
||||
boolean diezMilValidation = validateEfectivoMoneda(diezMil, this.view.getErrorDiezMil());
|
||||
boolean veinteMilValidation = validateEfectivoMoneda(veinteMil, this.view.getErrorVeinteMil());
|
||||
|
||||
return diezValidation && cincuentaValidation && cienValidation && quinientosValidation && milValidation && dosMilValidation && cincoMilValidation && diezMilValidation && veinteMilValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Llama a las validaciones necesarias el input de Documentos
|
||||
* @return si es que todas las validaciones fueron correctas
|
||||
@@ -319,43 +297,6 @@ public class ArqueoController {
|
||||
return tarjetasValidation && chequesValidation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Valida el valor entregado contra las siguientes pruebas
|
||||
* - Es null
|
||||
* - Esta vacio
|
||||
* - Los caracteres no son solamente digitos
|
||||
* - El largo es mayor que diez
|
||||
* Setea un mensaje de error correspondiente en el errorLabel entregado.
|
||||
* @return cuando cualquiera de los casos anteriores sea true se retorna falso, si no retorna true.
|
||||
*/
|
||||
private boolean validateEfectivoMoneda(String valor, JLabel errorLabel) {
|
||||
if (valor == null) {
|
||||
errorLabel.setText("Hubo un problema con los datos");
|
||||
errorLabel.setVisible(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (valor.isEmpty()) {
|
||||
errorLabel.setText("El campo esta vacio");
|
||||
errorLabel.setVisible(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!valor.chars().allMatch(Character::isDigit)) {
|
||||
errorLabel.setText("Deben ser numeros");
|
||||
errorLabel.setVisible(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (valor.length() > 10) {
|
||||
errorLabel.setText("El numero ingresado es demasiado largo");
|
||||
errorLabel.setVisible(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Valida el valor entregado contra las siguientes pruebas
|
||||
* - Es null
|
||||
@@ -394,21 +335,6 @@ public class ArqueoController {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Esconde los mensajes de error de los campos de efectivo
|
||||
*/
|
||||
private void hiddeEfectivoErrorMessages() {
|
||||
this.view.getErrorDiez().setVisible(false);
|
||||
this.view.getErrorCincuenta().setVisible(false);
|
||||
this.view.getErrorCien().setVisible(false);
|
||||
this.view.getErrorQuinientos().setVisible(false);
|
||||
this.view.getErrorMil().setVisible(false);
|
||||
this.view.getErrorDosMil().setVisible(false);
|
||||
this.view.getErrorCincoMil().setVisible(false);
|
||||
this.view.getErrorDiezMil().setVisible(false);
|
||||
this.view.getErrorVeinteMil().setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Esconde los mensajes de error en los campos de documentos
|
||||
*/
|
||||
@@ -417,21 +343,6 @@ public class ArqueoController {
|
||||
this.view.getErrorCheques().setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ejecuta trim sobre todos los campos de efectivo
|
||||
*/
|
||||
private void normalizeEfectivoInput() {
|
||||
this.view.getDiezField().setText(this.view.getDiezField().getText().trim());
|
||||
this.view.getCincuentaField().setText(this.view.getCincuentaField().getText().trim());
|
||||
this.view.getCienField().setText(this.view.getCienField().getText().trim());
|
||||
this.view.getQuinientosField().setText(this.view.getQuinientosField().getText().trim());
|
||||
this.view.getMilField().setText(this.view.getMilField().getText().trim());
|
||||
this.view.getDosMilField().setText(this.view.getDosMilField().getText().trim());
|
||||
this.view.getCincoMilField().setText(this.view.getCincoMilField().getText().trim());
|
||||
this.view.getDiezMilField().setText(this.view.getDiezMilField().getText().trim());
|
||||
this.view.getVeinteMilField().setText(this.view.getVeinteMilField().getText().trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ejecuta trim sobre todos los campos de documentos
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user