Add files via upload

This commit is contained in:
gopi17701 2018-07-23 13:25:06 -04:00 committed by GitHub
parent a73e859fa2
commit ce93f0f0ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 43 deletions

View File

@ -92,17 +92,17 @@ public abstract class DAO {
*/
public abstract void connect() throws AstuteException;
public abstract List<PO> getPOMaster(String PONum, String contractNum, java.sql.Date PODate) throws AstuteException;
public abstract List<PO> getPOMaster(String PONum, String contractNum, java.sql.Date PODate, String astuteProjectNumber) throws AstuteException;
public abstract List<PODetail> getPODetail(String PONum, int lineItemNo) throws AstuteException;
public abstract void updatePOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt) throws AstuteException;
public abstract void updatePOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt, String astuteProjectNumber) throws AstuteException;
public abstract void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, int serviceTypeId) throws AstuteException;
public abstract void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException;
public abstract void createPOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt, int customerId) throws AstuteException;
public abstract void createPOMaster(String PONum, String contractNum, java.sql.Date PODate, Double contractAmt, int customerId, String astuteProjectNumber) throws AstuteException;
public abstract void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, int serviceTypeId) throws AstuteException;
public abstract void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException;
public abstract List<Invoice> getInvoiceMaster(String invoiceNumber, int pmtStatus) throws AstuteException;
@ -111,11 +111,11 @@ public abstract class DAO {
public abstract void updateInvoiceMaster(String invoiceNum, java.sql.Date invoiceDate, String PONum, String changeOrderNum, int pmtStatus, Double billAmt, String specialNotes, String certification) throws AstuteException;
public abstract void updateInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double percentCompletion, double hours, double amount) throws AstuteException;
public abstract void updateInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double qty, double fee) throws AstuteException;
public abstract void createInvoiceMaster(String invoiceNum, java.sql.Date invoiceDate, String PONum, String changeOrderNum, int pmtStatus, Double billAmt, String specialNotes, String certification) throws AstuteException;
public abstract void createInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double percentCompletion, double hours, double amount) throws AstuteException;
public abstract void createInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double qty, double fee) throws AstuteException;
public abstract String generateInvoiceNumber(String poNum) throws AstuteException;

View File

@ -36,7 +36,7 @@ public class SqlDAO extends DAO {
=============================== PO Methods ===============================================
*/
public List<PO> getPOMaster(String PONum, String contractNum, Date PODate) throws AstuteException {
public List<PO> getPOMaster(String PONum, String contractNum, Date PODate, String astuteProjectNumber) throws AstuteException {
try {
List<PO> pos = new ArrayList<>();
Statement stmt = conn.createStatement();
@ -47,6 +47,8 @@ public class SqlDAO extends DAO {
sql += "WHERE UPPER(contract_num) = '" + contractNum.toUpperCase()+ "'";
} else if (PODate != null) {
sql += "WHERE PO_date = STR_TO_DATE(" + PODate + ", '%Y-%m-%d')";
} else if (astuteProjectNumber!= null) {
sql += "WHERE UPPER(astuteProjectNumber) = '" + astuteProjectNumber.toUpperCase()+ "'";
}
ResultSet rs = stmt.executeQuery(sql);
@ -72,7 +74,7 @@ public class SqlDAO extends DAO {
Statement stmt = conn.createStatement();
String whereClause = " WHERE ";
boolean whereClauseCriteria = false;
String sql = "SELECT PO_num, line_item_no, service_desc, fee_type_id, qty, service_type_id, get_remaining_qty_fun(PO_num, line_item_no) as get_remaining_qty FROM PO_DETAIL ";
String sql = "SELECT PO_num, line_item_no, service_desc, fee_type_id, qty, fee, service_type_id, get_remaining_qty_fun(PO_num, line_item_no) as get_remaining_qty FROM PO_DETAIL ";
if (PONum != null) {
whereClause = whereClause + " UPPER(PO_num) = '" + PONum.toUpperCase() + "'";
whereClauseCriteria = true;
@ -92,9 +94,10 @@ public class SqlDAO extends DAO {
String serviceDesc = rs.getString(3);
int feeTypeId = rs.getInt(4);
Double qty = rs.getDouble(5);
int serviceTypeId = rs.getInt(6);
double remainingQty = rs.getInt(7);
PODetail poDetail = new PODetail(poNum, lineItemNum, serviceDesc, feeTypeId, qty, serviceTypeId, remainingQty);
Double fee = rs.getDouble(6);
int serviceTypeId = rs.getInt(7);
double remainingQty = rs.getInt(8);
PODetail poDetail = new PODetail(poNum, lineItemNum, serviceDesc, feeTypeId, qty, fee, serviceTypeId, remainingQty);
poDetails.add(poDetail);
}
return poDetails;
@ -104,7 +107,7 @@ public class SqlDAO extends DAO {
}
}
public void updatePOMaster(String PONum, String contractNum, Date PODate, Double contractAmt) throws AstuteException {
public void updatePOMaster(String PONum, String contractNum, Date PODate, Double contractAmt, String astuteProjectNumber) throws AstuteException {
try {
String sql = "UPDATE PO ";
String updateClause = " SET ";
@ -115,15 +118,18 @@ public class SqlDAO extends DAO {
whereClause = " WHERE UPPER(PO_num) ='" + PONum.toUpperCase() + "'";
}
if (contractNum != null && !contractNum.isEmpty()) {
// if (contractNum != null && !contractNum.isEmpty()) {
updateClause = updateClause + " contract_num = '" + contractNum.toUpperCase() + "',";
}
if (PODate != null) {
// }
// if (PODate != null) {
updateClause = updateClause + " PO_Date = STR_TO_DATE(" + PODate + ", '%Y-%m-%d')" + ",";
}
if (contractAmt != null && contractAmt > 0) {
// }
// if (contractAmt != null && contractAmt > 0) {
updateClause = updateClause + " contract_amt = " + contractAmt;
}
// }
// if (astuteProjectNumber != null && !astuteProjectNumber.isEmpty()) {
updateClause = updateClause + " astuteProjectNumber = '" + astuteProjectNumber + "',";
// }
if (!updateClause.equalsIgnoreCase(" SET ")) {
sql = sql + trimLastCharacter(updateClause, ",") + whereClause;
@ -149,7 +155,7 @@ public class SqlDAO extends DAO {
}
public void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, int serviceTypeId) throws AstuteException {
public void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException {
try {
String sql = "UPDATE PO_DETAIL ";
String updateClause = " SET ";
@ -171,6 +177,9 @@ public class SqlDAO extends DAO {
if (qty != null && qty > 0) {
updateClause += " qty = " + qty + ",";
}
if (fee != null && fee > 0) {
updateClause += " fee = " + fee + ",";
}
if (serviceTypeId > 0) {
updateClause += " service_type_id = " + serviceTypeId + ",";
}
@ -189,14 +198,15 @@ public class SqlDAO extends DAO {
}
}
public void createPOMaster(String PONum, String contractNum, Date PODate, Double contractAmt, int customerId) throws AstuteException {
public void createPOMaster(String PONum, String contractNum, Date PODate, Double contractAmt, int customerId, String astuteProjectNumber) throws AstuteException {
try {
CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?,?)}");
CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?,?,?)}");
stmt.setString(1, PONum);
stmt.setString(2, contractNum);
stmt.setDate(3, PODate);
stmt.setDouble(4, contractAmt);
stmt.setInt(5, customerId);
stmt.setString(6, astuteProjectNumber);
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
@ -204,17 +214,18 @@ public class SqlDAO extends DAO {
}
}
public void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, int serviceTypeId) throws AstuteException {
public void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId) throws AstuteException {
try {
System.out.println("Calling create_po_detail Procedure");
System.out.println("POnum is " + POnum);
CallableStatement stmt = conn.prepareCall("{call create_po_detail(?,?,?,?,?,?)}");
CallableStatement stmt = conn.prepareCall("{call create_po_detail(?,?,?,?,?,?,?)}");
stmt.setString(1, POnum);
stmt.setInt(2, lineItemNo);
stmt.setString(3, serviceDesc);
stmt.setInt(4, feeTypeId);
stmt.setDouble(5, qty);
stmt.setInt(6, serviceTypeId);
stmt.setDouble(6, fee);
stmt.setInt(7, serviceTypeId);
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
@ -264,7 +275,7 @@ public class SqlDAO extends DAO {
Invoice invoice = getInvoiceMaster(invoiceNumber, 0).get(0);
String PONo = invoice.getPoNum();
List<InvoiceDetail> invoiceDetail = getInvoiceDetail(invoiceNumber, 0);
PO po = getPOMaster(PONo, null, null).get(0);
PO po = getPOMaster(PONo, null, null, null).get(0);
Integer customerId = po.getCustomerId();
Customer customer = getCustomers(customerId).get(0);
Double previouslyBilledAmt = getPreviouslyBilledAmount(PONo);
@ -343,10 +354,9 @@ public class SqlDAO extends DAO {
int POLineItemNum = rs.getInt(3);
int serviceTypeId = rs.getInt(4);
String desc = rs.getString(5);
Double percentCompletion = rs.getDouble(6);
Double hours = rs.getDouble(7);
Double amount = rs.getDouble(8);
InvoiceDetail service = new InvoiceDetail(invNo, lineItemNum, POLineItemNum, serviceTypeId, desc, percentCompletion, hours, amount);
Double qty = rs.getDouble(6);
Double fee = rs.getDouble(7);
InvoiceDetail service = new InvoiceDetail(invNo, lineItemNum, POLineItemNum, serviceTypeId, desc, qty, fee);
services.add(service);
}
return services;
@ -405,7 +415,7 @@ public class SqlDAO extends DAO {
}
}
public void updateInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double percentCompletion, double hours, double amount)throws AstuteException {
public void updateInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double qty, double fee)throws AstuteException {
try {
String sql = "UPDATE INVOICE_DETAIL ";
String updateClause = " SET ";
@ -424,16 +434,12 @@ public class SqlDAO extends DAO {
if(desc != null && !desc.isEmpty()) {
updateClause += " description = '" + desc + "',";
}
if(percentCompletion >0) {
updateClause += " percent_completion = " + percentCompletion + ",";
if(qty >0) {
updateClause += " qty = " + qty + ",";
}
if(hours > 0) {
updateClause += " hours = " + hours + ",";
if(fee > 0) {
updateClause += " fee = " + fee + ",";
}
if(amount >0) {
updateClause += " amt = " + amount + ",";
}
if (!updateClause.equalsIgnoreCase(" SET ")) {
sql = sql + trimLastCharacter(updateClause,",") + whereClause;
@ -469,7 +475,7 @@ public class SqlDAO extends DAO {
}
public void createInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double percentCompletion, double hours, double amount)throws AstuteException {
public void createInvoiceDetail(String invoiceNum, int lineItemNum, int POLineItemNum, int serviceTypeId, String desc, double qty, double fee)throws AstuteException {
try {
System.out.println("Calling create_invoice_detail Procedure");
System.out.println("invoiceNum is "+invoiceNum);
@ -479,9 +485,8 @@ public class SqlDAO extends DAO {
stmt.setInt(3, POLineItemNum);
stmt.setInt(4, serviceTypeId);
stmt.setString(5, desc);
stmt.setDouble(6, percentCompletion);
stmt.setDouble(7, hours);
stmt.setDouble(8, amount);
stmt.setDouble(6, qty);
stmt.setDouble(7, fee);
stmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();