diff --git a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java index 6d07410..e7d922f 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java @@ -464,7 +464,7 @@ public class SqlDAO extends DAO { public double getOutstandingBalance(String InvoiceNumber) throws AstuteException { double balance; try { - System.out.println("Calling delete_invoice DB function"); + System.out.println("Calling get_outstanding_inv_balance DB function"); CallableStatement stmt = conn.prepareCall("{? = call get_outstanding_inv_balance(?)}"); stmt.registerOutParameter(1, Types.VARCHAR); stmt.setString(2, InvoiceNumber); @@ -1322,6 +1322,9 @@ public class SqlDAO extends DAO { if (paymentAmount > getOutstandingBalance(invoiceNum) ) { throw new AstuteException(DB_ERROR,"Payment amount can't be greater than outstanding balance for Invoice " + invoiceNum); } + if (paymentAmount <= 0) { + throw new AstuteException(DB_ERROR,"Payment amount must be greater than 0"); + } String dateString = "STR_TO_DATE('" + paymentDate + "', '%Y-%m-%d')"; String sql = "insert into invoice_payment (inv_no, invoice_payment_type, invoice_amount, payment_date, check_no, transaction_no) values ('" + invoiceNum + "', " + invoicePaymentTypeId + ", " + paymentAmount + ", " + dateString + ", '" + checkNo +"', '" + transactionNo + "')"; Statement stmt = conn.createStatement();