Reports frontend — spec-driven generate form, sliceable viewer, dimension bars #16
@@ -162,7 +162,6 @@ export function ReportViewer({ id, version, fields, onClose, onRegenerated }: Re
|
||||
max: g.metrics.max,
|
||||
cadence: g.metrics.cadence,
|
||||
frequency: g.metrics.frequency,
|
||||
txnsPerMonth: g.metrics.txnsPerMonth,
|
||||
},
|
||||
})),
|
||||
[periodGroups],
|
||||
|
||||
@@ -12,7 +12,6 @@ export interface PeriodMetricsVM {
|
||||
lastDate: string | null;
|
||||
cadence: number | null;
|
||||
frequency: number | null;
|
||||
txnsPerMonth: number | null;
|
||||
}
|
||||
|
||||
export interface ReportPeriodGroup {
|
||||
@@ -109,7 +108,6 @@ export function buildPeriodGroups(buckets: any[], filter: SliceFilter): ReportPe
|
||||
sources: number;
|
||||
apiCadence: number | null;
|
||||
apiFrequency: number | null;
|
||||
apiTxnsPerMonth: number | null;
|
||||
}
|
||||
const byPeriod = new Map<string, Acc>();
|
||||
const seenTxnIds = new Set<string>();
|
||||
@@ -135,13 +133,11 @@ export function buildPeriodGroups(buckets: any[], filter: SliceFilter): ReportPe
|
||||
lastDate: null,
|
||||
cadence: null,
|
||||
frequency: null,
|
||||
txnsPerMonth: null,
|
||||
},
|
||||
txns: [],
|
||||
sources: 0,
|
||||
apiCadence: num(m.cadence),
|
||||
apiFrequency: num(m.frequency),
|
||||
apiTxnsPerMonth: num(m.txns_per_month),
|
||||
};
|
||||
byPeriod.set(period.period_id, acc);
|
||||
}
|
||||
@@ -192,11 +188,9 @@ export function buildPeriodGroups(buckets: any[], filter: SliceFilter): ReportPe
|
||||
vm.cadence = null;
|
||||
vm.frequency = null;
|
||||
}
|
||||
vm.txnsPerMonth = null;
|
||||
} else {
|
||||
vm.cadence = acc.apiCadence;
|
||||
vm.frequency = acc.apiFrequency;
|
||||
vm.txnsPerMonth = acc.apiTxnsPerMonth;
|
||||
}
|
||||
return { key, metrics: vm, txns: acc.txns, currency };
|
||||
})
|
||||
|
||||
@@ -48,7 +48,6 @@ function txnFallbackMetrics(items: ExpenseItem[]): ListGroupMetrics {
|
||||
max: t.max,
|
||||
cadence: t.cadenceDays,
|
||||
frequency: t.frequency,
|
||||
txnsPerMonth: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,18 +66,8 @@ function GroupMetrics({
|
||||
{ label: "Avg", value: m.avg == null ? "—" : formatCurrency(m.avg, currency) },
|
||||
{ label: "Min", value: m.min == null ? "—" : formatCurrency(m.min, currency) },
|
||||
{ label: "Max", value: m.max == null ? "—" : formatCurrency(m.max, currency) },
|
||||
{
|
||||
label: "Count",
|
||||
value:
|
||||
typeof m.count === "number"
|
||||
? m.count.toLocaleString("en-IN")
|
||||
: String(items.length),
|
||||
},
|
||||
cadenceRow(m.cadence, m.frequency),
|
||||
];
|
||||
if (m.txnsPerMonth != null) {
|
||||
rows.push({ label: "Per Month", value: Number.isInteger(m.txnsPerMonth) ? String(m.txnsPerMonth) : m.txnsPerMonth.toFixed(2) });
|
||||
}
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 2, flexWrap: "wrap", width: "100%" }}>
|
||||
{rows.map((row) => (
|
||||
|
||||
@@ -49,7 +49,6 @@ export interface ListGroupMetrics {
|
||||
max: number | null;
|
||||
cadence: number | null;
|
||||
frequency: number | null;
|
||||
txnsPerMonth: number | null;
|
||||
}
|
||||
|
||||
export interface ListPeriodGroup extends PeriodGroup {
|
||||
|
||||
Reference in New Issue
Block a user