From 498400173c139ffc6b4a9c7d95a4a08884214729 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Sat, 25 Apr 2026 22:59:24 +0000 Subject: [PATCH] wealthfolio-sync: skip the synthetic TOTAL row in ETL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wealthfolio's daily_account_valuation includes a row with account_id='TOTAL' that pre-aggregates the per-account values for that day. Mirroring it into PG verbatim caused every SUM(total_value) in the Wealth dashboard to double-count (showing ~£2M against actual ~£1M). Drop the synthetic row at the dump step so the PG mirror only holds real-account rows. Initial sync after fix: 8,649 DAV rows (was 10,798), net worth resolves to £1,024,071 — matches the per-account latest snapshot. --- stacks/wealthfolio/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stacks/wealthfolio/main.tf b/stacks/wealthfolio/main.tf index 258578a2..df4dca48 100644 --- a/stacks/wealthfolio/main.tf +++ b/stacks/wealthfolio/main.tf @@ -390,7 +390,8 @@ resource "kubernetes_deployment" "wealthfolio" { CAST(total_value AS REAL), CAST(cost_basis AS REAL), CAST(net_contribution AS REAL) - FROM daily_account_valuation; + FROM daily_account_valuation + WHERE account_id != 'TOTAL'; -- synthetic pre-aggregated row; would double-count when summed SQ sqlite3 -separator $'\t' /tmp/wf-sync/snapshot.db <<'SQ' > /tmp/wf-sync/activities.tsv