From dbb904d7c227109d8ae103c61123d2de79766928 Mon Sep 17 00:00:00 2001 From: gopi17701 Date: Fri, 5 Apr 2019 14:38:59 -0400 Subject: [PATCH 1/2] Bug fixes --- .../src/app/customer/customer.component.ts | 49 +- .../app/invoice-gen/invoice-gen.component.ts | 2 +- .../src/app/nav-bar/nav-bar.component.html | 69 ++- .../src/app/nav-bar/nav-bar.component.ts | 40 +- .../sales-order/sales-order.component.html | 4 +- .../app/sales-order/sales-order.component.ts | 29 +- .../src/app/services/astute-client-service.ts | 19 +- AstuteSystem/sql/astute_old.sql | 586 ++++++++++++++++++ .../src/main/java/com/astute/dao/DAO.java | 6 +- .../src/main/java/com/astute/dao/SqlDAO.java | 24 + .../java/com/astute/resources/POResource.java | 16 + .../java/com/astute/service/POService.java | 8 + AstuteSystem/src/main/resources/db.config | 6 + 13 files changed, 782 insertions(+), 76 deletions(-) create mode 100644 AstuteSystem/sql/astute_old.sql create mode 100644 AstuteSystem/src/main/resources/db.config diff --git a/AstuteClient2/src/app/customer/customer.component.ts b/AstuteClient2/src/app/customer/customer.component.ts index 174369b..d28ef46 100644 --- a/AstuteClient2/src/app/customer/customer.component.ts +++ b/AstuteClient2/src/app/customer/customer.component.ts @@ -99,6 +99,13 @@ export class CustomerComponent implements OnInit { // inName.value, inBillToDept.value, inAdd1.value, inAdd2.value, inCity.value, inState.value, inZIP.value, inZIP4.value, inEmail.value, inPhone.value, inFax.value addCustomer(customerId, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) { + if (fax.length > 0 && fax.length < 14) { + alert('Invalid fax.'); + } else if (phone.length > 0 && phone.length < 14) { + alert('Invalid phone.'); + } else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) == false) { + alert("You have entered an invalid email address!") + } else { let customerData = { "customerId": customerId, "customerName": name, @@ -124,25 +131,33 @@ export class CustomerComponent implements OnInit { }, (reason) => { alert("add customer failed for " + reason); }); - } + }} editCustomer(id, name, billTo, add1, add2, city, state, zip, zip4, email, phone, phExt, fax, ref) { - const customerData = { - "customerId": id, - "customerName": name, - "billToDept": billTo, - "add1": add1, - "add2": add2, - "city": city, - "state": state, - "zip": zip, - "ziplast4": zip4, - "email": email, - "phone": phone, - "phExt": phExt, - "fax": fax - }; + if (fax.length > 0 && fax.length < 14) { + alert('Invalid fax.'); + } else if (phone.length > 0 && phone.length < 14) { + alert('Invalid phone.'); + } else if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email) == false) { + alert("You have entered an invalid email address!") + } else { + const customerData = { + "customerId": id, + "customerName": name, + "billToDept": billTo, + "add1": add1, + "add2": add2, + "city": city, + "state": state, + "zip": zip, + "ziplast4": zip4, + "email": email, + "phone": phone, + "phExt": phExt, + "fax": fax + }; + this.astuteClientService.updateCustomer(id, customerData).then((data) => { if (data) { this.refreshData(); @@ -153,7 +168,7 @@ export class CustomerComponent implements OnInit { }, (reason) => { alert("update customer failed for " + reason); }); - } + }} deleteCustomer (customerId) { if (confirm('Are you sure you want to delete customer, ' + customerId)) { diff --git a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts index 9d141d9..492d760 100644 --- a/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts +++ b/AstuteClient2/src/app/invoice-gen/invoice-gen.component.ts @@ -59,7 +59,7 @@ export class InvoiceGenComponent implements OnInit { this.gridY[j] = y; y += 10; } - this.astuteClientService.getInvoiceGen('MDO-01_DRAFT_720').then((data) => { + this.astuteClientService.getInvoiceGen('VDO-02_0108_3').then((data) => { this.name = data.customer.customerName; this.email = data.customer.email; this.address = data.customer.add1 + ' ' + data.customer.add2 + ' ' + diff --git a/AstuteClient2/src/app/nav-bar/nav-bar.component.html b/AstuteClient2/src/app/nav-bar/nav-bar.component.html index 42b86e1..d08bef8 100644 --- a/AstuteClient2/src/app/nav-bar/nav-bar.component.html +++ b/AstuteClient2/src/app/nav-bar/nav-bar.component.html @@ -1,34 +1,35 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/AstuteClient2/src/app/nav-bar/nav-bar.component.ts b/AstuteClient2/src/app/nav-bar/nav-bar.component.ts index cf97637..490d460 100644 --- a/AstuteClient2/src/app/nav-bar/nav-bar.component.ts +++ b/AstuteClient2/src/app/nav-bar/nav-bar.component.ts @@ -1,19 +1,21 @@ -import {Component, Input, OnInit} from '@angular/core'; - -@Component({ - selector: 'app-nav-bar', - templateUrl: './nav-bar.component.html', - styleUrls: ['./nav-bar.component.css'] -}) -export class NavBarComponent implements OnInit { - @Input() customerActive: boolean; - @Input() salesOrderActive: boolean; - @Input() invoiceActive: boolean; - @Input() invoicePaymentActive: boolean; - - constructor() { } - - ngOnInit() { - } - -} +import {Component, Input, OnInit} from '@angular/core'; + +@Component({ + selector: 'app-nav-bar', + templateUrl: './nav-bar.component.html', + styleUrls: ['./nav-bar.component.css'] +}) +export class NavBarComponent implements OnInit { + @Input() customerActive: boolean; + @Input() salesOrderActive: boolean; + @Input() invoiceActive: boolean; + @Input() invoicePaymentActive: boolean; + @Input() logoffActive: boolean; + + + constructor() { } + + ngOnInit() { + } + +} diff --git a/AstuteClient2/src/app/sales-order/sales-order.component.html b/AstuteClient2/src/app/sales-order/sales-order.component.html index bd1035a..bec6264 100644 --- a/AstuteClient2/src/app/sales-order/sales-order.component.html +++ b/AstuteClient2/src/app/sales-order/sales-order.component.html @@ -23,10 +23,10 @@
- +
- +
diff --git a/AstuteClient2/src/app/sales-order/sales-order.component.ts b/AstuteClient2/src/app/sales-order/sales-order.component.ts index 1661fda..9e225de 100644 --- a/AstuteClient2/src/app/sales-order/sales-order.component.ts +++ b/AstuteClient2/src/app/sales-order/sales-order.component.ts @@ -45,11 +45,16 @@ export class SalesOrderComponent implements OnInit { } }); } - printValue(val) { console.log(val); } + gridOptions = { + onRowClicked: (event) => { + this.getSelectedRows(); + } + } + addPo(projNum, ponum, podate, customerid, contractnum, contractamt, title, notes, ref) { const poData = { "astuteProjectNumber": projNum, @@ -131,6 +136,28 @@ export class SalesOrderComponent implements OnInit { } } + + finalizePO(ponum) { + this.astuteClientService.finalizePO(ponum).then((data) => { + if (data) { + this.refreshData(); + alert("PO is now final and ready to be used, you can't delete it anymore!"); + } else { + alert("Finalizing PO failed, check input fields"); + } + }); + } + + deletePO(ponum) { + this.astuteClientService.deletePO(ponum).then((data) => { + if (data) { + this.refreshData(); + } else { + alert("deleting PO failed, check input fields"); + } + }); + } + pushOntoSelectedDetail(lineItemNo: number, ponum, serviceDesc, feeTypeId, serviceTypeId, qty, fee, remainingQty) { this.selectedPODetail.push({ 'lineItemNo': lineItemNo, diff --git a/AstuteClient2/src/app/services/astute-client-service.ts b/AstuteClient2/src/app/services/astute-client-service.ts index b377660..dcc8bfc 100644 --- a/AstuteClient2/src/app/services/astute-client-service.ts +++ b/AstuteClient2/src/app/services/astute-client-service.ts @@ -181,7 +181,24 @@ export class AstuteClientService { .then(response => response['entity']); } - // **************************************** Invoice Service methods + public finalizePO(ponum: string){ + console.log("*** In finalizePO()"); + const url = `${this.POUrl}/${ponum}/finalize`; //TODO send sessionId + return this.http.put(url, {}) + .toPromise() + .then(response => response['entity']); + } + + + public deletePO(ponum: string) { + console.log("*** In deletePO()"); + const url = `${this.POUrl}/${ponum}/delete`; //TODO send sessionId + return this.http.put(url, {}) + .toPromise() + .then(response => response['entity']); + } + + // **************************************** Invoice Service methods // /{InvoiceNumber}/void public submitInvoice (invoiceNumber) { diff --git a/AstuteSystem/sql/astute_old.sql b/AstuteSystem/sql/astute_old.sql new file mode 100644 index 0000000..f8af852 --- /dev/null +++ b/AstuteSystem/sql/astute_old.sql @@ -0,0 +1,586 @@ +-- -------------------------------------------------------- +-- Host: 127.0.0.1 +-- Server version: 5.7.12-log - MySQL Community Server (GPL) +-- Server OS: Win64 +-- HeidiSQL Version: 9.4.0.5125 +-- -------------------------------------------------------- + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET NAMES utf8 */; +/*!50503 SET NAMES utf8mb4 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; + + +-- Dumping database structure for astute +DROP DATABASE IF EXISTS `astute`; +CREATE DATABASE IF NOT EXISTS `astute` /*!40100 DEFAULT CHARACTER SET utf8 */; +USE `astute`; + +-- Dumping structure for table astute.change_order +CREATE TABLE IF NOT EXISTS `change_order` ( + `PO_num` varchar(20) NOT NULL, + `change_order_num` int(20) NOT NULL, + `change_order_date` date DEFAULT NULL, + `change_order_amt` double NOT NULL, + `description` varchar(500) DEFAULT NULL, + PRIMARY KEY (`PO_num`,`change_order_num`), + CONSTRAINT `fk_PO_CO_POnum` FOREIGN KEY (`PO_num`) REFERENCES `po` (`PO_num`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.change_order: ~0 rows (approximately) +/*!40000 ALTER TABLE `change_order` DISABLE KEYS */; +/*!40000 ALTER TABLE `change_order` ENABLE KEYS */; + +-- Dumping structure for function astute.create_customer_fun +DELIMITER // +CREATE DEFINER=`root`@`localhost` FUNCTION `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), faxIn varchar(20)) RETURNS varchar(20) CHARSET utf8 +BEGIN +DECLARE last_inserted_id varchar(20); +INSERT INTO customer (customer_id, customer_name, bill_to_dept, add1, add2, city, state ,zip, zip_last_4, email, phone, fax) +VALUES (customerid, customerName, billToDept, add1In, add2In, cityIn, stateIn, zipIn, ziplast4In, emailIn, phoneIn, faxIn); +SELECT LAST_INSERT_ID() into last_inserted_id; +return last_inserted_id; +END// +DELIMITER ; + +-- Dumping structure for procedure astute.create_invoice +DELIMITER // +CREATE DEFINER=`root`@`localhost` PROCEDURE `create_invoice`(invNo varchar(20),invDate date,PONo varchar(20),paymentStatus int,billAmt double,specialNotes varchar(500), certClause Varchar(500), invoiceStatus int) +BEGIN +INSERT INTO invoice (inv_no,inv_date,PO_num,pmt_status,bill_amt,special_notes,certification,inv_status) +VALUES (invNo, invDate, PONo, paymentStatus, billAmt, specialNotes, certClause, invoiceStatus); +END// +DELIMITER ; + +-- Dumping structure for procedure astute.create_invoice_detail +DELIMITER // +CREATE DEFINER=`root`@`localhost` PROCEDURE `create_invoice_detail`(invoiceNum varchar(20), lineItemNum int, POLineItemNum varchar(20), serviceTypeId int, description varchar(500), qty_in double, fee_in double, fee_type_id_in int) +BEGIN +INSERT INTO INVOICE_DETAIL (inv_num, line_item_num, PO_line_item_num, service_type_id, description, qty, fee, fee_type_id) +VALUES (invoiceNum, lineItemNum, POLineItemNum, serviceTypeId, description, qty_in, fee_in, fee_type_id_in); +END// +DELIMITER ; + +-- Dumping structure for procedure astute.create_po +DELIMITER // +CREATE DEFINER=`root`@`localhost` PROCEDURE `create_po`(PONum varchar(40), contractNum varchar(20), PODate date, contractAmt double(10,2), customerid varchar(20), astute_project_num_in varchar(20), title_in varchar(200)) +BEGIN +DECLARE next_po_id int(11); +SELECT count(*) + 1 INTO next_po_id FROM PO WHERE customer_id = customerid; +INSERT INTO PO (po_id, PO_num, contract_num, PO_date, contract_amt, customer_id,astute_project_num, title ) +VALUES (next_po_id, PONum, contractNum, PODate, contractAmt, customerId,astute_project_num_in, title_in); +END// +DELIMITER ; + +-- Dumping structure for procedure astute.create_po_detail +DELIMITER // +CREATE DEFINER=`root`@`localhost` PROCEDURE `create_po_detail`(PONum varchar(40), lineItemNo int, servicedesc varchar(500), feetypeid int(11), quantity double, fee_in double, servicetypeid int(1), remaining_qty double) +BEGIN +INSERT INTO PO_DETAIL (PO_num,line_item_no,service_desc,fee_type_id,qty,fee,service_type_id, remaining_qty) +VALUES (POnum,lineitemno,servicedesc,feetypeid,quantity,fee_in, servicetypeid, remaining_qty); +END// +DELIMITER ; + +-- Dumping structure for table astute.customer +CREATE TABLE IF NOT EXISTS `customer` ( + `customer_id` varchar(10) NOT NULL, + `customer_name` varchar(100) DEFAULT NULL, + `bill_to_dept` varchar(50) DEFAULT NULL, + `add1` varchar(50) DEFAULT NULL, + `add2` varchar(50) DEFAULT NULL, + `city` varchar(50) DEFAULT NULL, + `state` varchar(2) DEFAULT NULL, + `zip` int(5) DEFAULT NULL, + `zip_last_4` int(4) DEFAULT NULL, + `email` varchar(50) 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: ~0 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 + ('VDOT', 'Virginia Depart of Transportation', 'Billing Department', '13134 Saturn Drive', 'Unit 100', 'McLean', 'VA', 22043, 0, 'Billing@vdot.gov', '(703) 122-1234', '(703) 122-1212'); +/*!40000 ALTER TABLE `customer` ENABLE KEYS */; + +-- Dumping structure for function astute.delete_invoice +DELIMITER // +CREATE DEFINER=`root`@`localhost` FUNCTION `delete_invoice`(inv_no_in varchar(20)) RETURNS varchar(40) CHARSET utf8 +BEGIN + + DECLARE inv_status_in int; + + SELECT inv_status + INTO inv_status_in + FROM invoice + WHERE inv_no = inv_no_in; + + IF inv_status_in <> 1 THEN + RETURN 'ERROR - ONLY DRAFT INVOICE CAN BE DELETED'; + END IF; + + UPDATE INVOICE_DETAIL SET QTY = 0 WHERE inv_num = inv_no_in; + CALL update_all_remaining_quantities(inv_no_in); + DELETE FROM INVOICE WHERE inv_no = inv_no_in; + + RETURN 'SUCCESS'; + +END// +DELIMITER ; + +-- Dumping structure for function astute.duplicate_invoice +DELIMITER // +CREATE DEFINER=`root`@`localhost` FUNCTION `duplicate_invoice`(inv_no_in varchar(20)) RETURNS varchar(20) CHARSET utf8 +BEGIN + DECLARE generated_inv_number varchar(20); + DECLARE po_num_in varchar(20); + + SELECT po_num + INTO po_num_in + FROM invoice + WHERE inv_no = inv_no_in; + + SELECT generate_inv_number(po_num_in) + INTO generated_inv_number; + + INSERT INTO invoice + (inv_no,inv_date,PO_num,change_order_num,bill_amt,special_notes,certification,inv_status,pmt_status) + (SELECT generated_inv_number, CURDATE(), PO_num, change_order_num, bill_amt, special_notes, certification, inv_status, pmt_status + FROM invoice + WHERE inv_no = inv_no_in); + + INSERT INTO invoice_detail + (inv_num,line_item_num,PO_line_item_num,service_type_id,description,qty,fee,fee_type_id) + (SELECT generated_inv_number, line_item_num, PO_line_item_num, service_type_id, description, 0, fee, fee_type_id + FROM invoice_detail + WHERE inv_num = inv_no_in); + + return generated_inv_number; + +END// +DELIMITER ; + +-- Dumping structure for table astute.fee_type +CREATE TABLE IF NOT EXISTS `fee_type` ( + `fee_type_id` int(11) NOT NULL, + `fee_type_desc` varchar(40) NOT NULL, + PRIMARY KEY (`fee_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.fee_type: ~2 rows (approximately) +/*!40000 ALTER TABLE `fee_type` DISABLE KEYS */; +INSERT INTO `fee_type` (`fee_type_id`, `fee_type_desc`) VALUES + (1, 'Fixed fee'), + (2, 'Hourly'); +/*!40000 ALTER TABLE `fee_type` ENABLE KEYS */; + +-- Dumping structure for function astute.generate_final_inv_number +DELIMITER // +CREATE DEFINER=`root`@`localhost` FUNCTION `generate_final_inv_number`(po_num_in varchar(20)) RETURNS varchar(40) CHARSET utf8 +BEGIN + DECLARE customer_id_in int; + DECLARE customer_code varchar(4); + DECLARE po_count int; + DECLARE inv_count int; + DECLARE inv_number varchar(40); + + SELECT customer_id + INTO customer_id_in + FROM po + WHERE po.po_num = po_num_in; + + SELECT substr(customer.customer_id, 1, 3) + INTO customer_code + FROM customer + WHERE customer_id = customer_id_in; + + SELECT po_id + INTO po_count + FROM po + WHERE PO_num = po_num_in; + + SELECT inv_seq+1 + INTO inv_count + FROM po + WHERE po.PO_num = po_num_in; + + SELECT concat(customer_code, '-',LPAD(po_count, 2, '0'), '_', date_format(now(),'%m%d'),'_',inv_count) INTO inv_number; + RETURN inv_number; + +END// +DELIMITER ; + +-- Dumping structure for function astute.generate_inv_number +DELIMITER // +CREATE DEFINER=`root`@`localhost` FUNCTION `generate_inv_number`(po_num_in varchar(20)) RETURNS varchar(40) CHARSET utf8 +BEGIN + DECLARE customer_id_in varchar(20); + DECLARE customer_code varchar(4); + DECLARE po_count int; + DECLARE inv_count int; + DECLARE inv_number varchar(40); + + SELECT customer_id + INTO customer_id_in + FROM po + WHERE po.po_num = po_num_in; + + SELECT substr(customer.customer_id, 1, 3) + INTO customer_code + FROM customer + WHERE customer_id = customer_id_in; + + SELECT po_id + INTO po_count + FROM po + WHERE PO_num = po_num_in; + + SELECT inv_seq + 1 + INTO inv_count + FROM PO + WHERE PO.PO_num = po_num_in; + + SELECT concat(customer_code, '-',LPAD(po_count, 2, '0'), '_DRAFT_',FLOOR(RAND()*(999))) INTO inv_number; + RETURN inv_number; + +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 +BEGIN + declare payment_type VARCHAR(20); + SELECT payment_type_name INTO payment_type FROM payment_type WHERE payment_type_id = pmt_type; + return payment_type; +END// +DELIMITER ; + +-- Dumping structure for function astute.get_previously_billed_amt +DELIMITER // +CREATE DEFINER=`root`@`localhost` FUNCTION `get_previously_billed_amt`(po_no varchar(20)) RETURNS double(10,2) +BEGIN + declare billed_amt double(10,2); + SELECT sum(bill_amt) INTO billed_amt FROM invoice WHERE invoice.PO_num = po_no; + return billed_amt; +END// +DELIMITER ; + +-- Dumping structure for table astute.invoice +CREATE TABLE IF NOT EXISTS `invoice` ( + `inv_no` varchar(20) NOT NULL, + `inv_date` date NOT NULL, + `PO_num` varchar(40) NOT NULL, + `bill_amt` double NOT NULL, + `special_notes` varchar(500) DEFAULT NULL, + `certification` varchar(500) DEFAULT 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned.', + `inv_status` int(2) DEFAULT '1', + `pmt_status` int(11) NOT NULL DEFAULT '1', + PRIMARY KEY (`inv_no`), + KEY `fk_InvMaster_POnum` (`PO_num`), + CONSTRAINT `fk_InvMaster_POnum` FOREIGN KEY (`PO_num`) REFERENCES `po` (`PO_num`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.invoice: ~2 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 + ('VDO-01_0927_1', '2018-09-23', 'VDOT-54321', 5000, 'First invoice', 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned', 2, 0), + ('VDO-02_DRAFT_392', '2018-09-23', 'ABC-123', 500, 'First Invoice', 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned', 1, 0); +/*!40000 ALTER TABLE `invoice` ENABLE KEYS */; + +-- Dumping structure for table astute.invoice_detail +CREATE TABLE IF NOT EXISTS `invoice_detail` ( + `inv_num` varchar(20) NOT NULL, + `line_item_num` int(11) NOT NULL, + `PO_line_item_num` int(11) DEFAULT NULL, + `service_type_id` int(11) DEFAULT NULL, + `description` varchar(500) DEFAULT NULL, + `qty` double DEFAULT NULL, + `fee` double DEFAULT NULL, + `fee_type_id` int(11) DEFAULT NULL, + PRIMARY KEY (`inv_num`,`line_item_num`), + KEY `fk_InvDetail_FeeType` (`fee_type_id`), + CONSTRAINT `fk_InvDetail_FeeType` FOREIGN KEY (`fee_type_id`) REFERENCES `fee_type` (`fee_type_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_InvDetail_InvNum` FOREIGN KEY (`inv_num`) REFERENCES `invoice` (`inv_no`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.invoice_detail: ~4 rows (approximately) +/*!40000 ALTER TABLE `invoice_detail` DISABLE KEYS */; +INSERT INTO `invoice_detail` (`inv_num`, `line_item_num`, `PO_line_item_num`, `service_type_id`, `description`, `qty`, `fee`, `fee_type_id`) VALUES + ('VDO-01_0927_1', 1, 1, 1, 'Study existing designs', 0, 1000, 1), + ('VDO-01_0927_1', 2, 4, 3, 'Peer Review', 50, 100, 2), + ('VDO-02_DRAFT_392', 1, 1, 2, 'Design', 0, 5000, 1), + ('VDO-02_DRAFT_392', 2, -1, 1, 'Out of Pocket Expenses', 50, 10, 1); +/*!40000 ALTER TABLE `invoice_detail` ENABLE KEYS */; + +-- Dumping structure for table astute.invoice_notes +CREATE TABLE IF NOT EXISTS `invoice_notes` ( + `inv_no` varchar(20) NOT NULL, + `inv_note` varchar(500) NOT NULL, + PRIMARY KEY (`inv_no`), + CONSTRAINT `fk_inv_notes_inv_no` FOREIGN KEY (`inv_no`) REFERENCES `invoice` (`inv_no`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.invoice_notes: ~0 rows (approximately) +/*!40000 ALTER TABLE `invoice_notes` DISABLE KEYS */; +/*!40000 ALTER TABLE `invoice_notes` ENABLE KEYS */; + +-- Dumping structure for table astute.invoice_payment +CREATE TABLE IF NOT EXISTS `invoice_payment` ( + `inv_no` varchar(20) NOT NULL, + `invoice_payment_type` int(11) NOT NULL, + `invoice_amount` double NOT NULL, + `payment_date` date NOT NULL, + `invoice_payment_id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(50) DEFAULT NULL, + PRIMARY KEY (`invoice_payment_id`), + KEY `fk_inv_pmt_inv_no` (`inv_no`), + KEY `fk_pinv_pmt_type` (`invoice_payment_type`), + CONSTRAINT `fk_inv_pmt_inv_no` FOREIGN KEY (`inv_no`) REFERENCES `invoice` (`inv_no`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `fk_pinv_pmt_type` FOREIGN KEY (`invoice_payment_type`) REFERENCES `payment_type` (`payment_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.invoice_payment: ~6 rows (approximately) +/*!40000 ALTER TABLE `invoice_payment` DISABLE KEYS */; +INSERT INTO `invoice_payment` (`inv_no`, `invoice_payment_type`, `invoice_amount`, `payment_date`, `invoice_payment_id`, `description`) VALUES + ('VDO-01_0927_1', 2, 900, '2018-09-29', 1, 'VDO-01_0927_1 FIrst Payment'), + ('VDO-01_0927_1', 2, 980, '2018-09-27', 2, NULL), + ('VDO-01_0927_1', 2, 1000, '2018-09-27', 3, NULL), + ('VDO-01_0927_1', 2, 1000, '2018-09-27', 4, NULL), + ('VDO-01_0927_1', 2, 1000, '2018-09-27', 5, NULL), + ('VDO-01_0927_1', 2, 200, '2018-09-28', 12, NULL); +/*!40000 ALTER TABLE `invoice_payment` ENABLE KEYS */; + +-- Dumping structure for table astute.invoice_status +CREATE TABLE IF NOT EXISTS `invoice_status` ( + `inv_status_id` int(11) NOT NULL, + `inv_status_desc` varchar(20) NOT NULL, + PRIMARY KEY (`inv_status_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.invoice_status: ~3 rows (approximately) +/*!40000 ALTER TABLE `invoice_status` DISABLE KEYS */; +INSERT INTO `invoice_status` (`inv_status_id`, `inv_status_desc`) VALUES + (1, 'Draft'), + (2, 'Submitted'), + (3, 'Void'); +/*!40000 ALTER TABLE `invoice_status` ENABLE KEYS */; + +-- Dumping structure for table astute.payment_status +CREATE TABLE IF NOT EXISTS `payment_status` ( + `payment_status_id` int(11) NOT NULL, + `payment_status_desc` varchar(20) NOT NULL, + PRIMARY KEY (`payment_status_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.payment_status: ~3 rows (approximately) +/*!40000 ALTER TABLE `payment_status` DISABLE KEYS */; +INSERT INTO `payment_status` (`payment_status_id`, `payment_status_desc`) VALUES + (1, 'Outstanding'), + (2, 'Partially paid'), + (3, 'Paid'); +/*!40000 ALTER TABLE `payment_status` ENABLE KEYS */; + +-- Dumping structure for table astute.payment_type +CREATE TABLE IF NOT EXISTS `payment_type` ( + `payment_type_id` int(11) NOT NULL, + `payment_type_name` varchar(20) NOT NULL, + PRIMARY KEY (`payment_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.payment_type: ~3 rows (approximately) +/*!40000 ALTER TABLE `payment_type` DISABLE KEYS */; +INSERT INTO `payment_type` (`payment_type_id`, `payment_type_name`) VALUES + (1, 'Credit Card'), + (2, 'Check'), + (3, 'ACH'); +/*!40000 ALTER TABLE `payment_type` ENABLE KEYS */; + +-- Dumping structure for table astute.po +CREATE TABLE IF NOT EXISTS `po` ( + `PO_num` varchar(40) NOT NULL COMMENT 'Alpha numeric, auto generated in frontend', + `contract_num` varchar(20) DEFAULT NULL, + `PO_date` date DEFAULT NULL, + `contract_amt` double(10,2) DEFAULT NULL, + `customer_id` varchar(11) NOT NULL, + `astute_project_num` varchar(20) NOT NULL, + `po_id` int(11) NOT NULL, + `title` varchar(200) DEFAULT NULL, + `inv_seq` int(3) NOT NULL DEFAULT '0', + PRIMARY KEY (`PO_num`), + KEY `ind_pomaster_contractno` (`contract_num`), + KEY `ind_pomaster_podate` (`PO_date`), + KEY `po_customer_id` (`customer_id`), + CONSTRAINT `po_customer_id_fk` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.po: ~2 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`, `inv_seq`) VALUES + ('ABC-123', 'ABC-123', '2018-09-23', 5000.00, 'VDOT', 'ABC-123', 2, 'ABC-123', 0), + ('VDOT-54321', 'VDOT-54321', '2018-09-22', 10000.00, 'VDOT', 'VDOTProj', 1, 'Supervisor', 1); +/*!40000 ALTER TABLE `po` ENABLE KEYS */; + +-- Dumping structure for table astute.po_detail +CREATE TABLE IF NOT EXISTS `po_detail` ( + `PO_num` varchar(40) NOT NULL, + `line_item_no` int(11) NOT NULL, + `service_desc` varchar(500) DEFAULT NULL, + `fee_type_id` int(11) DEFAULT '1' COMMENT '1-fixed fee, 2-hourly', + `qty` double DEFAULT NULL, + `service_type_id` int(1) DEFAULT '1' COMMENT '1-studies, 2-supplemental service, 3-out of pocket, 4-reimbursement, 5-', + `fee` double DEFAULT NULL, + `remaining_qty` double DEFAULT NULL, + PRIMARY KEY (`PO_num`,`line_item_no`), + KEY `fk_PODetail_ServType` (`service_type_id`), + CONSTRAINT `fk_PODetail_POnum` FOREIGN KEY (`PO_num`) REFERENCES `po` (`PO_num`), + CONSTRAINT `fk_PODetail_ServType` FOREIGN KEY (`service_type_id`) REFERENCES `service_type` (`service_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.po_detail: ~5 rows (approximately) +/*!40000 ALTER TABLE `po_detail` DISABLE KEYS */; +INSERT INTO `po_detail` (`PO_num`, `line_item_no`, `service_desc`, `fee_type_id`, `qty`, `service_type_id`, `fee`, `remaining_qty`) VALUES + ('ABC-123', 1, 'Design', 1, 1, 2, 5000, 1), + ('VDOT-54321', 1, 'Study existing designs', 1, 1, 1, 1000, 1), + ('VDOT-54321', 2, 'Modify design', 1, 1, 2, 2000, 1), + ('VDOT-54321', 3, 'Cost estimation', 1, 1, 4, 1000, 1), + ('VDOT-54321', 4, 'Peer Review', 2, 100, 3, 100, 50); +/*!40000 ALTER TABLE `po_detail` ENABLE KEYS */; + +-- Dumping structure for table astute.service_type +CREATE TABLE IF NOT EXISTS `service_type` ( + `service_type_id` int(11) NOT NULL, + `desc` varchar(40) NOT NULL, + PRIMARY KEY (`service_type_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.service_type: ~5 rows (approximately) +/*!40000 ALTER TABLE `service_type` DISABLE KEYS */; +INSERT INTO `service_type` (`service_type_id`, `desc`) VALUES + (1, 'Study'), + (2, 'Design'), + (3, 'Peer Review'), + (4, 'Cost Estimation'), + (5, 'Forensic Investigation'), + (6, 'Out-of-pocket Expense'); +/*!40000 ALTER TABLE `service_type` ENABLE KEYS */; + +-- Dumping structure for table astute.session +CREATE TABLE IF NOT EXISTS `session` ( + `session_id` varchar(200) NOT NULL, + `user_id` int(11) NOT NULL, + `session_start_date` date DEFAULT NULL, + `session_end_date` date DEFAULT NULL, + PRIMARY KEY (`session_id`), + KEY `fk_session_user_id` (`user_id`), + CONSTRAINT `fk_session_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.session: ~10 rows (approximately) +/*!40000 ALTER TABLE `session` DISABLE KEYS */; +INSERT INTO `session` (`session_id`, `user_id`, `session_start_date`, `session_end_date`) VALUES + ('058cdb87447645da9ec265e566af834c', 1, NULL, NULL), + ('4f48b60481ab4729a26b809c077fc7c0', 1, NULL, NULL), + ('66ed2bccbaf34b1e96b2b81393996cf9', 1, NULL, NULL), + ('8f8991185a174b87adb7d0b1b40c1475', 1, NULL, NULL), + ('92cd1d01085c4ead892a1c7c137631dd', 1, NULL, NULL), + ('abeefc05fe8e48e5bac7ffab65c85ca6', 1, NULL, NULL), + ('b356aab1dbe84d4f9eea9c1cd965c9a4', 1, NULL, NULL), + ('d6387d93d84341fc91a0c4a5cbf266db', 1, NULL, NULL), + ('dcb4b261f925464bb69ff685c1c6134d', 1, NULL, NULL), + ('fea623a6ff3148899214750707f4f52e', 1, NULL, NULL); +/*!40000 ALTER TABLE `session` ENABLE KEYS */; + +-- Dumping structure for procedure astute.submit_invoice +DELIMITER // +CREATE DEFINER=`root`@`localhost` PROCEDURE `submit_invoice`(invNo varchar(20)) +BEGIN +DECLARE po_no varchar(20); +UPDATE INVOICE SET INV_STATUS = 2 WHERE INV_NO = invNo; +SELECT PO_NUM INTO po_no FROM INVOICE WHERE INV_NO = invNo; + UPDATE INVOICE SET INV_NO = generate_final_inv_number(po_no), INV_STATUS = 2 WHERE INV_NO = invNo; +UPDATE PO SET INV_SEQ = INV_SEQ + 1 WHERE PO_NUM = po_no; +Commit; +END// +DELIMITER ; + +-- Dumping structure for procedure astute.update_all_remaining_quantities +DELIMITER // +CREATE DEFINER=`root`@`localhost` PROCEDURE `update_all_remaining_quantities`(invNo varchar(20)) +BEGIN + +DECLARE po_line_item_no int; +DECLARE remaining_qty double; +DECLARE finished INTEGER DEFAULT 0; +DECLARE p_finished INTEGER DEFAULT 0; +DECLARE done boolean DEFAULT FALSE; + +DECLARE po_line_items CURSOR FOR select distinct po_line_item_num from invoice_detail where inv_num = invNo; +DECLARE CONTINUE HANDLER FOR NOT FOUND SET p_finished = 1; + OPEN po_line_items; + po_loop: LOOP + FETCH po_line_items INTO po_line_item_no; + IF p_finished = 1 THEN + LEAVE po_loop; + END IF; + BEGIN + SET remaining_qty = update_remaining_qty_fun('',invNo,po_line_item_no); + END; + END LOOP po_loop; + CLOSE po_line_items; +END// +DELIMITER ; + +-- Dumping structure for function astute.update_remaining_qty_fun +DELIMITER // +CREATE DEFINER=`root`@`localhost` FUNCTION `update_remaining_qty_fun`(po_no_in varchar(40), inv_num_in varchar(40), item_no_in int) RETURNS double +BEGIN +DECLARE rem_qty double; +DECLARE po_no varchar(40); +if inv_num_in <> null or inv_num_in <> '' THEN + SELECT po_num INTO po_no FROM invoice where inv_no = inv_num_in; +else + set po_no = po_no_in; +end if; + +select po_detail.qty - ifnull(sum(invoice_detail.qty),0) into rem_qty from invoice_detail, invoice, po_detail +where invoice_detail.inv_num in (select inv_no from invoice where invoice.PO_num = po_no) +and invoice_detail.po_line_item_num = item_no_in +and po_detail.PO_num = po_no +and invoice.PO_num = po_detail.PO_num +and invoice.inv_no = invoice_detail.inv_num +and invoice.inv_status <> 3 +and invoice_detail.po_line_item_num = po_detail.line_item_no; + +update po_detail set remaining_qty = rem_qty where PO_num = po_no and line_item_no = item_no_in; +return rem_qty; +END// +DELIMITER ; + +-- Dumping structure for table astute.user +CREATE TABLE IF NOT EXISTS `user` ( + `user_id` int(5) NOT NULL, + `username` varchar(20) DEFAULT NULL, + `password` varchar(20) DEFAULT NULL, + `first_name` varchar(20) DEFAULT NULL, + `middle_name` varchar(20) DEFAULT NULL, + `last_name` varchar(20) DEFAULT NULL, + `role` varchar(20) DEFAULT NULL, + `email` varchar(40) DEFAULT NULL, + `office_phone_ext` int(3) DEFAULT NULL, + `cell_phone` bigint(20) DEFAULT NULL, + PRIMARY KEY (`user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- Dumping data for table astute.user: ~2 rows (approximately) +/*!40000 ALTER TABLE `user` DISABLE KEYS */; +INSERT INTO `user` (`user_id`, `username`, `password`, `first_name`, `middle_name`, `last_name`, `role`, `email`, `office_phone_ext`, `cell_phone`) VALUES + (1, 'sparikh', 'sparikh', 'Saurin', NULL, 'Parikh', 'Owner', 'sparikh@Astuteng.com', 2024002004, 3014616485), + (2, 'humarethiya', 'humarethiya', 'Haresh', NULL, 'Umaretiya', 'Owner', 'Humaretiya@astuteng.com', 2024002004, 0); +/*!40000 ALTER TABLE `user` ENABLE KEYS */; + +/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; +/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/AstuteSystem/src/main/java/com/astute/dao/DAO.java b/AstuteSystem/src/main/java/com/astute/dao/DAO.java index ec86c52..45f270c 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/DAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/DAO.java @@ -60,7 +60,7 @@ public abstract class DAO { host = "localhost"; port = 3306; schema = "astute"; - username = "root"; + username = "astute_user"; password = "password"; System.out.println("============================================="); System.out.println("host is " + host); @@ -101,6 +101,10 @@ public abstract class DAO { public abstract void createPODetail(String POnum, int lineItemNo, String serviceDesc, int feeTypeId, Double qty, Double fee, int serviceTypeId, Double remainingQuantity) throws AstuteException; + public abstract void finalizePO(String PONum) throws AstuteException; + + public abstract void deletePO(String PONum) throws AstuteException; + public abstract List getServiceTypes() throws AstuteException; public abstract void createServiceType(String desc) 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 2c8f47b..53f8124 100644 --- a/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java +++ b/AstuteSystem/src/main/java/com/astute/dao/SqlDAO.java @@ -248,6 +248,30 @@ public class SqlDAO extends DAO { } } + public void finalizePO(String PONum) throws AstuteException { + try { + String sql = "UPDATE PO_MASTER SET final = 1 WHERE PO_Num = '" + PONum + "''"; + 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 deletePO(String PONum) throws AstuteException { + try { + String sql = "DELETE FROM PO_MASTER SET final = 1 WHERE PO_Num = '" + PONum + "'' AND final = 0"; + System.out.println(sql); + Statement stmt = conn.createStatement(); + stmt.executeUpdate(sql); + } catch (SQLException e) { + e.printStackTrace(); + throw new AstuteException(DB_ERROR,e.getMessage()); + } + } + public List getServiceTypes() throws AstuteException { try { List serviceTypes = new ArrayList(); diff --git a/AstuteSystem/src/main/java/com/astute/resources/POResource.java b/AstuteSystem/src/main/java/com/astute/resources/POResource.java index 6e2797d..32dd53c 100644 --- a/AstuteSystem/src/main/java/com/astute/resources/POResource.java +++ b/AstuteSystem/src/main/java/com/astute/resources/POResource.java @@ -74,6 +74,22 @@ public class POResource { return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); } + // Finalize + @Path("/{PONum}/finalize") + @POST + public Response finalizePO(@PathParam("PONum") String PONum) throws AstuteException { + POService.finalizePO(PONum); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } + + // delete + @Path("/{PONum}/delete") + @POST + public Response deletePO(@PathParam("PONum") String PONum) throws AstuteException { + POService.deletePO(PONum); + return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); + } + // Misc @Path("/serviceTypes") @GET diff --git a/AstuteSystem/src/main/java/com/astute/service/POService.java b/AstuteSystem/src/main/java/com/astute/service/POService.java index 44c2ef2..754f845 100644 --- a/AstuteSystem/src/main/java/com/astute/service/POService.java +++ b/AstuteSystem/src/main/java/com/astute/service/POService.java @@ -50,6 +50,14 @@ public class POService extends Service{ getDao().createPODetail(POnum, lineItemNo, serviceDesc, feeTypeId, qty, fee, serviceTypeId, remainingQuantity); } + public void finalizePO(String PONum) throws AstuteException { + getDao().finalizePO(PONum); + } + + public void deletePO(String PONum) throws AstuteException { + getDao().finalizePO(PONum); + } + public List getServiceTypes() throws AstuteException { return getDao().getServiceTypes(); } diff --git a/AstuteSystem/src/main/resources/db.config b/AstuteSystem/src/main/resources/db.config new file mode 100644 index 0000000..dfdfd8a --- /dev/null +++ b/AstuteSystem/src/main/resources/db.config @@ -0,0 +1,6 @@ +database=sql +host=localhost +port=3306 +username=root +password=password +schema=astute From c4d1ba52fefc84090f04052d79413673bccb6d2e Mon Sep 17 00:00:00 2001 From: gopi17701 Date: Fri, 5 Apr 2019 20:47:00 -0400 Subject: [PATCH 2/2] Bug fixes --- AstuteClient2/src/app/app-routing.module.ts | 66 ++++---- AstuteClient2/src/app/app.module.ts | 108 ++++++------- .../src/app/nav-bar/nav-bar.component.html | 1 + .../src/app/nav-bar/nav-bar.component.ts | 1 + .../src/app/services/astute-client-service.ts | 147 ++++-------------- .../java/com/astute/model/ServiceType.java | 59 ++++--- .../astute/requests/ServiceTypeRequest.java | 12 +- .../java/com/astute/resources/POResource.java | 4 +- .../astute/resources/ServiceTypeResource.java | 6 +- .../astute/service/ServiceTypeService.java | 8 +- 10 files changed, 163 insertions(+), 249 deletions(-) diff --git a/AstuteClient2/src/app/app-routing.module.ts b/AstuteClient2/src/app/app-routing.module.ts index 41f605c..f545174 100644 --- a/AstuteClient2/src/app/app-routing.module.ts +++ b/AstuteClient2/src/app/app-routing.module.ts @@ -1,32 +1,34 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import {RouterModule, Routes} from '@angular/router'; -import {CustomerComponent} from './customer/customer.component'; -import {SalesOrderComponent} from './sales-order/sales-order.component'; -import {InvoiceComponent} from './invoice/invoice.component'; -import {HomepageComponent} from './homepage/homepage.component'; -import {InvoiceGenComponent} from './invoice-gen/invoice-gen.component'; -import {InvoicePaymentComponent} from './invoice-payment/invoice-payment.component'; -import {LoginComponent} from './login/login.component'; - -const routes: Routes = [ - { path: '', redirectTo: 'login', pathMatch: 'full'}, - { path: 'home', redirectTo: 'homepage', pathMatch: 'full'}, - { path: 'homepage', component: HomepageComponent }, - { path: 'customer', component: CustomerComponent }, - { path: 'sales-order', component: SalesOrderComponent }, - { path: 'invoice', component: InvoiceComponent }, - { path: 'invoice-gen', component: InvoiceGenComponent }, - { path: 'invoice-payment', component: InvoicePaymentComponent }, - { path: 'login', component: LoginComponent } -]; - -@NgModule({ - exports: [RouterModule], - imports: [ - CommonModule, - RouterModule.forRoot(routes) - ], - declarations: [] -}) -export class AppRoutingModule { } +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import {RouterModule, Routes} from '@angular/router'; +import {CustomerComponent} from './customer/customer.component'; +import {SalesOrderComponent} from './sales-order/sales-order.component'; +import {InvoiceComponent} from './invoice/invoice.component'; +import {HomepageComponent} from './homepage/homepage.component'; +import {InvoiceGenComponent} from './invoice-gen/invoice-gen.component'; +import {InvoicePaymentComponent} from './invoice-payment/invoice-payment.component'; +import {ServiceTypeComponent} from './service-type/service-type.component'; +import {LoginComponent} from './login/login.component'; + +const routes: Routes = [ + { path: '', redirectTo: 'login', pathMatch: 'full'}, + { path: 'home', redirectTo: 'homepage', pathMatch: 'full'}, + { path: 'homepage', component: HomepageComponent }, + { path: 'customer', component: CustomerComponent }, + { path: 'sales-order', component: SalesOrderComponent }, + { path: 'invoice', component: InvoiceComponent }, + { path: 'invoice-gen', component: InvoiceGenComponent }, + { path: 'invoice-payment', component: InvoicePaymentComponent }, + { path: 'service-type', component: ServiceTypeComponent}, + { path: 'login', component: LoginComponent } +]; + +@NgModule({ + exports: [RouterModule], + imports: [ + CommonModule, + RouterModule.forRoot(routes) + ], + declarations: [] +}) +export class AppRoutingModule { } diff --git a/AstuteClient2/src/app/app.module.ts b/AstuteClient2/src/app/app.module.ts index f8bfeb3..bbd60a2 100644 --- a/AstuteClient2/src/app/app.module.ts +++ b/AstuteClient2/src/app/app.module.ts @@ -1,53 +1,55 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; - -import { AppComponent } from './app.component'; -import { CustomerComponent } from './customer/customer.component'; -import { AstuteClientService } from './services/astute-client-service'; -import { AgGridModule } from 'ag-grid-angular'; -import { ModalFormComponent } from './modal-form/modal-form.component'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import {HttpClientModule} from '@angular/common/http'; -import { AppRoutingModule } from './/app-routing.module'; -import { NavBarComponent } from './nav-bar/nav-bar.component'; -import { SalesOrderComponent } from './sales-order/sales-order.component'; -import { InvoiceComponent } from './invoice/invoice.component'; -import { HomepageComponent } from './homepage/homepage.component'; -import { AppBoxComponent } from './app-box/app-box.component'; -import { InvoiceGenComponent } from './invoice-gen/invoice-gen.component'; -import { TextMaskModule } from 'angular2-text-mask'; -import { LoginComponent } from './login/login.component'; -import { InvoicePaymentComponent } from './invoice-payment/invoice-payment.component'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { ReactiveFormsModule } from '@angular/forms'; - -@NgModule({ - declarations: [ - AppComponent, - CustomerComponent, - ModalFormComponent, - NavBarComponent, - SalesOrderComponent, - InvoiceComponent, - HomepageComponent, - AppBoxComponent, - InvoiceGenComponent, - LoginComponent, - InvoicePaymentComponent - ], - imports: [ - BrowserModule, - AgGridModule.withComponents([]), - NgbModule.forRoot(), - HttpClientModule, - AppRoutingModule, - TextMaskModule, - CommonModule, - FormsModule, - ReactiveFormsModule - ], - providers: [AstuteClientService], - bootstrap: [AppComponent] -}) -export class AppModule { } +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; + +import { AppComponent } from './app.component'; +import { CustomerComponent } from './customer/customer.component'; +import { AstuteClientService } from './services/astute-client-service'; +import { AgGridModule } from 'ag-grid-angular'; +import { ModalFormComponent } from './modal-form/modal-form.component'; +import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import {HttpClientModule} from '@angular/common/http'; +import { AppRoutingModule } from './/app-routing.module'; +import { NavBarComponent } from './nav-bar/nav-bar.component'; +import { SalesOrderComponent } from './sales-order/sales-order.component'; +import { InvoiceComponent } from './invoice/invoice.component'; +import { HomepageComponent } from './homepage/homepage.component'; +import { AppBoxComponent } from './app-box/app-box.component'; +import { InvoiceGenComponent } from './invoice-gen/invoice-gen.component'; +import { TextMaskModule } from 'angular2-text-mask'; +import { LoginComponent } from './login/login.component'; +import { InvoicePaymentComponent } from './invoice-payment/invoice-payment.component'; +import { CommonModule } from '@angular/common'; +import { FormsModule } from '@angular/forms'; +import { ReactiveFormsModule } from '@angular/forms'; +import { ServiceTypeComponent } from './service-type/service-type.component'; + +@NgModule({ + declarations: [ + AppComponent, + CustomerComponent, + ModalFormComponent, + NavBarComponent, + SalesOrderComponent, + InvoiceComponent, + HomepageComponent, + AppBoxComponent, + InvoiceGenComponent, + LoginComponent, + InvoicePaymentComponent, + ServiceTypeComponent + ], + imports: [ + BrowserModule, + AgGridModule.withComponents([]), + NgbModule.forRoot(), + HttpClientModule, + AppRoutingModule, + TextMaskModule, + CommonModule, + FormsModule, + ReactiveFormsModule + ], + providers: [AstuteClientService], + bootstrap: [AppComponent] +}) +export class AppModule { } diff --git a/AstuteClient2/src/app/nav-bar/nav-bar.component.html b/AstuteClient2/src/app/nav-bar/nav-bar.component.html index d08bef8..c389c05 100644 --- a/AstuteClient2/src/app/nav-bar/nav-bar.component.html +++ b/AstuteClient2/src/app/nav-bar/nav-bar.component.html @@ -9,6 +9,7 @@ Sales Order Invoice Invoice Payment + Service Type Log off diff --git a/AstuteClient2/src/app/nav-bar/nav-bar.component.ts b/AstuteClient2/src/app/nav-bar/nav-bar.component.ts index 490d460..209d0c7 100644 --- a/AstuteClient2/src/app/nav-bar/nav-bar.component.ts +++ b/AstuteClient2/src/app/nav-bar/nav-bar.component.ts @@ -10,6 +10,7 @@ export class NavBarComponent implements OnInit { @Input() salesOrderActive: boolean; @Input() invoiceActive: boolean; @Input() invoicePaymentActive: boolean; + @Input() serviceTypeActive: boolean; @Input() logoffActive: boolean; diff --git a/AstuteClient2/src/app/services/astute-client-service.ts b/AstuteClient2/src/app/services/astute-client-service.ts index dcc8bfc..a7a3c02 100644 --- a/AstuteClient2/src/app/services/astute-client-service.ts +++ b/AstuteClient2/src/app/services/astute-client-service.ts @@ -15,6 +15,7 @@ export class AstuteClientService { private invoiceDetailUrl = 'http://localhost:8080/astutesystem/invoice/detail'; private invoiceGenUrl = 'http://localhost:8080/astutesystem/invoice/generatedInvoice'; private invoicePaymentUrl = 'http://localhost:8080/astutesystem/invoicePayment'; + private serviceTypeUrl = 'http://localhost:8080/astutesystem/serviceType'; private sessionId = localStorage.getItem(''); private sessionString = `?sessionId=${this.sessionId}`; @@ -119,17 +120,6 @@ export class AstuteClientService { }); } - public getServiceTypes(): Promise { - console.log("*** In getPOServiceTypes()"); - const url = `${this.POServiceTypesUrl}`; - return this.http.get(url) - .toPromise() - .then(response => { - console.log(response['entity']); - return response['entity']; - }); - } - public getPODetail(ponum): Promise { console.log("*** In getPODetails()"); const url = `${this.PODetailUrl}?PONum=${ponum}`; @@ -158,12 +148,6 @@ export class AstuteClientService { .then(response => response['entity']); } - // String serviceDesc; - // int feeTypeId; - // Double qty; - // int serviceTypeId; - // String schedule; - // Date deliverBy; public updatePODetail(ponum, lineItemNo, data) { console.log("*** In updatePODetail()"); const sessionId = localStorage.getItem('sessionId'); @@ -363,108 +347,33 @@ export class AstuteClientService { .then(response => response['entity']); } - // public getRecord(patientId: number): Promise { - // const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`; - // return this.http.get(url) - // .toPromise() - // .then(response => { - // console.log(response); - // }); - // } - // - // public getInfo(patientId: number): Promise { - // const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`; - // return this.http.get(url) - // .toPromise() - // .then(response => { - // return response['entity']; - // }); - // } - // - // public getVisits(patientId: number): Promise { - // const url = `${this.recordsUrl}/${patientId}/visits?sessionId=${this.getSessionId()}`; - // return this.http.get(url) - // .toPromise() - // .then(response => { - // return response['entity']; - // }); - // } - // - // public getAllVisits(): Promise { - // const url = `${this.recordsUrl}/visits?sessionId=${this.getSessionId()}`; - // return this.http.get(url) - // .toPromise() - // .then(response => { - // return response['entity']; - // }); - // } - // - // public getVitals(visitId: number): Promise { - // const url = `${this.visitsUrl}/${visitId}/vitals?sessionId=${this.getSessionId()}`; - // return this.http.get(url) - // .toPromise() - // .then(response => { - // return response['entity']; - // }); - // } - // - // public getLatestVitals(patientId: number): Promise { - // const url = `${this.recordsUrl}/${patientId}/vitals?sessionId=${this.getSessionId()}`; - // return this.http.get(url) - // .toPromise() - // .then(response => { - // return response['entity']; - // }); - // } - // - // public updateInfo(patientId: number, data: any): Promise { - // const url = `${this.recordsUrl}/${patientId}?sessionId=${this.getSessionId()}`; - // return this.http.put(url, data) - // .toPromise() - // .then(response => response['entity']); - // } - // public updateVisit(patientId: number, visit: any): Promise { - // console.log(visit); - // - // const url = `${this.recordsUrl}/${patientId}/visits/${visit.visitId}?sessionId=${this.getSessionId()}`; - // return this.http.put(url, visit) - // .toPromise() - // .then(response => { - // console.log(response['entity']); - // return response['entity']; - // }); - // } - // - // public getSessionPatientId(): Promise { - // const url = `${this.sessionsUrl}/${this.getSessionId()}`; - // console.log(url); - // return this.http.get(url) - // .toPromise() - // .then(response => { - // console.log(response); - // return response['entity'].patientId; - // }); - // } - // - // public startVisit(patientId: number): Promise { - // const url = `${this.recordsUrl}/${patientId}/visits?${this.getSessionId()}`; - // return this.http.post(url, null) - // .toPromise() - // .then(response => { - // console.log(response); - // return response['entity']; - // }); - // } - // - // getMedications() { - // const url = `${this.medsUrl}?${this.getSessionId()}`; - // return this.http.get(url) - // .toPromise() - // .then(response => { - // console.log(response); - // return response['entity']; - // }); - // } + // **************************************** Service Type methods + public getServiceTypes(): Promise { + console.log("*** In getPOServiceTypes()"); + const url = `${this.serviceTypeUrl}`; + return this.http.get(url) + .toPromise() + .then(response => { + console.log(response['entity']); + return response['entity']; + }); + } + public updateServiceType(serviceTypeId, serviceTypeDesc, data: any): Promise { + console.log("*** In updateServiceType()"); + const url = `${this.serviceTypeUrl}/${serviceTypeId}/?desc=${serviceTypeDesc}`; //TODO send sessionId + console.log("*** updateServiceType is " + url); + return this.http.put(url, data) + .toPromise() + .then(response => response['entity']); + } + + public createServiceType(data: any): Promise { + console.log("*** In createServiceType()"); + const url = `${this.serviceTypeUrl}`; //TODO send sessionId + return this.http.post(url, data) + .toPromise() + .then(response => response['entity']); + } } diff --git a/AstuteSystem/src/main/java/com/astute/model/ServiceType.java b/AstuteSystem/src/main/java/com/astute/model/ServiceType.java index ac44447..244edf3 100644 --- a/AstuteSystem/src/main/java/com/astute/model/ServiceType.java +++ b/AstuteSystem/src/main/java/com/astute/model/ServiceType.java @@ -1,30 +1,29 @@ -package com.astute.model; - -import java.sql.Date; - -public class ServiceType { - int serviceTypeId; - String desc; - - public int getServiceTypeId() { - return serviceTypeId; - } - - public void setServiceTypeId(int serviceTypeId) { - this.serviceTypeId = serviceTypeId; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public ServiceType(int serviceTypeId, String desc) { - this.serviceTypeId = serviceTypeId; - this.desc = desc; - } - -} +package com.astute.model; + + +public class ServiceType { + int serviceTypeId; + String serviceTypeDesc; + + public int getServiceTypeId() { + return serviceTypeId; + } + + public void setServiceTypeId(int serviceTypeId) { + this.serviceTypeId = serviceTypeId; + } + + public String getServiceTypeDesc() { + return serviceTypeDesc; + } + + public void setServiceTypeDesc(String serviceTypeDesc) { + this.serviceTypeDesc = serviceTypeDesc; + } + + public ServiceType(int serviceTypeId, String serviceTypeDesc) { + this.serviceTypeId = serviceTypeId; + this.serviceTypeDesc = serviceTypeDesc; + } + +} diff --git a/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java b/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java index 6024c20..153b612 100644 --- a/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java +++ b/AstuteSystem/src/main/java/com/astute/requests/ServiceTypeRequest.java @@ -2,7 +2,7 @@ package com.astute.requests; public class ServiceTypeRequest { int serviceTypeId; - String desc; + String serviceTypeDesc; public int getServiceTypeId() { return serviceTypeId; @@ -12,17 +12,17 @@ public class ServiceTypeRequest { this.serviceTypeId = serviceTypeId; } - public String getDesc() { - return desc; + public String getServiceTypeDesc() { + return serviceTypeDesc; } - public void setDesc(String desc) { - this.desc = desc; + public void setServiceTypeDesc(String serviceTypeDesc) { + this.serviceTypeDesc = serviceTypeDesc; } public ServiceTypeRequest(int serviceTypeId, String desc) { this.serviceTypeId = serviceTypeId; - this.desc = desc; + this.serviceTypeDesc = serviceTypeDesc; } } diff --git a/AstuteSystem/src/main/java/com/astute/resources/POResource.java b/AstuteSystem/src/main/java/com/astute/resources/POResource.java index 32dd53c..614618e 100644 --- a/AstuteSystem/src/main/java/com/astute/resources/POResource.java +++ b/AstuteSystem/src/main/java/com/astute/resources/POResource.java @@ -76,7 +76,7 @@ public class POResource { // Finalize @Path("/{PONum}/finalize") - @POST + @PUT public Response finalizePO(@PathParam("PONum") String PONum) throws AstuteException { POService.finalizePO(PONum); return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); @@ -84,7 +84,7 @@ public class POResource { // delete @Path("/{PONum}/delete") - @POST + @PUT public Response deletePO(@PathParam("PONum") String PONum) throws AstuteException { POService.deletePO(PONum); return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); diff --git a/AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java b/AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java index 8331b36..20a96e1 100644 --- a/AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java +++ b/AstuteSystem/src/main/java/com/astute/resources/ServiceTypeResource.java @@ -34,10 +34,10 @@ public class ServiceTypeResource { @Path("/{serviceTypeId}") @PUT - public Response updateServiceType(@PathParam("serviceTypeId") int serviceTypeId, @QueryParam("desc") String desc) + public Response updateServiceType(@PathParam("serviceTypeId") int serviceTypeId, @QueryParam("serviceTypeDesc") String serviceTypeDesc) throws AstuteException { System.out.println("in updateServiceType()"); - service.updateServiceType(serviceTypeId, desc); + service.updateServiceType(serviceTypeId, serviceTypeDesc); return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); } @@ -54,7 +54,7 @@ public class ServiceTypeResource { public Response createServiceType(ServiceTypeRequest request) throws AstuteException { System.out.println("in AstuteSyste createServiceType()"); - service.createServiceType(request.getDesc()); + service.createServiceType(request.getServiceTypeDesc()); return new ApiResponse(ApiResponse.UPDATE_ACCESS_SUCESS).toResponse(); } } diff --git a/AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java b/AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java index 8838e33..4d91a1b 100644 --- a/AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java +++ b/AstuteSystem/src/main/java/com/astute/service/ServiceTypeService.java @@ -19,12 +19,12 @@ public class ServiceTypeService extends Service{ return getDao().getServiceTypes(); } - public void createServiceType(String desc) throws AstuteException { - getDao().createServiceType(desc); + public void createServiceType(String serviceTypeDesc) throws AstuteException { + getDao().createServiceType(serviceTypeDesc); } - public void updateServiceType(int serviceTypeId, String desc) throws AstuteException { - getDao().updateServiceType(serviceTypeId, desc); + public void updateServiceType(int serviceTypeId, String serviceTypeDesc) throws AstuteException { + getDao().updateServiceType(serviceTypeId, serviceTypeDesc); } public void deleteServiceType(int serviceTypeId) throws AstuteException {