feat(insights): committed/discretionary chart, recurring charge detection, fees & interest audit
This commit is contained in:
@@ -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();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user