()
| 51 | } |
| 52 | |
| 53 | export function hasClaudeAiBillingAccess(): boolean { |
| 54 | // Check for mock billing access first (for /mock-limits testing) |
| 55 | if (mockBillingAccessOverride !== null) { |
| 56 | return mockBillingAccessOverride |
| 57 | } |
| 58 | |
| 59 | if (!isClaudeAISubscriber()) { |
| 60 | return false |
| 61 | } |
| 62 | |
| 63 | const subscriptionType = getSubscriptionType() |
| 64 | |
| 65 | // Consumer plans (Max/Pro) - individual users always have billing access |
| 66 | if (subscriptionType === 'max' || subscriptionType === 'pro') { |
| 67 | return true |
| 68 | } |
| 69 | |
| 70 | // Team/Enterprise - check for admin or billing roles |
| 71 | const config = getGlobalConfig() |
| 72 | const orgRole = config.oauthAccount?.organizationRole |
| 73 | |
| 74 | return ( |
| 75 | !!orgRole && |
| 76 | ['admin', 'billing', 'owner', 'primary_owner'].includes(orgRole) |
| 77 | ) |
| 78 | } |
| 79 |
no test coverage detected