diff --git a/AstuteSystem/src/main/java/com/astute/dao/DAO.java b/AstuteSystem/src/main/java/com/astute/dao/DAO.java index 668e193..e095354 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/DAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/DAO.java @@ -121,6 +121,9 @@ public abstract class DAO { public abstract GeneratedInvoice getGeneratedInvoice(String invoiceNumber)throws AstuteException; + public abstract void submitInvoice(String InvoiceNumber) throws AstuteException; + + public abstract void voidInvoice(String InvoiceNumber) throws AstuteException; public abstract List getCustomers(int customerId) throws AstuteException; diff --git a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java index 212bde8..8eb127e 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java @@ -119,7 +119,7 @@ public class SqlDAO extends DAO { } // if (contractNum != null && !contractNum.isEmpty()) { - updateClause = updateClause + " contract_num = '" + contractNum.toUpperCase() + "',"; + updateClause = updateClause + " contract_num = '" + contractNum + "',"; // } // if (PODate != null) { updateClause = updateClause + " PO_Date = STR_TO_DATE(" + PODate + ", '%Y-%m-%d')" + ","; @@ -494,6 +494,35 @@ public class SqlDAO extends DAO { } } + public void submitInvoice(String InvoiceNumber) throws AstuteException { + try { + if (InvoiceNumber == null || InvoiceNumber.isEmpty()) { + throw new AstuteException(0, "Invoice Number should not be null!"); + } else { + String sql = "UPDATE INVOICE SET INV_STATUS = 2 WHERE UPPER(INV_NO) = 'UPPER(" + InvoiceNumber + ")'"; + Statement stmt = conn.createStatement(); + stmt.executeUpdate(sql); + } + } catch(SQLException e){ + e.printStackTrace(); + throw new AstuteException(DB_ERROR, e.getMessage()); + } + } + + public void voidInvoice(String InvoiceNumber) throws AstuteException { + try { + if (InvoiceNumber == null || InvoiceNumber.isEmpty()) { + throw new AstuteException(0, "Invoice Number should not be null!"); + } else { + String sql = "UPDATE INVOICE SET INV_STATUS = 3 WHERE UPPER(INV_NO) = 'UPPER(" + InvoiceNumber + ")'"; + Statement stmt = conn.createStatement(); + stmt.executeUpdate(sql); + } + } catch(SQLException e){ + e.printStackTrace(); + throw new AstuteException(DB_ERROR, e.getMessage()); + } + } /* =============================== Customer Methods =============================================== */