Terminada la creacion de logs para la capa de base de datos
This commit is contained in:
BIN
dist/Programa Caja.jar
vendored
BIN
dist/Programa Caja.jar
vendored
Binary file not shown.
11
dist/config/logging.properties
vendored
11
dist/config/logging.properties
vendored
@@ -1,11 +1,10 @@
|
|||||||
#handlers= java.util.logging.ConsoleHandler
|
#handlers= java.util.logging.ConsoleHandler
|
||||||
handlers= java.util.logging.FileHandler
|
handlers= java.util.logging.FileHandler
|
||||||
|
java.util.logging.FileHandler.level=FINER
|
||||||
java.util.logging.FileHandler.level = ALL
|
java.util.logging.FileHandler.pattern=logs/logs-%u-%g.log
|
||||||
java.util.logging.FileHandler.pattern = logs/logs-%u.log
|
java.util.logging.FileHandler.formatter=java.util.logging.XMLFormatter
|
||||||
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
|
java.util.logging.FileHandler.append=true
|
||||||
|
|
||||||
#java.util.logging.ConsoleHandler.level = ALL
|
#java.util.logging.ConsoleHandler.level = ALL
|
||||||
#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
||||||
|
danielcortes.level=FINER
|
||||||
danielcortes.level= ALL
|
|
||||||
@@ -29,18 +29,21 @@ import danielcortes.xyz.data.Configuration;
|
|||||||
import danielcortes.xyz.views.ManagerView;
|
import danielcortes.xyz.views.ManagerView;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.util.Arrays;
|
import java.io.FileInputStream;
|
||||||
import java.util.Locale;
|
import java.io.IOException;
|
||||||
import java.util.logging.*;
|
import java.util.logging.LogManager;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
static {
|
||||||
|
setUpLogger();
|
||||||
|
setUpSystemProperties();
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void run() {
|
private static void run() {
|
||||||
setUpSystemProperties();
|
|
||||||
|
|
||||||
ManagerView view = new ManagerView();
|
ManagerView view = new ManagerView();
|
||||||
ManagerController managerController = new ManagerController(view);
|
ManagerController managerController = new ManagerController(view);
|
||||||
|
|
||||||
@@ -57,7 +60,6 @@ public class Main {
|
|||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void setUpSystemProperties() {
|
private static void setUpSystemProperties() {
|
||||||
System.setProperty("awt.useSystemAAFontSettings", "on");
|
System.setProperty("awt.useSystemAAFontSettings", "on");
|
||||||
System.setProperty("swing.aatext", "true");
|
System.setProperty("swing.aatext", "true");
|
||||||
@@ -68,7 +70,19 @@ public class Main {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Locale.setDefault(new Locale("es"));
|
//Locale.setDefault(new Locale("es"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setUpLogger() {
|
||||||
|
LogManager manager = LogManager.getLogManager();
|
||||||
|
try {
|
||||||
|
FileInputStream in = new FileInputStream("config/logging.properties");
|
||||||
|
manager.readConfiguration(in);
|
||||||
|
in.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class SQLiteConnectionHolder implements ConnectionHolder {
|
|||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
con = DriverManager.getConnection(databaseURI);
|
con = DriverManager.getConnection(databaseURI);
|
||||||
LOGGER.log(Level.FINER, "Creada conexion a base de datos SQLITE");
|
LOGGER.log(Level.FINEST, "Creada conexion a base de datos SQLITE");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
LOGGER.log(Level.SEVERE, e.toString(), e);
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
System.exit(133);
|
System.exit(133);
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.caja;
|
package danielcortes.xyz.models.caja;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.ConnectionHolder;
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -36,7 +35,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class CajaDAO {
|
public abstract class CajaDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Configuration.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(CajaDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.caja;
|
package danielcortes.xyz.models.caja;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
import danielcortes.xyz.models.documentos.Documentos;
|
import danielcortes.xyz.models.documentos.Documentos;
|
||||||
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
import danielcortes.xyz.models.documentos.DocumentosDAO;
|
||||||
@@ -44,7 +43,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteCajaDAO extends CajaDAO {
|
public class SQLiteCajaDAO extends CajaDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger( Configuration.class.getName() );
|
private static final Logger LOGGER = Logger.getLogger(SQLiteCajaDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteCajaDAO() {
|
public SQLiteCajaDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
@@ -127,8 +126,7 @@ public class SQLiteCajaDAO extends CajaDAO {
|
|||||||
ps.setString(1, caja.getFecha().toString());
|
ps.setString(1, caja.getFecha().toString());
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1} | updates: {2}", new Object[]{query, caja.getFecha(), updates});
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} values: {1}", new Object[]{query, caja.getFecha().toString()});
|
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
@@ -161,7 +159,7 @@ public class SQLiteCajaDAO extends CajaDAO {
|
|||||||
ps.setInt(2, caja.getId());
|
ps.setInt(2, caja.getId());
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2}]", new Object[]{query, caja.getFecha().toString(), caja.getId()});
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2} | updates: {3}]", new Object[]{query, caja.getFecha(), caja.getId(), updates});
|
||||||
|
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
@@ -178,7 +176,7 @@ public class SQLiteCajaDAO extends CajaDAO {
|
|||||||
LocalDate endDate = date.withDayOfMonth(date.lengthOfMonth()).plusDays(1);
|
LocalDate endDate = date.withDayOfMonth(date.lengthOfMonth()).plusDays(1);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "Se intentara crear las cajas para un mes para las fechas entre {0} y {1}", new Object[]{date, endDate});
|
LOGGER.log(Level.FINE, "Se intentara crear las cajas no existentes para las fechas entre {0} y {1}", new Object[]{date, endDate});
|
||||||
|
|
||||||
while (date.isBefore(endDate)) {
|
while (date.isBefore(endDate)) {
|
||||||
if (this.findByFecha(date) != null) {
|
if (this.findByFecha(date) != null) {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.calculo_fondo;
|
package danielcortes.xyz.models.calculo_fondo;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.ConnectionHolder;
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
|
import danielcortes.xyz.models.caja.SQLiteCajaDAO;
|
||||||
@@ -37,7 +36,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class CalculoFondoDAO {
|
public abstract class CalculoFondoDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Configuration.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(CalculoFondoDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.calculo_fondo;
|
package danielcortes.xyz.models.calculo_fondo;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
|
public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Configuration.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(SQLiteCalculoFondoDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteCalculoFondoDAO() {
|
public SQLiteCalculoFondoDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
@@ -73,7 +72,7 @@ public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
|
|||||||
ps.setInt(1, caja.getId());
|
ps.setInt(1, caja.getId());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}]", new Object[]{query, caja.getId()});
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, caja.getId()});
|
||||||
|
|
||||||
calculoFondoList = this.cajasFromResultSet(rs);
|
calculoFondoList = this.cajasFromResultSet(rs);
|
||||||
|
|
||||||
@@ -94,7 +93,7 @@ public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
|
|||||||
ps.setInt(1, id);
|
ps.setInt(1, id);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}]", new Object[]{query, id});
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, id});
|
||||||
|
|
||||||
calculoFondo = this.cajasFromResultSet(rs).get(0);
|
calculoFondo = this.cajasFromResultSet(rs).get(0);
|
||||||
|
|
||||||
@@ -117,7 +116,7 @@ public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
|
|||||||
ps.setInt(3, calculoFondo.getCaja().getId());
|
ps.setInt(3, calculoFondo.getCaja().getId());
|
||||||
|
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
LOGGER.log(Level.FINE, "QUERY {0} | values: [{1},{2},{3}] | updates: {4}", new Object[]{query, calculoFondo.getValor(), calculoFondo.getDescripcion(), calculoFondo.getCaja().getId(), updates});
|
LOGGER.log(Level.FINE, "QUERY {0} | values: [{1}, {2}, {3}] | updates: {4}", new Object[]{query, calculoFondo.getValor(), calculoFondo.getDescripcion(), calculoFondo.getCaja().getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
@@ -149,7 +148,7 @@ public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
|
|||||||
ps.setInt(4, calculoFondo.getId());
|
ps.setInt(4, calculoFondo.getId());
|
||||||
|
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
LOGGER.log(Level.FINE, "QUERY {0} | values: [{1},{2},{3},{4}] | updates: {5}", new Object[]{query, calculoFondo.getValor(), calculoFondo.getDescripcion(), calculoFondo.getCaja().getId(), updates});
|
LOGGER.log(Level.FINE, "QUERY {0} | values: [{1}, {2}, {3}, {4}] | updates: {5}", new Object[]{query, calculoFondo.getValor(), calculoFondo.getDescripcion(), calculoFondo.getCaja().getId(), updates});
|
||||||
|
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.documentos;
|
package danielcortes.xyz.models.documentos;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.ConnectionHolder;
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.caja.CajaDAO;
|
import danielcortes.xyz.models.caja.CajaDAO;
|
||||||
@@ -38,7 +37,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class DocumentosDAO {
|
public abstract class DocumentosDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Configuration.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(DocumentosDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.documentos;
|
package danielcortes.xyz.models.documentos;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteDocumentosDAO extends DocumentosDAO {
|
public class SQLiteDocumentosDAO extends DocumentosDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Configuration.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(SQLiteDocumentosDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteDocumentosDAO() {
|
public SQLiteDocumentosDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
@@ -124,7 +123,7 @@ public class SQLiteDocumentosDAO extends DocumentosDAO {
|
|||||||
ps.setInt(4, documentos.getCaja().getId());
|
ps.setInt(4, documentos.getCaja().getId());
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}, {2}, {3}, {4}]", new Object[]{query, documentos.getCheques(), documentos.getTarjetas(), documentos.getRetiros(), documentos.getCaja().getId()});
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}, {2}, {3}, {4}] | updates: {5}", new Object[]{query, documentos.getCheques(), documentos.getTarjetas(), documentos.getRetiros(), documentos.getCaja().getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
@@ -155,7 +154,7 @@ public class SQLiteDocumentosDAO extends DocumentosDAO {
|
|||||||
ps.setInt(1, documentos.getCaja().getId());
|
ps.setInt(1, documentos.getCaja().getId());
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, documentos.getCaja().getId()});
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1} | updates: {2}", new Object[]{query, documentos.getCaja().getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
@@ -189,7 +188,7 @@ public class SQLiteDocumentosDAO extends DocumentosDAO {
|
|||||||
ps.setInt(5, documentos.getId());
|
ps.setInt(5, documentos.getId());
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}, {2}, {3}, {4}]", new Object[]{query, documentos.getCheques(), documentos.getTarjetas(), documentos.getRetiros(), documentos.getCaja().getId(), documentos.getId()});
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}, {2}, {3}, {4}] | updates: {5}", new Object[]{query, documentos.getCheques(), documentos.getTarjetas(), documentos.getRetiros(), documentos.getCaja().getId(), documentos.getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@@ -208,7 +207,7 @@ public class SQLiteDocumentosDAO extends DocumentosDAO {
|
|||||||
ps.setInt(1, documentos.getId());
|
ps.setInt(1, documentos.getId());
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, documentos.getCaja().getId()});
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1} | updates: {2}", new Object[]{query, documentos.getCaja().getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.efectivo;
|
package danielcortes.xyz.models.efectivo;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.ConnectionHolder;
|
import danielcortes.xyz.data.ConnectionHolder;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
import danielcortes.xyz.models.caja.CajaDAO;
|
import danielcortes.xyz.models.caja.CajaDAO;
|
||||||
@@ -38,7 +37,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class EfectivoDAO {
|
public abstract class EfectivoDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Configuration.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(EfectivoDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
package danielcortes.xyz.models.efectivo;
|
package danielcortes.xyz.models.efectivo;
|
||||||
|
|
||||||
import danielcortes.xyz.data.Configuration;
|
|
||||||
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
import danielcortes.xyz.data.SQLiteConnectionHolder;
|
||||||
import danielcortes.xyz.models.caja.Caja;
|
import danielcortes.xyz.models.caja.Caja;
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteEfectivoDAO extends EfectivoDAO {
|
public class SQLiteEfectivoDAO extends EfectivoDAO {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Configuration.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(SQLiteEfectivoDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteEfectivoDAO() {
|
public SQLiteEfectivoDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
|
|||||||
@@ -36,8 +36,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class EgresoDAO {
|
public abstract class EgresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(EgresoDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
public abstract List<Egreso> findAll();
|
public abstract List<Egreso> findAll();
|
||||||
@@ -78,6 +82,8 @@ public abstract class EgresoDAO {
|
|||||||
egreso.setTipoEgreso(tipoEgreso);
|
egreso.setTipoEgreso(tipoEgreso);
|
||||||
egreso.setCaja(caja);
|
egreso.setCaja(caja);
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINER, "Se a creado: {0}", egreso);
|
||||||
|
|
||||||
egresoList.add(egreso);
|
egresoList.add(egreso);
|
||||||
}
|
}
|
||||||
return egresoList;
|
return egresoList;
|
||||||
|
|||||||
@@ -34,8 +34,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteEgresoDAO extends EgresoDAO {
|
public class SQLiteEgresoDAO extends EgresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(SQLiteEgresoDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteEgresoDAO() {
|
public SQLiteEgresoDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
@@ -44,16 +48,18 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public List<Egreso> findAll() {
|
public List<Egreso> findAll() {
|
||||||
List<Egreso> egresoList = new ArrayList<>();
|
List<Egreso> egresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from egresos");
|
String query = "select * from egresos";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0}", query);
|
||||||
|
|
||||||
egresoList = this.egresosFromResultSet(rs);
|
egresoList = this.egresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return egresoList;
|
return egresoList;
|
||||||
}
|
}
|
||||||
@@ -62,17 +68,19 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public List<Egreso> findById(int id) {
|
public List<Egreso> findById(int id) {
|
||||||
List<Egreso> egresoList = new ArrayList<>();
|
List<Egreso> egresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from egresos where id = ?");
|
String query = "select * from egresos where id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, id);
|
ps.setInt(1, id);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, id});
|
||||||
|
|
||||||
egresoList = this.egresosFromResultSet(rs);
|
egresoList = this.egresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return egresoList;
|
return egresoList;
|
||||||
}
|
}
|
||||||
@@ -81,17 +89,19 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public List<Egreso> findByCaja(Caja caja) {
|
public List<Egreso> findByCaja(Caja caja) {
|
||||||
List<Egreso> egresoList = new ArrayList<>();
|
List<Egreso> egresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from egresos where caja_id = ?");
|
String query = "select * from egresos where caja_id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, caja.getId());
|
ps.setInt(1, caja.getId());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, caja.getId()});
|
||||||
|
|
||||||
egresoList = this.egresosFromResultSet(rs);
|
egresoList = this.egresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return egresoList;
|
return egresoList;
|
||||||
}
|
}
|
||||||
@@ -100,17 +110,19 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public List<Egreso> findByNro(String nro) {
|
public List<Egreso> findByNro(String nro) {
|
||||||
List<Egreso> egresoList = new ArrayList<>();
|
List<Egreso> egresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from egresos where nro = ?");
|
String query = "select * from egresos where nro = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setString(1, nro);
|
ps.setString(1, nro);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values {1}", new Object[]{query, nro});
|
||||||
|
|
||||||
egresoList = this.egresosFromResultSet(rs);
|
egresoList = this.egresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return egresoList;
|
return egresoList;
|
||||||
}
|
}
|
||||||
@@ -119,17 +131,19 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public List<Egreso> findByTipoEgreso(TipoEgreso tipoEgreso) {
|
public List<Egreso> findByTipoEgreso(TipoEgreso tipoEgreso) {
|
||||||
List<Egreso> egresoList = new ArrayList<>();
|
List<Egreso> egresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from egresos where tipo_egreso_id = ?");
|
String query = "select * from egresos where tipo_egreso_id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, tipoEgreso.getId());
|
ps.setInt(1, tipoEgreso.getId());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, tipoEgreso.getId()});
|
||||||
|
|
||||||
egresoList = this.egresosFromResultSet(rs);
|
egresoList = this.egresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return egresoList;
|
return egresoList;
|
||||||
}
|
}
|
||||||
@@ -138,14 +152,17 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public boolean insertEgreso(Egreso egreso) {
|
public boolean insertEgreso(Egreso egreso) {
|
||||||
int updates;
|
int updates;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("insert into egresos (nro, descripcion, valor, tipo_egreso_id, caja_id) values (?,?,?,?,?)");
|
String query = "insert into egresos (nro, descripcion, valor, tipo_egreso_id, caja_id) values (?,?,?,?,?)";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setString(1, egreso.getNro());
|
ps.setString(1, egreso.getNro());
|
||||||
ps.setString(2, egreso.getDescripcion());
|
ps.setString(2, egreso.getDescripcion());
|
||||||
ps.setInt(3, egreso.getValor());
|
ps.setInt(3, egreso.getValor());
|
||||||
ps.setInt(4, egreso.getTipoEgreso().getId());
|
ps.setInt(4, egreso.getTipoEgreso().getId());
|
||||||
ps.setInt(5, egreso.getCaja().getId());
|
ps.setInt(5, egreso.getCaja().getId());
|
||||||
|
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}, {2}, {3}, {4}, {5}] | updates: {6}", new Object[]{query, egreso.getNro(), egreso.getDescripcion(), egreso.getValor(), egreso.getTipoEgreso().getId(), egreso.getCaja().getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
ps = conn.prepareStatement("select last_insert_rowid()");
|
ps = conn.prepareStatement("select last_insert_rowid()");
|
||||||
@@ -154,9 +171,8 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
egreso.setId(rs.getInt(1));
|
egreso.setId(rs.getInt(1));
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return updates > 0;
|
return updates > 0;
|
||||||
@@ -166,20 +182,22 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public boolean updateEgreso(Egreso egreso) {
|
public boolean updateEgreso(Egreso egreso) {
|
||||||
int updates;
|
int updates;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("update egresos set nro = ?, descripcion = ?, valor = ?, tipo_egreso_id = ?, caja_id = ? where id = ? ");
|
String query = "update egresos set nro = ?, descripcion = ?, valor = ?, tipo_egreso_id = ?, caja_id = ? where id = ? ";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setString(1, egreso.getNro());
|
ps.setString(1, egreso.getNro());
|
||||||
ps.setString(2, egreso.getDescripcion());
|
ps.setString(2, egreso.getDescripcion());
|
||||||
ps.setInt(3, egreso.getValor());
|
ps.setInt(3, egreso.getValor());
|
||||||
ps.setInt(4, egreso.getTipoEgreso().getId());
|
ps.setInt(4, egreso.getTipoEgreso().getId());
|
||||||
ps.setInt(5, egreso.getCaja().getId());
|
ps.setInt(5, egreso.getCaja().getId());
|
||||||
ps.setInt(6, egreso.getId());
|
ps.setInt(6, egreso.getId());
|
||||||
|
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1}, {2}, {3}, {4}, {5}, {6}] | updates: {7}", new Object[]{query, egreso.getNro(), egreso.getDescripcion(), egreso.getValor(), egreso.getTipoEgreso().getId(), egreso.getCaja().getId(), egreso.getId(), updates});
|
||||||
|
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return updates > 0;
|
return updates > 0;
|
||||||
@@ -189,15 +207,16 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public boolean deleteEgreso(Egreso egreso) {
|
public boolean deleteEgreso(Egreso egreso) {
|
||||||
int updates;
|
int updates;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("delete from egresos where id = ? ");
|
String query = "delete from egresos where id = ? ";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, egreso.getId());
|
ps.setInt(1, egreso.getId());
|
||||||
|
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1} | updates: {2}", new Object[]{query, egreso.getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return updates > 0;
|
return updates > 0;
|
||||||
@@ -207,18 +226,20 @@ public class SQLiteEgresoDAO extends EgresoDAO {
|
|||||||
public int getTotalEgreso(Caja caja) {
|
public int getTotalEgreso(Caja caja) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select sum(valor) from egresos where caja_id = ?");
|
String query = "select sum(valor) from egresos where caja_id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, caja.getId());
|
ps.setInt(1, caja.getId());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, caja.getId()});
|
||||||
|
|
||||||
rs.next();
|
rs.next();
|
||||||
total = rs.getInt(1);
|
total = rs.getInt(1);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,12 @@ import java.sql.SQLException;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteInformeEgresosContentDAO extends InformeEgresosContentDAO {
|
public class SQLiteInformeEgresosContentDAO extends InformeEgresosContentDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(InformeEgresosContentDAO.class.getName());
|
||||||
|
|
||||||
private List<InformeEgresosContent> list;
|
private List<InformeEgresosContent> list;
|
||||||
|
|
||||||
public SQLiteInformeEgresosContentDAO() {
|
public SQLiteInformeEgresosContentDAO() {
|
||||||
@@ -46,22 +50,25 @@ public class SQLiteInformeEgresosContentDAO extends InformeEgresosContentDAO {
|
|||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
|
|
||||||
String query = "select caja.fecha as \"fecha\",\n" +
|
String query = "select caja.fecha as \"fecha\"," +
|
||||||
"egresos.nro as \"nro\",\n" +
|
"egresos.nro as \"nro\"," +
|
||||||
"egresos.descripcion as \"descripcion\",\n" +
|
"egresos.descripcion as \"descripcion\"," +
|
||||||
"egresos.valor as \"valor\"\n" +
|
"egresos.valor as \"valor\"" +
|
||||||
"from egresos inner join caja on egresos.caja_id = caja.id\n" +
|
"from egresos inner join caja on egresos.caja_id = caja.id " +
|
||||||
"where caja.fecha between date(?) and date(?) and egresos.tipo_egreso_id = ? \n" +
|
"where caja.fecha between date(?) and date(?) and egresos.tipo_egreso_id = ? " +
|
||||||
"order by caja.fecha\n";
|
"order by caja.fecha;";
|
||||||
|
|
||||||
PreparedStatement ps = conn.prepareStatement(query);
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setString(1, date.withDayOfMonth(1).toString());
|
ps.setString(1, date.withDayOfMonth(1).toString());
|
||||||
ps.setString(2, date.withDayOfMonth(date.lengthOfMonth()).toString());
|
ps.setString(2, date.withDayOfMonth(date.lengthOfMonth()).toString());
|
||||||
ps.setInt(3, tipoEgresoId);
|
ps.setInt(3, tipoEgresoId);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2},{3}]", new Object[]{date.withDayOfMonth(1), date.withDayOfMonth(date.lengthOfMonth()), tipoEgresoId});
|
||||||
|
|
||||||
this.fillInforme(rs);
|
this.fillInforme(rs);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -73,6 +80,7 @@ public class SQLiteInformeEgresosContentDAO extends InformeEgresosContentDAO {
|
|||||||
content.setDescripcion(rs.getString("descripcion"));
|
content.setDescripcion(rs.getString("descripcion"));
|
||||||
content.setNro(rs.getString("nro"));
|
content.setNro(rs.getString("nro"));
|
||||||
content.setValor(rs.getInt("valor"));
|
content.setValor(rs.getInt("valor"));
|
||||||
|
LOGGER.log(Level.FINER, "Se a creado: {0}", content);
|
||||||
list.add(content);
|
list.add(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,12 @@ import java.time.LocalDate;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteInformeLibroDeVentasContentDAO extends InformeLibroDeVentasContentDAO {
|
public class SQLiteInformeLibroDeVentasContentDAO extends InformeLibroDeVentasContentDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(SQLiteInformeLibroDeVentasContentDAO.class.getName());
|
||||||
|
|
||||||
private HashMap<Integer, InformeLibroDeVentasContent> map;
|
private HashMap<Integer, InformeLibroDeVentasContent> map;
|
||||||
|
|
||||||
public SQLiteInformeLibroDeVentasContentDAO() {
|
public SQLiteInformeLibroDeVentasContentDAO() {
|
||||||
@@ -73,47 +77,52 @@ public class SQLiteInformeLibroDeVentasContentDAO extends InformeLibroDeVentasCo
|
|||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
String queryTotales =
|
String queryTotales =
|
||||||
"select " +
|
"select " +
|
||||||
"caja.id as \"caja\",\n" +
|
"caja.id as \"caja\"," +
|
||||||
"strftime(\"%w\", caja.fecha) as \"dia\",\n" +
|
"strftime(\"%w\", caja.fecha) as \"dia\"," +
|
||||||
"caja.fecha as \"fecha\",\n" +
|
"caja.fecha as \"fecha\"," +
|
||||||
"sum(case when ingresos.tipo_ingreso_id = 2 then ingresos.valor else 0 end) as \"manuales\",\n" +
|
"sum(case when ingresos.tipo_ingreso_id = 2 then ingresos.valor else 0 end) as \"manuales\"," +
|
||||||
"sum(case when ingresos.tipo_ingreso_id = 1 then ingresos.valor else 0 end) as \"fiscales\",\n" +
|
"sum(case when ingresos.tipo_ingreso_id = 1 then ingresos.valor else 0 end) as \"fiscales\"," +
|
||||||
"sum(case when ingresos.tipo_ingreso_id = 5 then ingresos.valor else 0 end) as \"exentas\",\n" +
|
"sum(case when ingresos.tipo_ingreso_id = 5 then ingresos.valor else 0 end) as \"exentas\"," +
|
||||||
"sum(case when ingresos.tipo_ingreso_id in (2, 1, 5) then ingresos.valor else 0 end) as \"sub_total\",\n" +
|
"sum(case when ingresos.tipo_ingreso_id in (2, 1, 5) then ingresos.valor else 0 end) as \"sub_total\"," +
|
||||||
"sum(case when ingresos.tipo_ingreso_id = 3 then ingresos.valor else 0 end) as \"facturas\",\n" +
|
"sum(case when ingresos.tipo_ingreso_id = 3 then ingresos.valor else 0 end) as \"facturas\"," +
|
||||||
"sum(case when ingresos.tipo_ingreso_id = 4 then ingresos.valor else 0 end) as \"guias\",\n" +
|
"sum(case when ingresos.tipo_ingreso_id = 4 then ingresos.valor else 0 end) as \"guias\"," +
|
||||||
"sum(case when ingresos.valor not null then ingresos.valor else 0 end) as \"total\"\n" +
|
"sum(case when ingresos.valor not null then ingresos.valor else 0 end) as \"total\" " +
|
||||||
"from caja left join ingresos on (caja.id = ingresos.caja_id)\n" +
|
"from caja left join ingresos on (caja.id = ingresos.caja_id) " +
|
||||||
"where caja.fecha between date(?) and date(?)\n" +
|
"where caja.fecha between date(?) and date(?) " +
|
||||||
"group by caja.fecha\n";
|
"group by caja.fecha;";
|
||||||
String queryNumeros =
|
|
||||||
"select\n" +
|
|
||||||
"caja.id as \"caja\",\n" +
|
|
||||||
"caja.fecha as \"fecha\",\n" +
|
|
||||||
"ingresos.nro_inicial as \"inicial\",\n" +
|
|
||||||
"ingresos.nro_final as \"final\",\n" +
|
|
||||||
"ingresos.nro_z_inicial as \"z_inicial\",\n" +
|
|
||||||
"ingresos.nro_z_final as \"z_final\",\n" +
|
|
||||||
"ingresos.tipo_ingreso_id as \"tipo_ingreso\"\n" +
|
|
||||||
"from caja join ingresos on (caja.id = ingresos.caja_id)\n" +
|
|
||||||
"where caja.fecha between date(?) and date(?)\n";
|
|
||||||
|
|
||||||
PreparedStatement ps = conn.prepareStatement(queryTotales);
|
PreparedStatement ps = conn.prepareStatement(queryTotales);
|
||||||
ps.setString(1, date.withDayOfMonth(1).toString());
|
ps.setString(1, date.withDayOfMonth(1).toString());
|
||||||
ps.setString(2, date.withDayOfMonth(date.lengthOfMonth()).toString());
|
ps.setString(2, date.withDayOfMonth(date.lengthOfMonth()).toString());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2}]", new Object[]{queryTotales, date.withDayOfMonth(1), date.withDayOfMonth(date.lengthOfMonth())});
|
||||||
|
|
||||||
this.fillTotalesFromResultSet(rs);
|
this.fillTotalesFromResultSet(rs);
|
||||||
|
|
||||||
|
String queryNumeros =
|
||||||
|
"select\n" +
|
||||||
|
"caja.id as \"caja\"," +
|
||||||
|
"caja.fecha as \"fecha\"," +
|
||||||
|
"ingresos.nro_inicial as \"inicial\"," +
|
||||||
|
"ingresos.nro_final as \"final\"," +
|
||||||
|
"ingresos.nro_z_inicial as \"z_inicial\"," +
|
||||||
|
"ingresos.nro_z_final as \"z_final\"," +
|
||||||
|
"ingresos.tipo_ingreso_id as \"tipo_ingreso\" " +
|
||||||
|
"from caja join ingresos on (caja.id = ingresos.caja_id) " +
|
||||||
|
"where caja.fecha between date(?) and date(?);";
|
||||||
ps = conn.prepareStatement(queryNumeros);
|
ps = conn.prepareStatement(queryNumeros);
|
||||||
ps.setString(1, date.withDayOfMonth(1).toString());
|
ps.setString(1, date.withDayOfMonth(1).toString());
|
||||||
ps.setString(2, date.withDayOfMonth(date.lengthOfMonth()).toString());
|
ps.setString(2, date.withDayOfMonth(date.lengthOfMonth()).toString());
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2}]", new Object[]{queryNumeros, date.withDayOfMonth(1), date.withDayOfMonth(date.lengthOfMonth())});
|
||||||
|
|
||||||
this.fillBoletasFromResultSet(rs);
|
this.fillBoletasFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return map.values();
|
return map.values();
|
||||||
@@ -131,6 +140,7 @@ public class SQLiteInformeLibroDeVentasContentDAO extends InformeLibroDeVentasCo
|
|||||||
informe.setFacturas(rs.getInt("facturas"));
|
informe.setFacturas(rs.getInt("facturas"));
|
||||||
informe.setGuias(rs.getInt("guias"));
|
informe.setGuias(rs.getInt("guias"));
|
||||||
informe.setTotal(rs.getInt("total"));
|
informe.setTotal(rs.getInt("total"));
|
||||||
|
LOGGER.log(Level.FINER, "Se a creado una linea del informe con los totales {0}", informe);
|
||||||
map.put(rs.getInt("caja"), informe);
|
map.put(rs.getInt("caja"), informe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,6 +270,7 @@ public class SQLiteInformeLibroDeVentasContentDAO extends InformeLibroDeVentasCo
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
LOGGER.log(Level.FINER, "Se termino de llenar la linea del informe resultando en: {0}", informe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class IngresoDAO {
|
public abstract class IngresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(IngresoDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
public abstract List<Ingreso> findAll();
|
public abstract List<Ingreso> findAll();
|
||||||
@@ -79,6 +83,8 @@ public abstract class IngresoDAO {
|
|||||||
ingreso.setTipoIngreso(tipoIngreso);
|
ingreso.setTipoIngreso(tipoIngreso);
|
||||||
ingreso.setCaja(caja);
|
ingreso.setCaja(caja);
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINER, "Se a creado: {0}", ingreso);
|
||||||
|
|
||||||
ingresosList.add(ingreso);
|
ingresosList.add(ingreso);
|
||||||
}
|
}
|
||||||
return ingresosList;
|
return ingresosList;
|
||||||
|
|||||||
@@ -34,8 +34,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteIngresoDAO extends IngresoDAO {
|
public class SQLiteIngresoDAO extends IngresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(SQLiteIngresoDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteIngresoDAO() {
|
public SQLiteIngresoDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
@@ -44,16 +48,18 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public List<Ingreso> findAll() {
|
public List<Ingreso> findAll() {
|
||||||
List<Ingreso> ingresosList = new ArrayList<>();
|
List<Ingreso> ingresosList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from ingresos");
|
String query = "select * from ingresos";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0}", query);
|
||||||
|
|
||||||
ingresosList = this.ingresosFromResultSet(rs);
|
ingresosList = this.ingresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return ingresosList;
|
return ingresosList;
|
||||||
}
|
}
|
||||||
@@ -62,15 +68,17 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public List<Ingreso> findByCaja(Caja caja) {
|
public List<Ingreso> findByCaja(Caja caja) {
|
||||||
List<Ingreso> ingresosList = new ArrayList<>();
|
List<Ingreso> ingresosList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from ingresos where caja_id = ?");
|
String query = "select * from ingresos where caja_id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, caja.getId());
|
ps.setInt(1, caja.getId());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, caja.getId()});
|
||||||
|
|
||||||
ingresosList = this.ingresosFromResultSet(rs);
|
ingresosList = this.ingresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -81,17 +89,19 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public List<Ingreso> findById(int id) {
|
public List<Ingreso> findById(int id) {
|
||||||
List<Ingreso> ingresosList = new ArrayList<>();
|
List<Ingreso> ingresosList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from ingresos where id = ?");
|
String query = "select * from ingresos where id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, id);
|
ps.setInt(1, id);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, id});
|
||||||
|
|
||||||
ingresosList = this.ingresosFromResultSet(rs);
|
ingresosList = this.ingresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return ingresosList;
|
return ingresosList;
|
||||||
}
|
}
|
||||||
@@ -100,17 +110,20 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public List<Ingreso> findByTipoIngreso(TipoIngreso tipoIngreso) {
|
public List<Ingreso> findByTipoIngreso(TipoIngreso tipoIngreso) {
|
||||||
List<Ingreso> ingresosList = new ArrayList<>();
|
List<Ingreso> ingresosList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select ingresos.* from ingresos inner join tipos_ingreso on (ingresos.tipo_ingreso_id = tipos_ingreso.id) where ingresos.tipo_ingreso_id = ?");
|
String query = "select ingresos.* from ingresos inner join tipos_ingreso on (ingresos.tipo_ingreso_id = tipos_ingreso.id) where ingresos.tipo_ingreso_id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, tipoIngreso.getId());
|
ps.setInt(1, tipoIngreso.getId());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, tipoIngreso.getId()});
|
||||||
|
|
||||||
|
|
||||||
ingresosList = this.ingresosFromResultSet(rs);
|
ingresosList = this.ingresosFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return ingresosList;
|
return ingresosList;
|
||||||
}
|
}
|
||||||
@@ -119,7 +132,8 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public boolean insertIngreso(Ingreso ingreso) {
|
public boolean insertIngreso(Ingreso ingreso) {
|
||||||
int updates;
|
int updates;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("insert into ingresos (valor, nro_z_inicial, nro_z_final, nro_inicial, nro_final, tipo_ingreso_id, caja_id) values (?,?,?,?,?,?,?)");
|
String query = "insert into ingresos (valor, nro_z_inicial, nro_z_final, nro_inicial, nro_final, tipo_ingreso_id, caja_id) values (?,?,?,?,?,?,?)";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, ingreso.getValor());
|
ps.setInt(1, ingreso.getValor());
|
||||||
ps.setString(2, ingreso.getNroZInicial());
|
ps.setString(2, ingreso.getNroZInicial());
|
||||||
ps.setString(3, ingreso.getNroZFinal());
|
ps.setString(3, ingreso.getNroZFinal());
|
||||||
@@ -127,8 +141,10 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
ps.setString(5, ingreso.getNroFinal());
|
ps.setString(5, ingreso.getNroFinal());
|
||||||
ps.setInt(6, ingreso.getTipoIngreso().getId());
|
ps.setInt(6, ingreso.getTipoIngreso().getId());
|
||||||
ps.setInt(7, ingreso.getCaja().getId());
|
ps.setInt(7, ingreso.getCaja().getId());
|
||||||
|
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2},{3},{4},{5},{6},{7}] | updates: {8}", new Object[]{query, ingreso.getValor(), ingreso.getNroZInicial(), ingreso.getNroZFinal(), ingreso.getNroInicial(), ingreso.getNroFinal(), ingreso.getTipoIngreso().getId(), ingreso.getCaja().getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
ps = conn.prepareStatement("select last_insert_rowid()");
|
ps = conn.prepareStatement("select last_insert_rowid()");
|
||||||
@@ -137,9 +153,8 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
ingreso.setId(rs.getInt(1));
|
ingreso.setId(rs.getInt(1));
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return updates > 0;
|
return updates > 0;
|
||||||
@@ -149,7 +164,8 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public boolean updateIngreso(Ingreso ingreso) {
|
public boolean updateIngreso(Ingreso ingreso) {
|
||||||
int updates;
|
int updates;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("update ingresos set valor = ?, nro_z_inicial = ?, nro_z_final = ?, nro_inicial = ?, nro_final = ?, tipo_ingreso_id = ?, caja_id = ? where id = ?");
|
String query = "update ingresos set valor = ?, nro_z_inicial = ?, nro_z_final = ?, nro_inicial = ?, nro_final = ?, tipo_ingreso_id = ?, caja_id = ? where id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, ingreso.getValor());
|
ps.setInt(1, ingreso.getValor());
|
||||||
ps.setString(2, ingreso.getNroZInicial());
|
ps.setString(2, ingreso.getNroZInicial());
|
||||||
ps.setString(3, ingreso.getNroZFinal());
|
ps.setString(3, ingreso.getNroZFinal());
|
||||||
@@ -158,13 +174,14 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
ps.setInt(6, ingreso.getTipoIngreso().getId());
|
ps.setInt(6, ingreso.getTipoIngreso().getId());
|
||||||
ps.setInt(7, ingreso.getCaja().getId());
|
ps.setInt(7, ingreso.getCaja().getId());
|
||||||
ps.setInt(8, ingreso.getId());
|
ps.setInt(8, ingreso.getId());
|
||||||
|
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: [{1},{2},{3},{4},{5},{6},{7},{8}] | updates: {9}", new Object[]{query, ingreso.getValor(), ingreso.getNroZInicial(), ingreso.getNroZFinal(), ingreso.getNroInicial(), ingreso.getNroFinal(), ingreso.getTipoIngreso().getId(), ingreso.getCaja().getId(), ingreso.getId(), updates});
|
||||||
|
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return updates > 0;
|
return updates > 0;
|
||||||
@@ -174,13 +191,16 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public boolean deleteIngreso(Ingreso ingreso) {
|
public boolean deleteIngreso(Ingreso ingreso) {
|
||||||
int updates;
|
int updates;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("delete from ingresos where id = ?");
|
String query = "delete from ingresos where id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, ingreso.getId());
|
ps.setInt(1, ingreso.getId());
|
||||||
updates = ps.executeUpdate();
|
updates = ps.executeUpdate();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1} | updates: {2}", new Object[]{query, ingreso.getId(), updates});
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return updates > 0;
|
return updates > 0;
|
||||||
@@ -190,18 +210,20 @@ public class SQLiteIngresoDAO extends IngresoDAO {
|
|||||||
public int getTotalIngreso(Caja caja) {
|
public int getTotalIngreso(Caja caja) {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select sum(valor) from ingresos where caja_id = ?");
|
String query = "select sum(valor) from ingresos where caja_id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, caja.getId());
|
ps.setInt(1, caja.getId());
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, caja.getId()});
|
||||||
|
|
||||||
rs.next();
|
rs.next();
|
||||||
total = rs.getInt(1);
|
total = rs.getInt(1);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteTipoEgresoDAO extends TipoEgresoDAO {
|
public class SQLiteTipoEgresoDAO extends TipoEgresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(SQLiteTipoEgresoDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteTipoEgresoDAO() {
|
public SQLiteTipoEgresoDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
@@ -42,16 +46,18 @@ public class SQLiteTipoEgresoDAO extends TipoEgresoDAO {
|
|||||||
public List<TipoEgreso> findAll() {
|
public List<TipoEgreso> findAll() {
|
||||||
List<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
List<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso");
|
String query = "select * from tipos_egreso";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0}", query);
|
||||||
|
|
||||||
tipoEgresoList = this.tipoEgresoFromResultSet(rs);
|
tipoEgresoList = this.tipoEgresoFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return tipoEgresoList;
|
return tipoEgresoList;
|
||||||
}
|
}
|
||||||
@@ -60,17 +66,19 @@ public class SQLiteTipoEgresoDAO extends TipoEgresoDAO {
|
|||||||
public List<TipoEgreso> findById(int id) {
|
public List<TipoEgreso> findById(int id) {
|
||||||
List<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
List<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso where id = ?");
|
String query = "select * from tipos_egreso where id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, id);
|
ps.setInt(1, id);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, id});
|
||||||
|
|
||||||
tipoEgresoList = this.tipoEgresoFromResultSet(rs);
|
tipoEgresoList = this.tipoEgresoFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return tipoEgresoList;
|
return tipoEgresoList;
|
||||||
}
|
}
|
||||||
@@ -79,34 +87,20 @@ public class SQLiteTipoEgresoDAO extends TipoEgresoDAO {
|
|||||||
public List<TipoEgreso> findByNombre(String nombre) {
|
public List<TipoEgreso> findByNombre(String nombre) {
|
||||||
List<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
List<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from tipos_egreso where nombre = ?");
|
String query = "select * from tipos_egreso where nombre = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setString(1, nombre);
|
ps.setString(1, nombre);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, nombre});
|
||||||
|
|
||||||
tipoEgresoList = this.tipoEgresoFromResultSet(rs);
|
tipoEgresoList = this.tipoEgresoFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
LOGGER.log(Level.SEVERE, e.toString(), e);
|
||||||
}
|
}
|
||||||
return tipoEgresoList;
|
return tipoEgresoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean insertTipoEgreso(TipoEgreso tipoEgreso) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updateTipoEgreso(TipoEgreso tipoEgreso) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deleteTipoEgreso(TipoEgreso tipoEgreso) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class TipoEgresoDAO {
|
public abstract class TipoEgresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(TipoEgresoDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
public abstract List<TipoEgreso> findAll();
|
public abstract List<TipoEgreso> findAll();
|
||||||
@@ -64,18 +68,15 @@ public abstract class TipoEgresoDAO {
|
|||||||
|
|
||||||
public abstract List<TipoEgreso> findByNombre(String nombre);
|
public abstract List<TipoEgreso> findByNombre(String nombre);
|
||||||
|
|
||||||
public abstract boolean insertTipoEgreso(TipoEgreso tipoEgreso);
|
|
||||||
|
|
||||||
public abstract boolean updateTipoEgreso(TipoEgreso tipoEgreso);
|
|
||||||
|
|
||||||
public abstract boolean deleteTipoEgreso(TipoEgreso tipoEgreso);
|
|
||||||
|
|
||||||
List<TipoEgreso> tipoEgresoFromResultSet(ResultSet rs) throws SQLException {
|
List<TipoEgreso> tipoEgresoFromResultSet(ResultSet rs) throws SQLException {
|
||||||
ArrayList<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
ArrayList<TipoEgreso> tipoEgresoList = new ArrayList<>();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
TipoEgreso tipoEgreso = new TipoEgreso();
|
TipoEgreso tipoEgreso = new TipoEgreso();
|
||||||
tipoEgreso.setId(rs.getInt("id"));
|
tipoEgreso.setId(rs.getInt("id"));
|
||||||
tipoEgreso.setNombre(rs.getString("nombre"));
|
tipoEgreso.setNombre(rs.getString("nombre"));
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINER, "Se a creado {0}", tipoEgreso);
|
||||||
|
|
||||||
tipoEgresoList.add(tipoEgreso);
|
tipoEgresoList.add(tipoEgreso);
|
||||||
}
|
}
|
||||||
return tipoEgresoList;
|
return tipoEgresoList;
|
||||||
|
|||||||
@@ -32,8 +32,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class SQLiteTipoIngresoDAO extends TipoIngresoDAO {
|
public class SQLiteTipoIngresoDAO extends TipoIngresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(SQLiteTipoIngresoDAO.class.getName());
|
||||||
|
|
||||||
public SQLiteTipoIngresoDAO() {
|
public SQLiteTipoIngresoDAO() {
|
||||||
this.connectionHolder = new SQLiteConnectionHolder();
|
this.connectionHolder = new SQLiteConnectionHolder();
|
||||||
}
|
}
|
||||||
@@ -42,14 +46,16 @@ public class SQLiteTipoIngresoDAO extends TipoIngresoDAO {
|
|||||||
public List<TipoIngreso> findAll() {
|
public List<TipoIngreso> findAll() {
|
||||||
List<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
List<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso");
|
String query = "select * from tipos_ingreso";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0}", query);
|
||||||
|
|
||||||
tiposIngresoList = this.tiposIngresoFromResultSet(rs);
|
tiposIngresoList = this.tiposIngresoFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -60,15 +66,17 @@ public class SQLiteTipoIngresoDAO extends TipoIngresoDAO {
|
|||||||
public List<TipoIngreso> findById(int id) {
|
public List<TipoIngreso> findById(int id) {
|
||||||
List<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
List<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso where id = ?");
|
String query = "select * from tipos_ingreso where id = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setInt(1, id);
|
ps.setInt(1, id);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, id});
|
||||||
|
|
||||||
tiposIngresoList = this.tiposIngresoFromResultSet(rs);
|
tiposIngresoList = this.tiposIngresoFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
conn.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -79,10 +87,13 @@ public class SQLiteTipoIngresoDAO extends TipoIngresoDAO {
|
|||||||
public List<TipoIngreso> findByNombre(String nombre) {
|
public List<TipoIngreso> findByNombre(String nombre) {
|
||||||
List<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
List<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
||||||
try (Connection conn = connectionHolder.getConnection()) {
|
try (Connection conn = connectionHolder.getConnection()) {
|
||||||
PreparedStatement ps = conn.prepareStatement("select * from tipos_ingreso where nombre = ?");
|
String query = "select * from tipos_ingreso where nombre = ?";
|
||||||
|
PreparedStatement ps = conn.prepareStatement(query);
|
||||||
ps.setString(1, nombre);
|
ps.setString(1, nombre);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "QUERY: {0} | values: {1}", new Object[]{query, nombre});
|
||||||
|
|
||||||
tiposIngresoList = this.tiposIngresoFromResultSet(rs);
|
tiposIngresoList = this.tiposIngresoFromResultSet(rs);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
@@ -93,19 +104,4 @@ public class SQLiteTipoIngresoDAO extends TipoIngresoDAO {
|
|||||||
return tiposIngresoList;
|
return tiposIngresoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean insertTipoIngreso(TipoIngreso tipoEgreso) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updateTipoIngreso(TipoIngreso tipoEgreso) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deleteTipoIngreso(TipoIngreso tipoEgreso) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,12 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public abstract class TipoIngresoDAO {
|
public abstract class TipoIngresoDAO {
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(SQLiteTipoIngresoDAO.class.getName());
|
||||||
|
|
||||||
protected ConnectionHolder connectionHolder;
|
protected ConnectionHolder connectionHolder;
|
||||||
|
|
||||||
public abstract List<TipoIngreso> findAll();
|
public abstract List<TipoIngreso> findAll();
|
||||||
@@ -40,18 +44,15 @@ public abstract class TipoIngresoDAO {
|
|||||||
|
|
||||||
public abstract List<TipoIngreso> findByNombre(String nombre);
|
public abstract List<TipoIngreso> findByNombre(String nombre);
|
||||||
|
|
||||||
public abstract boolean insertTipoIngreso(TipoIngreso tipoEgreso);
|
|
||||||
|
|
||||||
public abstract boolean updateTipoIngreso(TipoIngreso tipoEgreso);
|
|
||||||
|
|
||||||
public abstract boolean deleteTipoIngreso(TipoIngreso tipoEgreso);
|
|
||||||
|
|
||||||
List<TipoIngreso> tiposIngresoFromResultSet(ResultSet rs) throws SQLException {
|
List<TipoIngreso> tiposIngresoFromResultSet(ResultSet rs) throws SQLException {
|
||||||
ArrayList<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
ArrayList<TipoIngreso> tiposIngresoList = new ArrayList<>();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
TipoIngreso tipoIngreso = new TipoIngreso();
|
TipoIngreso tipoIngreso = new TipoIngreso();
|
||||||
tipoIngreso.setId(rs.getInt("id"));
|
tipoIngreso.setId(rs.getInt("id"));
|
||||||
tipoIngreso.setNombre(rs.getString("nombre"));
|
tipoIngreso.setNombre(rs.getString("nombre"));
|
||||||
|
|
||||||
|
LOGGER.log(Level.FINE, "Se a creado: {0]", tipoIngreso);
|
||||||
|
|
||||||
tiposIngresoList.add(tipoIngreso);
|
tiposIngresoList.add(tipoIngreso);
|
||||||
}
|
}
|
||||||
return tiposIngresoList;
|
return tiposIngresoList;
|
||||||
|
|||||||
Reference in New Issue
Block a user