Agregada una ventana para realizar el calculo del fondo de la caja, es wip, falta la aprobacion del jefe jajaj
This commit is contained in:
@@ -26,6 +26,7 @@ package danielcortes.xyz.controllers;
|
||||
|
||||
import danielcortes.xyz.controllers.actions.NextAction;
|
||||
import danielcortes.xyz.models.caja.Caja;
|
||||
import danielcortes.xyz.models.calculo_fondo.SQLiteCalculoFondoDAO;
|
||||
import danielcortes.xyz.models.documentos.Documentos;
|
||||
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
||||
import danielcortes.xyz.models.efectivo.Efectivo;
|
||||
@@ -33,15 +34,18 @@ import danielcortes.xyz.models.efectivo.EfectivoDAO;
|
||||
import danielcortes.xyz.models.egreso.EgresoDAO;
|
||||
import danielcortes.xyz.models.ingreso.IngresoDAO;
|
||||
import danielcortes.xyz.views.ArqueoView;
|
||||
import danielcortes.xyz.views.CalcularFondoView;
|
||||
import danielcortes.xyz.views.components.NumberFormatedTextField;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.KeyStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
|
||||
/**
|
||||
* Controlador destinado a la vista ArqueoView
|
||||
* Maneja su contenido y las acciones que esta realiza.
|
||||
* Controlador destinado a la vista ArqueoView
|
||||
* Maneja su contenido y las acciones que esta realiza.
|
||||
*/
|
||||
public class ArqueoController {
|
||||
private ArqueoView view;
|
||||
@@ -56,7 +60,6 @@ public class ArqueoController {
|
||||
|
||||
/**
|
||||
* Crea el controlador y ejecuta el metodo que genera los eventos para su vista.
|
||||
*
|
||||
*/
|
||||
public ArqueoController(ArqueoView view, EfectivoDAO efectivoDAO, DocumentosDAO documentosDAO, IngresoDAO ingresoDAO, EgresoDAO egresoDAO) {
|
||||
this.view = view;
|
||||
@@ -70,6 +73,7 @@ public class ArqueoController {
|
||||
|
||||
/**
|
||||
* Actualiza los campos de documentos, efectivo y resumen con los datos de la caja.
|
||||
*
|
||||
* @param caja Caja para la cual se seleccionaran los datos a mostrar
|
||||
*/
|
||||
public void updateCaja(Caja caja) {
|
||||
@@ -164,10 +168,10 @@ public class ArqueoController {
|
||||
this.view.getDebeRendirField().setValue(totalIngresos);
|
||||
this.view.getDiferenciaField().setValue(diferencia);
|
||||
|
||||
if(diferencia < 0) {
|
||||
this.view.getDiferenciaField().setForeground(new Color(255,0,0));
|
||||
}else{
|
||||
this.view.getDiferenciaField().setForeground(new Color(0,0,0));
|
||||
if (diferencia < 0) {
|
||||
this.view.getDiferenciaField().setForeground(new Color(255, 0, 0));
|
||||
} else {
|
||||
this.view.getDiferenciaField().setForeground(new Color(0, 0, 0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -176,15 +180,15 @@ public class ArqueoController {
|
||||
* Setea los eventos de los fields de la vista
|
||||
*/
|
||||
private void setUpViewEvents() {
|
||||
this.view.getVeinteMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getDiezMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getCincoMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getDosMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getQuinientosField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getCienField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getCincuentaField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getDiezField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"save");
|
||||
this.view.getVeinteMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getDiezMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getCincoMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getDosMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getMilField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getQuinientosField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getCienField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getCincuentaField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getDiezField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
||||
|
||||
this.view.getVeinteMilField().getActionMap().put("nextField", new NextAction(this.view.getDiezMilField()));
|
||||
this.view.getDiezMilField().getActionMap().put("nextField", new NextAction(this.view.getCincoMilField()));
|
||||
@@ -194,24 +198,26 @@ public class ArqueoController {
|
||||
this.view.getQuinientosField().getActionMap().put("nextField", new NextAction(this.view.getCienField()));
|
||||
this.view.getCienField().getActionMap().put("nextField", new NextAction(this.view.getCincuentaField()));
|
||||
this.view.getCincuentaField().getActionMap().put("nextField", new NextAction(this.view.getDiezField()));
|
||||
this.view.getDiezField().getActionMap().put("save", new GuardarEfectivoAction(this));
|
||||
this.view.getDiezField().getActionMap().put("save", new GuardarEfectivoAction());
|
||||
|
||||
|
||||
this.view.getChequesField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getTarjetasField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"nextField");
|
||||
this.view.getRetiroField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"),"save");
|
||||
this.view.getChequesField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getTarjetasField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "nextField");
|
||||
this.view.getRetiroField().getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "save");
|
||||
|
||||
this.view.getChequesField().getActionMap().put("nextField", new NextAction(this.view.getTarjetasField()));
|
||||
this.view.getTarjetasField().getActionMap().put("nextField", new NextAction(this.view.getRetiroField()));
|
||||
this.view.getRetiroField().getActionMap().put("save", new GuardarDocumentosAction(this));
|
||||
this.view.getRetiroField().getActionMap().put("save", new GuardarDocumentosAction());
|
||||
|
||||
this.view.getGuardarEfectivoButton().addActionListener(e ->{
|
||||
this.view.getGuardarEfectivoButton().addActionListener(e -> {
|
||||
this.guardarEfectivoActionListener();
|
||||
});
|
||||
this.view.getGuardarDocumentosButton().addActionListener(e ->{
|
||||
this.view.getGuardarDocumentosButton().addActionListener(e -> {
|
||||
this.guardarEfectivoActionListener();
|
||||
});
|
||||
|
||||
this.view.getCalcularFondoButton().addActionListener(e -> {
|
||||
this.calcularFondoActionListener();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -219,7 +225,7 @@ public class ArqueoController {
|
||||
* Llama a los metodos necesarios para guardar los campos de efectivo
|
||||
* Primero llama a normalizar el input, luego a esconder los mensajes de error, para finalmente llamar a guardar el efectivo
|
||||
*/
|
||||
private void guardarEfectivoActionListener(){
|
||||
private void guardarEfectivoActionListener() {
|
||||
this.view.getGuardarEfectivoButton().requestFocus();
|
||||
this.guardarEfectivo();
|
||||
}
|
||||
@@ -228,11 +234,18 @@ public class ArqueoController {
|
||||
* Llama a los metodos necesarios para guardar los documentos
|
||||
* Primero llama a normalizar el input, luego a esconder los mensajes de error y finalmente a guardar los documentos
|
||||
*/
|
||||
private void guardarDocumentosActionListener(){
|
||||
private void guardarDocumentosActionListener() {
|
||||
this.view.getGuardarDocumentosButton().requestFocus();
|
||||
this.guardarDocumentos();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lanza la ventana en la que se puede calcular el fondo de la caja.
|
||||
*/
|
||||
private void calcularFondoActionListener() {
|
||||
new CalcularFondoController(this.view.getContentPanel(), new CalcularFondoView(), this.caja, new SQLiteCalculoFondoDAO());
|
||||
}
|
||||
|
||||
/**
|
||||
* Guarda los datos del detalle de efectivo solo despues de que los campos sean validados, luego de guardar
|
||||
* llama a updateResumenEfectivo y updateResumenArqueo para actualizar los datos en efectivoField y arqueoField
|
||||
@@ -282,28 +295,16 @@ public class ArqueoController {
|
||||
}
|
||||
|
||||
private class GuardarEfectivoAction extends AbstractAction {
|
||||
ArqueoController controller;
|
||||
|
||||
GuardarEfectivoAction(ArqueoController controller){
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
this.controller.guardarEfectivoActionListener();
|
||||
ArqueoController.this.guardarEfectivoActionListener();
|
||||
}
|
||||
}
|
||||
|
||||
private class GuardarDocumentosAction extends AbstractAction {
|
||||
ArqueoController controller;
|
||||
|
||||
GuardarDocumentosAction(ArqueoController controller){
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
this.controller.guardarDocumentosActionListener();
|
||||
ArqueoController.this.guardarDocumentosActionListener();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user