mirror of
https://github.com/documenso/documenso.git
synced 2026-07-27 02:15:05 +10:00
fix: minor changes
This commit is contained in:
@@ -235,7 +235,7 @@ const handleLiveSubscription = async ({
|
||||
// the freshly-fetched one — the convergent equivalent of the old
|
||||
// `previous_attributes.current_period_start` signal. On renewal, reconcile
|
||||
// the seat quantity and claim down to the actual member count. The reconcile
|
||||
// itself no-ops for non-seat/unlimited plans and non-ACTIVE subscriptions.
|
||||
// itself no-ops for non-seat/unlimited plans and inactive subscriptions.
|
||||
const previousPeriodEnd = organisation.subscription?.periodEnd ?? null;
|
||||
|
||||
const hasPeriodAdvanced = previousPeriodEnd !== null && periodEnd.getTime() > previousPeriodEnd.getTime();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { stripe } from '@documenso/lib/server-only/stripe';
|
||||
import { appLog } from '@documenso/lib/utils/debugger';
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import type { OrganisationClaim, Subscription } from '@prisma/client';
|
||||
import { SubscriptionStatus } from '@prisma/client';
|
||||
import type Stripe from 'stripe';
|
||||
|
||||
import { isPriceSeatsBased } from './is-price-seats-based';
|
||||
@@ -138,9 +139,10 @@ export const syncMemberCountWithStripeSeatPlan = async (
|
||||
prorationBehaviour: billsForNewSeats ? 'always_invoice' : 'none',
|
||||
});
|
||||
|
||||
// Advance the high-water mark when billing for new seats reset it to the
|
||||
// actual count on reconcile. Re-adds and shrinks deliberately leave it so a
|
||||
// seat already paid for this period is never re-charged.
|
||||
// Advance the high-water mark when billing for new seats; it is reset to the
|
||||
// actual member count when the billing period rolls over. Re-adds and shrinks
|
||||
// deliberately leave it untouched so a seat already paid for this period is
|
||||
// never re-charged.
|
||||
if (billsForNewSeats) {
|
||||
await prisma.organisationClaim.update({
|
||||
where: {
|
||||
@@ -180,6 +182,12 @@ export const reconcileSeatBasedPlans = async (organisationId: string) => {
|
||||
|
||||
const { subscription, organisationClaim } = organisation;
|
||||
|
||||
// Stripe rejects quantity updates on canceled subscriptions. PAST_DUE is
|
||||
// still live and a no-proration sync is safe, so it's allowed through.
|
||||
if (subscription.status === SubscriptionStatus.INACTIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Unlimited seats — nothing to meter.
|
||||
if (organisationClaim.memberCount === 0) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user