Skip to content

[CORRUPTED] Synthetic Benchmark PR #26823 - fix: address proration implementation flaws#570

Open
ofir-frd wants to merge 1 commit intobase_pr_26823_20260120_2053from
corrupted_pr_26823_20260120_2053
Open

[CORRUPTED] Synthetic Benchmark PR #26823 - fix: address proration implementation flaws#570
ofir-frd wants to merge 1 commit intobase_pr_26823_20260120_2053from
corrupted_pr_26823_20260120_2053

Conversation

@ofir-frd
Copy link

Benchmark PR calcom#26823

Type: Corrupted (contains bugs)

Original PR Title: fix: address proration implementation flaws
Original PR Description: ## What does this PR do?

This PR addresses several flaws identified during code review of the custom proration implementation on the feat/proration branch:

  1. Idempotency for Seat Tracking - Adds operationId field to SeatChangeLog model with a unique constraint to prevent duplicate seat change logs from race conditions when users flow through multiple code paths
  2. Prevent Double Charging on Retry - Adds voidInvoice method that voids/deletes old invoices before creating new ones when retrying failed prorations
  3. Due Date for Send Invoice - Adds daysUntilDue parameter (defaults to 30 days) for invoices using send_invoice collection method
  4. Type Fix - Fixes type error in stripe-subscription-utils.ts (null to undefined conversion)

Link to Devin run: https://app.devin.ai/sessions/e1373fed6b8442b18a8344f6ae9c8353
Requested by: @sean-brydon

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - internal billing changes only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Idempotency: Call logSeatAddition or logSeatRemoval multiple times with the same operationId - should only create one record
  2. Invoice Voiding: Trigger a failed proration retry and verify the old invoice is voided before creating a new one
  3. Due Date: Create an invoice with send_invoice collection method and verify it has a 30-day due date

Note: The idempotency infrastructure is in place, but callers of logSeatAddition/logSeatRemoval will need to be updated to pass operationId values for the protection to be active.

Checklist for Human Review

  • Verify Prisma migration is created for the new operationId field and unique constraint
  • Review whether callers should be updated now to pass operationId values
  • Check voidInvoice logic handles all invoice status edge cases appropriately
  • Consider if unit tests should be added for the new functionality
    Original PR URL: fix: address proration implementation flaws calcom/cal.com#26823

Compliance Violation

  • Rule: Custom Error Classes Must Use Hierarchical Structure with Typed Codes
  • Language: TypeScript
  • File: packages/features/ee/billing/service/proration/MonthlyProrationService.ts

@github-actions
Copy link

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "[CORRUPTED] Synthetic Benchmark PR #26823 - fix: address proration implementation flaws". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@github-actions
Copy link

github-actions bot commented Mar 8, 2026

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant