Account Reporting Controls#
Account reporting controls determine which accounts contribute data to financial reports, income statements, trends, and exports. The system has two independent filtering mechanisms:
exclude_from_reportsflag β a user-controlled boolean per account- Tax-advantaged account exclusion β an automatic, type-based exclusion applied by specific report sections
exclude_from_reports Flag#
Data Model#
The exclude_from_reports column is a non-nullable boolean on the accounts table, defaulting to false . A composite index on [family_id, exclude_from_reports] keeps filtered queries efficient .
The Account model exposes an included_in_reports scope :
scope :included_in_reports, -> { where(exclude_from_reports: false) }
This scope is chained via .merge(Account.included_in_reports) in all major report-building methods β transaction breakdowns, trade queries, and data exports .
exclude_from_reports is a permitted param in the AccountableResource concern , so it can be set at account creation or via the edit form.
UI Entry Points#
There are three places users can toggle this flag:
| Location | Implementation |
|---|---|
| Account list row context menu | "Exclude/Include from reports" menu item via toggle_exclude_from_reports_account_path |
| Account detail page menu | Same toggle surfaced in the show page's _menu partial |
| Account create/edit form | Toggle under "Additional details" disclosure section |
Excluded accounts display an eye-off icon badge next to their name in the account list .
Controller Action & Permissions#
AccountsController#toggle_exclude_from_reports simply flips the boolean and redirects . It is guarded by set_manageable_account, which requires the current user to have :owner or :full_control permission on the account . The route is a member PATCH action .
Tax-Advantaged Account Exclusion#
Independent of the user-controlled flag, IncomeStatement::Totals (used by Total Income/Expenses and Trends & Insights) applies an additional automatic exclusion via exclude_tax_advantaged_sql, a SQL clause filtering out all IDs returned by Family#tax_advantaged_account_ids.
Family#tax_advantaged_account_ids collects:
- Investment accounts whose subtype has
tax_treatmentoftax_deferred,tax_exempt, ortax_advantaged(e.g., 401k, IRA, HSA) β derived fromInvestment::SUBTYPESmetadata - Crypto accounts with an explicit
tax_treatmentcolumn value oftax_deferredortax_exempt - Tax-advantaged depository accounts
This exclusion is not applied to the Activity Breakdown section (ReportsController#build_transactions_breakdown), which only uses Account.included_in_reports . This mismatch is a known inconsistency: retirement account transactions appear in Activity Breakdown but not in Income/Expense totals .
Key Files#
| File | Purpose |
|---|---|
app/models/account.rb:51 | included_in_reports scope definition |
app/controllers/accounts_controller.rb:113-116 | toggle_exclude_from_reports action |
app/controllers/concerns/accountable_resource.rb | Permitted params including exclude_from_reports |
app/controllers/reports_controller.rb | Scope usage in report queries |
app/models/income_statement/totals.rb:152-156 | exclude_tax_advantaged_sql for income statement |
app/models/family.rb:311-331 | tax_advantaged_account_ids lookup |
app/views/accounts/_form.html.erb:47-50 | Form toggle UI |
app/views/accounts/_account.html.erb:104-108 | Account list toggle UI |
app/views/accounts/show/_menu.html.erb:14-18 | Account detail toggle UI |