export interface Payor { id?: string; name: string; username: string; email: string; } export interface Payee { type: "merchant" | "person" | "transfer" | "other"; name: string; } export interface Account { id: string; name: string; number: string; type: "cash" | "bank" | "credit_card" | "wallet" | "other"; currency: string; is_active?: boolean; } export interface Tag { id: string; name: string; icon: string; parent_id?: string | null; } export interface Transaction { id: string; payor: Payor; payee: Payee; amount: number; account: Account; tags: Tag[]; occurred_at: string; created_at: string; } // ----------------------------- // Metrics // ----------------------------- export interface ReportMetric { sum: number; count: number; average: number; transactions?: Transaction[]; } // ----------------------------- // Period // ----------------------------- export type PeriodType = "daily" | "weekly" | "monthly" | "all"; export interface ReportPeriod { start: string; end: string; metric: ReportMetric; } // ----------------------------- // Group (bucket) // ----------------------------- export type GroupKey = { [dimension: string]: string[]; }; export interface ReportBucket { group_key: GroupKey; periods: { daily?: ReportPeriod[]; weekly?: ReportPeriod[]; monthly?: ReportPeriod[]; all?: ReportPeriod[]; }; } // ----------------------------- // Report Query // ----------------------------- export interface ReportQuery { accounts?: string[] | null; ignore_self?: boolean | null; start_date?: string | null; end_date?: string | null; min_amount?: number | null; max_amount?: number | null; } // ----------------------------- // Final Report // ----------------------------- export interface ReportData { snapshot_id?: string | null; flow?: "inflows" | "outflows" | null; periods: PeriodType[]; tags?: string[] | null; payee?: string[] | null; buckets: ReportBucket[]; query: ReportQuery; }