create or replace function public.get_invitations_with_account_ids(
  company_id uuid,
  personal_codes text[]
)
returns table (
  invite_token text,
  personal_code text,
  account_id uuid
)
language sql
as $$
  select
    i.invite_token,
    i.personal_code,
    a.id as account_id
  from public.invitations i
  join public.accounts a on a.personal_code = i.personal_code
  where  i.account_id = company_id 
  and i.personal_code = any(personal_codes);
$$;
