diff --git a/winebrewdb/src/com/pori/WineBrewDB/Ledger/LedgerEquipmentPanel.java b/winebrewdb/src/com/pori/WineBrewDB/Ledger/LedgerEquipmentPanel.java index 1bb1a7c..54c3545 100644 --- a/winebrewdb/src/com/pori/WineBrewDB/Ledger/LedgerEquipmentPanel.java +++ b/winebrewdb/src/com/pori/WineBrewDB/Ledger/LedgerEquipmentPanel.java @@ -572,7 +572,7 @@ public static void setLedgerEquipmentCostData(){ } } - //TODO: Fix divide by zero error + public static void setBrewTotalCostData(){ BigDecimal total = new BigDecimal("0"); for (int i = 0; i < (LedgerEquipmentCostTable.getRowCount()); i++ ) { diff --git a/winebrewdb/src/com/pori/WineBrewDB/SQLite/DBEngine.java b/winebrewdb/src/com/pori/WineBrewDB/SQLite/DBEngine.java index 78fd63c..acbaa40 100644 --- a/winebrewdb/src/com/pori/WineBrewDB/SQLite/DBEngine.java +++ b/winebrewdb/src/com/pori/WineBrewDB/SQLite/DBEngine.java @@ -1472,14 +1472,19 @@ public static BigDecimal getTotalNumberBrews() throws Exception { ResultSet rs = pre.executeQuery(); int NumberBrews = 0; + BigDecimal DecimalNumberBrews = new BigDecimal("0"); while(rs.next()){ //Add one to the current highest NumberBrews = rs.getInt(1); } - BigDecimal DecimalNumberBrews = new BigDecimal(NumberBrews); + if(NumberBrews == 0){ + DecimalNumberBrews = new BigDecimal("0.00000001"); + }else{ + DecimalNumberBrews = new BigDecimal(NumberBrews); + } /*Close the connection after use (MUST)*/ if(conn!=null) @@ -1501,14 +1506,19 @@ public static BigDecimal getTotalNumberBottles() throws Exception { ResultSet rs = pre.executeQuery(); int NumberBottles = 0; + BigDecimal DecimalNumberBottles = new BigDecimal("0"); while(rs.next()){ //Add one to the current highest NumberBottles = rs.getInt(1); } - BigDecimal DecimalNumberBottles = new BigDecimal(NumberBottles); + if(NumberBottles == 0){ + DecimalNumberBottles = new BigDecimal("0.00000001"); + }else{ + DecimalNumberBottles = new BigDecimal(NumberBottles); + } /*Close the connection after use (MUST)*/ if(conn!=null)