From b897d2cc1b6cd006297b96b9b19ca85b77883907 Mon Sep 17 00:00:00 2001 From: Gopi Katwala Date: Tue, 16 Jul 2019 15:07:00 -0400 Subject: [PATCH] * Fixed Invoice Payment checks. Must be >= 0, can't be more than outstanding balance --- AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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();