From bcc9a5425cb7842cad68d0202352d43ced707a96 Mon Sep 17 00:00:00 2001 From: Gopi Katwala Date: Tue, 16 Jul 2019 16:33:27 -0400 Subject: [PATCH] * SQL - Fixed get_outstanding_balance method, fixed create_customer_contact function to have phone/fax as string * Fixed Customer contact phone/fax to be String in Web Service code --- AstuteSystem/sql/astute.sql | 14 ++++++------ .../src/main/java/com/astute/dao/DAO.java | 4 ++-- .../src/main/java/com/astute/dao/SqlDAO.java | 22 +++++++++---------- .../com/astute/model/CustomerContact.java | 20 ++++++++--------- .../requests/CustomerContactRequest.java | 20 ++++++++--------- .../service/CustomerContactService.java | 4 ++-- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/AstuteSystem/sql/astute.sql b/AstuteSystem/sql/astute.sql index fc8964f..0c7d48d 100644 --- a/AstuteSystem/sql/astute.sql +++ b/AstuteSystem/sql/astute.sql @@ -39,7 +39,7 @@ END; /*!40000 ALTER TABLE `change_order` DISABLE KEYS */; /*!40000 ALTER TABLE `change_order` ENABLE KEYS */; -CREATE FUNCTION astute.`create_customer_contact_fun`(customer_id_in varchar(20), name varchar(100), title varchar(50), work_phone int, work_phone_ext int, mobile int, fax int, email varchar(100), address varchar(500)) RETURNS varchar(20) CHARSET utf8 +CREATE FUNCTION astute.`create_customer_contact_fun`(customer_id_in varchar(20), name varchar(100), title varchar(50), work_phone varchar(20), work_phone_ext int, mobile varchar(20), fax varchar(20), email varchar(100), address varchar(500)) RETURNS varchar(20) CHARSET utf8 BEGIN DECLARE last_inserted_id varchar(20); DECLARE new_contact_id int; @@ -52,12 +52,13 @@ else SET new_contact_id = 1; end if; INSERT INTO astute.customer_contact -(customer_id, contact_id, name, title, work_phone, work_phone_ext, mobile, fax, email, address) +(customer_id, contact_id, name, title, work_phone, work_phone_ext, mobile, fax, email, address) VALUES (customer_id_in, new_contact_id, name, title, work_phone, work_phone_ext, mobile, fax, email, address); SELECT LAST_INSERT_ID() into last_inserted_id; return last_inserted_id; END; + -- Dumping structure for function astute.create_customer_fun DELIMITER // CREATE FUNCTION astute.`create_customer_fun`(customerid varchar(20), customerName varchar(100), billToDept varchar(100), add1In varchar(100), add2In varchar(100), cityIn varchar(50), stateIn varchar(20), zipIn int(5), zipLast4In int(4), emailIn varchar(50), phoneIn varchar(20), extIn int(6), faxIn varchar(20)) RETURNS varchar(20) CHARSET utf8 @@ -363,14 +364,13 @@ DELIMITER ; -- Dumping structure for function astute.get_outstanding_inv_balance DELIMITER // -CREATE DEFINER=`root`@`localhost` FUNCTION `get_outstanding_inv_balance`(invno varchar(20)) RETURNS double(10,2) +CREATE FUNCTION astute.`get_outstanding_inv_balance`(invno varchar(20)) RETURNS double(10,2) BEGIN declare outstanding_amt double(10,2); - SELECT invoice.bill_amt - sum(invoice_amount) INTO outstanding_amt + SELECT invoice.bill_amt - ifnull(sum(invoice_amount),0) INTO outstanding_amt FROM invoice join invoice_payment on invoice.inv_no = invoice_payment.inv_no - where invoice.inv_no = invno - group by invoice_payment.inv_no; - + where invoice.inv_no = invno; + return outstanding_amt; END// DELIMITER ; diff --git a/AstuteSystem/src/main/java/com/astute/dao/DAO.java b/AstuteSystem/src/main/java/com/astute/dao/DAO.java index e178aff..4cb06b3 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/DAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/DAO.java @@ -166,9 +166,9 @@ public abstract class DAO { */ public abstract List getCustomerContacts(String customerId) throws AstuteException; - public abstract String createCustomerContact(String customerId, String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) throws AstuteException; + public abstract String createCustomerContact(String customerId, String name,String title,String workPhone,int phExt,String mobile, String fax, String email, String address) throws AstuteException; - public abstract void updateCustomerContact(String customerId, int contactId, String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) throws AstuteException; + public abstract void updateCustomerContact(String customerId, int contactId, String name,String title,String workPhone,int phExt,String mobile, String fax, String email, String address) throws AstuteException; public abstract void deleteCustomerContact(String customerId, int contactId) throws AstuteException; diff --git a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java index e7d922f..87bb0fb 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java @@ -984,10 +984,10 @@ public class SqlDAO extends DAO { int contactId = rs.getInt(2); String name = rs.getString(3); String title = rs.getString(4); - int workPhone = rs.getInt(5); + String workPhone = rs.getString(5); int phoneExt = rs.getInt(6); - int mobile = rs.getInt(7); - int fax = rs.getInt(8); + String mobile = rs.getString(7); + String fax = rs.getString(8); String email = rs.getString(9); String address = rs.getString(10); CustomerContact contact = new CustomerContact(customerID, contactId, name, title, workPhone, phoneExt, mobile, fax, email, address); @@ -1000,17 +1000,17 @@ public class SqlDAO extends DAO { } } - public String createCustomerContact(String customerId, String name,String title, int workPhone,int phExt,int mobile, int fax, String email, String address) throws AstuteException { + public String createCustomerContact(String customerId, String name,String title, String workPhone,int phExt,String mobile, String fax, String email, String address) throws AstuteException { try { CallableStatement stmt = conn.prepareCall("{? = call create_customer_contact_fun(?,?,?,?,?,?,?,?,?)}"); stmt.registerOutParameter(1, Types.INTEGER); stmt.setString(2, customerId); stmt.setString(3, name); stmt.setString(4, title); - stmt.setInt(5, workPhone); + stmt.setString(5, workPhone); stmt.setInt(6, phExt); - stmt.setInt(7, mobile); - stmt.setInt(8, fax); + stmt.setString(7, mobile); + stmt.setString(8, fax); stmt.setString(9, email); stmt.setString(10, address); stmt.executeUpdate(); @@ -1021,7 +1021,7 @@ public class SqlDAO extends DAO { throw new AstuteException(DB_ERROR,e.getMessage()); } } - public void updateCustomerContact(String customerId, int contactId, String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) throws + public void updateCustomerContact(String customerId, int contactId, String name,String title,String workPhone,int phExt,String mobile, String fax, String email, String address) throws AstuteException { try { String sql = "UPDATE CUSTOMER_CONTACT "; @@ -1035,10 +1035,10 @@ public class SqlDAO extends DAO { updateClause = updateClause + " name = '" + name + "',"; updateClause = updateClause + " title = '" + title + "',"; - updateClause = updateClause + " work_phone = " + workPhone + ","; + updateClause = updateClause + " work_phone = '" + workPhone + "',"; updateClause = updateClause + " work_phone_ext = " + phExt + ","; - updateClause = updateClause + " mobile = " + mobile + ","; - updateClause = updateClause + " fax = " + fax + ","; + updateClause = updateClause + " mobile = '" + mobile + "',"; + updateClause = updateClause + " fax = '" + fax + "',"; updateClause = updateClause + " address = '" + address + "',"; updateClause = updateClause + " email = '" + email + "',"; if (!updateClause.equalsIgnoreCase(" SET ")) { diff --git a/AstuteSystem/src/main/java/com/astute/model/CustomerContact.java b/AstuteSystem/src/main/java/com/astute/model/CustomerContact.java index 1e4e579..b156805 100644 --- a/AstuteSystem/src/main/java/com/astute/model/CustomerContact.java +++ b/AstuteSystem/src/main/java/com/astute/model/CustomerContact.java @@ -5,14 +5,14 @@ public class CustomerContact { int contactId; String name; String title; - int workPhone; + String workPhone; int phExt; - int mobile; - int fax; + String mobile; + String fax; String email; String address; - public CustomerContact(String customerId,int contactId,String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) { + public CustomerContact(String customerId,int contactId,String name,String title,String workPhone,int phExt,String mobile, String fax, String email, String address) { this.customerId = customerId; this.contactId = contactId; this.name = name; @@ -57,11 +57,11 @@ public class CustomerContact { this.title = title; } - public int getWorkPhone() { + public String getWorkPhone() { return workPhone; } - public void setWorkPhone(int workPhone) { + public void setWorkPhone(String workPhone) { this.workPhone = workPhone; } @@ -73,19 +73,19 @@ public class CustomerContact { this.phExt = phExt; } - public int getMobile() { + public String getMobile() { return mobile; } - public void setMobile(int mobile) { + public void setMobile(String mobile) { this.mobile = mobile; } - public int getFax() { + public String getFax() { return fax; } - public void setFax(int fax) { + public void setFax(String fax) { this.fax = fax; } diff --git a/AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java b/AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java index 6b422d4..81ccd81 100644 --- a/AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java +++ b/AstuteSystem/src/main/java/com/astute/requests/CustomerContactRequest.java @@ -5,17 +5,17 @@ public class CustomerContactRequest { int contactId; String name; String title; - int workPhone; + String workPhone; int phExt; - int mobile; - int fax; + String mobile; + String fax; String email; String address; public CustomerContactRequest() { } - public CustomerContactRequest(String customerId,int contactId,String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) { + public CustomerContactRequest(String customerId,int contactId,String name,String title,String workPhone,int phExt,String mobile, String fax, String email, String address) { this.customerId = customerId; this.contactId = contactId; this.name = name; @@ -60,11 +60,11 @@ public class CustomerContactRequest { this.title = title; } - public int getWorkPhone() { + public String getWorkPhone() { return workPhone; } - public void setWorkPhone(int workPhone) { + public void setWorkPhone(String workPhone) { this.workPhone = workPhone; } @@ -76,19 +76,19 @@ public class CustomerContactRequest { this.phExt = phExt; } - public int getMobile() { + public String getMobile() { return mobile; } - public void setMobile(int mobile) { + public void setMobile(String mobile) { this.mobile = mobile; } - public int getFax() { + public String getFax() { return fax; } - public void setFax(int fax) { + public void setFax(String fax) { this.fax = fax; } diff --git a/AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java b/AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java index ec8a065..6de3e8b 100644 --- a/AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java +++ b/AstuteSystem/src/main/java/com/astute/service/CustomerContactService.java @@ -17,11 +17,11 @@ public class CustomerContactService extends Service{ return getDao().getCustomerContacts(customerId); } - public String createCustomerContact(String customerId, String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) throws AstuteException { + public String createCustomerContact(String customerId, String name,String title,String workPhone,int phExt,String mobile, String fax, String email, String address) throws AstuteException { return getDao().createCustomerContact(customerId, name, title, workPhone, phExt, mobile, fax, email, address); } - public void updateCustomerContact(String customerId, int contactId, String name,String title,int workPhone,int phExt,int mobile, int fax, String email, String address) throws AstuteException { + public void updateCustomerContact(String customerId, int contactId, String name,String title,String workPhone,int phExt,String mobile, String fax, String email, String address) throws AstuteException { getDao().updateCustomerContact(customerId, contactId, name,title,workPhone,phExt,mobile, fax, email, address); }