From d3349231f3b048e2672c6d260c6ae11bc3a3c260 Mon Sep 17 00:00:00 2001 From: Minz Date: Mon, 9 Feb 2026 15:20:39 +0100 Subject: [PATCH] Fix cumulative budget being reverse and not casting properly --- commands/receipts/receiptCommands.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/receipts/receiptCommands.js b/commands/receipts/receiptCommands.js index c7f3cba..980ecf2 100644 --- a/commands/receipts/receiptCommands.js +++ b/commands/receipts/receiptCommands.js @@ -125,7 +125,7 @@ module.exports = { const allBudgets = db.prepare(` SELECT id, budget_amount, exchange_rate, start_date, end_date FROM weekly_budgets - ORDER BY start_date DESC + ORDER BY start_date ASC LIMIT 4 `).all(); @@ -140,7 +140,7 @@ module.exports = { `).all(budgetPeriod.id, targetUser.id); const totalSpentInPeriodEur = periodSpendings.reduce((acc, s) => acc + s.amount, 0); - const savedInPeriodEur = budgetPeriod.budget_amount - totalSpentInPeriodEur; + const savedInPeriodEur = Number(budgetPeriod.budget_amount) - Number(totalSpentInPeriodEur); cumulativeSavingsEur += savedInPeriodEur; statsDescription += `**Period: ${budgetPeriod.start_date} - ${budgetPeriod.end_date}**\n`;