CI minutes provisioning not working after two days of its purchase
Problem
In https://gitlab.com/gitlab-org/customers-gitlab-com/-/issues/6102+, a fix to only provision current CI minutes purchases and not future dated one was implemented. It was just discovered when investigating a failed provision that this introduced a new bug which prevents to provision CI minutes if they weren't provisioned within the first two days of its purchase. It turned out that since CI minutes is a one time purchase, the effective period is only two days long:
Before the mentioned issues was implemented, the CustomersDot's Order
record and its subscription
record was used. But with the fix the current_subscription
is used. This led to the CI minutes not being returned after those two days because of this logic here that only selects products where today's date is covered within their effective dates.
Proposal
When filtering the products to be effective as of today, add a special condition to check if the product is CI minutes (rate_plan_charge.rate_plan.product_rate_plan_id == Plan::CI_1000_MINUTES_PLAN
) AND today's date is greater or equal to the effective start date of the rate plan charge.
We could also set the effective end date to be the effective start date + 12 months which would be similar to how it's done on the GitLab side.
Result
Return the correct amount of purchased CI minutes for the current subscription regardless of its Zuora effective date period.