Skip to content

improvement(billing): replace daily refresh credits with weekly refresh - #7113

Merged
icecrasher321 merged 2 commits into
stagingfrom
staging-v73
Aug 26, 2026
Merged

improvement(billing): replace daily refresh credits with weekly refresh#7113
icecrasher321 merged 2 commits into
stagingfrom
staging-v73

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • Replace daily refresh credits with weekly refresh: Pro +2,000 credits/week, Max +4,000 credits/week (team plans scale per seat; legacy pro/team plans take the Pro amount; enterprise unchanged with no refresh)
  • Refresh stays computed at read time from the usage ledger — buckets are now 7-day windows anchored at billing period start; no cron, no env vars, no DB migration
  • Replace the uniform DAILY_REFRESH_RATE with fixed per-tier weeklyRefreshCredits and a getPlanWeeklyRefreshDollars resolver shared by the billing math and every display surface
  • Update all copy: upgrade cards, pricing comparison table, upgrade emails, docs, comparison content
  • Surface the allowance as a subtle "Weekly refresh" row in Settings → Subscription (paid non-enterprise plans only)

Type of Change

  • Improvement

Testing

  • lib/billing suite passes (672 tests) including the rewritten weekly-refresh tests: weekly cap shared across days, unprorated partial final week, boundary bucketing, straggler clamping, seat scaling
  • Verified the SQL bucketing against a real Postgres database: exact 7-day window boundary, partial-final-week allowance, straggler clamping into edge weeks, pooled team seats, billing-period scoping, and that every plan resolves to its advertised amount
  • lint, check:api-validation:strict, check:migrations (no new migrations — schema change is comment-only), and the full audit suite pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 26, 2026 7:32pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces daily refresh credits with fixed weekly allowances, using seven-day usage-ledger buckets anchored to the billing-period start.

  • Adds shared Pro and Max weekly-refresh allowance resolution, including organization seat scaling.
  • Updates billing enforcement, overage calculations, usage reporting, tests, product displays, emails, and documentation.
  • Adds a scope-aware weekly-refresh row to subscription settings.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported scope-dependent display mismatch is corrected because both the subscription display and enforcement path now scale by seats only for organization-scoped billing.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/settings/components/billing/billing.tsx Displays the resolved weekly allowance and now applies seat scaling only in organization billing scope, matching enforcement.
apps/sim/lib/billing/credits/weekly-refresh.ts Implements seven-day ledger bucketing, per-window allowance caps, period clamping, and organization seat scaling.
apps/sim/lib/billing/plan-helpers.ts Centralizes plan-to-weekly-refresh resolution while excluding free and enterprise plans.
apps/sim/lib/billing/core/usage.ts Replaces daily-refresh deductions with weekly-refresh deductions across resolved and current-period usage.
apps/sim/lib/billing/core/billing.ts Applies weekly-refresh deductions consistently to personal and organization overage calculations.
apps/sim/lib/billing/calculations/usage-monitor.ts Uses weekly allowances in both personal and pooled organization usage enforcement.
packages/db/schema.ts Updates schema documentation for the weekly-refresh billing-period interpretation without changing the persisted schema contract.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  P[Subscription plan] --> R[getPlanWeeklyRefreshDollars]
  R --> S{Organization scoped?}
  S -- Yes --> M[Multiply allowance by seats]
  S -- No --> O[Use one-seat allowance]
  M --> B[Bucket ledger usage into 7-day windows]
  O --> B
  B --> D[Deduct consumed refresh from usage]
  D --> E[Enforcement and overage calculation]
  R --> U[Subscription display]
  S --> U
Loading

Reviews (2): Last reviewed commit: "fix(billing): scope weekly refresh row s..." | Re-trigger Greptile

Comment thread apps/sim/app/workspace/[workspaceId]/settings/components/billing/billing.tsx Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 22 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/sim/lib/billing/core/billing.ts
Comment thread apps/sim/lib/billing/cycle-close.ts
Comment thread apps/sim/app/workspace/[workspaceId]/settings/components/billing/billing.tsx Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown

@cubic-dev-ai review

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 22 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@icecrasher321
icecrasher321 merged commit db88eca into staging Aug 26, 2026
30 checks passed
@icecrasher321
icecrasher321 deleted the staging-v73 branch August 26, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant