MCPcopy Index your code
hub / github.com/simstudioai/sim / getOrgMemberLedgerByUser

Function getOrgMemberLedgerByUser

apps/sim/lib/billing/core/organization.ts:67–87  ·  view source on GitHub ↗
(
  organizationId: string,
  period?: { start: Date; end: Date } | null,
  executor: DbClient = db
)

Source from the content-addressed store, hash-verified

65 * look up the org's subscription here. Returns an empty map when there's no period.
66 */
67export async function getOrgMemberLedgerByUser(
68 organizationId: string,
69 period?: { start: Date; end: Date } | null,
70 executor: DbClient = db
71): Promise<Map<string, number>> {
72 let billingPeriod = period ?? null
73 if (period === undefined) {
74 const subscription = await getOrganizationSubscription(organizationId, { executor })
75 billingPeriod =
76 subscription?.periodStart && subscription?.periodEnd
77 ? { start: subscription.periodStart, end: subscription.periodEnd }
78 : null
79 }
80 if (!billingPeriod) return new Map<string, number>()
81 return getBillingPeriodUsageCostByUser(
82 { type: 'organization', id: organizationId },
83 billingPeriod,
84 undefined,
85 executor
86 )
87}
88
89/**
90 * Get comprehensive organization billing and usage data

Callers 5

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 2

Tested by

no test coverage detected