Add files via upload

This commit is contained in:
gopi17701 2018-09-09 02:33:27 -04:00 committed by GitHub
parent 7613f1a0ce
commit c6cdd80bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 30 deletions

View File

@ -112,6 +112,8 @@ public abstract class DAO {
public abstract void updateInvoiceMaster(String invoiceNum, String invoiceDate, String PONum, int pmtStatus, Double billAmt, String specialNotes, String certification, int invoiceStatus) throws AstuteException;
public abstract void deleteInvoice(String invoiceNum) throws AstuteException;
public abstract void updateInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double qty, double fee, int feeTypeId) throws AstuteException;
public abstract void createInvoiceMaster(String invoiceNum, String invoiceDate, String PONum, int pmtStatus, Double billAmt, String specialNotes, String certification, int invoiceStatus) throws AstuteException, ParseException;

View File

@ -42,7 +42,7 @@ public class SqlDAO extends DAO {
try {
List<PO> pos = new ArrayList<>();
Statement stmt = conn.createStatement();
String sql = "SELECT PO_num, contract_num, PO_date, customer_id, contract_amt, astute_project_num , title, get_previously_billed_amt(PO_num) FROM PO ";
String sql = "SELECT PO_num, contract_num, PO_date, customer_id, contract_amt, astute_project_num , title, get_previously_billed_amt(PO_num), inv_seq FROM PO ";
if (PONum != null && !PONum.isEmpty()) {
sql += "WHERE UPPER(PO_num) = '" + PONum.toUpperCase() + "'";
} else if (contractNum != null && !contractNum.isEmpty()) {
@ -63,12 +63,13 @@ public class SqlDAO extends DAO {
String astuteProjectNum = rs.getString(6);
String title = rs.getString(7);
Double previouslyBilledAmount = rs.getDouble(8);
int invoiceSequence = rs.getInt(8);
String date = null;
if (poDate != null) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
date = formatter.format(poDate);
}
PO po = new PO(poNum, cntrctNum, date, customerId, contractAmt,astuteProjectNum,title,previouslyBilledAmount);
PO po = new PO(poNum, cntrctNum, date, customerId, contractAmt,astuteProjectNum,title,previouslyBilledAmount,invoiceSequence);
pos.add(po);
}
return pos;
@ -403,25 +404,50 @@ public class SqlDAO extends DAO {
}
}
public Double updateRemainingQty(String poNum, String inv_no, int lineItemNo) throws AstuteException {
public void deleteInvoice(String invoiceNum) throws AstuteException {
try {
System.out.println("deleting invoice " + invoiceNum);
CallableStatement stmt = conn.prepareCall("DELETE FROM INVOICE WHERE INV_NO = '"+ invoiceNum + "' AND inv_status = 1");
stmt.executeUpdate();
updateAllRemainingQuantities(invoiceNum);
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
}
}
public void updateAllRemainingQuantities(String invNo) throws AstuteException {
try {
System.out.println("Calling update_all_remaining_quantities DB procedure");
CallableStatement stmt = conn.prepareCall("{call update_all_remaining_quantities(?)}");
stmt.setString(1, invNo);
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
}
}
public Double updateRemainingQty(String poNum, String invNo, int lineItemNo) throws AstuteException {
Double remainingQty;
try {
System.out.println("Calling update_remaining_qty DB procedure");
System.out.println("poNum is " + poNum);
CallableStatement stmt = conn.prepareCall("{? = call update_remaining_qty_fun(?,?,?)}");
stmt.registerOutParameter(1, Types.VARCHAR);
stmt.setString(2, poNum);
stmt.setString(3, inv_no);
stmt.setInt(4, lineItemNo);
stmt.executeUpdate();
remainingQty = stmt.getDouble(1);
System.out.println("remaining qty is updated to " + remainingQty);
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
}
return remainingQty;
System.out.println("Calling update_remaining_qty DB procedure");
System.out.println("poNum is " + poNum);
CallableStatement stmt = conn.prepareCall("{? = call update_remaining_qty_fun(?,?,?)}");
stmt.registerOutParameter(1, Types.VARCHAR);
stmt.setString(2, poNum);
stmt.setString(3, invNo);
stmt.setInt(4, lineItemNo);
stmt.executeUpdate();
remainingQty = stmt.getDouble(1);
System.out.println("remaining qty is updated to " + remainingQty);
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
}
return remainingQty;
}
public void updateInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double qty, double fee, int feeTypeId)throws AstuteException {
try {
String sql = "UPDATE INVOICE_DETAIL ";
@ -504,17 +530,15 @@ 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());
}
System.out.println("Calling submit_invoice Procedure ");
System.out.println("invoiceNum is "+InvoiceNumber);
CallableStatement stmt = conn.prepareCall("{call submit_invoice(?)}");
stmt.setString(1, InvoiceNumber);
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
}
}
public void voidInvoice(String InvoiceNumber) throws AstuteException {
@ -522,9 +546,11 @@ public class SqlDAO extends DAO {
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 + "')";
String sql = "UPDATE INVOICE SET INV_STATUS = 3 WHERE UPPER(INV_NO) = UPPER('" + InvoiceNumber + "') AND PMT_STATUS = 1";
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
System.out.println("Updating all remaining quantities");
updateAllRemainingQuantities(InvoiceNumber);
}
} catch(SQLException e){
e.printStackTrace();