MCPcopy
hub / github.com/simstudioai/sim / resolveBillingContext

Function resolveBillingContext

apps/sim/lib/billing/core/usage-log.ts:162–177  ·  view source on GitHub ↗
(
  userId: string,
  billingEntity?: BillingEntity,
  billingPeriod?: { start: Date; end: Date }
)

Source from the content-addressed store, hash-verified

160}
161
162async function resolveBillingContext(
163 userId: string,
164 billingEntity?: BillingEntity,
165 billingPeriod?: { start: Date; end: Date }
166): Promise<BillingContext> {
167 if (billingEntity && billingPeriod) {
168 return { billingEntity, billingPeriod }
169 }
170
171 const subscription = await getHighestPrioritySubscription(userId)
172 const derived = deriveBillingContext(userId, subscription)
173 return {
174 billingEntity: billingEntity ?? derived.billingEntity,
175 billingPeriod: billingPeriod ?? derived.billingPeriod,
176 }
177}
178
179/**
180 * Returns post-cutover usage for an attributed billing entity/period.

Callers 2

recordUsageFunction · 0.85
recordCumulativeUsageFunction · 0.85

Calls 2

deriveBillingContextFunction · 0.85

Tested by

no test coverage detected