Merge remote-tracking branch 'origin/master'

This commit is contained in:
Akash Shah 2018-08-23 13:27:15 -04:00
commit b5c306a658
7 changed files with 99 additions and 69 deletions

View File

@ -94,18 +94,18 @@ CREATE TABLE IF NOT EXISTS `customer` (
`zip` int(5) DEFAULT NULL,
`zip_last_4` int(4) DEFAULT NULL,
`email` varchar(50) DEFAULT NULL,
`phone` bigint(15) DEFAULT NULL,
`fax` bigint(15) DEFAULT NULL,
`phone` varchar(20) DEFAULT NULL,
`fax` varchar(20) DEFAULT NULL,
PRIMARY KEY (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Dumping data for table astute.customer: ~3 rows (approximately)
-- Dumping data for table astute.customer: ~4 rows (approximately)
/*!40000 ALTER TABLE `customer` DISABLE KEYS */;
INSERT INTO `customer` (`customer_id`, `customer_name`, `bill_to_dept`, `add1`, `add2`, `city`, `state`, `zip`, `zip_last_4`, `email`, `phone`, `fax`) VALUES
('1', 'test4565', 'test123', 'test123', 'null', 'test123', 'md', 20874, 0, 'null', 0, 0),
('2', 'test123', 'test123', 'test123', NULL, 'test123', 'md', 20874, 0, NULL, 0, 0),
('3', 'Hampton Road Transit', 'Accounts Payable', '3400 Victoria Blvd', '', 'Hampton', 'VA', 23661, 0, 'wcollins@hrtransit.org', 7572226000, 7572226000),
('test500', 'test500', 'test500', 'test500', 'test500', 'test500', 'md', 20874, 1234, 'Test@Test.com', 1231231233, 131231233);
('1', 'test4565', 'test123', 'test123', 'null', 'test123', 'md', 20874, 0, 'null', '123-123-1233', '123-123-1233'),
('2', 'test123', 'test123', 'test123', NULL, 'test123', 'md', 20874, 0, NULL, '0', '0'),
('3', 'Hampton Road Transit', 'Accounts Payable', '3400 Victoria Blvd', '', 'Hampton', 'VA', 23661, 0, 'wcollins@hrtransit.org', '7572226000', '7572226000'),
('test500', 'test500', 'test500', 'test500', 'test500', 'test500', 'md', 20874, 1234, 'Test@Test.com', '1231231233', '131231233');
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;
-- Dumping structure for function astute.duplicate_invoice
@ -189,6 +189,21 @@ BEGIN
END//
DELIMITER ;
-- Dumping structure for function astute.get_inv_remaining_qty_fun
DELIMITER //
CREATE DEFINER=`root`@`localhost` FUNCTION `get_inv_remaining_qty_fun`(inv_num_in varchar(40), item_no_in int) RETURNS double
BEGIN
DECLARE remaining_qty double;
DECLARE po_no varchar(40);
SELECT po_num INTO po_no FROM invoice where inv_no = inv_num_in;
select po_detail.qty - sum(invoice_detail.qty) into remaining_qty from invoice_detail, po_detail
where invoice_detail.inv_num in (select inv_num from invoice where invoice.PO_num = po_no)
and invoice_detail.line_item_num = item_no_in
and invoice_detail.line_item_num = po_detail.line_item_no;
return remaining_qty;
END//
DELIMITER ;
-- Dumping structure for function astute.get_payment_type
DELIMITER //
CREATE DEFINER=`root`@`localhost` FUNCTION `get_payment_type`(pmt_type int) RETURNS varchar(20) CHARSET utf8
@ -237,7 +252,7 @@ CREATE TABLE IF NOT EXISTS `invoice` (
CONSTRAINT `fk_InvMaster_POnum` FOREIGN KEY (`PO_num`) REFERENCES `po` (`PO_num`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Dumping data for table astute.invoice: ~3 rows (approximately)
-- Dumping data for table astute.invoice: ~4 rows (approximately)
/*!40000 ALTER TABLE `invoice` DISABLE KEYS */;
INSERT INTO `invoice` (`inv_no`, `inv_date`, `PO_num`, `bill_amt`, `special_notes`, `certification`, `inv_status`, `pmt_status`) VALUES
('123', '2018-01-01', 'EP2649247', 5000, 'asdf', 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned.', 1, 1),
@ -373,15 +388,17 @@ CREATE TABLE IF NOT EXISTS `po` (
CONSTRAINT `po_customer_id_fk` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Dumping data for table astute.po: ~6 rows (approximately)
-- Dumping data for table astute.po: ~8 rows (approximately)
/*!40000 ALTER TABLE `po` DISABLE KEYS */;
INSERT INTO `po` (`PO_num`, `contract_num`, `PO_date`, `contract_amt`, `customer_id`, `astute_project_num`, `po_id`, `title`) VALUES
('EP2649247', 'test123', NULL, 30000.00, '1', 'null', 1, 'SO Dummy Title for Test123'),
('HRT-16-72046', '16-72046', NULL, 23360.00, '3', 'HRT-01-01', 1, 'SO Dummy Title for 16-72046 adding upto 200 characters ****************************'),
('ABC1234', 'ABC1234', '2018-08-23', 50000.00, '3', 'ABC1234', 2, 'new from HRT'),
('EP2649247', 'test123', '2018-08-19', 30000.00, '1', 'null', 1, 'null'),
('HRT-16-72046', '16-72046', '2018-08-07', 23360.00, '3', 'HRT-01-01', 1, 'SO Dummy Title for 16-72046 '),
('test12', 'test', '2018-07-11', 60000.00, '1', 'adf', 2, 'SO Dummy Title for test'),
('test3', 'test', '2018-07-12', 60000.00, '1', 'adf', 3, 'SO Dummy Title for test'),
('test5', 'test', '2018-07-13', 60000.00, '1', 'adf', 4, 'SO Dummy Title for test'),
('test500', 'test', NULL, 60000.00, 'Test500', 'test', 1, 'SO Dummy Title for test');
('test500', 'test', '2018-08-13', 60000.00, 'Test500', 'test', 1, 'SO Dummy Title for test'),
('test55', 'test', '2018-01-12', 60000.00, '1', 'test', 5, NULL);
/*!40000 ALTER TABLE `po` ENABLE KEYS */;
-- Dumping structure for table astute.po_detail

View File

@ -130,9 +130,9 @@ public abstract class DAO {
public abstract List<Customer> getCustomers(String customerId) throws AstuteException;
public abstract String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax) throws AstuteException;
public abstract String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax) throws AstuteException;
public abstract void updateCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax) throws AstuteException;
public abstract void updateCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax) throws AstuteException;
// User and session method implementation

View File

@ -65,7 +65,7 @@ public class SqlDAO extends DAO {
Double previouslyBilledAmount = rs.getDouble(8);
String date = null;
if (poDate != null) {
SimpleDateFormat formatter = new SimpleDateFormat("MM/DD/YYYY");
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
date = formatter.format(poDate);
}
PO po = new PO(poNum, cntrctNum, date, customerId, contractAmt,astuteProjectNum,title,previouslyBilledAmount);
@ -107,7 +107,7 @@ public class SqlDAO extends DAO {
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);
PODetail poDetail = new PODetail(poNum, lineItemNum, serviceDesc, feeTypeId, qty, fee, serviceTypeId, qty);
poDetails.add(poDetail);
}
return poDetails;
@ -156,7 +156,7 @@ public class SqlDAO extends DAO {
public void updatePODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId, Double remainingQuantity) throws AstuteException {
try {
// remainingQuantity is not used , need to take it out from signature eventually
String sql = "UPDATE PO_DETAIL ";
String updateClause = " SET ";
String whereClause = " WHERE UPPER(PO_num) = '" + POnum.toUpperCase() + "' AND line_item_no = " + lineItemNo;
@ -172,14 +172,14 @@ public class SqlDAO extends DAO {
List<PODetail> lineItem = getPODetail(POnum, lineItemNo);
if (lineItem.size() == 0) {
// new line item
createPODetail(POnum, lineItemNo, serviceDesc, feeTypeId, qty, fee, serviceTypeId, remainingQuantity);
createPODetail(POnum, lineItemNo, serviceDesc, feeTypeId, qty, fee, serviceTypeId, qty);
} else {
updateClause += " service_desc = '" + serviceDesc + "',";
updateClause += " fee_type_id = " + feeTypeId + ",";
updateClause += " qty = " + qty + ",";
updateClause += " fee = " + fee + ",";
updateClause += " service_type_id = " + serviceTypeId + ",";
updateClause += " remaining_qty = " + remainingQuantity + ",";
updateClause += " remaining_qty = get_remaining_qty_fun('" + POnum + "'," + lineItemNo + ")";
if (!updateClause.equalsIgnoreCase(" SET ")) {
sql = sql + trimLastCharacter(updateClause, ",") + whereClause;
@ -199,12 +199,12 @@ public class SqlDAO extends DAO {
public void createPOMaster(String PONum, String contractNum, String PODate, Double contractAmt, String customerId, String astuteProjectNumber, String title) throws AstuteException, ParseException {
try {
Date date= (Date) new SimpleDateFormat("yyyy/mm/dd").parse(PODate);
java.util.Date date= new SimpleDateFormat("yyyy-mm-dd").parse(PODate);
java.sql.Date poDate = new java.sql.Date(date.getTime());
CallableStatement stmt = conn.prepareCall("{call create_PO(?,?,?,?,?,?,?)}");
stmt.setString(1, PONum);
stmt.setString(2, contractNum);
stmt.setDate(3, date);
stmt.setDate(3, poDate);
stmt.setDouble(4, contractAmt);
stmt.setString(5, customerId);
stmt.setString(6, astuteProjectNumber);
@ -218,6 +218,7 @@ public class SqlDAO extends DAO {
public void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId, Double remainingQuantity) throws AstuteException {
try {
// TODO remainingQuantity not used, need to take it out from signature
System.out.println("Calling create_po_detail Procedure");
System.out.println("POnum is " + POnum);
CallableStatement stmt = conn.prepareCall("{call create_po_detail(?,?,?,?,?,?,?,?)}");
@ -228,7 +229,7 @@ public class SqlDAO extends DAO {
stmt.setDouble(5, qty);
stmt.setDouble(6, fee);
stmt.setInt(7, serviceTypeId);
stmt.setDouble(8, remainingQuantity);
stmt.setDouble(8, qty);
stmt.executeUpdate();
} catch (SQLException e) {
@ -400,34 +401,44 @@ public class SqlDAO extends DAO {
}
}
public void updateRemainingQty(String poNum, int lineItemNo) throws AstuteException {
try {
String sql = " UPDATE PO SET remaining_qty = get_remaining_qty_fun('" + poNum + "'," + lineItemNo + ")";
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 updateInvRemainingQty(String invNum, int poLineItemNo) throws AstuteException {
try {
String sql = " UPDATE PO SET remaining_qty = get_inv_remaining_qty_fun('" + invNum + "'," + poLineItemNo + ")";
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 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 ";
String updateClause = " SET ";
String whereClause = "";
if(invoiceNum == null || invoiceNum.isEmpty() || lineItemNum < 0) {
throw new AstuteException(0, "PO Number should not be null and line item number must be greater than 0.");
throw new AstuteException(0, "Invoice Number should not be null and line item number must be greater than 0.");
} else {
whereClause = " WHERE UPPER(inv_num) = '" + invoiceNum.toUpperCase() + "' AND line_item_num = " + lineItemNum;
}
if(POLineItemNum >0) {
updateClause += " PO_line_item_num = " + POLineItemNum + ",";
}
if(serviceTypeId >0) {
updateClause += " service_type_id = " + serviceTypeId + ",";
}
if(desc != null && !desc.isEmpty()) {
updateClause += " description = '" + desc + "',";
}
if(qty >0) {
updateClause += " qty = " + qty + ",";
}
if(fee > 0) {
updateClause += " fee = " + fee + ",";
}
if(feeTypeId > 0) {
updateClause += " fee_type_id = " + feeTypeId + ",";
}
updateClause += " service_type_id = " + serviceTypeId + ",";
updateClause += " description = '" + desc + "',";
updateClause += " qty = " + qty + ",";
updateClause += " fee = " + fee + ",";
updateClause += " fee_type_id = " + feeTypeId + ",";
if (!updateClause.equalsIgnoreCase(" SET ")) {
sql = sql + trimLastCharacter(updateClause,",") + whereClause;
@ -437,6 +448,7 @@ public class SqlDAO extends DAO {
System.out.println(sql);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
updateInvRemainingQty(invoiceNum, POLineItemNum);
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
@ -477,6 +489,7 @@ public class SqlDAO extends DAO {
stmt.setDouble(7, fee);
stmt.setInt(8, feeTypeId);
stmt.executeUpdate();
updateInvRemainingQty(invoiceNum, POLineItemNum);
} catch (SQLException e) {
e.printStackTrace();
throw new AstuteException(DB_ERROR,e.getMessage());
@ -488,7 +501,7 @@ 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 = 2 WHERE UPPER(INV_NO) = 'UPPER(" + InvoiceNumber + ")'";
String sql = "UPDATE INVOICE SET INV_STATUS = 2 WHERE UPPER(INV_NO) = 'UPPER('" + InvoiceNumber + "')";
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
@ -503,7 +516,7 @@ 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 + "')";
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
@ -551,8 +564,8 @@ public class SqlDAO extends DAO {
int zip = rs.getInt(8);
int ziplast4 = rs.getInt(9);
String email = rs.getString(10);
Long phone = rs.getLong(11);
Long fax = rs.getLong(12);
String phone = rs.getString(11);
String fax = rs.getString(12);
Customer customer = new Customer(customerID, customerName,billToDept, add1, add2, city, state, zip, ziplast4, email, phone, fax);
customers.add(customer);
}
@ -563,7 +576,7 @@ public class SqlDAO extends DAO {
}
}
public String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax) throws AstuteException {
public String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax) throws AstuteException {
try {
CallableStatement stmt = conn.prepareCall("{? = call create_customer_fun(?,?,?,?,?,?,?,?,?,?,?,?)}");
stmt.registerOutParameter(1, Types.INTEGER);
@ -577,8 +590,8 @@ public class SqlDAO extends DAO {
stmt.setInt(9, zip);
stmt.setInt(10, ziplast4);
stmt.setString(11, email);
stmt.setLong(12, phone);
stmt.setLong(13, fax);
stmt.setString(12, phone);
stmt.setString(13, fax);
stmt.executeUpdate();
String customerIdOut = stmt.getString(1);
return customerIdOut;
@ -588,7 +601,7 @@ public class SqlDAO extends DAO {
}
}
public void updateCustomer( String customerId, String customerName, String billToDept, String add1, String
add2, String city, String state, int zip, int ziplast4, String email,Long phone, Long fax) throws
add2, String city, String state, int zip, int ziplast4, String email,String phone, String fax) throws
AstuteException {
try {
String sql = "UPDATE CUSTOMER ";
@ -609,8 +622,8 @@ public class SqlDAO extends DAO {
updateClause = updateClause + " zip = " + zip + ",";
updateClause = updateClause + " zip_last_4 = " + ziplast4 + ",";
updateClause = updateClause + " email = '" + email + "',";
updateClause = updateClause + " phone = " + phone + ",";
updateClause = updateClause + " fax = " + fax + ",";
updateClause = updateClause + " phone = '" + phone + "',";
updateClause = updateClause + " fax = '" + fax + "',";
if (!updateClause.equalsIgnoreCase(" SET ")) {
sql = sql + trimLastCharacter(updateClause, ",") + whereClause;

View File

@ -13,10 +13,10 @@ public class Customer {
int zip;
int ziplast4;
String email;
Long phone;
Long fax;
String phone;
String fax;
public Customer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax) {
public Customer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax) {
this.customerId = customerId;
this.customerName = customerName;
this.billToDept = billToDept;
@ -111,19 +111,19 @@ public class Customer {
this.email = email;
}
public Long getPhone() {
public String getPhone() {
return phone;
}
public void setPhone(Long phone) {
public void setPhone(String phone) {
this.phone = phone;
}
public Long getFax() {
public String getFax() {
return fax;
}
public void setFax(Long fax) {
public void setFax(String fax) {
this.fax = fax;
}
}

View File

@ -13,8 +13,8 @@ public class CustomerRequest {
int zip;
int ziplast4;
String email;
Long phone;
Long fax;
String phone;
String fax;
public String getCustomerId() {
return customerId;
@ -96,19 +96,19 @@ public class CustomerRequest {
this.email = email;
}
public Long getPhone() {
public String getPhone() {
return phone;
}
public void setPhone(Long phone) {
public void setPhone(String phone) {
this.phone = phone;
}
public Long getFax() {
public String getFax() {
return fax;
}
public void setFax(Long fax) {
public void setFax(String fax) {
this.fax = fax;
}
}

View File

@ -17,13 +17,13 @@ public class AuthService extends Service{
return getDao().login(username,password);
}
public void updateCustomer( String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax)
public void updateCustomer( String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax)
throws AstuteException {
getDao().updateCustomer(customerId, customerName,billToDept, add1, add2, city, state, zip, ziplast4, email, phone, fax);
}
public void createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax)
public void createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax)
throws AstuteException {
getDao().createCustomer(customerId, customerName,billToDept, add1, add2, city, state, zip, ziplast4, email, phone, fax);
}

View File

@ -18,13 +18,13 @@ public class CustomerService extends Service{
return getDao().getCustomers(customerId);
}
public void updateCustomer( String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax)
public void updateCustomer( String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax)
throws AstuteException {
getDao().updateCustomer(customerId, customerName,billToDept, add1, add2, city, state, zip, ziplast4, email, phone, fax);
}
public String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, Long phone, Long fax)
public String createCustomer(String customerId, String customerName, String billToDept, String add1, String add2, String city, String state, int zip, int ziplast4, String email, String phone, String fax)
throws AstuteException {
return getDao().createCustomer(customerId, customerName,billToDept, add1, add2, city, state, zip, ziplast4, email, phone, fax);
}