
USE inventory;
DROP TRIGGER IF EXISTS inventory.harga_barang_after_insert;
DELIMITER //

CREATE DEFINER=`root`@`localhost` TRIGGER `harga_barang_after_insert` AFTER INSERT ON `harga_barang` FOR EACH ROW BEGIN
	IF NEW.REF_PENERIMAAN IS NOT NULL OR NEW.REF_PENERIMAAN != 0 AND NEW.IS_UPDATE_BY_CORE = 0 THEN
		UPDATE inventory.harga_barang_log_penerimaan SET STATUS = 99, IS_UPDATE_CORE = 0 WHERE REF_PENERIMAAN = NEW.REF_PENERIMAAN AND STATUS = 1;
	END IF;
END//
DELIMITER ;