Show investments under Operating/Reserve tabs and include in fund totals
- Investment accounts now appear under their respective Operating/Reserve tabs in the Accounts page, with a compact sub-table showing name, type, institution, principal/value, rate, interest earned, and maturity info - Investment values (current_value) are included in dashboard Total Cash KPI - Reserve investment values are added to Reserve Fund Balance KPI and project funded percentage calculations - Year-end report reserve status now includes reserve investment values - Tab counts updated to include investment accounts per fund type - Summary cards show separate "asset (investments)" total for visibility Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,7 +10,7 @@ export class ProjectsService {
|
||||
// The total reserve fund balance (from reserve EQUITY accounts = fund balance) is distributed
|
||||
// proportionally across reserve projects based on their estimated_cost
|
||||
return this.tenant.query(`
|
||||
WITH reserve_balance AS (
|
||||
WITH reserve_equity AS (
|
||||
SELECT COALESCE(SUM(sub.balance), 0) as total FROM (
|
||||
SELECT COALESCE(SUM(jel.credit), 0) - COALESCE(SUM(jel.debit), 0) as balance
|
||||
FROM accounts a
|
||||
@@ -20,6 +20,14 @@ export class ProjectsService {
|
||||
GROUP BY a.id
|
||||
) sub
|
||||
),
|
||||
reserve_investments AS (
|
||||
SELECT COALESCE(SUM(current_value), 0) as total
|
||||
FROM investment_accounts WHERE fund_type = 'reserve' AND is_active = true
|
||||
),
|
||||
reserve_balance AS (
|
||||
SELECT re.total + ri.total as total
|
||||
FROM reserve_equity re, reserve_investments ri
|
||||
),
|
||||
reserve_total_cost AS (
|
||||
SELECT COALESCE(SUM(estimated_cost), 0) as total
|
||||
FROM projects
|
||||
@@ -54,7 +62,7 @@ export class ProjectsService {
|
||||
// Only return projects that have target_year set (for the Capital Planning kanban)
|
||||
// Uses the same dynamic reserve fund balance computation as findAll()
|
||||
return this.tenant.query(`
|
||||
WITH reserve_balance AS (
|
||||
WITH reserve_equity AS (
|
||||
SELECT COALESCE(SUM(sub.balance), 0) as total FROM (
|
||||
SELECT COALESCE(SUM(jel.credit), 0) - COALESCE(SUM(jel.debit), 0) as balance
|
||||
FROM accounts a
|
||||
@@ -64,6 +72,14 @@ export class ProjectsService {
|
||||
GROUP BY a.id
|
||||
) sub
|
||||
),
|
||||
reserve_investments AS (
|
||||
SELECT COALESCE(SUM(current_value), 0) as total
|
||||
FROM investment_accounts WHERE fund_type = 'reserve' AND is_active = true
|
||||
),
|
||||
reserve_balance AS (
|
||||
SELECT re.total + ri.total as total
|
||||
FROM reserve_equity re, reserve_investments ri
|
||||
),
|
||||
reserve_total_cost AS (
|
||||
SELECT COALESCE(SUM(estimated_cost), 0) as total
|
||||
FROM projects
|
||||
|
||||
Reference in New Issue
Block a user