Fix struct compatibility error in IncomeStatement::Totals (#603)

The TotalsRow struct was expanded from 5 to 6 fields in commit a4f70f4
(adding is_uncategorized_investment), but cached data from the old
5-field struct causes "struct size differs" errors when deserialized.

This adds a cache version ("v2") to the totals_query cache key to
invalidate all old cached structs and force recalculation with the
new 6-field definition.

Fixes: TypeError (struct IncomeStatement::Totals::TotalsRow not compatible (struct size differs))

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Juan José Mata
2026-01-10 20:26:08 +01:00
committed by GitHub
parent d4ab29ae1b
commit c3395ef06d

View File

@@ -130,7 +130,7 @@ class IncomeStatement
sql_hash = Digest::MD5.hexdigest(transactions_scope.to_sql)
Rails.cache.fetch([
"income_statement", "totals_query", family.id, sql_hash, family.entries_cache_version
"income_statement", "totals_query", "v2", family.id, sql_hash, family.entries_cache_version
]) { Totals.new(family, transactions_scope: transactions_scope, date_range: date_range).call }
end