feat(insights): committed/discretionary chart, recurring charge detection, fees & interest audit

This commit is contained in:
2026-03-09 23:04:52 +11:00
parent 7379437cc3
commit c1d031511a
5 changed files with 535 additions and 0 deletions
+55
View File
@@ -502,3 +502,58 @@ export function useMonthlyAnalytics(months?: number) {
},
});
}
export interface SubscriptionRow {
merchant: string;
category: string;
frequency: string;
avg_amount: number;
monthly_equiv: number;
first_seen: string;
last_seen: string;
occurrences: number;
total_paid: number;
is_active: boolean;
}
export function useSubscriptions() {
return useQuery<{ subscriptions: SubscriptionRow[]; total_monthly_equiv: number }>({
queryKey: ["analytics", "subscriptions"],
queryFn: async () => {
const res = await fetch("/api/analytics/subscriptions");
return res.json();
},
});
}
export interface FeeBankRow {
bank_name: string;
fees: number;
interest: number;
total: number;
}
export interface FeeTxnRow {
id: number;
transaction_date: string;
description: string;
merchant_name: string | null;
transaction_type: string;
my_amount: number;
bank_name: string;
}
export function useFees() {
return useQuery<{
by_bank: FeeBankRow[];
transactions: FeeTxnRow[];
total_fees: number;
total_interest: number;
}>({
queryKey: ["analytics", "fees"],
queryFn: async () => {
const res = await fetch("/api/analytics/fees");
return res.json();
},
});
}