(
organizationId: string,
period?: { start: Date; end: Date } | null,
executor: DbClient = db
)
| 65 | * look up the org's subscription here. Returns an empty map when there's no period. |
| 66 | */ |
| 67 | export 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 |
no test coverage detected