Las cajas pueden ser Empty y tener id = 0

Se debe comprobar para ello. si no se hara una query con un id invalido.
This commit is contained in:
Daniel Cortes
2019-03-07 01:53:03 -03:00
parent db9568c85f
commit ecb3315bc8
2 changed files with 10 additions and 0 deletions

BIN
dist/Programa Caja.jar vendored

Binary file not shown.

View File

@@ -65,6 +65,11 @@ public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
@Override
public List<CalculoFondo> findByCaja(Caja caja) {
List<CalculoFondo> calculoFondoList = new ArrayList<>();
if(Caja.EMPTY == caja){
return calculoFondoList;
}
String query = "select * from calculo_fondo where caja_id = ?";
try (Connection conn = connectionHolder.getConnection()) {
try (PreparedStatement ps = conn.prepareStatement(query)) {
@@ -176,6 +181,11 @@ public class SQLiteCalculoFondoDAO extends CalculoFondoDAO {
@Override
public int getTotalCalculoFondo(Caja caja) {
int sum = 0;
if(Caja.EMPTY == caja){
return sum;
}
String query = "select sum(valor) from calculo_fondo where caja_id = ?";
try (Connection conn = connectionHolder.getConnection()) {
try (PreparedStatement ps = conn.prepareStatement(query)) {