From f3877be0dbdd2098d385d73d1832d65697964130 Mon Sep 17 00:00:00 2001 From: justl Date: Tue, 6 Oct 2026 16:57:13 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B7=D0=B0=D0=BA=D1=80=D0=B5=D0=BF?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D1=80=D0=B0=D1=81=D1=85=D0=BE=D0=B4=D1=8B?= =?UTF-8?q?=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5=20=D1=82=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B7=D0=B0=D0=BA=D1=86=D0=B8=D0=B9=20=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D1=91=D1=82=D0=B0=20=D0=BF=D0=BE=20=D1=82=D0=B5=D0=B3?= =?UTF-8?q?=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/ReportsPage.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/ReportsPage.tsx b/frontend/src/pages/ReportsPage.tsx index 0058711..4308ae5 100644 --- a/frontend/src/pages/ReportsPage.tsx +++ b/frontend/src/pages/ReportsPage.tsx @@ -29,6 +29,15 @@ const PAGE_SIZE = 20; * two pages. */ type ReportMode = "category" | "tag"; +/** Which side of the ledger the tag report shows. A category carries its own + * kind, so in category mode filtering the transaction list by `category_id` + * already pins the type implicitly; a tag carries none and can legitimately + * sit on both sides of the ledger, so every part of the tag report — chart, + * ranking *and* transaction list — has to be pinned to the same side + * explicitly. One constant rather than four literals so they can't drift + * apart and leave the list showing income the totals above it don't count. */ +const TAG_REPORT_KIND = "expense" as const; + export function ReportsPage() { const { t, language } = useTranslation(); const now = new Date(); @@ -74,17 +83,20 @@ export function ReportsPage() { const { startDate, endDate } = computeRange(range, customRange); const isTagMode = mode === "tag"; const { data: ranking, isLoading: isRankingLoading } = useCategoryRanking("expense", startDate, endDate); - const { data: tagRanking, isLoading: isTagRankingLoading } = useTagRanking("expense", startDate, endDate); + const { data: tagRanking, isLoading: isTagRankingLoading } = useTagRanking(TAG_REPORT_KIND, startDate, endDate); const { data: report, isLoading: isReportLoading } = useCategorySpendingReport(categoryId, startDate, endDate); const { data: tagReport, isLoading: isTagReportLoading } = useTagSpendingReport( isTagMode ? tagId : null, - "expense", + TAG_REPORT_KIND, startDate, endDate ); const { data: transactions, isLoading: isTransactionsLoading } = useTransactions({ category_id: isTagMode ? undefined : categoryId ?? undefined, tag_id: isTagMode ? tagId ?? undefined : undefined, + // Category mode needs no type filter: the chosen category's own kind + // already restricts which transactions can carry it. + type: isTagMode ? TAG_REPORT_KIND : undefined, start_date: startDate, end_date: endDate, sort,