From f357fba2a5f219e124866da505ee7cfa0c415c44 Mon Sep 17 00:00:00 2001 From: fukunee Date: Wed, 6 May 2026 02:07:36 +0800 Subject: [PATCH] Exclude transfer red packets from expense pie chart and breakdown --- client/src/pages/Dashboard.js | 2 +- server/routes/stats.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/src/pages/Dashboard.js b/client/src/pages/Dashboard.js index 3ab58b4..3e3fc90 100644 --- a/client/src/pages/Dashboard.js +++ b/client/src/pages/Dashboard.js @@ -35,7 +35,7 @@ const COLORS = [ ]; // 不参与支出饼图的分类 -const EXCLUDED_CATEGORIES = ["投资理财"]; +const EXCLUDED_CATEGORIES = ["投资理财", "转账红包"]; export default function Dashboard() { const [overview, setOverview] = useState(null); diff --git a/server/routes/stats.js b/server/routes/stats.js index e15e5ea..ea78c7d 100644 --- a/server/routes/stats.js +++ b/server/routes/stats.js @@ -38,8 +38,8 @@ router.get("/overview", (req, res) => { // 按分类统计支出(用于饼图) const catWhere = where - ? where + " AND d.direction = 'expense' AND d.category IS NOT NULL" - : "WHERE d.direction = 'expense' AND d.category IS NOT NULL"; + ? where + " AND d.direction = 'expense' AND d.category IS NOT NULL AND d.category NOT IN ('投资理财','转账红包')" + : "WHERE d.direction = 'expense' AND d.category IS NOT NULL AND d.category NOT IN ('投资理财','转账红包')"; const categoryStats = db .prepare( @@ -57,10 +57,10 @@ router.get("/overview", (req, res) => { ) .all(...params); - // 按分类汇总(收入+支出),排除投资理财 + // 按分类汇总(收入+支出),排除投资理财、转账红包 const catBreakWhere = where - ? where + " AND d.category IS NOT NULL AND d.category != '投资理财'" - : "WHERE d.category IS NOT NULL AND d.category != '投资理财'"; + ? where + " AND d.category IS NOT NULL AND d.category NOT IN ('投资理财','转账红包')" + : "WHERE d.category IS NOT NULL AND d.category NOT IN ('投资理财','转账红包')"; const categoryBreakdown = db .prepare(