diff --git a/AstuteSystem/sql/astute.sql b/AstuteSystem/sql/astute.sql index e8f673e..2ef30de 100644 --- a/AstuteSystem/sql/astute.sql +++ b/AstuteSystem/sql/astute.sql @@ -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