Skip to content

Count awaiting users on checkout for free groups

What does this MR do and why?

This changes how we calculate the billable members for free plans when free_user_cap is enabled when a subscription gets purchased.

Example:

  • free group where free_user_cap is enabled has 7 users.
  • 2 users get their memberships set to awaiting when free_user_cap applies.
  • When they want to purchase a plan it's likely that they want to purchase seats for these 2 users. We therefore need to count them in the checkout process as billable members.

We also have to change the way how we calculate seats_in_use as it was using billable_members_count. It's now using directly billed_user_ids and we therefore distinguish between billable (potentially billable) and billed users (actually billed users).

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/357257

Screenshots or screen recordings

On Usage Quota Page (5 seats used) On Checkout (7 billable)
Screenshot_2022-06-07_at_14.41.33 Screenshot_2022-06-07_at_14.41.28

How to set up and validate locally

  1. Start gdk in SaaS mode
    export GITLAB_SIMULATE_SAAS=1
    gdk start
  2. Enable the feature flags: bin/rails c
    Feature.enable(:seats_in_use_for_free_or_trial)
    Feature.enable(:free_user_cap)
  3. Enable check_namespace_plan
    ApplicationSetting.first.update(check_namespace_plan: true)
  4. Visit a free group's usage quota page, e.g. http://localhost:3000/groups/my-testing-group/-/usage_quotas#seats-quota-tab
  5. Go to "Explore all Plans" on the Usage Quota Page, or go to "Billing" in the group settings. Then click "Upgrade" on a Plan to go to the checkout page.
  6. To view the checkout page, you need to have customerDot running

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Nicolas Dular

Merge request reports