diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b819e41..3c7e3ae 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -6,7 +6,7 @@
-
+
@@ -14,10 +14,9 @@
-
-
-
-
+
+
+
@@ -73,7 +72,87 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- print
- "
fec
System
[2018] [Daniel Cortes]
@@ -116,6 +193,8 @@
Copyright (c) 2018 Daniel Cortes
format
format(
+ getvalor
+ gettotalIngreso
2018 Daniel Cortes
@@ -161,11 +240,7 @@
-
-
-
-
@@ -176,17 +251,21 @@
-
-
-
-
+
+
+
+
+
+
+
+
@@ -273,14 +352,6 @@
-
-
-
-
-
-
-
-
@@ -488,7 +559,7 @@
-
+
1545280618093
@@ -700,11 +771,25 @@
1546737934935
-
+
+ 1546745282741
+
+
+
+ 1546745282741
+
+
+ 1546746290385
+
+
+
+ 1546746290385
+
+
-
+
@@ -717,8 +802,9 @@
+
-
+
@@ -807,8 +893,6 @@
-
-
@@ -832,7 +916,9 @@
-
+
+
+
@@ -910,25 +996,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -957,16 +1024,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -977,62 +1034,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1194,21 +1195,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1226,19 +1212,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1246,9 +1219,6 @@
-
-
-
@@ -1345,10 +1315,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -1362,37 +1368,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
-
@@ -1405,6 +1431,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dist/caja.jar b/dist/caja.jar
index 559d843..5544f7c 100644
Binary files a/dist/caja.jar and b/dist/caja.jar differ
diff --git a/dist/database.sqlite b/dist/database.sqlite
index 6b4bfee..99717d7 100644
Binary files a/dist/database.sqlite and b/dist/database.sqlite differ
diff --git a/src/danielcortes/xyz/controllers/EgresosController.java b/src/danielcortes/xyz/controllers/EgresosController.java
index 60e06dd..58bb8fb 100644
--- a/src/danielcortes/xyz/controllers/EgresosController.java
+++ b/src/danielcortes/xyz/controllers/EgresosController.java
@@ -159,7 +159,7 @@ public class EgresosController {
String nro = this.view.getNroField().getText();
String descripcion = this.view.getDescripcionField().getText();
- String valor = this.view.getValorField().getText();
+ int valor = this.view.getValorField().getValue();
TipoEgreso tipo = (TipoEgreso) this.view.getTipoCombo().getSelectedItem();
if(editing){
@@ -182,6 +182,7 @@ public class EgresosController {
this.egresoDAO.deleteEgreso(egreso);
this.updateTotalEgresos();
this.updateButtonsEnabled();
+ this.resetFocus();
}
}
@@ -206,7 +207,7 @@ public class EgresosController {
this.view.getNroField().setText(egreso.getNro());
this.view.getDescripcionField().setText(egreso.getDescripcion());
- this.view.getValorField().setText(String.valueOf(egreso.getValor()));
+ this.view.getValorField().setValue(egreso.getValor());
this.view.getTipoCombo().setSelectedItem(egreso.getTipoEgreso());
}
}
@@ -216,7 +217,7 @@ public class EgresosController {
*/
private void updateTotalEgresos() {
int total = this.egresoDAO.getTotalEgreso(this.caja);
- this.view.getTotalEgresosField().setText(String.valueOf(total));
+ this.view.getTotalEgresosField().setValue(total);
}
/**
@@ -237,10 +238,10 @@ public class EgresosController {
* Guarda un egreso tras llamar a validar su input
* Luego de guardar, agrega el egreso a la tabla, llama a actualizar el total de egresos y llama a limpiar a los inputs
*/
- private void guardarEgreso(String nro, String descripcion, String valor, TipoEgreso tipo, Caja caja) {
- if (this.validateInput(nro, descripcion, valor, tipo, caja)) {
+ private void guardarEgreso(String nro, String descripcion, int valor, TipoEgreso tipo, Caja caja) {
+ if (this.validateInput(nro, descripcion, tipo, caja)) {
Egreso egreso = new Egreso();
- egreso.setValor(Integer.valueOf(valor));
+ egreso.setValor(valor);
egreso.setDescripcion(descripcion);
egreso.setNro(nro);
egreso.setTipoEgreso(tipo);
@@ -257,8 +258,8 @@ public class EgresosController {
* Tras esto actualiza el egreso en la tabla, llama a actualizar el total de egresos y a limpiar los inputs
* Finalmente setea la flag editing a false
*/
- private void editarEgreso(String nro, String descripcion, String valor, TipoEgreso tipo, Caja caja) {
- if (this.validateInput(nro, descripcion, valor, tipo, caja)) {
+ private void editarEgreso(String nro, String descripcion, int valor, TipoEgreso tipo, Caja caja) {
+ if (this.validateInput(nro, descripcion, tipo, caja)) {
this.editingEgreso.setValor(Integer.valueOf(valor));
this.editingEgreso.setDescripcion(descripcion);
this.editingEgreso.setNro(nro);
@@ -275,15 +276,14 @@ public class EgresosController {
* llama a los metodos necesarios para validar los inputs entregados
* @return true cuando todas las validaciones retoran true, si no, false
*/
- private boolean validateInput(String nro, String descripcion, String valor, TipoEgreso tipoEgreso, Caja caja) {
+ private boolean validateInput(String nro, String descripcion, TipoEgreso tipoEgreso, Caja caja) {
boolean nroValidation = this.validateNro(nro);
boolean descripcionValidation = this.validateDescripcion(descripcion);
- boolean valorValidation = this.validateValor(valor);
boolean tipoEgresoValidation = this.validateTipoEgreso(tipoEgreso);
boolean cajaValidation = this.validateCaja(caja);
- return nroValidation && descripcionValidation && valorValidation && tipoEgresoValidation;
+ return nroValidation && descripcionValidation && tipoEgresoValidation;
}
/**
@@ -332,44 +332,6 @@ public class EgresosController {
return true;
}
- /**
- * Valida la variable valor contra los casos
- * - Es null
- * - Esta vacio
- * - Los caracteres no son todos digitos
- * - El largo del string es mayot a 10
- * Cuando el primer caso sea true, colocara un mensaje de error correspondiente en el jlabel correspondiente
- * @return Si cualquiera de estos casos son true se retornara false, si no, se retorna true
- */
- private boolean validateValor(String valor) {
- if (valor == null) {
- this.view.getErrorValor().setText("Hubo un problema con los datos");
- this.view.getErrorValor().setVisible(true);
- return false;
- }
-
- if (valor.isEmpty()) {
- this.view.getErrorValor().setText("El campo esta vacio");
- this.view.getErrorValor().setVisible(true);
- return false;
- }
-
- if (!valor.chars().allMatch(Character::isDigit)) {
- this.view.getErrorValor().setText("Deben ser numeros");
- this.view.getErrorValor().setVisible(true);
- return false;
- }
-
- if (valor.length() > 10) {
- this.view.getErrorValor().setText("El numero ingresado es demasiado largo");
- this.view.getErrorValor().setVisible(true);
- return false;
- }
-
- return true;
-
- }
-
/**
* Valida la variable tipoEgreso contra los casos
* - Es null
@@ -399,7 +361,6 @@ public class EgresosController {
*/
private void hideErrorMessages() {
this.view.getErrorTipoEgreso().setVisible(false);
- this.view.getErrorValor().setVisible(false);
this.view.getErrorDescripcion().setVisible(false);
this.view.getErrorNumero().setVisible(false);
}
@@ -410,6 +371,7 @@ public class EgresosController {
private void clearInputs() {
this.view.getTipoCombo().setSelectedIndex(0);
this.view.getNroField().setText("");
+ this.view.getValorField().setValue(0);
this.view.getValorField().setText("");
this.view.getDescripcionField().setText("");
}
@@ -418,7 +380,6 @@ public class EgresosController {
* Ejecuta trim sobre todos los campos de texto
*/
private void normalizeInputs(){
- this.view.getValorField().setText(this.view.getValorField().getText().trim());
this.view.getNroField().setText(this.view.getNroField().getText().trim());
this.view.getDescripcionField().setText(this.view.getDescripcionField().getText().trim());
diff --git a/src/danielcortes/xyz/views/EgresosView.form b/src/danielcortes/xyz/views/EgresosView.form
index 17bc1d5..fae978d 100644
--- a/src/danielcortes/xyz/views/EgresosView.form
+++ b/src/danielcortes/xyz/views/EgresosView.form
@@ -69,7 +69,7 @@
-
+
@@ -218,7 +218,7 @@
-
+
diff --git a/src/danielcortes/xyz/views/EgresosView.java b/src/danielcortes/xyz/views/EgresosView.java
index 4f0c299..71abfc9 100644
--- a/src/danielcortes/xyz/views/EgresosView.java
+++ b/src/danielcortes/xyz/views/EgresosView.java
@@ -29,6 +29,7 @@ import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import danielcortes.xyz.models.tipo_egreso.TipoEgreso;
import danielcortes.xyz.views.components.EgresosTableModel;
+import danielcortes.xyz.views.components.NumberFormatedTextField;
import javax.swing.*;
import javax.swing.table.TableRowSorter;
@@ -38,10 +39,10 @@ public class EgresosView {
public JPanel contentPanel;
private JTable egresosTable;
private JButton guardarButton;
- private JTextField valorField;
+ private NumberFormatedTextField valorField;
private JTextField descripcionField;
private JTextField nroField;
- private JTextField totalEgresosField;
+ private NumberFormatedTextField totalEgresosField;
private JComboBox tipoCombo;
@@ -83,7 +84,7 @@ public class EgresosView {
return editarButton;
}
- public JTextField getValorField() {
+ public NumberFormatedTextField getValorField() {
return valorField;
}
@@ -95,7 +96,7 @@ public class EgresosView {
return nroField;
}
- public JTextField getTotalEgresosField() {
+ public NumberFormatedTextField getTotalEgresosField() {
return totalEgresosField;
}
@@ -165,7 +166,7 @@ public class EgresosView {
panel2.add(descripcionField, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
nroField = new JTextField();
panel2.add(nroField, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
- valorField = new JTextField();
+ valorField = new NumberFormatedTextField();
panel2.add(valorField, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
final JLabel label3 = new JLabel();
label3.setText("Valor");
@@ -230,7 +231,7 @@ public class EgresosView {
final JLabel label5 = new JLabel();
label5.setText("Total Egresos:");
panel5.add(label5, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- totalEgresosField = new JTextField();
+ totalEgresosField = new NumberFormatedTextField();
totalEgresosField.setEditable(false);
panel5.add(totalEgresosField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false));
}
diff --git a/src/danielcortes/xyz/views/IngresosView.form b/src/danielcortes/xyz/views/IngresosView.form
index c25b730..67c0357 100644
--- a/src/danielcortes/xyz/views/IngresosView.form
+++ b/src/danielcortes/xyz/views/IngresosView.form
@@ -115,16 +115,6 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/src/danielcortes/xyz/views/IngresosView.java b/src/danielcortes/xyz/views/IngresosView.java
index cf50b9c..c2585ee 100644
--- a/src/danielcortes/xyz/views/IngresosView.java
+++ b/src/danielcortes/xyz/views/IngresosView.java
@@ -201,11 +201,6 @@ public class IngresosView {
errorTipoIngreso.setText("Label");
errorTipoIngreso.setVisible(false);
panel2.add(errorTipoIngreso, new GridConstraints(2, 5, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
- errorValor = new JLabel();
- errorValor.setForeground(new Color(-65536));
- errorValor.setText("Label");
- errorValor.setVisible(false);
- panel2.add(errorValor, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
errorNroInicial = new JLabel();
errorNroInicial.setForeground(new Color(-65536));
errorNroInicial.setText("Label");