diff --git a/AstuteSystem/sql/astute.sql b/AstuteSystem/sql/astute.sql index 24c1bef..b7c0df0 100644 --- a/AstuteSystem/sql/astute.sql +++ b/AstuteSystem/sql/astute.sql @@ -97,7 +97,7 @@ CREATE TABLE IF NOT EXISTS `customer` ( PRIMARY KEY (`customer_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Dumping data for table astute.customer: ~2 rows (approximately) +-- Dumping data for table astute.customer: ~3 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, 'test1233', 'test123', 'test123', 'null', 'test123', 'md', 20874, 0, 'null', 0, 0), @@ -153,6 +153,16 @@ BEGIN 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) @@ -246,7 +256,9 @@ CREATE TABLE IF NOT EXISTS `invoice_payment` ( `invoice_payment_type` int(11) NOT NULL, `invoice_amount` double NOT NULL, `payment_date` date NOT NULL, - PRIMARY KEY (`inv_no`), + `invoice_payment_id` int(11) NOT NULL AUTO_INCREMENT, + 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`), CONSTRAINT `fk_pinv_pmt_type` FOREIGN KEY (`invoice_payment_type`) REFERENCES `payment_type` (`payment_type_id`) @@ -278,7 +290,7 @@ CREATE TABLE IF NOT EXISTS `payment_status` ( PRIMARY KEY (`payment_status_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Dumping data for table astute.payment_status: ~3 rows (approximately) +-- Dumping data for table astute.payment_status: ~2 rows (approximately) /*!40000 ALTER TABLE `payment_status` DISABLE KEYS */; INSERT INTO `payment_status` (`payment_status_id`, `payment_status_desc`) VALUES (1, 'Outstanding'), @@ -293,7 +305,7 @@ CREATE TABLE IF NOT EXISTS `payment_type` ( PRIMARY KEY (`payment_type_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Dumping data for table astute.payment_type: ~3 rows (approximately) +-- Dumping data for table astute.payment_type: ~2 rows (approximately) /*!40000 ALTER TABLE `payment_type` DISABLE KEYS */; INSERT INTO `payment_type` (`payment_type_id`, `payment_type_name`) VALUES (1, 'Credit Card'), @@ -318,7 +330,8 @@ CREATE TABLE IF NOT EXISTS `po` ( -- Dumping data for table astute.po: ~1 rows (approximately) /*!40000 ALTER TABLE `po` DISABLE KEYS */; INSERT INTO `po` (`PO_num`, `contract_num`, `PO_date`, `contract_amt`, `customer_id`) VALUES - ('EP2649247', 'TEST123', '2017-10-13', 30000.00, 1); + ('EP2649247', 'TEST123', '2017-10-13', 30000.00, 1), + ('test12', 'test', NULL, 60000.00, 1); /*!40000 ALTER TABLE `po` ENABLE KEYS */; -- Dumping structure for table astute.po_detail