-- Slice 8R-PricingDefaults · perms
-- Read (index): CRM, Finance Manager, Executive, Administrator.
-- Write (saveAj): same four groups.

INSERT INTO user_groups_perms (user_group_id, controller_allowed, action_allowed, created_by, created_on)
SELECT g.c0d, 'PricingDefaults', act.action_allowed, 0, NOW()
FROM user_groups g
CROSS JOIN (SELECT 'index' AS action_allowed UNION ALL SELECT 'saveAj') act
WHERE g.user_group_name IN ('CRM','Finance Manager','Executive','Administrator')
  AND NOT EXISTS (
    SELECT 1 FROM user_groups_perms p
    WHERE p.user_group_id = g.c0d
      AND p.controller_allowed = 'PricingDefaults'
      AND p.action_allowed     = act.action_allowed
  );
