mirror of
https://github.com/dyiop/astute.git
synced 2025-04-05 21:10:16 -04:00
Added triggers for invoice_detail
This commit is contained in:
parent
716a69ba82
commit
b02ad814d0
|
@ -455,6 +455,25 @@ 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
|
CONSTRAINT `fk_InvDetail_InvNum` FOREIGN KEY (`inv_num`) REFERENCES `invoice` (`inv_no`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
CREATE DEFINER=`root`@`localhost` TRIGGER `astute`.`after_invoice_detail_update` AFTER UPDATE ON astute.invoice_detail FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE invoice
|
||||||
|
SET bill_amt = (SELECT SUM(QTY*FEE) FROM invoice_detail WHERE invoice_detail.inv_num = OLD.inv_num);
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE DEFINER=`root`@`localhost` TRIGGER `astute`.`after_invoice_detail_insert` AFTER INSERT ON astute.invoice_detail FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE invoice
|
||||||
|
SET bill_amt = (SELECT SUM(QTY*FEE) FROM invoice_detail WHERE invoice_detail.inv_num = NEW.inv_num);
|
||||||
|
END;
|
||||||
|
|
||||||
|
CREATE DEFINER=`root`@`localhost` TRIGGER `astute`.`after_invoice_detail_delete` AFTER DELETE ON astute.invoice_detail FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE invoice
|
||||||
|
SET bill_amt = (SELECT SUM(QTY*FEE) FROM invoice_detail WHERE invoice_detail.inv_num = OLD.inv_num);
|
||||||
|
END;
|
||||||
|
|
||||||
|
|
||||||
-- Dumping data for table astute.invoice_detail: ~14 rows (approximately)
|
-- Dumping data for table astute.invoice_detail: ~14 rows (approximately)
|
||||||
/*!40000 ALTER TABLE `invoice_detail` DISABLE KEYS */;
|
/*!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
|
INSERT INTO `invoice_detail` (`inv_num`, `line_item_num`, `PO_line_item_num`, `service_type_id`, `description`, `qty`, `fee`, `fee_type_id`) VALUES
|
||||||
|
|
Loading…
Reference in New Issue
Block a user