-- v4.20 — Ensure existing cashier employees can sell and view quotations.
-- The cashier default set already includes these permissions, but employees
-- created before the fix may be missing them.
INSERT INTO employee_permissions (employee_id, permission)
SELECT e.id, p.perm
FROM employees e
CROSS JOIN (VALUES
    ('pos.sell'),
    ('pos.discount'),
    ('pos.cancel'),
    ('pos.view')
) AS p(perm)
WHERE e.role = 'cashier'
  AND e.is_active = true
  AND NOT EXISTS (
      SELECT 1 FROM employee_permissions ep
      WHERE ep.employee_id = e.id AND ep.permission = p.perm
  );
