diff --git a/database/sqlite.sql b/database/sqlite.sql index 7cc80e7..50f6ec1 100644 --- a/database/sqlite.sql +++ b/database/sqlite.sql @@ -141,4 +141,29 @@ create table calculo_fondo descripcion text not null, caja_id integer not null, foreign key (caja_id) references caja (id) on update cascade on delete restrict -); \ No newline at end of file +); + +-- Quinta migracion, tabla para generar y guardar el estado de resultado +drop table if exists estado_resultado; +create table estado_resultado +( + id integer primary key, + mes date unique not null, + costo_venta integer null, + cuenta_corriente_factura integer null, + cuenta_corriente_boleta integer null, + cuenta_corriente_sin_respaldo integer null, + remuneraciones integer null, + finiquitos integer null, + aguinaldo integer null, + bonos_personal integer null, + honorarios_contador integer null, + arriendo integer null, + agua integer null, + luz integer null, + gas integer null, + telefono integer null, + otro_servicio integer null, + ppm real null, + ivaFavor int null +); diff --git a/dist/local-release/Programa Caja.jar b/dist/local-release/Programa Caja.jar index 415c874..d4f3c47 100644 Binary files a/dist/local-release/Programa Caja.jar and b/dist/local-release/Programa Caja.jar differ diff --git a/src/danielcortes/xyz/controllers/EstadoResultadoController.java b/src/danielcortes/xyz/controllers/EstadoResultadoController.java new file mode 100644 index 0000000..1d7ecb6 --- /dev/null +++ b/src/danielcortes/xyz/controllers/EstadoResultadoController.java @@ -0,0 +1,281 @@ +package danielcortes.xyz.controllers; + +import danielcortes.xyz.data.DAOManager; +import danielcortes.xyz.models.estado_resultado.EstadoResultado; +import danielcortes.xyz.models.estado_resultado.EstadoResultadoDAO; +import danielcortes.xyz.models.tipo_egreso.TipoEgreso; +import danielcortes.xyz.views.EstadoResultadoView; +import danielcortes.xyz.views.listeners.FocusLostListener; + +import java.time.YearMonth; + +public class EstadoResultadoController { + private EstadoResultadoView view; + private EstadoResultado estadoResultado; + private YearMonth mes; + + public EstadoResultadoController(EstadoResultadoView view) { + this.view = view; + this.setupViewEvents(); + this.updateMonth(); + } + + private void setupViewEvents() { + this.view.getMonthCombo().addActionListener(e -> this.updateMonth()); + this.view.getYearSpinner().addChangeListener(e -> this.updateMonth()); + + this.view.getGastosGeneralesCuentaCorrienteFactura().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosGenerales()); + this.view.getGastosGeneralesCuentaCorrienteBoleta().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosGenerales()); + this.view.getGastosGeneralesCuentaCorrienteSinRespaldo().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosGenerales()); + + this.view.getServiciosAgua().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateServicios()); + this.view.getServiciosLuz().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateServicios()); + this.view.getServiciosGas().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateServicios()); + this.view.getServiciosTelefono().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateServicios()); + this.view.getServiciosOtro().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateServicios()); + + this.view.getGastosOperacionalesCostoVenta().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosOperacionales()); + this.view.getGastosOperacionalesRemuneraciones().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosOperacionales()); + this.view.getGastosOperacionalesFiniquitos().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosOperacionales()); + this.view.getGastosOperacionalesAguinaldo().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosOperacionales()); + this.view.getGastosOperacionalesBonos().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosOperacionales()); + this.view.getGastosOperacionalesHonorariosContador().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosOperacionales()); + this.view.getGastosOperacionalesArriendo().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateGastosOperacionales()); + + this.view.getResumenIVAFavor().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateResumen()); + this.view.getResumenPPM().addFocusListener((FocusLostListener) e -> EstadoResultadoController.this.updateResumen()); + + this.view.getGuardarButton().addActionListener(e -> EstadoResultadoController.this.guardarListener()); + } + + private void guardarListener() { + EstadoResultadoDAO dao = DAOManager.getEstadoResultadoDAO(); + dao.updateEstadoResultado(this.estadoResultado); + } + + private void updateMonth() { + this.mes = this.view.getMonth(); + this.estadoResultado = DAOManager.getEstadoResultadoDAO().findByMonth(this.mes); + if (estadoResultado == null) { + this.estadoResultado = EstadoResultado.emptyEstadoResultado; + this.estadoResultado.setMes(this.mes); + DAOManager.getEstadoResultadoDAO().insertEstadoResultado(estadoResultado); + } + + this.fillVentas(); + this.fillGastosGenerales(); + this.fillServicios(); + this.fillGastosOperacionales(); + this.fillResumen(); + } + + private void fillVentas() { + int ventaBruta = DAOManager.getIngresoDAO().getTotalIngresoMes(this.mes); + int ventaExentas = DAOManager.getIngresoDAO().getTotalExentasMes(this.mes); + int ventaIVA = (int) Math.round((double) ventaBruta * .19d); + int ventaNeta = ventaBruta - ventaIVA; + int ventaNetaYExentas = ventaExentas + ventaNeta; + + this.view.getVentaBrutaField().setValue(ventaBruta); + this.view.getVentaIVAField().setValue(ventaIVA); + this.view.getVentaNetaField().setValue(ventaNeta); + this.view.getVentaExentasField().setValue(ventaExentas); + this.view.getVentasNetaExentasField().setValue(ventaNetaYExentas); + } + + private void fillGastosGenerales() { + TipoEgreso facturaMateriaPrima = DAOManager.getTipoEgresoDAO().findByNombre("Factura Materia Prima").get(0); + TipoEgreso facturaGastosGenerales = DAOManager.getTipoEgresoDAO().findByNombre("Factura Gastos Generales").get(0); + TipoEgreso gastoGeneralConBoleta = DAOManager.getTipoEgresoDAO().findByNombre("Gasto General Con Boleta").get(0); + TipoEgreso gastoMenorMateriaPrima = DAOManager.getTipoEgresoDAO().findByNombre("Gasto Menor Materia Prima").get(0); + TipoEgreso gastoGeneralSinRespaldo = DAOManager.getTipoEgresoDAO().findByNombre("Gasto General Sin Respaldo").get(0); + + int cuentaCorrienteFactura = this.estadoResultado.getCuentaCorrienteFactura(); + int cuentaCorrienteBoleta = this.estadoResultado.getCuentaCorrienteBoleta(); + int cuentaCorrienteSinRespaldo = this.estadoResultado.getCuentaCorrienteSinRespaldo(); + int efectivoFacturaMateriaPrima = DAOManager.getEgresoDAO().getTotalEgresoMesPorTipo(this.mes, facturaMateriaPrima); + int efectivoFacturaGastosGenerales = DAOManager.getEgresoDAO().getTotalEgresoMesPorTipo(this.mes, facturaGastosGenerales); + int efectivoGastoGeneralConBoleta = DAOManager.getEgresoDAO().getTotalEgresoMesPorTipo(this.mes, gastoGeneralConBoleta); + int efectivoGastoMenorMateriaPrima = DAOManager.getEgresoDAO().getTotalEgresoMesPorTipo(this.mes, gastoMenorMateriaPrima); + int efectivoGastoGeneralSinRespaldo = DAOManager.getEgresoDAO().getTotalEgresoMesPorTipo(this.mes, gastoGeneralSinRespaldo); + int gastoTotal = efectivoFacturaMateriaPrima + efectivoFacturaGastosGenerales + efectivoGastoGeneralConBoleta + efectivoGastoMenorMateriaPrima + efectivoGastoGeneralSinRespaldo + cuentaCorrienteBoleta + cuentaCorrienteFactura + cuentaCorrienteSinRespaldo; + + this.view.getGastosGeneralesEfectivoFacturaField().setValue(efectivoFacturaGastosGenerales + efectivoFacturaMateriaPrima); + this.view.getGastosGeneralesEfectivoBoletaField().setValue(efectivoGastoGeneralConBoleta + efectivoGastoMenorMateriaPrima); + this.view.getGastosGeneralesEfectivoSinRespaldo().setValue(efectivoGastoGeneralSinRespaldo); + this.view.getGastosGeneralesCuentaCorrienteFactura().setValue(cuentaCorrienteFactura); + this.view.getGastosGeneralesCuentaCorrienteBoleta().setValue(cuentaCorrienteBoleta); + this.view.getGastosGeneralesCuentaCorrienteSinRespaldo().setValue(cuentaCorrienteSinRespaldo); + this.view.getGastosGeneralesTotal().setValue(gastoTotal); + } + + private void fillGastosOperacionales() { + TipoEgreso tipoPagoPartime = DAOManager.getTipoEgresoDAO().findByNombre("Pago Partime").get(0); + + int costosVenta = this.estadoResultado.getCostoVenta(); + int remuneraciones = this.estadoResultado.getRemuneraciones(); + int finiquitos = this.estadoResultado.getFiniquitos(); + int aguinaldo = this.estadoResultado.getAguinaldo(); + int bonosPersonal = this.estadoResultado.getBonosPersonal(); + int honorariosContador = this.estadoResultado.getHonorariosContador(); + int arriendo = this.estadoResultado.getArriendo(); + int partime = DAOManager.getEgresoDAO().getTotalEgresoMesPorTipo(this.mes, tipoPagoPartime); + + int total = costosVenta + remuneraciones + finiquitos + aguinaldo + bonosPersonal + + honorariosContador + arriendo + partime; + + this.view.getGastosOperacionalesCostoVenta().setValue(costosVenta); + this.view.getGastosOperacionalesRemuneraciones().setValue(remuneraciones); + this.view.getGastosOperacionalesFiniquitos().setValue(finiquitos); + this.view.getGastosOperacionalesAguinaldo().setValue(aguinaldo); + this.view.getGastosOperacionalesBonos().setValue(bonosPersonal); + this.view.getGastosOperacionalesHonorariosContador().setValue(honorariosContador); + this.view.getGastosOperacionalesArriendo().setValue(arriendo); + this.view.getGastosOperacionalesPartime().setValue(partime); + + this.view.getGastosOperacionalesTotal().setValue(total); + } + + private void fillServicios() { + int agua = this.estadoResultado.getAgua(); + int luz = this.estadoResultado.getLuz(); + int gas = this.estadoResultado.getGas(); + int telefono = this.estadoResultado.getTelefono(); + int otro = this.estadoResultado.getOtroServicio(); + + int total = agua + luz + gas + telefono + otro; + + this.view.getServiciosAgua().setValue(agua); + this.view.getServiciosLuz().setValue(luz); + this.view.getServiciosGas().setValue(gas); + this.view.getServiciosTelefono().setValue(telefono); + this.view.getServiciosOtro().setValue(telefono); + this.view.getServiciosTotal().setValue(total); + } + + private void fillResumen() { + double ppm = this.estadoResultado.getPpm(); + int aFavor = this.estadoResultado.getIvaFavor(); + + this.view.getResumenPPM().setValue(ppm); + this.view.getResumenIVAFavor().setValue(aFavor); + + this.updateResumen(); + } + + private void updateGastosGenerales() { + int oldCuentaCorrienteFactura = this.estadoResultado.getCuentaCorrienteFactura(); + int oldCuentaCorrienteBoleta = this.estadoResultado.getCuentaCorrienteBoleta(); + int oldCuentaCorrienteSinRespaldo = this.estadoResultado.getCuentaCorrienteSinRespaldo(); + int oldTotal = this.view.getGastosGeneralesTotal().getValue(); + + int cuentaCorrienteFactura = this.view.getGastosGeneralesCuentaCorrienteFactura().getValue(); + int cuentaCorrienteBoleta = this.view.getGastosGeneralesCuentaCorrienteBoleta().getValue(); + int cuentaCorrienteSinRespaldo = this.view.getGastosGeneralesCuentaCorrienteSinRespaldo().getValue(); + + this.estadoResultado.setCuentaCorrienteFactura(cuentaCorrienteFactura); + this.estadoResultado.setCuentaCorrienteBoleta(cuentaCorrienteBoleta); + this.estadoResultado.setCuentaCorrienteSinRespaldo(cuentaCorrienteSinRespaldo); + + int total = oldTotal + - (oldCuentaCorrienteFactura + oldCuentaCorrienteBoleta + oldCuentaCorrienteSinRespaldo) + + (cuentaCorrienteFactura + cuentaCorrienteBoleta + cuentaCorrienteSinRespaldo); + + this.view.getGastosGeneralesTotal().setValue(total); + + this.updateResumen(); + } + + private void updateServicios() { + int oldAgua = this.estadoResultado.getAgua(); + int oldLuz = this.estadoResultado.getLuz(); + int oldGas = this.estadoResultado.getGas(); + int oldTelefono = this.estadoResultado.getTelefono(); + int oldOtro = this.estadoResultado.getOtroServicio(); + int oldTotal = this.view.getServiciosTotal().getValue(); + + int agua = this.view.getServiciosAgua().getValue(); + int luz = this.view.getServiciosLuz().getValue(); + int gas = this.view.getServiciosGas().getValue(); + int telefono = this.view.getServiciosTelefono().getValue(); + int otro = this.view.getServiciosOtro().getValue(); + + this.estadoResultado.setAgua(agua); + this.estadoResultado.setLuz(luz); + this.estadoResultado.setGas(gas); + this.estadoResultado.setTelefono(telefono); + this.estadoResultado.setOtroServicio(otro); + + int total = oldTotal + - (oldAgua + oldLuz + oldGas + oldTelefono + oldOtro) + + (agua + luz + gas + telefono + otro); + + this.view.getServiciosTotal().setValue(total); + + this.updateResumen(); + } + + private void updateGastosOperacionales() { + int oldCostoVenta = this.estadoResultado.getCostoVenta(); + int oldRemuneraciones = this.estadoResultado.getRemuneraciones(); + int oldFiniquitos = this.estadoResultado.getFiniquitos(); + int oldAguinaldo = this.estadoResultado.getAguinaldo(); + int oldBonos = this.estadoResultado.getBonosPersonal(); + int oldHonorarios = this.estadoResultado.getHonorariosContador(); + int oldArriendo = this.estadoResultado.getArriendo(); + int oldTotal = this.view.getGastosOperacionalesTotal().getValue(); + + int costoVenta = this.view.getGastosOperacionalesCostoVenta().getValue(); + int remuneraciones = this.view.getGastosOperacionalesRemuneraciones().getValue(); + int finiquitos = this.view.getGastosOperacionalesFiniquitos().getValue(); + int aguinaldo = this.view.getGastosOperacionalesAguinaldo().getValue(); + int bonos = this.view.getGastosOperacionalesBonos().getValue(); + int honorarios = this.view.getGastosOperacionalesHonorariosContador().getValue(); + int arriendo = this.view.getGastosOperacionalesArriendo().getValue(); + + this.estadoResultado.setCostoVenta(costoVenta); + this.estadoResultado.setRemuneraciones(remuneraciones); + this.estadoResultado.setFiniquitos(finiquitos); + this.estadoResultado.setAguinaldo(aguinaldo); + this.estadoResultado.setBonosPersonal(bonos); + this.estadoResultado.setHonorariosContador(honorarios); + this.estadoResultado.setArriendo(arriendo); + + int total = oldTotal + - (oldCostoVenta + oldRemuneraciones + oldFiniquitos + oldAguinaldo + oldBonos + oldHonorarios + oldArriendo) + + (costoVenta + remuneraciones + finiquitos + aguinaldo + bonos + honorarios + arriendo); + + this.view.getGastosOperacionalesTotal().setValue(total); + + this.updateResumen(); + } + + private void updateResumen() { + int bruto = this.view.getVentaBrutaField().getValue(); + int totalGastosOperacionales = this.view.getGastosOperacionalesTotal().getValue(); + int totalGastosGenerales = this.view.getGastosGeneralesTotal().getValue(); + int totalServicios = this.view.getServiciosTotal().getValue(); + int netoExentas = this.view.getVentasNetaExentasField().getValue(); + int iva = this.view.getVentaIVAField().getValue(); + double ppm = this.view.getResumenPPM().getValue(); + int ivaFavor = this.view.getResumenIVAFavor().getValue(); + + int utilidad = bruto - totalGastosGenerales - totalGastosOperacionales - totalServicios; + int ppmMes = (int) Math.round(ppm * (double)netoExentas / 100d); + int IVAPPM = iva + ppmMes; + int aPagar = IVAPPM - ivaFavor; + int resultado = utilidad - aPagar; + + + this.view.getResumenUtilidad().setValue(utilidad); + this.view.getResumenPPMMes().setValue(ppmMes); + this.view.getResumenIVAMes().setValue(iva); + this.view.getResumenIVAPPM().setValue(IVAPPM); + this.view.getResumenAPagar().setValue(aPagar); + this.view.getResumenResultado().setValue(resultado); + + this.estadoResultado.setPpm(ppm); + this.estadoResultado.setIvaFavor(ivaFavor); + } +} + diff --git a/src/danielcortes/xyz/controllers/InformesController.java b/src/danielcortes/xyz/controllers/InformesController.java index 527839e..afeccdd 100644 --- a/src/danielcortes/xyz/controllers/InformesController.java +++ b/src/danielcortes/xyz/controllers/InformesController.java @@ -29,6 +29,7 @@ import danielcortes.xyz.informes.InformeEgresos; import danielcortes.xyz.informes.InformeLibroDeVentas; import danielcortes.xyz.models.tipo_egreso.TipoEgreso; import danielcortes.xyz.utils.StringUtils; +import danielcortes.xyz.views.EstadoResultadoView; import danielcortes.xyz.views.InformesView; import danielcortes.xyz.views.dialogs.MonthSelectDialog; import danielcortes.xyz.views.dialogs.TipoEgresoSelectDialog; @@ -53,6 +54,21 @@ public class InformesController { private void setupViewEvents() { this.view.getInformeLibroDeVentasButton().addActionListener(e -> generarInformeLibroDeVentasListener()); this.view.getGenerarEgresosFacturasMateriaPrimaButton().addActionListener(e -> generarInformeEgresosListener()); + this.view.getEstadoResultadoButton().addActionListener(e -> { + EstadoResultadoView view = new EstadoResultadoView(); + EstadoResultadoController controller = new EstadoResultadoController(view); + + JFrame frame = new JFrame("Estado Resultado"+ ": " + Configuration.get("nombre_caja")); + frame.setContentPane(view.getContentPanel()); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.setSize(1000,600); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + + this.view.getSalirButton().addActionListener(e -> { + ((JFrame) this.view.getContentPanel().getParent().getParent().getParent()).dispose(); + }); } private void generarInformeLibroDeVentasListener() { diff --git a/src/danielcortes/xyz/controllers/MainController.java b/src/danielcortes/xyz/controllers/MainController.java index 50f3b65..9df8c3d 100644 --- a/src/danielcortes/xyz/controllers/MainController.java +++ b/src/danielcortes/xyz/controllers/MainController.java @@ -12,8 +12,6 @@ import java.awt.*; public class MainController { private MainView view; - private CajasController cajasController; - public MainController(MainView view){ this.view = view; this.setupViewEvents(); @@ -38,6 +36,9 @@ public class MainController { this.executeView(view.getContentPanel(), "Informes Mensuales", new Dimension(250, 500)); }); + this.view.getSalirButton().addActionListener(e -> { + System.exit(0); + }); } private void executeView(JComponent view, String title, Dimension d){ diff --git a/src/danielcortes/xyz/data/DAOManager.java b/src/danielcortes/xyz/data/DAOManager.java index 3addaff..313553c 100644 --- a/src/danielcortes/xyz/data/DAOManager.java +++ b/src/danielcortes/xyz/data/DAOManager.java @@ -34,6 +34,8 @@ import danielcortes.xyz.models.efectivo.EfectivoDAO; import danielcortes.xyz.models.efectivo.SQLiteEfectivoDAO; import danielcortes.xyz.models.egreso.EgresoDAO; import danielcortes.xyz.models.egreso.SQLiteEgresoDAO; +import danielcortes.xyz.models.estado_resultado.EstadoResultadoDAO; +import danielcortes.xyz.models.estado_resultado.SQLiteEstadoResultadoDAO; import danielcortes.xyz.models.informes.egresos.InformeEgresosContentDAO; import danielcortes.xyz.models.informes.egresos.SQLiteInformeEgresosContentDAO; import danielcortes.xyz.models.informes.libro_de_ventas.InformeLibroDeVentasContentDAO; @@ -56,6 +58,7 @@ public class DAOManager { private static final IngresoDAO ingresoDAO; private static final TipoEgresoDAO tipoEgresoDAO; private static final TipoIngresoDAO tipoIngresoDAO; + private static final EstadoResultadoDAO estadoResultadoDAO; static { cajaDAO = new SQLiteCajaDAO(); @@ -68,6 +71,7 @@ public class DAOManager { ingresoDAO = new SQLiteIngresoDAO(); tipoEgresoDAO = new SQLiteTipoEgresoDAO(); tipoIngresoDAO = new SQLiteTipoIngresoDAO(); + estadoResultadoDAO = new SQLiteEstadoResultadoDAO(); } public static CajaDAO getCajaDAO() { @@ -109,4 +113,8 @@ public class DAOManager { public static TipoIngresoDAO getTipoIngresoDAO() { return tipoIngresoDAO; } + + public static EstadoResultadoDAO getEstadoResultadoDAO() { + return estadoResultadoDAO; + } } diff --git a/src/danielcortes/xyz/models/egreso/EgresoDAO.java b/src/danielcortes/xyz/models/egreso/EgresoDAO.java index a1c2040..2d26153 100644 --- a/src/danielcortes/xyz/models/egreso/EgresoDAO.java +++ b/src/danielcortes/xyz/models/egreso/EgresoDAO.java @@ -34,6 +34,7 @@ import danielcortes.xyz.models.tipo_egreso.TipoEgresoDAO; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.YearMonth; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -62,6 +63,8 @@ public abstract class EgresoDAO { public abstract int getTotalEgreso(Caja caja); + public abstract int getTotalEgresoMesPorTipo(YearMonth mes, TipoEgreso tipo); + List egresosFromResultSet(ResultSet rs) throws SQLException { ArrayList egresoList = new ArrayList<>(); while (rs.next()) { diff --git a/src/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java b/src/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java index c58a815..c39e2e2 100644 --- a/src/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java +++ b/src/danielcortes/xyz/models/egreso/SQLiteEgresoDAO.java @@ -32,6 +32,8 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.LocalDate; +import java.time.YearMonth; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -243,4 +245,32 @@ public class SQLiteEgresoDAO extends EgresoDAO { } return total; } + + @Override + public int getTotalEgresoMesPorTipo(YearMonth mes, TipoEgreso tipo) { + int total = 0; + try (Connection conn = connectionHolder.getConnection()) { + LocalDate start = mes.atDay(1); + LocalDate end = mes.atEndOfMonth(); + String query = "select sum(valor) from egresos inner join caja on (egresos.caja_id = caja.id) where fecha between ? and ? and tipo_egreso_id = ?"; + PreparedStatement ps = conn.prepareStatement(query); + ps.setString(1, start.toString()); + ps.setString(2, end.toString()); + ps.setInt(3, tipo.getId()); + ResultSet rs = ps.executeQuery(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}, {2}, {3}", new Object[]{query, start, end, tipo}); + + rs.next(); + total = rs.getInt(1); + + rs.close(); + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + } + return total; + } + + } diff --git a/src/danielcortes/xyz/models/estado_resultado/EstadoResultado.java b/src/danielcortes/xyz/models/estado_resultado/EstadoResultado.java new file mode 100644 index 0000000..d023915 --- /dev/null +++ b/src/danielcortes/xyz/models/estado_resultado/EstadoResultado.java @@ -0,0 +1,201 @@ +package danielcortes.xyz.models.estado_resultado; + +import java.time.YearMonth; + +public class EstadoResultado { + public static final EstadoResultado emptyEstadoResultado; + + static { + emptyEstadoResultado = new EstadoResultado(); + emptyEstadoResultado.costoVenta = 0; + emptyEstadoResultado.cuentaCorrienteBoleta = 0; + emptyEstadoResultado.cuentaCorrienteFactura = 0; + emptyEstadoResultado.cuentaCorrienteSinRespaldo = 0; + emptyEstadoResultado.remuneraciones = 0; + emptyEstadoResultado.finiquitos = 0; + emptyEstadoResultado.aguinaldo = 0; + emptyEstadoResultado.bonosPersonal = 0; + emptyEstadoResultado.honorariosContador = 0; + emptyEstadoResultado.arriendo = 0; + emptyEstadoResultado.agua = 0; + emptyEstadoResultado.luz = 0; + emptyEstadoResultado.gas = 0; + emptyEstadoResultado.telefono = 0; + emptyEstadoResultado.otroServicio = 0; + emptyEstadoResultado.ppm = 0d; + emptyEstadoResultado.ivaFavor = 0; + } + + private int id; + private YearMonth mes; + private int costoVenta; + private int cuentaCorrienteFactura; + private int cuentaCorrienteBoleta; + private int cuentaCorrienteSinRespaldo; + private int remuneraciones; + private int finiquitos; + private int aguinaldo; + private int bonosPersonal; + private int honorariosContador; + private int arriendo; + private int agua; + private int luz; + private int gas; + private int telefono; + private int otroServicio; + private double ppm; + private int ivaFavor; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public YearMonth getMes() { + return mes; + } + + public void setMes(YearMonth mes) { + this.mes = mes; + } + + public int getCostoVenta() { + return costoVenta; + } + + public void setCostoVenta(int costoVenta) { + this.costoVenta = costoVenta; + } + + public int getCuentaCorrienteFactura() { + return cuentaCorrienteFactura; + } + + public void setCuentaCorrienteFactura(int cuentaCorrienteFactura) { + this.cuentaCorrienteFactura = cuentaCorrienteFactura; + } + + public int getCuentaCorrienteBoleta() { + return cuentaCorrienteBoleta; + } + + public void setCuentaCorrienteBoleta(int cuentaCorrienteBoleta) { + this.cuentaCorrienteBoleta = cuentaCorrienteBoleta; + } + + public int getCuentaCorrienteSinRespaldo() { + return cuentaCorrienteSinRespaldo; + } + + public void setCuentaCorrienteSinRespaldo(int cuentaCorrienteSinRespaldo) { + this.cuentaCorrienteSinRespaldo = cuentaCorrienteSinRespaldo; + } + + public int getRemuneraciones() { + return remuneraciones; + } + + public void setRemuneraciones(int remuneraciones) { + this.remuneraciones = remuneraciones; + } + + public int getFiniquitos() { + return finiquitos; + } + + public void setFiniquitos(int finiquitos) { + this.finiquitos = finiquitos; + } + + public int getAguinaldo() { + return aguinaldo; + } + + public void setAguinaldo(int aguinaldo) { + this.aguinaldo = aguinaldo; + } + + public int getBonosPersonal() { + return bonosPersonal; + } + + public void setBonosPersonal(int bonosPersonal) { + this.bonosPersonal = bonosPersonal; + } + + public int getHonorariosContador() { + return honorariosContador; + } + + public void setHonorariosContador(int honorariosContador) { + this.honorariosContador = honorariosContador; + } + + public int getArriendo() { + return arriendo; + } + + public void setArriendo(int arriendo) { + this.arriendo = arriendo; + } + + public int getAgua() { + return agua; + } + + public void setAgua(int agua) { + this.agua = agua; + } + + public int getLuz() { + return luz; + } + + public void setLuz(int luz) { + this.luz = luz; + } + + public int getGas() { + return gas; + } + + public void setGas(int gas) { + this.gas = gas; + } + + public int getTelefono() { + return telefono; + } + + public void setTelefono(int telefono) { + this.telefono = telefono; + } + + public int getOtroServicio() { + return otroServicio; + } + + public void setOtroServicio(int otroServicio) { + this.otroServicio = otroServicio; + } + + public double getPpm() { + return ppm; + } + + public void setPpm(double ppm) { + this.ppm = ppm; + } + + public void setIvaFavor(int ivaFavor) { + this.ivaFavor = ivaFavor; + } + + public int getIvaFavor() { + return ivaFavor; + } +} + diff --git a/src/danielcortes/xyz/models/estado_resultado/EstadoResultadoDAO.java b/src/danielcortes/xyz/models/estado_resultado/EstadoResultadoDAO.java new file mode 100644 index 0000000..cef3db8 --- /dev/null +++ b/src/danielcortes/xyz/models/estado_resultado/EstadoResultadoDAO.java @@ -0,0 +1,55 @@ +package danielcortes.xyz.models.estado_resultado; + +import danielcortes.xyz.models.egreso.EgresoDAO; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Logger; + +public abstract class EstadoResultadoDAO { + protected static final Logger LOGGER = Logger.getLogger(EgresoDAO.class.getName()); + + + + public abstract List findAll(); + public abstract EstadoResultado findById(int id); + public abstract EstadoResultado findByMonth(YearMonth month); + + public abstract boolean insertEstadoResultado(EstadoResultado estadoResultado); + public abstract boolean updateEstadoResultado(EstadoResultado estadoResultado); + public abstract boolean deleteEstadoResultado(EstadoResultado estadoResultado); + + List estadoResultadosFromResultSet(ResultSet rs) throws SQLException { + List estadoResultadoList = new ArrayList<>(); + + while(rs.next()) { + EstadoResultado estadoResultado = new EstadoResultado(); + estadoResultado.setId(rs.getInt("id")); + estadoResultado.setMes(YearMonth.from(LocalDate.parse(rs.getString("mes")))); + estadoResultado.setCostoVenta(rs.getInt("costo_venta")); + estadoResultado.setCuentaCorrienteFactura(rs.getInt("cuenta_corriente_factura")); + estadoResultado.setCuentaCorrienteBoleta(rs.getInt("cuenta_corriente_boleta")); + estadoResultado.setCuentaCorrienteSinRespaldo(rs.getInt("cuenta_corriente_sin_respaldo")); + estadoResultado.setRemuneraciones(rs.getInt("remuneraciones")); + estadoResultado.setFiniquitos(rs.getInt("finiquitos")); + estadoResultado.setAguinaldo(rs.getInt("aguinaldo")); + estadoResultado.setBonosPersonal(rs.getInt("bonos_personal")); + estadoResultado.setHonorariosContador(rs.getInt("honorarios_contador")); + estadoResultado.setArriendo(rs.getInt("arriendo")); + estadoResultado.setAgua(rs.getInt("agua")); + estadoResultado.setLuz(rs.getInt("luz")); + estadoResultado.setGas(rs.getInt("gas")); + estadoResultado.setTelefono(rs.getInt("telefono")); + estadoResultado.setOtroServicio(rs.getInt("otro_servicio")); + estadoResultado.setPpm(rs.getDouble("ppm")); + estadoResultado.setIvaFavor(rs.getInt("ivaFavor")); + + estadoResultadoList.add(estadoResultado); + } + return estadoResultadoList; + } +} diff --git a/src/danielcortes/xyz/models/estado_resultado/SQLiteEstadoResultadoDAO.java b/src/danielcortes/xyz/models/estado_resultado/SQLiteEstadoResultadoDAO.java new file mode 100644 index 0000000..bda4b35 --- /dev/null +++ b/src/danielcortes/xyz/models/estado_resultado/SQLiteEstadoResultadoDAO.java @@ -0,0 +1,194 @@ +package danielcortes.xyz.models.estado_resultado; + +import danielcortes.xyz.data.SQLiteConnectionHolder; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.time.YearMonth; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; + +public class SQLiteEstadoResultadoDAO extends EstadoResultadoDAO { + private SQLiteConnectionHolder connectionHolder; + + public SQLiteEstadoResultadoDAO() { + this.connectionHolder = new SQLiteConnectionHolder(); + } + + @Override + public List findAll() { + List estadoResultadoList = new ArrayList<>(); + try (Connection conn = connectionHolder.getConnection()) { + String query = "select * from estado_resultado"; + PreparedStatement ps = conn.prepareStatement(query); + ResultSet rs = ps.executeQuery(); + + LOGGER.log(Level.FINE, "QUERY: {0}", new Object[]{query}); + + estadoResultadoList = this.estadoResultadosFromResultSet(rs); + + rs.close(); + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + } + return estadoResultadoList; + } + + @Override + public EstadoResultado findById(int id) { + EstadoResultado estadoResultado = null; + try (Connection conn = connectionHolder.getConnection()) { + String query = "select * from estado_resultado where id = ?"; + PreparedStatement ps = conn.prepareStatement(query); + ps.setInt(1, id); + ResultSet rs = ps.executeQuery(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, id}); + + estadoResultado = this.estadoResultadosFromResultSet(rs).get(0); + + rs.close(); + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + } + return estadoResultado; + } + + @Override + public EstadoResultado findByMonth(YearMonth month) { + EstadoResultado estadoResultado = null; + try (Connection conn = connectionHolder.getConnection()) { + String query = "select * from estado_resultado where mes = ?"; + PreparedStatement ps = conn.prepareStatement(query); + ps.setString(1, month.atDay(1).toString()); + ResultSet rs = ps.executeQuery(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, month}); + + + List estadosResultado = this.estadoResultadosFromResultSet(rs); + if (estadosResultado.size() > 0) { + estadoResultado = estadosResultado.get(0); + } + + rs.close(); + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + } + return estadoResultado; + } + + @Override + public boolean insertEstadoResultado(EstadoResultado estadoResultado) { + int updates; + try (Connection conn = connectionHolder.getConnection()) { + String query = "insert into estado_resultado (mes, costo_venta, cuenta_corriente_factura, cuenta_corriente_boleta, cuenta_corriente_sin_respaldo, remuneraciones, finiquitos, aguinaldo, bonos_personal, honorarios_contador, arriendo, agua, luz, gas, telefono, otro_servicio, ppm, ivaFavor) values (?, ?, ?, ?, ?, ? , ?, ? , ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + PreparedStatement ps = conn.prepareStatement(query); + + ps.setString(1, estadoResultado.getMes().atDay(1).toString()); + ps.setInt(2, estadoResultado.getCostoVenta()); + ps.setInt(3, estadoResultado.getCuentaCorrienteFactura()); + ps.setInt(4, estadoResultado.getCuentaCorrienteBoleta()); + ps.setInt(5, estadoResultado.getCuentaCorrienteSinRespaldo()); + ps.setInt(6, estadoResultado.getRemuneraciones()); + ps.setInt(7, estadoResultado.getFiniquitos()); + ps.setInt(8, estadoResultado.getAguinaldo()); + ps.setInt(9, estadoResultado.getBonosPersonal()); + ps.setInt(10, estadoResultado.getHonorariosContador()); + ps.setInt(11, estadoResultado.getArriendo()); + ps.setInt(12, estadoResultado.getAgua()); + ps.setInt(13, estadoResultado.getLuz()); + ps.setInt(14, estadoResultado.getGas()); + ps.setInt(15, estadoResultado.getTelefono()); + ps.setInt(16, estadoResultado.getOtroServicio()); + ps.setDouble(17, estadoResultado.getPpm()); + ps.setDouble(18, estadoResultado.getIvaFavor()); + + updates = ps.executeUpdate(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}] | updates: {19}", new Object[]{query, estadoResultado.getMes(), estadoResultado.getCostoVenta(), estadoResultado.getCuentaCorrienteFactura(), estadoResultado.getCuentaCorrienteBoleta(), estadoResultado.getCuentaCorrienteSinRespaldo(), estadoResultado.getRemuneraciones(), estadoResultado.getFiniquitos(), estadoResultado.getAguinaldo(), estadoResultado.getBonosPersonal(), estadoResultado.getHonorariosContador(), estadoResultado.getArriendo(), estadoResultado.getAgua(), estadoResultado.getLuz(), estadoResultado.getGas(), estadoResultado.getTelefono(), estadoResultado.getOtroServicio(), estadoResultado.getPpm(),estadoResultado.getIvaFavor(), updates}); + + ps.close(); + + query = "select last_insert_rowid()"; + ps = conn.prepareStatement(query); + ResultSet rs = ps.executeQuery(); + + LOGGER.log(Level.FINE, "QUERY: {0}", query); + + rs.next(); + estadoResultado.setId(rs.getInt(1)); + + rs.close(); + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + return false; + } + return updates > 0; + } + + @Override + public boolean updateEstadoResultado(EstadoResultado estadoResultado) { + int updates; + try (Connection conn = connectionHolder.getConnection()) { + String query = "update estado_resultado set mes = ?, costo_venta = ?, cuenta_corriente_factura = ?, cuenta_corriente_boleta = ?, cuenta_corriente_sin_respaldo = ?, remuneraciones = ?, finiquitos = ?, aguinaldo = ?, bonos_personal = ?, honorarios_contador = ?, arriendo = ?, agua = ?, luz = ?, gas = ?, telefono = ?, otro_servicio = ?, ppm = ?, ivaFavor = ? where id = ?"; + PreparedStatement ps = conn.prepareStatement(query); + + ps.setString(1, estadoResultado.getMes().atDay(1).toString()); + ps.setInt(2, estadoResultado.getCostoVenta()); + ps.setInt(3, estadoResultado.getCuentaCorrienteFactura()); + ps.setInt(4, estadoResultado.getCuentaCorrienteBoleta()); + ps.setInt(5, estadoResultado.getCuentaCorrienteSinRespaldo()); + ps.setInt(6, estadoResultado.getRemuneraciones()); + ps.setInt(7, estadoResultado.getFiniquitos()); + ps.setInt(8, estadoResultado.getAguinaldo()); + ps.setInt(9, estadoResultado.getBonosPersonal()); + ps.setInt(10, estadoResultado.getHonorariosContador()); + ps.setInt(11, estadoResultado.getArriendo()); + ps.setInt(12, estadoResultado.getAgua()); + ps.setInt(13, estadoResultado.getLuz()); + ps.setInt(14, estadoResultado.getGas()); + ps.setInt(15, estadoResultado.getTelefono()); + ps.setInt(16, estadoResultado.getOtroServicio()); + ps.setDouble(17, estadoResultado.getPpm()); + ps.setDouble(18, estadoResultado.getIvaFavor()); + ps.setInt(19, estadoResultado.getId()); + + updates = ps.executeUpdate(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2},{3},{4},{5},{6},{7},{8},{9},{10}, {11}, {12}, {13}, {14}, {15}, {16}, {17}, {18}, {19}] | updates: {20}", new Object[]{query, estadoResultado.getMes(), estadoResultado.getCostoVenta(), estadoResultado.getCuentaCorrienteFactura(), estadoResultado.getCuentaCorrienteBoleta(), estadoResultado.getCuentaCorrienteSinRespaldo(), estadoResultado.getRemuneraciones(), estadoResultado.getFiniquitos(), estadoResultado.getAguinaldo(), estadoResultado.getBonosPersonal(), estadoResultado.getHonorariosContador(), estadoResultado.getArriendo(), estadoResultado.getAgua(), estadoResultado.getLuz(), estadoResultado.getGas(), estadoResultado.getTelefono(), estadoResultado.getOtroServicio(), estadoResultado.getPpm(),estadoResultado.getIvaFavor(), estadoResultado.getId(), updates}); + + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + return false; + } + return updates > 0; + } + + @Override + public boolean deleteEstadoResultado(EstadoResultado estadoResultado) { + int updates; + try (Connection conn = connectionHolder.getConnection()) { + String query = "delete from estado_resultado where id = ?"; + PreparedStatement ps = conn.prepareStatement(query); + ps.setInt(1, estadoResultado.getId()); + updates = ps.executeUpdate(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: {1} | updates: {2}", new Object[]{query, estadoResultado.getId(), updates}); + + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + return false; + } + return updates > 0; + } +} diff --git a/src/danielcortes/xyz/models/ingreso/IngresoDAO.java b/src/danielcortes/xyz/models/ingreso/IngresoDAO.java index 9766955..b95c8c3 100644 --- a/src/danielcortes/xyz/models/ingreso/IngresoDAO.java +++ b/src/danielcortes/xyz/models/ingreso/IngresoDAO.java @@ -35,6 +35,7 @@ import danielcortes.xyz.models.tipo_ingreso.TipoIngresoDAO; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.YearMonth; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -61,7 +62,12 @@ public abstract class IngresoDAO { public abstract int getTotalIngreso(Caja caja); - List ingresosFromResultSet(ResultSet rs) throws SQLException { + public abstract int getTotalIngresoMes(YearMonth mes); + + public abstract int getTotalExentasMes(YearMonth mes); + + + List ingresosFromResultSet(ResultSet rs) throws SQLException { ArrayList ingresosList = new ArrayList<>(); while (rs.next()) { int tipoIngresoId = rs.getInt("tipo_ingreso_id"); diff --git a/src/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java b/src/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java index 47c55ce..a26a89c 100644 --- a/src/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java +++ b/src/danielcortes/xyz/models/ingreso/SQLiteIngresoDAO.java @@ -32,6 +32,8 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.LocalDate; +import java.time.YearMonth; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -227,4 +229,56 @@ public class SQLiteIngresoDAO extends IngresoDAO { } return total; } + + @Override + public int getTotalIngresoMes(YearMonth mes) { + int total = 0; + try (Connection conn = connectionHolder.getConnection()) { + LocalDate start = mes.atDay(1); + LocalDate end = mes.atEndOfMonth(); + String query = + "select sum(valor) from ingresos inner join caja on (ingresos.caja_id == caja.id) where caja.fecha between ? and ? and ingresos.tipo_ingreso_id != 5"; + PreparedStatement ps = conn.prepareStatement(query); + ps.setString(1, start.toString()); + ps.setString(2, end.toString()); + ResultSet rs = ps.executeQuery(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}, {2}", new Object[]{query, start, end}); + + rs.next(); + total = rs.getInt(1); + + rs.close(); + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + } + return total; + } + + @Override + public int getTotalExentasMes(YearMonth mes) { + int total = 0; + try (Connection conn = connectionHolder.getConnection()) { + LocalDate start = mes.atDay(1); + LocalDate end = mes.atEndOfMonth(); + String query = + "select sum(valor) from ingresos inner join caja on (ingresos.caja_id == caja.id) where caja.fecha between ? and ? and ingresos.tipo_ingreso_id = 5"; + PreparedStatement ps = conn.prepareStatement(query); + ps.setString(1, start.toString()); + ps.setString(2, end.toString()); + ResultSet rs = ps.executeQuery(); + + LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}, {2}", new Object[]{query, start, end}); + + rs.next(); + total = rs.getInt(1); + + rs.close(); + ps.close(); + } catch (SQLException e) { + LOGGER.log(Level.SEVERE, e.toString(), e); + } + return total; + } } diff --git a/src/danielcortes/xyz/views/EstadoResultadoView.form b/src/danielcortes/xyz/views/EstadoResultadoView.form new file mode 100644 index 0000000..1f9d2f3 --- /dev/null +++ b/src/danielcortes/xyz/views/EstadoResultadoView.form @@ -0,0 +1,770 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/danielcortes/xyz/views/EstadoResultadoView.java b/src/danielcortes/xyz/views/EstadoResultadoView.java new file mode 100644 index 0000000..7ff6744 --- /dev/null +++ b/src/danielcortes/xyz/views/EstadoResultadoView.java @@ -0,0 +1,536 @@ +package danielcortes.xyz.views; + +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; +import danielcortes.xyz.views.components.DoubleFormatedTextField; +import danielcortes.xyz.views.components.NumberFormatedTextField; +import danielcortes.xyz.views.components.YearSpinnerModel; + +import javax.swing.*; +import java.awt.*; +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.ArrayList; + +public class EstadoResultadoView { + private NumberFormatedTextField ventaBrutaField; + private NumberFormatedTextField ventaNetaField; + private NumberFormatedTextField ventaIVAField; + private NumberFormatedTextField ventaExentasField; + private NumberFormatedTextField ventasNetaExentasField; + private NumberFormatedTextField gastosOperacionalesCostoVenta; + private NumberFormatedTextField gastosOperacionalesRemuneraciones; + private NumberFormatedTextField gastosOperacionalesFiniquitos; + private NumberFormatedTextField gastosOperacionalesAguinaldo; + private NumberFormatedTextField gastosOperacionalesPartime; + private NumberFormatedTextField gastosOperacionalesBonos; + private NumberFormatedTextField gastosOperacionalesHonorariosContador; + private NumberFormatedTextField gastosOperacionalesArriendo; + private NumberFormatedTextField gastosOperacionalesTotal; + private NumberFormatedTextField serviciosAgua; + private NumberFormatedTextField serviciosLuz; + private NumberFormatedTextField serviciosGas; + private NumberFormatedTextField serviciosTelefono; + private NumberFormatedTextField serviciosTotal; + private NumberFormatedTextField gastosGeneralesCuentaCorrienteFactura; + private NumberFormatedTextField gastosGeneralesCuentaCorrienteBoleta; + private NumberFormatedTextField gastosGeneralesCuentaCorrienteSinRespaldo; + private NumberFormatedTextField gastosGeneralesEfectivoFacturaField; + private NumberFormatedTextField gastosGeneralesEfectivoBoletaField; + private NumberFormatedTextField gastosGeneralesEfectivoSinRespaldo; + private NumberFormatedTextField gastosGeneralesTotal; + private NumberFormatedTextField resumenUtilidad; + private NumberFormatedTextField resumenPPMMes; + private NumberFormatedTextField resumenIVAMes; + private NumberFormatedTextField resumenIVAFavor; + private NumberFormatedTextField resumenResultado; + private JSpinner yearSpinner; + private JComboBox monthCombo; + private JPanel contentPanel; + private NumberFormatedTextField serviciosOtro; + private NumberFormatedTextField resumenAPagar; + private NumberFormatedTextField resumenIVAPPM; + private DoubleFormatedTextField resumenPPM; + private JButton guardarButton; + private JButton exportarButton; + + private ArrayList months; + + public EstadoResultadoView() { + $$$setupUI$$$(); + } + + public JPanel getContentPanel() { + return contentPanel; + } + + public YearMonth getMonth() { + int year = Integer.valueOf((String) yearSpinner.getValue()); + int month = this.months.indexOf((String) this.monthCombo.getSelectedItem()) + 1; + + YearMonth yearMonth = YearMonth.of(year, month); + return yearMonth; + } + + public JSpinner getYearSpinner() { + return yearSpinner; + } + + public JComboBox getMonthCombo() { + return monthCombo; + } + + public NumberFormatedTextField getVentaBrutaField() { + return ventaBrutaField; + } + + public NumberFormatedTextField getVentaNetaField() { + return ventaNetaField; + } + + public NumberFormatedTextField getVentaIVAField() { + return ventaIVAField; + } + + public NumberFormatedTextField getVentaExentasField() { + return ventaExentasField; + } + + public NumberFormatedTextField getVentasNetaExentasField() { + return ventasNetaExentasField; + } + + public NumberFormatedTextField getGastosOperacionalesCostoVenta() { + return gastosOperacionalesCostoVenta; + } + + public NumberFormatedTextField getGastosOperacionalesRemuneraciones() { + return gastosOperacionalesRemuneraciones; + } + + public NumberFormatedTextField getGastosOperacionalesFiniquitos() { + return gastosOperacionalesFiniquitos; + } + + public NumberFormatedTextField getGastosOperacionalesAguinaldo() { + return gastosOperacionalesAguinaldo; + } + + public NumberFormatedTextField getGastosOperacionalesPartime() { + return gastosOperacionalesPartime; + } + + public NumberFormatedTextField getGastosOperacionalesBonos() { + return gastosOperacionalesBonos; + } + + public NumberFormatedTextField getGastosOperacionalesHonorariosContador() { + return gastosOperacionalesHonorariosContador; + } + + public NumberFormatedTextField getGastosOperacionalesArriendo() { + return gastosOperacionalesArriendo; + } + + public NumberFormatedTextField getGastosOperacionalesTotal() { + return gastosOperacionalesTotal; + } + + public NumberFormatedTextField getServiciosAgua() { + return serviciosAgua; + } + + public NumberFormatedTextField getServiciosLuz() { + return serviciosLuz; + } + + public NumberFormatedTextField getServiciosGas() { + return serviciosGas; + } + + public NumberFormatedTextField getServiciosTelefono() { + return serviciosTelefono; + } + + public NumberFormatedTextField getServiciosTotal() { + return serviciosTotal; + } + + public NumberFormatedTextField getGastosGeneralesCuentaCorrienteFactura() { + return gastosGeneralesCuentaCorrienteFactura; + } + + public NumberFormatedTextField getGastosGeneralesCuentaCorrienteBoleta() { + return gastosGeneralesCuentaCorrienteBoleta; + } + + public NumberFormatedTextField getGastosGeneralesCuentaCorrienteSinRespaldo() { + return gastosGeneralesCuentaCorrienteSinRespaldo; + } + + public NumberFormatedTextField getGastosGeneralesEfectivoFacturaField() { + return gastosGeneralesEfectivoFacturaField; + } + + public NumberFormatedTextField getGastosGeneralesEfectivoBoletaField() { + return gastosGeneralesEfectivoBoletaField; + } + + public NumberFormatedTextField getGastosGeneralesEfectivoSinRespaldo() { + return gastosGeneralesEfectivoSinRespaldo; + } + + public NumberFormatedTextField getGastosGeneralesTotal() { + return gastosGeneralesTotal; + } + + public NumberFormatedTextField getResumenUtilidad() { + return resumenUtilidad; + } + + public NumberFormatedTextField getResumenPPMMes() { + return resumenPPMMes; + } + + public NumberFormatedTextField getResumenIVAMes() { + return resumenIVAMes; + } + + public NumberFormatedTextField getResumenIVAFavor() { + return resumenIVAFavor; + } + + public NumberFormatedTextField getResumenResultado() { + return resumenResultado; + } + + public NumberFormatedTextField getServiciosOtro() { + return serviciosOtro; + } + + public NumberFormatedTextField getResumenAPagar() { + return resumenAPagar; + } + + public NumberFormatedTextField getResumenIVAPPM() { + return resumenIVAPPM; + } + + public DoubleFormatedTextField getResumenPPM() { + return resumenPPM; + } + + public JButton getGuardarButton() { + return guardarButton; + } + + public JButton getExportarButton() { + return exportarButton; + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + createUIComponents(); + contentPanel = new JPanel(); + contentPanel.setLayout(new GridLayoutManager(3, 3, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(6, 2, new Insets(10, 10, 10, 10), -1, -1)); + contentPanel.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Venta")); + final JLabel label1 = new JLabel(); + label1.setText("Bruto:"); + panel1.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label2 = new JLabel(); + label2.setText("Neto:"); + panel1.add(label2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label3 = new JLabel(); + label3.setText("IVA:"); + panel1.add(label3, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label4 = new JLabel(); + label4.setText("Exentas:"); + panel1.add(label4, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label5 = new JLabel(); + label5.setText("Neto + Exentas:"); + panel1.add(label5, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + ventaBrutaField = new NumberFormatedTextField(); + ventaBrutaField.setEditable(false); + panel1.add(ventaBrutaField, 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)); + ventaNetaField = new NumberFormatedTextField(); + ventaNetaField.setEditable(false); + panel1.add(ventaNetaField, 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)); + ventaIVAField = new NumberFormatedTextField(); + ventaIVAField.setEditable(false); + panel1.add(ventaIVAField, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + ventaExentasField = new NumberFormatedTextField(); + ventaExentasField.setEditable(false); + panel1.add(ventaExentasField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + ventasNetaExentasField = new NumberFormatedTextField(); + ventasNetaExentasField.setEditable(false); + panel1.add(ventasNetaExentasField, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(10, 2, new Insets(10, 10, 10, 10), -1, -1)); + contentPanel.add(panel2, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Gastos Operacionales")); + final JLabel label6 = new JLabel(); + label6.setText("Costo de Venta:"); + panel2.add(label6, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label7 = new JLabel(); + label7.setText("Remuneraciones:"); + panel2.add(label7, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label8 = new JLabel(); + label8.setText("Finiquitos:"); + panel2.add(label8, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label9 = new JLabel(); + label9.setText("Aguinaldo:"); + panel2.add(label9, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label10 = new JLabel(); + label10.setText("Partime:"); + panel2.add(label10, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label11 = new JLabel(); + label11.setText("Bonos Personal:"); + panel2.add(label11, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label12 = new JLabel(); + label12.setText("Honorarios Contador:"); + panel2.add(label12, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label13 = new JLabel(); + label13.setText("Arriendo:"); + panel2.add(label13, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + gastosOperacionalesCostoVenta = new NumberFormatedTextField(); + panel2.add(gastosOperacionalesCostoVenta, 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)); + gastosOperacionalesRemuneraciones = new NumberFormatedTextField(); + panel2.add(gastosOperacionalesRemuneraciones, 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)); + gastosOperacionalesFiniquitos = new NumberFormatedTextField(); + panel2.add(gastosOperacionalesFiniquitos, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosOperacionalesAguinaldo = new NumberFormatedTextField(); + panel2.add(gastosOperacionalesAguinaldo, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosOperacionalesPartime = new NumberFormatedTextField(); + gastosOperacionalesPartime.setEditable(false); + panel2.add(gastosOperacionalesPartime, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosOperacionalesBonos = new NumberFormatedTextField(); + panel2.add(gastosOperacionalesBonos, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosOperacionalesHonorariosContador = new NumberFormatedTextField(); + panel2.add(gastosOperacionalesHonorariosContador, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosOperacionalesArriendo = new NumberFormatedTextField(); + panel2.add(gastosOperacionalesArriendo, new GridConstraints(7, 1, 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 label14 = new JLabel(); + label14.setText("Total:"); + panel2.add(label14, new GridConstraints(9, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + gastosOperacionalesTotal = new NumberFormatedTextField(); + gastosOperacionalesTotal.setEditable(false); + panel2.add(gastosOperacionalesTotal, new GridConstraints(9, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer2 = new Spacer(); + panel2.add(spacer2, new GridConstraints(8, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(7, 2, new Insets(10, 10, 10, 10), -1, -1)); + contentPanel.add(panel3, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel3.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Servicios")); + final JLabel label15 = new JLabel(); + label15.setText("Agua:"); + panel3.add(label15, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label16 = new JLabel(); + label16.setText("Luz:"); + panel3.add(label16, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label17 = new JLabel(); + label17.setText("Gas:"); + panel3.add(label17, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label18 = new JLabel(); + label18.setText("Telefono:"); + panel3.add(label18, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label19 = new JLabel(); + label19.setText("Total:"); + panel3.add(label19, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + serviciosAgua = new NumberFormatedTextField(); + panel3.add(serviciosAgua, 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)); + serviciosLuz = new NumberFormatedTextField(); + panel3.add(serviciosLuz, 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)); + serviciosGas = new NumberFormatedTextField(); + panel3.add(serviciosGas, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + serviciosTelefono = new NumberFormatedTextField(); + panel3.add(serviciosTelefono, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + serviciosTotal = new NumberFormatedTextField(); + serviciosTotal.setEditable(false); + panel3.add(serviciosTotal, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer3 = new Spacer(); + panel3.add(spacer3, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + serviciosOtro = new NumberFormatedTextField(); + panel3.add(serviciosOtro, new GridConstraints(4, 1, 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 label20 = new JLabel(); + label20.setText("Otros:"); + panel3.add(label20, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel4 = new JPanel(); + panel4.setLayout(new GridLayoutManager(8, 2, new Insets(10, 10, 10, 10), -1, -1)); + contentPanel.add(panel4, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel4.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Gastos Generales")); + gastosGeneralesCuentaCorrienteFactura = new NumberFormatedTextField(); + panel4.add(gastosGeneralesCuentaCorrienteFactura, 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)); + gastosGeneralesCuentaCorrienteBoleta = new NumberFormatedTextField(); + panel4.add(gastosGeneralesCuentaCorrienteBoleta, 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)); + gastosGeneralesCuentaCorrienteSinRespaldo = new NumberFormatedTextField(); + panel4.add(gastosGeneralesCuentaCorrienteSinRespaldo, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosGeneralesEfectivoFacturaField = new NumberFormatedTextField(); + gastosGeneralesEfectivoFacturaField.setEditable(false); + panel4.add(gastosGeneralesEfectivoFacturaField, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosGeneralesEfectivoBoletaField = new NumberFormatedTextField(); + gastosGeneralesEfectivoBoletaField.setEditable(false); + panel4.add(gastosGeneralesEfectivoBoletaField, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosGeneralesEfectivoSinRespaldo = new NumberFormatedTextField(); + gastosGeneralesEfectivoSinRespaldo.setEditable(false); + panel4.add(gastosGeneralesEfectivoSinRespaldo, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + gastosGeneralesTotal = new NumberFormatedTextField(); + gastosGeneralesTotal.setEditable(false); + panel4.add(gastosGeneralesTotal, new GridConstraints(7, 1, 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 label21 = new JLabel(); + label21.setText("CTA CTE Con Factura:"); + panel4.add(label21, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label22 = new JLabel(); + label22.setText("CTA CTE Con Boleta:"); + panel4.add(label22, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label23 = new JLabel(); + label23.setText("CTA CTE Sin Respaldo:"); + panel4.add(label23, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label24 = new JLabel(); + label24.setText("Efectivo Con Factura:"); + panel4.add(label24, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label25 = new JLabel(); + label25.setText("Efectivo Con Boleta:"); + panel4.add(label25, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label26 = new JLabel(); + label26.setText("Efectivo Sin Respaldo"); + panel4.add(label26, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label27 = new JLabel(); + label27.setText("Total:"); + panel4.add(label27, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer4 = new Spacer(); + panel4.add(spacer4, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JPanel panel5 = new JPanel(); + panel5.setLayout(new GridLayoutManager(9, 2, new Insets(10, 10, 10, 10), -1, -1)); + contentPanel.add(panel5, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Resumen")); + resumenUtilidad = new NumberFormatedTextField(); + resumenUtilidad.setEditable(false); + panel5.add(resumenUtilidad, 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)); + resumenPPMMes = new NumberFormatedTextField(); + resumenPPMMes.setEditable(false); + panel5.add(resumenPPMMes, new GridConstraints(2, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + resumenIVAMes = new NumberFormatedTextField(); + resumenIVAMes.setEditable(false); + panel5.add(resumenIVAMes, new GridConstraints(3, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + resumenIVAFavor = new NumberFormatedTextField(); + resumenIVAFavor.setEditable(true); + panel5.add(resumenIVAFavor, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + resumenResultado = new NumberFormatedTextField(); + resumenResultado.setEditable(false); + panel5.add(resumenResultado, new GridConstraints(8, 1, 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 label28 = new JLabel(); + label28.setText("Utilidad:"); + panel5.add(label28, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label29 = new JLabel(); + label29.setText("PPM Mes:"); + panel5.add(label29, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label30 = new JLabel(); + label30.setText("+ IVA Mes:"); + panel5.add(label30, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label31 = new JLabel(); + label31.setText("- IVA A Favor:"); + panel5.add(label31, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label32 = new JLabel(); + label32.setText("Resultado:"); + panel5.add(label32, new GridConstraints(8, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final Spacer spacer5 = new Spacer(); + panel5.add(spacer5, new GridConstraints(7, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final JLabel label33 = new JLabel(); + label33.setText("PPM:"); + panel5.add(label33, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + resumenAPagar = new NumberFormatedTextField(); + resumenAPagar.setEditable(false); + panel5.add(resumenAPagar, new GridConstraints(6, 1, 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 label34 = new JLabel(); + label34.setText("A Pagar PPM + IVA"); + panel5.add(label34, new GridConstraints(6, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + resumenIVAPPM = new NumberFormatedTextField(); + resumenIVAPPM.setEditable(false); + panel5.add(resumenIVAPPM, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + resumenPPM = new DoubleFormatedTextField(); + panel5.add(resumenPPM, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final JPanel panel6 = new JPanel(); + panel6.setLayout(new GridLayoutManager(1, 3, new Insets(10, 10, 10, 10), -1, -1)); + contentPanel.add(panel6, new GridConstraints(0, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel7 = new JPanel(); + panel7.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel6.add(panel7, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + panel7.add(yearSpinner, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); + panel7.add(monthCombo, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false)); + final JLabel label35 = new JLabel(); + label35.setText("Mes"); + panel7.add(label35, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JLabel label36 = new JLabel(); + label36.setText("Año"); + panel7.add(label36, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel8 = new JPanel(); + panel8.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel6.add(panel8, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + guardarButton = new JButton(); + guardarButton.setText("Guardar"); + panel8.add(guardarButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + exportarButton = new JButton(); + exportarButton.setText("Exportar"); + panel8.add(exportarButton, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); + final Spacer spacer6 = new Spacer(); + panel8.add(spacer6, new GridConstraints(0, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + final Spacer spacer7 = new Spacer(); + panel6.add(spacer7, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPanel; + } + + private void createUIComponents() { + createYearSpinner(); + createMonthCombo(); + } + + private void createYearSpinner() { + SpinnerModel model = new YearSpinnerModel(); + this.yearSpinner = new JSpinner(); + this.yearSpinner.setModel(model); + ((JSpinner.DefaultEditor) this.yearSpinner.getEditor()).getTextField().setEditable(true); + } + + private void createMonthCombo() { + months = new ArrayList<>(); + months.add("Enero"); + months.add("Febrero"); + months.add("Marzo"); + months.add("Abril"); + months.add("Mayo"); + months.add("Junio"); + months.add("Julio"); + months.add("Agosto"); + months.add("Septiembre"); + months.add("Octubre"); + months.add("Noviembre"); + months.add("Diciembre"); + + monthCombo = new JComboBox<>(); + for (String month : months) { + monthCombo.addItem(month); + } + + int currentMonth = LocalDate.now().getMonth().getValue() - 1; + monthCombo.setSelectedIndex(currentMonth); + } + +} diff --git a/src/danielcortes/xyz/views/InformesView.form b/src/danielcortes/xyz/views/InformesView.form index 5a969ad..f760280 100644 --- a/src/danielcortes/xyz/views/InformesView.form +++ b/src/danielcortes/xyz/views/InformesView.form @@ -8,7 +8,7 @@ - + @@ -34,9 +34,25 @@ - + + + + + + + + + + + + + + + + + diff --git a/src/danielcortes/xyz/views/InformesView.java b/src/danielcortes/xyz/views/InformesView.java index e4d119b..cb3d10e 100644 --- a/src/danielcortes/xyz/views/InformesView.java +++ b/src/danielcortes/xyz/views/InformesView.java @@ -35,6 +35,8 @@ public class InformesView { private JButton generarLibroVentasButton; private JPanel contentPanel; private JButton GenerarEgresosFacturasMateriaPrimaButton; + private JButton estadoResultadoButton; + private JButton salirButton; public JPanel getContentPanel() { return contentPanel; @@ -48,6 +50,13 @@ public class InformesView { return GenerarEgresosFacturasMateriaPrimaButton; } + public JButton getEstadoResultadoButton() { + return estadoResultadoButton; + } + + public JButton getSalirButton() { + return salirButton; + } { // GUI initializer generated by IntelliJ IDEA GUI Designer @@ -67,7 +76,7 @@ public class InformesView { contentPanel = new JPanel(); contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1)); final JPanel panel1 = new JPanel(); - panel1.setLayout(new GridLayoutManager(3, 1, new Insets(10, 10, 10, 10), -1, -1)); + panel1.setLayout(new GridLayoutManager(5, 1, new Insets(10, 10, 10, 10), -1, -1)); contentPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Informes Mensuales")); generarLibroVentasButton = new JButton(); @@ -77,7 +86,13 @@ public class InformesView { GenerarEgresosFacturasMateriaPrimaButton.setText("Informe de Egresos"); panel1.add(GenerarEgresosFacturasMateriaPrimaButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); - panel1.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + panel1.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + estadoResultadoButton = new JButton(); + estadoResultadoButton.setText("Estado Resultado"); + panel1.add(estadoResultadoButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + salirButton = new JButton(); + salirButton.setText("Salir"); + panel1.add(salirButton, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); } /** diff --git a/src/danielcortes/xyz/views/MainView.form b/src/danielcortes/xyz/views/MainView.form index ca1ea00..d1123e9 100644 --- a/src/danielcortes/xyz/views/MainView.form +++ b/src/danielcortes/xyz/views/MainView.form @@ -24,17 +24,9 @@ - - - - - - - - - + @@ -45,6 +37,14 @@ + + + + + + + + diff --git a/src/danielcortes/xyz/views/MainView.java b/src/danielcortes/xyz/views/MainView.java index 2f01361..92b816d 100644 --- a/src/danielcortes/xyz/views/MainView.java +++ b/src/danielcortes/xyz/views/MainView.java @@ -13,6 +13,7 @@ public class MainView { private JButton cajasButton; private JButton informesGeneralesButton; private JPanel buttonPanel; + private JButton salirButton; public JPanel getContentPanel() { return contentPanel; @@ -34,6 +35,9 @@ public class MainView { return informesGeneralesButton; } + public JButton getSalirButton() { + return salirButton; + } { // GUI initializer generated by IntelliJ IDEA GUI Designer @@ -59,14 +63,14 @@ public class MainView { cajasButton = new JButton(); cajasButton.setText("Cajas"); buttonPanel.add(cajasButton, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - informesGeneralesButton = new JButton(); - informesGeneralesButton.setText("Informes Generales"); - buttonPanel.add(informesGeneralesButton, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); - buttonPanel.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); + buttonPanel.add(spacer1, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); informesMensualesButton = new JButton(); informesMensualesButton.setText("Informes Mensuales"); buttonPanel.add(informesMensualesButton, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + salirButton = new JButton(); + salirButton.setText("Salir"); + buttonPanel.add(salirButton, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); } /** diff --git a/src/danielcortes/xyz/views/components/DoubleFormatedTextField.java b/src/danielcortes/xyz/views/components/DoubleFormatedTextField.java new file mode 100644 index 0000000..73b9767 --- /dev/null +++ b/src/danielcortes/xyz/views/components/DoubleFormatedTextField.java @@ -0,0 +1,61 @@ +package danielcortes.xyz.views.components; + +import org.mariuszgromada.math.mxparser.Expression; + +import javax.swing.*; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.text.NumberFormat; + +public class DoubleFormatedTextField extends JTextField { + private double value; + private NumberFormat nf; + + public DoubleFormatedTextField() { + super(); + + this.nf = NumberFormat.getIntegerInstance(); + this.nf.setMaximumFractionDigits(2); + + this.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + DoubleFormatedTextField.this.select(0, getText().length()); + } + + @Override + public void focusLost(FocusEvent e) { + DoubleFormatedTextField.this.readValue(); + DoubleFormatedTextField.this.formatText(); + } + }); + } + + public double getValue() { + this.readValue(); + return this.value; + } + + public void setValue(double value) { + this.value = value; + this.formatText(); + } + + private void readValue() { + String currentText = this.getText(); + String stripedDots = currentText.replace(".", ""); + String replacedPeriods = stripedDots.replace(",", "."); + Expression expression = new Expression(replacedPeriods); + + if (expression.checkSyntax()) { + this.value = expression.calculate(); + } else { + this.value = 0; + } + + } + + private void formatText() { + this.setText(nf.format(this.value)); + } +} diff --git a/src/danielcortes/xyz/views/listeners/FocusLostListener.java b/src/danielcortes/xyz/views/listeners/FocusLostListener.java new file mode 100644 index 0000000..5df597d --- /dev/null +++ b/src/danielcortes/xyz/views/listeners/FocusLostListener.java @@ -0,0 +1,10 @@ +package danielcortes.xyz.views.listeners; + +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +public interface FocusLostListener extends FocusListener { + @Override + default void focusGained(FocusEvent e){ } +} +