Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: team billing on batch operations #15570

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

zomars
Copy link
Member

@zomars zomars commented Jun 25, 2024

What does this PR do?

  • Fixes CAL-3867

A quick and dirty fix preceding a full refactor on #15366

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected)
  • I have added a Docs issue here if this PR makes changes that would require a documentation change
  • I have added or modified automated tests that prove my fix is effective or that my feature works (PRs might be rejected if logical changes are not properly tested)

How should this be tested?

  • Having Stripe keys setup, batch invite and batch remove members from a team/org. Stripe subscription should match the correct membership count.

Copy link

linear bot commented Jun 25, 2024

@zomars zomars requested a review from a team June 25, 2024 17:36
Copy link
Contributor

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:

Unknown release type "hotfix" found in pull request title "hotfix: team billing on batch operations". 

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

@keithwillcode keithwillcode added core area: core, team members only foundation labels Jun 25, 2024
@dosubot dosubot bot added billing area: billing, stripe, payments, paypal, get paid teams area: teams, round robin, collective, managed event-types 🐛 bug Something isn't working labels Jun 25, 2024
@@ -62,7 +63,7 @@ export async function bulkDeleteUsersHandler({ ctx, input }: BulkDeleteUsersHand
// We do this in a transaction to make sure that all memberships are removed before we remove the organization relation from the user
// We also do this to make sure that if one of the queries fail, the whole transaction fails
await prisma.$transaction([removeProfiles, deleteMany, removeOrgrelation]);

await updateQuantitySubscriptionFromStripe(currentUser.organizationId);
Copy link
Member Author

Choose a reason for hiding this comment

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

Batch deleting didn't update Stripe subscription before.

@@ -151,7 +151,7 @@ export const inviteMemberHandler = async ({ ctx, input }: InviteMemberOptions) =
isOrg: input.isOrg,
});
});
sendEmails(sendVerifEmailsPromises);
await sendEmails(sendVerifEmailsPromises);
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this was causing a race condition that caused to report a wrong membership count

await updateQuantitySubscriptionFromStripe(input.teamId);
}
}
await handleSubscriptionUpdates(team.parentId || input.teamId);
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored for denesting

@zomars zomars changed the title hotfix: team billing on batch operations fix: team billing on batch operations Jun 25, 2024
Copy link

vercel bot commented Jun 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
ai ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2024 9:22am
cal ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2024 9:22am
calcom-web-canary ⬜️ Ignored (Inspect) Visit Preview Jun 26, 2024 9:22am

Copy link
Contributor

@emrysal emrysal left a comment

Choose a reason for hiding this comment

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

Looks good - indeed quick & dirty but straightforward.

@emrysal emrysal added this pull request to the merge queue Jun 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 26, 2024
@emrysal emrysal added this pull request to the merge queue Jun 26, 2024
Merged via the queue into main with commit 4f944ec Jun 26, 2024
35 checks passed
@emrysal emrysal deleted the zomars/cal-3867-fix-team-billing-issues branch June 26, 2024 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
billing area: billing, stripe, payments, paypal, get paid 🐛 bug Something isn't working core area: core, team members only foundation High priority Created by Linear-GitHub Sync ready-for-e2e teams area: teams, round robin, collective, managed event-types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants