
DROP TRIGGER IF EXISTS `after_dispensary_quantity_edit`;
CREATE TRIGGER `after_dispensary_quantity_and_markup_edit` 
AFTER UPDATE ON `drugpurchaserecords` FOR EACH ROW 
BEGIN
    IF OLD.dispensary_balance <> new.dispensary_balance OR OLD.markUp <> new.markUp THEN
        INSERT INTO audit_trail(id,drug_name,facilityId,old_dispensary_balance,new_dispensary_balance,old_markup,new_markup,source_table,updated_by)
        VALUES(old.drug_code,old.drug, old.facilityId, old.dispensary_balance,new.dispensary_balance, old.markUp,new.markUp, 'drugpurchaserecords', new.by_whom);
    END IF;
END