/** * Stats agrégées d'un client. Calculées on-the-fly à partir des invoices * (V1 : pas de cache, le volume reste raisonnable). * * Tant que le domaine Invoice n'est pas câblé, on retourne EMPTY pour * tous les clients — le contrat reste stable côté SPA. */ export type ClientStats = { invoiceCount: number activeInvoiceCount: number lateInvoiceCount: number paidInvoiceCount: number paidLifetimeCents: number pendingLifetimeCents: number lastActivityAt: string | null } export const EMPTY_CLIENT_STATS: ClientStats = { invoiceCount: 0, activeInvoiceCount: 0, lateInvoiceCount: 0, paidInvoiceCount: 0, paidLifetimeCents: 0, pendingLifetimeCents: 0, lastActivityAt: null, } /** * Calcule les stats pour un ensemble de clients d'une org. * @returns Map clientId → ClientStats * * @todo Implémenter quand Invoice arrive — pour l'instant tout le monde a 0. */ export async function bulkComputeClientStats( _organizationId: string, clientIds: string[] ): Promise> { const map = new Map() for (const id of clientIds) { map.set(id, EMPTY_CLIENT_STATS) } return map }