resolved the issues raised post pr

This commit is contained in:
DataEnginr
2026-06-20 20:17:17 +00:00
parent eb0866a678
commit 9723dc9e98
3 changed files with 5 additions and 4 deletions

View File

@@ -107,7 +107,8 @@ class AccountsController < ApplicationController
end
def toggle_exclude_from_reports
@account.update!(exclude_from_reports: !@account.exclude_from_reports)
Account.where(id: @account.id).update_all("exclude_from_reports = NOT exclude_from_reports")
@account.reload
redirect_to accounts_path
end

View File

@@ -493,8 +493,8 @@ class ReportsController < ApplicationController
# Get sell trades in period with realized gains
# Eager-load security, account, and accountable to avoid N+1
sell_trades = Current.family.trades
.joins(:entry)
.where(entries: { date: @period.date_range })
.joins(entry: :account)
.where(entries: { date: @period.date_range }, accounts: { exclude_from_reports: [ false, nil ] })
.where("trades.qty < 0")
.includes(:security, entry: { account: :accountable })
.to_a

View File

@@ -222,7 +222,7 @@ class IncomeStatement
sql_hash = Digest::MD5.hexdigest(transactions_scope.to_sql)
Rails.cache.fetch([
"income_statement", "totals_query", "v2", family.id, user&.id, included_account_ids_hash, sql_hash, date_range.begin, date_range.end, family.entries_cache_version
"income_statement", "totals_query", "v2", family.id, user&.id, included_account_ids_hash, sql_hash, date_range.begin, date_range.end, family.entries_cache_version, family.accounts.maximum(:updated_at)&.to_i
]) { Totals.new(family, transactions_scope: transactions_scope, date_range: date_range, included_account_ids: included_account_ids).call }
end