all periods

This commit is contained in:
2026-05-07 15:23:50 +05:30
parent 04b72d5843
commit 55b604f700
2 changed files with 10 additions and 7 deletions

View File

@@ -8,11 +8,12 @@ type DecoratedPeriod = ReportPeriod & {
label: string; label: string;
}; };
const TAB_TO_KEY: Record<string, "weekly" | "monthly" | "yearly" | "fyly"> = { const TAB_TO_KEY: Record<string, "weekly" | "monthly" | "yearly" | "fyly" | "full"> = {
Weekly: "weekly", Weekly: "weekly",
Monthly: "monthly", Monthly: "monthly",
Yearly: "yearly", Yearly: "yearly",
FYLY: "fyly" 'Financial Year': "fyly",
'All Time': "full"
}; };
function getAmount(p: ReportPeriod, mode: "expense" | "income") { function getAmount(p: ReportPeriod, mode: "expense" | "income") {
@@ -39,7 +40,7 @@ function mergeMetric(a: any, b: any) {
function mergeBuckets( function mergeBuckets(
buckets: any[], buckets: any[],
key: "weekly" | "monthly" | "yearly" | "fyly" key: "weekly" | "monthly" | "yearly" | "fyly" | "full"
): DecoratedPeriod[] { ): DecoratedPeriod[] {
const map = new Map<string, DecoratedPeriod>(); const map = new Map<string, DecoratedPeriod>();
@@ -72,7 +73,7 @@ function mergeBuckets(
function attachComparison( function attachComparison(
points: ChartDataPoint[], points: ChartDataPoint[],
key: "weekly" | "monthly" | "yearly" | "fyly" key: "weekly" | "monthly" | "yearly" | "fyly" | "full"
): ChartDataPoint[] { ): ChartDataPoint[] {
const getCompareIndex = (i: number) => { const getCompareIndex = (i: number) => {
if (key === "weekly") return i - 4; if (key === "weekly") return i - 4;
@@ -101,7 +102,7 @@ function attachComparison(
function buildChartData( function buildChartData(
reportData: HistoryChartProps["reportData"], reportData: HistoryChartProps["reportData"],
key: "weekly" | "monthly" | "yearly" | "fyly", key: "weekly" | "monthly" | "yearly" | "fyly" | "full",
mode: "expense" | "income", mode: "expense" | "income",
comparison: boolean comparison: boolean
): ChartDataPoint[] { ): ChartDataPoint[] {
@@ -157,7 +158,8 @@ export default function HistoryChart(props: HistoryChartProps) {
weekly: 6, weekly: 6,
monthly: 4, monthly: 4,
yearly: 4, yearly: 4,
fyly: 4 fyly: 4,
full: 4,
}; };
const visibleCount = visibleCountMap[activeDataKey] ?? 4; const visibleCount = visibleCountMap[activeDataKey] ?? 4;

View File

@@ -67,6 +67,7 @@ export interface ReportBucket {
monthly?: ReportPeriod[]; monthly?: ReportPeriod[];
yearly?: ReportPeriod[]; yearly?: ReportPeriod[];
fyly?: ReportPeriod[]; fyly?: ReportPeriod[];
full?: ReportPeriod[];
}; };
} }
@@ -75,7 +76,7 @@ export interface ReportBucket {
// ----------------------------- // -----------------------------
export interface ReportData { export interface ReportData {
periods: ("weekly" | "monthly" | "yearly" | "fyly")[]; periods: ("weekly" | "monthly" | "yearly" | "fyly" | "full")[];
rolling: boolean; rolling: boolean;
report_date?: string; report_date?: string;