diff --git a/AstuteSystem/sql/astute.sql b/AstuteSystem/sql/astute.sql index 5d1bf6c..1f2de48 100644 --- a/AstuteSystem/sql/astute.sql +++ b/AstuteSystem/sql/astute.sql @@ -99,7 +99,7 @@ CREATE TABLE IF NOT EXISTS `customer` ( PRIMARY KEY (`customer_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Dumping data for table astute.customer: ~1 rows (approximately) +-- 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'); @@ -283,10 +283,11 @@ 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: ~1 rows (approximately) +-- 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_DRAFT_220', '2018-09-23', 'VDOT-54321', 250, 'First Invoice', 'Certified that the above items and rates are in accordance with the contractual agreement as verified by the undersigned', 1, 0); + ('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 @@ -305,10 +306,13 @@ CREATE TABLE IF NOT EXISTS `invoice_detail` ( 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: ~1 rows (approximately) +-- 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_DRAFT_220', 1, 1, 1, 'Study existing designs', 0.25, 1000, 1); + ('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 @@ -338,8 +342,15 @@ CREATE TABLE IF NOT EXISTS `invoice_payment` ( 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: ~0 rows (approximately) +-- 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 @@ -409,7 +420,7 @@ CREATE TABLE IF NOT EXISTS `po` ( /*!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', 2); + ('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 @@ -432,10 +443,10 @@ CREATE TABLE IF NOT EXISTS `po_detail` ( /*!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, 0.75), + ('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, 100); + ('VDOT-54321', 4, 'Peer Review', 2, 100, 3, 100, 50); /*!40000 ALTER TABLE `po_detail` ENABLE KEYS */; -- Dumping structure for table astute.service_type @@ -445,7 +456,7 @@ CREATE TABLE IF NOT EXISTS `service_type` ( PRIMARY KEY (`service_type_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Dumping data for table astute.service_type: ~6 rows (approximately) +-- 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'), @@ -467,10 +478,34 @@ CREATE TABLE IF NOT EXISTS `session` ( CONSTRAINT `fk_session_user_id` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- Dumping data for table astute.session: ~0 rows (approximately) +-- 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))