-- ============================================
-- 此文件由 Meoo Cloud 自动生成，请勿修改
-- This file is auto-generated by Meoo Cloud, DO NOT MODIFY
-- ============================================


DROP TRIGGER IF EXISTS trg_validate_plan_quantity ON production_plans;
CREATE TRIGGER trg_validate_plan_quantity
 BEFORE UPDATE ON production_plans
 FOR EACH ROW
 WHEN (OLD.completed_quantity IS DISTINCT FROM NEW.completed_quantity)
 EXECUTE FUNCTION validate_plan_quantity_consistency();

DROP TRIGGER IF EXISTS trg_validate_inventory_positive ON inventory_records;
CREATE TRIGGER trg_validate_inventory_positive
 BEFORE INSERT OR UPDATE ON inventory_records
 FOR EACH ROW
 EXECUTE FUNCTION validate_inventory_record_positive();

DROP TRIGGER IF EXISTS trg_validate_payment ON payments;
CREATE TRIGGER trg_validate_payment
 BEFORE INSERT OR UPDATE ON payments
 FOR EACH ROW
 EXECUTE FUNCTION validate_payment_amount();

DROP TRIGGER IF EXISTS trg_validate_accounts_payable ON accounts_payable;
CREATE TRIGGER trg_validate_accounts_payable
 BEFORE INSERT OR UPDATE ON accounts_payable
 FOR EACH ROW
 EXECUTE FUNCTION validate_accounts_payable_totals();

