mirror of
https://github.com/we-promise/sure.git
synced 2026-07-21 01:05:28 +00:00
resolved the issues raised post pr
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user