From 280a5996f6d757c922bc3d804ab211bcba202082 Mon Sep 17 00:00:00 2001 From: olsch01 Date: Fri, 13 Mar 2026 14:52:54 -0400 Subject: [PATCH] fix: use rate-based estimate for interest YoY projection The projected interest was extrapolating from sparse YTD journal entries, producing inaccurate results early in the year. Now uses the same rate-based est_monthly_interest calculation (from account balances and investment rates) for remaining months, consistent with the dashboard KPI. Co-Authored-By: Claude Opus 4.6 --- backend/src/modules/reports/reports.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/modules/reports/reports.service.ts b/backend/src/modules/reports/reports.service.ts index 9069fb9..b18f7e6 100644 --- a/backend/src/modules/reports/reports.service.ts +++ b/backend/src/modules/reports/reports.service.ts @@ -741,11 +741,11 @@ export class ReportsService { AND LOWER(a.name) LIKE '%interest%' `, [currentYear - 1]); - // Projected interest for current year (YTD actual + remaining months estimated) + // Projected interest for current year: YTD actual + remaining months using + // the rate-based est_monthly_interest (same source as the dashboard KPI) const currentMonth = new Date().getMonth() + 1; const ytdInterest = parseFloat(interestEarned[0]?.total || '0'); - const monthlyAvg = currentMonth > 0 ? ytdInterest / currentMonth : 0; - const projectedInterest = ytdInterest + (monthlyAvg * (12 - currentMonth)); + const projectedInterest = ytdInterest + (estMonthlyInterest * (12 - currentMonth)); // Planned capital spend for current year const capitalSpend = await this.tenant.query(`