Skip to content

Commit 6ba9623

Browse files
asizikovCopilot
andcommitted
fix: address included credit policy feedback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 08a2b7d commit 6ba9623

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/pipeline/aicIncludedCredits.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ describe('AIC included credit tiering and pool sizing', () => {
176176
)
177177
expect(getAicIncludedCreditTier(1900)).toBeNull()
178178
expect(getMonthlyAicIncludedCredits(3900)).toBe(0)
179+
expect(getAicIncludedCreditTier(
180+
1900,
181+
'organization',
182+
NATIVE_AI_CREDITS_SUMMER_PROMO_INCLUDED_CREDITS_POLICY,
183+
)).toBe('business')
184+
expect(getMonthlyAicIncludedCredits(
185+
3900,
186+
'organization',
187+
NATIVE_AI_CREDITS_STANDARD_INCLUDED_CREDITS_POLICY,
188+
)).toBe(3900)
189+
expect(getPlanLabel(1900, 'organization', NATIVE_AI_CREDITS_SUMMER_PROMO_INCLUDED_CREDITS_POLICY)).toBe(
190+
'Copilot Business',
191+
)
192+
expect(getPlanLabel(1234, 'organization', NATIVE_AI_CREDITS_SUMMER_PROMO_INCLUDED_CREDITS_POLICY)).toBe(
193+
'Unknown (1,234 AI Credits/month)',
194+
)
179195
})
180196

181197
it('classifies 300 as Pro/Student for an individual report', () => {

src/pipeline/aicIncludedCredits.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export function isKnownMonthlyQuota(totalMonthlyQuota: number): boolean {
147147

148148
function isKnownMonthlyQuotaForPolicy(totalMonthlyQuota: number, policy: IncludedCreditsPolicy): boolean {
149149
if (!Number.isFinite(totalMonthlyQuota)) return false
150-
if (policy === TRANSITION_PERIOD_INCLUDED_CREDITS_POLICY) {
150+
if (policy.id === TRANSITION_PERIOD_INCLUDED_CREDITS_POLICY.id) {
151151
return TRANSITION_PERIOD_KNOWN_MONTHLY_QUOTAS.has(totalMonthlyQuota)
152152
}
153153

@@ -182,10 +182,18 @@ export function getPlanLabel(
182182
const individualPlan = findIndividualIncludedCreditsPlan(totalMonthlyQuota, reportPlanScope)
183183
if (individualPlan) return individualPlan.label
184184

185-
if (totalMonthlyQuota > 0) return `Unknown (${totalMonthlyQuota.toLocaleString()} PRUs/month)`
185+
if (totalMonthlyQuota > 0) {
186+
return `Unknown (${totalMonthlyQuota.toLocaleString()} ${getUnknownQuotaLabel(reportPlanScope, policy)})`
187+
}
186188
return 'Unknown'
187189
}
188190

191+
function getUnknownQuotaLabel(reportPlanScope: ReportPlanScope, policy: IncludedCreditsPolicy): string {
192+
if (reportPlanScope === 'individual') return 'PRUs/month'
193+
194+
return policy.organizationPlans.business.identity.quotaUnit === 'aic' ? 'AI Credits/month' : 'PRUs/month'
195+
}
196+
189197
export function getAicIncludedCreditTier(
190198
totalMonthlyQuota: number,
191199
reportPlanScope: ReportPlanScope = 'organization',

0 commit comments

Comments
 (0)