mirror of
https://github.com/dyiop/astute.git
synced 2025-04-06 21:30:20 -04:00
Add files via upload
This commit is contained in:
parent
5863d58436
commit
f38d508485
|
@ -35,6 +35,10 @@ 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) throws AstuteException {
|
||||||
try {
|
try {
|
||||||
List<PO> pos = new ArrayList<>();
|
List<PO> pos = new ArrayList<>();
|
||||||
|
@ -197,9 +201,7 @@ 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) throws AstuteException {
|
||||||
try {
|
try {
|
||||||
System.out.println("Calling create_PO Procedure");
|
CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?,?)}");
|
||||||
System.out.println("PONum is " + PONum);
|
|
||||||
CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?)}");
|
|
||||||
stmt.setString(1, PONum);
|
stmt.setString(1, PONum);
|
||||||
stmt.setString(2, contractNum);
|
stmt.setString(2, contractNum);
|
||||||
stmt.setDate(3, PODate);
|
stmt.setDate(3, PODate);
|
||||||
|
@ -232,6 +234,10 @@ public class SqlDAO extends DAO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============================== Invoice Methods ===============================================
|
||||||
|
*/
|
||||||
|
|
||||||
public Double getPreviouslyBilledAmount(String poNum) throws AstuteException {
|
public Double getPreviouslyBilledAmount(String poNum) throws AstuteException {
|
||||||
try {
|
try {
|
||||||
Double billedAmt = new Double(0);
|
Double billedAmt = new Double(0);
|
||||||
|
@ -495,6 +501,10 @@ public class SqlDAO extends DAO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============================== Customer Methods ===============================================
|
||||||
|
*/
|
||||||
|
|
||||||
public List<Customer> getCustomers(int customerId) throws AstuteException {
|
public List<Customer> getCustomers(int customerId) throws AstuteException {
|
||||||
try {
|
try {
|
||||||
List<Customer> customers = new ArrayList<>();
|
List<Customer> customers = new ArrayList<>();
|
||||||
|
@ -611,6 +621,9 @@ public class SqlDAO extends DAO {
|
||||||
throw new AstuteException(DB_ERROR,e.getMessage());
|
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
=============================== User/Session Methods ===============================================
|
||||||
|
*/
|
||||||
|
|
||||||
// user and session methods
|
// user and session methods
|
||||||
public ResultSet executeQuery(String sessionId, String sql) throws AstuteException {
|
public ResultSet executeQuery(String sessionId, String sql) throws AstuteException {
|
||||||
|
@ -680,6 +693,10 @@ public class SqlDAO extends DAO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============================== Change Order ===============================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
public List<ChangeOrder> getChangeOrders(String poNum) throws AstuteException {
|
public List<ChangeOrder> getChangeOrders(String poNum) throws AstuteException {
|
||||||
try {
|
try {
|
||||||
|
@ -707,7 +724,7 @@ public class SqlDAO extends DAO {
|
||||||
};
|
};
|
||||||
|
|
||||||
public void updateChangeOrder(String poNum, int changeOrderNum, double changeOrderAmt, Date changeOrderDate, String description) throws AstuteException {
|
public void updateChangeOrder(String poNum, int changeOrderNum, double changeOrderAmt, Date changeOrderDate, String description) throws AstuteException {
|
||||||
try {
|
try {
|
||||||
String sql = "UPDATE CHANGE_ORDER ";
|
String sql = "UPDATE CHANGE_ORDER ";
|
||||||
String updateClause = " SET ";
|
String updateClause = " SET ";
|
||||||
String whereClause = "";
|
String whereClause = "";
|
||||||
|
@ -728,27 +745,99 @@ public class SqlDAO extends DAO {
|
||||||
System.out.println(sql);
|
System.out.println(sql);
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement();
|
||||||
stmt.executeUpdate(sql);
|
stmt.executeUpdate(sql);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new AstuteException(DB_ERROR,e.getMessage());
|
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int createChangeOrder(String poNum, int changeOrderNum, double changeOrderAmt, Date changeOrderDate, String description) throws AstuteException{
|
public int createChangeOrder(String poNum, int changeOrderNum, double changeOrderAmt, Date changeOrderDate, String description) throws AstuteException{
|
||||||
try {
|
try {
|
||||||
String dateString = "STR_TO_DATE(" + changeOrderDate + ", '%Y-%m-%d')";
|
String dateString = "STR_TO_DATE(" + changeOrderDate + ", '%Y-%m-%d')";
|
||||||
String sql = "insert into change_order (po_num, change_order_num, change_order_amt, change_order_date, description) values ('" + poNum + "', " + changeOrderNum + ", " + changeOrderAmt + ", " + dateString + ", '" + description + "')";
|
String sql = "insert into change_order (po_num, change_order_num, change_order_amt, change_order_date, description) values ('" + poNum + "', " + changeOrderNum + ", " + changeOrderAmt + ", " + dateString + ", '" + description + "')";
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement();
|
||||||
stmt.execute(sql);
|
stmt.execute(sql);
|
||||||
return changeOrderNum;
|
return changeOrderNum;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new AstuteException(DB_ERROR,e.getMessage());
|
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============================== Invoice Payment ===============================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public List<InvoicePayment> getInvoicePayments(String invoiceNum) throws AstuteException {
|
||||||
|
try {
|
||||||
|
List<InvoicePayment> invoicePayments = new ArrayList<InvoicePayment>();
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
String sql = "SELECT invoice_payment_id, invoice_payment_type, get_payment_type(invoice_payment_type), invoice_amount, payment_date FROM invoice_payment ";
|
||||||
|
if (invoiceNum != null) {
|
||||||
|
sql += " WHERE inv_no = '" + invoiceNum + "'";
|
||||||
|
}
|
||||||
|
ResultSet rs = stmt.executeQuery(sql);
|
||||||
|
while (rs.next()) {
|
||||||
|
int invoicePaymentId = rs.getInt(1);
|
||||||
|
int invoicePaymentTypeId = rs.getInt(2);
|
||||||
|
String invoicePaymentType = rs.getString(3);
|
||||||
|
Double paymentAmount = rs.getDouble(4);
|
||||||
|
Date paymentDate = rs.getDate(5);
|
||||||
|
InvoicePayment invoicePayment = new InvoicePayment(invoiceNum, invoicePaymentId, invoicePaymentTypeId, invoicePaymentType, paymentDate, paymentAmount);
|
||||||
|
invoicePayments.add(invoicePayment);
|
||||||
|
}
|
||||||
|
return invoicePayments;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public void updateInvoicePayment(String invoiceNum, int invoicePaymentId, Double paymentAmount, Date paymentDate) throws AstuteException {
|
||||||
|
try {
|
||||||
|
String sql = "UPDATE INVOICE_PAYMENT ";
|
||||||
|
String updateClause = " SET ";
|
||||||
|
String whereClause = "";
|
||||||
|
if (invoiceNum == null || invoiceNum.isEmpty() || invoicePaymentId <=0 ) {
|
||||||
|
throw new AstuteException(DB_ERROR,"Invoice Number can't be null and Invoice Payment Id should be a positive number! ");
|
||||||
|
} else {
|
||||||
|
whereClause = " WHERE UPPER(inv_no) ='" + invoiceNum.toUpperCase() + "' and invoice_amount = " + paymentAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateClause = updateClause + " payment_amount = " + paymentAmount ;
|
||||||
|
if (paymentDate != null) {
|
||||||
|
updateClause = "payment_date " + ", paymentDate = STR_TO_DATE(" + paymentDate + ", '%Y-%m-%d')";
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = sql + updateClause + whereClause;
|
||||||
|
System.out.println(sql);
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
stmt.executeUpdate(sql);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createInvoicePayment(String invoiceNum, int invoicePaymentTypeId, Double paymentAmount, Date paymentDate) throws AstuteException{
|
||||||
|
try {
|
||||||
|
String dateString = "STR_TO_DATE(" + paymentDate + ", '%Y-%m-%d')";
|
||||||
|
String sql = "insert into invoice_payment (inv_no, invoice_payment_type, invoice_amount, payment_date) values ('" + invoiceNum + "', " + paymentAmount + ", " + dateString + "')";
|
||||||
|
Statement stmt = conn.createStatement();
|
||||||
|
stmt.execute(sql);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new AstuteException(DB_ERROR,e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============================== Utility Methods ===============================================
|
||||||
|
*/
|
||||||
public String login(String username, String password) throws AstuteException{
|
public String login(String username, String password) throws AstuteException{
|
||||||
User user = dao.getUser(username);
|
User user = dao.getUser(username);
|
||||||
boolean check = false;
|
boolean check = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user