The personal finance app for everyone
Separate exclude and one-time transaction handling (#2400)
Zach Gollwitzer63d8114b057a
diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rbindex 5e3eb25c..1c260d8f 100644--- a/app/controllers/transactions_controller.rb+++ b/app/controllers/transactions_controller.rb@@ -133,7 +133,7 @@ class TransactionsController < ApplicationControllerdef entry_paramsentry_params = params.require(:entry).permit(:name, :date, :amount, :currency, :excluded, :notes, :nature, :entryable_type,- entryable_attributes: [ :id, :category_id, :merchant_id, { tag_ids: [] } ]+ entryable_attributes: [ :id, :category_id, :merchant_id, :kind, { tag_ids: [] } ])nature = entry_params.delete(:nature)@@ -150,7 +150,7 @@ class TransactionsController < ApplicationControllercleaned_params = params.fetch(:q, {}).permit(:start_date, :end_date, :search, :amount,- :amount_operator, :active_accounts_only, :excluded_transactions,+ :amount_operator, :active_accounts_only,accounts: [], account_ids: [],categories: [], merchants: [], types: [], tags: [])diff --git a/app/models/income_statement/category_stats.rb b/app/models/income_statement/category_stats.rbindex f3572e71..3daf69c5 100644--- a/app/models/income_statement/category_stats.rb+++ b/app/models/income_statement/category_stats.rb@@ -48,6 +48,7 @@ class IncomeStatement::CategoryStats)WHERE a.family_id = :family_idAND t.kind NOT IN ('funds_movement', 'one_time', 'cc_payment')+ AND ae.excluded = falseGROUP BY c.id, period, CASE WHEN ae.amount < 0 THEN 'income' ELSE 'expense' END)SELECTdiff --git a/app/models/income_statement/family_stats.rb b/app/models/income_statement/family_stats.rbindex 3e2e9e29..a2509b11 100644--- a/app/models/income_statement/family_stats.rb+++ b/app/models/income_statement/family_stats.rb@@ -44,7 +44,8 @@ class IncomeStatement::FamilyStatser.to_currency = :target_currency)WHERE a.family_id = :family_id- AND t.kind NOT IN ('funds_movement', 'one_time', 'cc_payment')+ AND t.kind NOT IN ('funds_movement', 'one_time', 'cc_payment')+ AND ae.excluded = falseGROUP BY period, CASE WHEN ae.amount < 0 THEN 'income' ELSE 'expense' END)SELECTdiff --git a/app/models/income_statement/totals.rb b/app/models/income_statement/totals.rbindex 01d61b14..858093a7 100644--- a/app/models/income_statement/totals.rb+++ b/app/models/income_statement/totals.rb@@ -45,6 +45,7 @@ class IncomeStatement::Totalser.to_currency = :target_currency)WHERE at.kind NOT IN ('funds_movement', 'one_time', 'cc_payment')+ AND ae.excluded = falseGROUP BY c.id, c.parent_id, CASE WHEN ae.amount < 0 THEN 'income' ELSE 'expense' END;SQLenddiff --git a/app/models/transaction/search.rb b/app/models/transaction/search.rbindex e9914c2a..71406e71 100644--- a/app/models/transaction/search.rb+++ b/app/models/transaction/search.rb@@ -14,7 +14,6 @@ class Transaction::Searchattribute :merchants, array: trueattribute :tags, array: trueattribute :active_accounts_only, :boolean, default: true- attribute :excluded_transactions, :boolean, default: falseattr_reader :family@@ -29,7 +28,6 @@ class Transaction::Searchquery = family.transactionsquery = apply_active_accounts_filter(query, active_accounts_only)- query = apply_excluded_transactions_filter(query, excluded_transactions)query = apply_category_filter(query, categories)query = apply_type_filter(query, types)query = apply_merchant_filter(query, merchants)@@ -89,13 +87,6 @@ class Transaction::Searchendend- def apply_excluded_transactions_filter(query, excluded_transactions_filter)- unless excluded_transactions_filter- query.where(entries: { excluded: false })- else- query- end- enddef apply_category_filter(query, categories)return query unless categories.present?diff --git a/app/views/doorkeeper/applications/_delete_form.html.erb b/app/views/doorkeeper/applications/_delete_form.html.erbindex 654fb2a6..bf7a0d0d 100644--- a/app/views/doorkeeper/applications/_delete_form.html.erb+++ b/app/views/doorkeeper/applications/_delete_form.html.erb@@ -1,6 +1,6 @@-<%- submit_btn_css ||= 'btn btn-link' %>+<%- submit_btn_css ||= "btn btn-link" %><%= form_tag oauth_application_path(application), method: :delete do %>- <%= submit_tag t('doorkeeper.applications.buttons.destroy'),+ <%= submit_tag t("doorkeeper.applications.buttons.destroy"),onclick: "return confirm('#{ t('doorkeeper.applications.confirmations.destroy') }')",class: submit_btn_css %><% end %>diff --git a/app/views/doorkeeper/applications/_form.html.erb b/app/views/doorkeeper/applications/_form.html.erbindex de86503b..4cc71b3d 100644--- a/app/views/doorkeeper/applications/_form.html.erb+++ b/app/views/doorkeeper/applications/_form.html.erb@@ -1,10 +1,10 @@-<%= form_for application, url: doorkeeper_submit_path(application), as: :doorkeeper_application, html: { role: 'form' } do |f| %>+<%= form_for application, url: doorkeeper_submit_path(application), as: :doorkeeper_application, html: { role: "form" } do |f| %><% if application.errors.any? %>- <div class="alert alert-danger" data-alert><p><%= t('doorkeeper.applications.form.error') %></p></div>+ <div class="alert alert-danger" data-alert><p><%= t("doorkeeper.applications.form.error") %></p></div><% end %><div class="form-group row">- <%= f.label :name, class: 'col-sm-2 col-form-label font-weight-bold' %>+ <%= f.label :name, class: "col-sm-2 col-form-label font-weight-bold" %><div class="col-sm-10"><%= f.text_field :name, class: "form-control #{ 'is-invalid' if application.errors[:name].present? }", required: true %><%= doorkeeper_errors_for application, :name %>@@ -12,48 +12,48 @@</div><div class="form-group row">- <%= f.label :redirect_uri, class: 'col-sm-2 col-form-label font-weight-bold' %>+ <%= f.label :redirect_uri, class: "col-sm-2 col-form-label font-weight-bold" %><div class="col-sm-10"><%= f.text_area :redirect_uri, class: "form-control #{ 'is-invalid' if application.errors[:redirect_uri].present? }" %><%= doorkeeper_errors_for application, :redirect_uri %><span class="form-text text-secondary">- <%= t('doorkeeper.applications.help.redirect_uri') %>+ <%= t("doorkeeper.applications.help.redirect_uri") %></span><% if Doorkeeper.configuration.allow_blank_redirect_uri?(application) %><span class="form-text text-secondary">- <%= t('doorkeeper.applications.help.blank_redirect_uri') %>+ <%= t("doorkeeper.applications.help.blank_redirect_uri") %></span><% end %></div></div><div class="form-group row">- <%= f.label :confidential, class: 'col-sm-2 form-check-label font-weight-bold' %>+ <%= f.label :confidential, class: "col-sm-2 form-check-label font-weight-bold" %><div class="col-sm-10"><%= f.check_box :confidential, class: "checkbox #{ 'is-invalid' if application.errors[:confidential].present? }" %><%= doorkeeper_errors_for application, :confidential %><span class="form-text text-secondary">- <%= t('doorkeeper.applications.help.confidential') %>+ <%= t("doorkeeper.applications.help.confidential") %></span></div></div><div class="form-group row">- <%= f.label :scopes, class: 'col-sm-2 col-form-label font-weight-bold' %>+ <%= f.label :scopes, class: "col-sm-2 col-form-label font-weight-bold" %><div class="col-sm-10"><%= f.text_field :scopes, class: "form-control #{ 'has-error' if application.errors[:scopes].present? }" %><%= doorkeeper_errors_for application, :scopes %><span class="form-text text-secondary">- <%= t('doorkeeper.applications.help.scopes') %>+ <%= t("doorkeeper.applications.help.scopes") %></span></div></div><div class="form-group"><div class="col-sm-offset-2 col-sm-10">- <%= f.submit t('doorkeeper.applications.buttons.submit'), class: 'btn btn-primary' %>- <%= link_to t('doorkeeper.applications.buttons.cancel'), oauth_applications_path, class: 'btn btn-secondary' %>+ <%= f.submit t("doorkeeper.applications.buttons.submit"), class: "btn btn-primary" %>+ <%= link_to t("doorkeeper.applications.buttons.cancel"), oauth_applications_path, class: "btn btn-secondary" %></div></div><% end %>diff --git a/app/views/doorkeeper/applications/edit.html.erb b/app/views/doorkeeper/applications/edit.html.erbindex 737186bc..91cf6f8c 100644--- a/app/views/doorkeeper/applications/edit.html.erb+++ b/app/views/doorkeeper/applications/edit.html.erb@@ -1,5 +1,5 @@<div class="border-bottom mb-4">- <h1><%= t('.title') %></h1>+ <h1><%= t(".title") %></h1></div>-<%= render 'form', application: @application %>+<%= render "form", application: @application %>diff --git a/app/views/doorkeeper/applications/index.html.erb b/app/views/doorkeeper/applications/index.html.erbindex 3ba2650d..259e72d3 100644--- a/app/views/doorkeeper/applications/index.html.erb+++ b/app/views/doorkeeper/applications/index.html.erb@@ -1,16 +1,16 @@<div class="border-bottom mb-4">- <h1><%= t('.title') %></h1>+ <h1><%= t(".title") %></h1></div>-<p><%= link_to t('.new'), new_oauth_application_path, class: 'btn btn-success' %></p>+<p><%= link_to t(".new"), new_oauth_application_path, class: "btn btn-success" %></p><table class="table table-striped"><thead><tr>- <th><%= t('.name') %></th>- <th><%= t('.callback_url') %></th>- <th><%= t('.confidential') %></th>- <th><%= t('.actions') %></th>+ <th><%= t(".name") %></th>+ <th><%= t(".callback_url") %></th>+ <th><%= t(".confidential") %></th>+ <th><%= t(".actions") %></th><th></th></tr></thead>@@ -24,13 +24,13 @@<%= simple_format(application.redirect_uri) %></td><td class="align-middle">- <%= application.confidential? ? t('doorkeeper.applications.index.confidentiality.yes') : t('doorkeeper.applications.index.confidentiality.no') %>+ <%= application.confidential? ? t("doorkeeper.applications.index.confidentiality.yes") : t("doorkeeper.applications.index.confidentiality.no") %></td><td class="align-middle">- <%= link_to t('doorkeeper.applications.buttons.edit'), edit_oauth_application_path(application), class: 'btn btn-link' %>+ <%= link_to t("doorkeeper.applications.buttons.edit"), edit_oauth_application_path(application), class: "btn btn-link" %></td><td class="align-middle">- <%= render 'delete_form', application: application %>+ <%= render "delete_form", application: application %></td></tr><% end %>diff --git a/app/views/doorkeeper/applications/new.html.erb b/app/views/doorkeeper/applications/new.html.erbindex 737186bc..91cf6f8c 100644--- a/app/views/doorkeeper/applications/new.html.erb+++ b/app/views/doorkeeper/applications/new.html.erb@@ -1,5 +1,5 @@<div class="border-bottom mb-4">- <h1><%= t('.title') %></h1>+ <h1><%= t(".title") %></h1></div>-<%= render 'form', application: @application %>+<%= render "form", application: @application %>diff --git a/app/views/doorkeeper/applications/show.html.erb b/app/views/doorkeeper/applications/show.html.erbindex 540ba484..53e84c78 100644--- a/app/views/doorkeeper/applications/show.html.erb+++ b/app/views/doorkeeper/applications/show.html.erb@@ -1,39 +1,39 @@<div class="border-bottom mb-4">- <h1><%= t('.title', name: @application.name) %></h1>+ <h1><%= t(".title", name: @application.name) %></h1></div><div class="row"><div class="col-md-8">- <h4><%= t('.application_id') %>:</h4>+ <h4><%= t(".application_id") %>:</h4><p><code class="bg-light" id="application_id"><%= @application.uid %></code></p>- <h4><%= t('.secret') %>:</h4>+ <h4><%= t(".secret") %>:</h4><p><code class="bg-light" id="secret"><% secret = flash[:application_secret].presence || @application.plaintext_secret %><% if secret.blank? && Doorkeeper.config.application_secret_hashed? %>- <span class="bg-light font-italic text-uppercase text-muted"><%= t('.secret_hashed') %></span>+ <span class="bg-light font-italic text-uppercase text-muted"><%= t(".secret_hashed") %></span><% else %><%= secret %><% end %></code></p>- <h4><%= t('.scopes') %>:</h4>+ <h4><%= t(".scopes") %>:</h4><p><code class="bg-light" id="scopes"><% if @application.scopes.present? %><%= @application.scopes %><% else %>- <span class="bg-light font-italic text-uppercase text-muted"><%= t('.not_defined') %></span>+ <span class="bg-light font-italic text-uppercase text-muted"><%= t(".not_defined") %></span><% end %></code></p>- <h4><%= t('.confidential') %>:</h4>+ <h4><%= t(".confidential") %>:</h4><p><code class="bg-light" id="confidential"><%= @application.confidential? %></code></p>- <h4><%= t('.callback_urls') %>:</h4>+ <h4><%= t(".callback_urls") %>:</h4><% if @application.redirect_uri.present? %><table>@@ -43,21 +43,21 @@<code class="bg-light"><%= uri %></code></td><td>- <%= link_to t('doorkeeper.applications.buttons.authorize'), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: 'code', scope: @application.scopes), class: 'btn btn-success', target: '_blank' %>+ <%= link_to t("doorkeeper.applications.buttons.authorize"), oauth_authorization_path(client_id: @application.uid, redirect_uri: uri, response_type: "code", scope: @application.scopes), class: "btn btn-success", target: "_blank" %></td></tr><% end %></table><% else %>- <span class="bg-light font-italic text-uppercase text-muted"><%= t('.not_defined') %></span>+ <span class="bg-light font-italic text-uppercase text-muted"><%= t(".not_defined") %></span><% end %></div><div class="col-md-4">- <h3><%= t('.actions') %></h3>+ <h3><%= t(".actions") %></h3>- <p><%= link_to t('doorkeeper.applications.buttons.edit'), edit_oauth_application_path(@application), class: 'btn btn-primary' %></p>+ <p><%= link_to t("doorkeeper.applications.buttons.edit"), edit_oauth_application_path(@application), class: "btn btn-primary" %></p>- <p><%= render 'delete_form', application: @application, submit_btn_css: 'btn btn-danger' %></p>+ <p><%= render "delete_form", application: @application, submit_btn_css: "btn btn-danger" %></p></div></div>diff --git a/app/views/doorkeeper/authorizations/error.html.erb b/app/views/doorkeeper/authorizations/error.html.erbindex 303ec57f..8df12c18 100644--- a/app/views/doorkeeper/authorizations/error.html.erb+++ b/app/views/doorkeeper/authorizations/error.html.erb@@ -3,7 +3,7 @@<div class="mx-auto w-12 h-12 rounded-full bg-destructive-surface flex items-center justify-center mb-4"><%= icon("alert-circle", class: "w-6 h-6 text-destructive") %></div>- <h1 class="text-2xl font-medium text-primary"><%= t('doorkeeper.authorizations.error.title') %></h1>+ <h1 class="text-2xl font-medium text-primary"><%= t("doorkeeper.authorizations.error.title") %></h1></div><div class="bg-surface-inset rounded-lg p-4">diff --git a/app/views/doorkeeper/authorizations/form_post.html.erb b/app/views/doorkeeper/authorizations/form_post.html.erbindex 637aa663..d9c0a15b 100644--- a/app/views/doorkeeper/authorizations/form_post.html.erb+++ b/app/views/doorkeeper/authorizations/form_post.html.erb@@ -3,12 +3,12 @@<div class="mx-auto w-12 h-12 rounded-full bg-surface-inset flex items-center justify-center mb-4"><%= icon("loader-circle", class: "w-6 h-6 text-primary animate-spin") %></div>- <h1 class="text-2xl font-medium text-primary"><%= t('.title') %></h1>+ <h1 class="text-2xl font-medium text-primary"><%= t(".title") %></h1><p class="text-sm text-secondary">Redirecting you back to the application...</p></div></div>-<% turbo_disabled = @pre_auth.redirect_uri&.start_with?('maybeapp://') || params[:display] == 'mobile' %>+<% turbo_disabled = @pre_auth.redirect_uri&.start_with?("maybeapp://") || params[:display] == "mobile" %><%= form_tag @pre_auth.redirect_uri, method: :post, name: :redirect_form, authenticity_token: false, data: { turbo: !turbo_disabled } do %><% auth.body.compact.each do |key, value| %><%= hidden_field_tag key, value %>diff --git a/app/views/doorkeeper/authorizations/new.html.erb b/app/views/doorkeeper/authorizations/new.html.erbindex 49630fec..4c3a727a 100644--- a/app/views/doorkeeper/authorizations/new.html.erb+++ b/app/views/doorkeeper/authorizations/new.html.erb@@ -5,13 +5,13 @@<div class="bg-container rounded-xl p-6 space-y-6"><div class="space-y-2 text-center"><p class="text-sm text-secondary">- <%= raw t('.prompt', client_name: content_tag(:span, @pre_auth.client.name, class: 'font-medium text-primary')) %>+ <%= raw t(".prompt", client_name: content_tag(:span, @pre_auth.client.name, class: "font-medium text-primary")) %></p></div><% if @pre_auth.scopes.count > 0 %><div class="bg-surface-inset rounded-lg p-4 space-y-3">- <p class="text-sm font-medium text-primary"><%= t('.able_to') %>:</p>+ <p class="text-sm font-medium text-primary"><%= t(".able_to") %>:</p><ul class="space-y-2"><% @pre_auth.scopes.each do |scope| %><li class="flex items-start gap-2 text-sm text-secondary">@@ -24,7 +24,7 @@<% end %><div class="space-y-3">- <% turbo_disabled = params[:redirect_uri]&.start_with?('maybeapp://') || params[:display] == 'mobile' %>+ <% turbo_disabled = params[:redirect_uri]&.start_with?("maybeapp://") || params[:display] == "mobile" %><%= form_tag oauth_authorization_path, method: :post, class: "w-full", data: { turbo: !turbo_disabled } do %><%= hidden_field_tag :client_id, @pre_auth.client.uid, id: nil %><%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri, id: nil %>@@ -38,7 +38,7 @@<%= hidden_field_tag :display, params[:display], id: nil %><% end %><%= render ButtonComponent.new(- text: t('doorkeeper.authorizations.buttons.authorize'),+ text: t("doorkeeper.authorizations.buttons.authorize"),variant: :primary,size: :lg,full_width: true,@@ -46,7 +46,7 @@data: { disable_with: "Authorizing..." }) %><% end %>-+<%= form_tag oauth_authorization_path, method: :delete, class: "w-full", data: { turbo: !turbo_disabled } do %><%= hidden_field_tag :client_id, @pre_auth.client.uid, id: nil %><%= hidden_field_tag :redirect_uri, @pre_auth.redirect_uri, id: nil %>@@ -60,7 +60,7 @@<%= hidden_field_tag :display, params[:display], id: nil %><% end %><%= render ButtonComponent.new(- text: t('doorkeeper.authorizations.buttons.deny'),+ text: t("doorkeeper.authorizations.buttons.deny"),variant: :outline,size: :lg,full_width: true,diff --git a/app/views/doorkeeper/authorizations/show.html.erb b/app/views/doorkeeper/authorizations/show.html.erbindex 6a8f0399..4653af2a 100644--- a/app/views/doorkeeper/authorizations/show.html.erb+++ b/app/views/doorkeeper/authorizations/show.html.erb@@ -3,7 +3,7 @@<div class="mx-auto w-12 h-12 rounded-full bg-success-surface flex items-center justify-center mb-4"><%= icon("check", class: "w-6 h-6 text-success") %></div>- <h1 class="text-2xl font-medium text-primary"><%= t('.title') %></h1>+ <h1 class="text-2xl font-medium text-primary"><%= t(".title") %></h1></div><div class="bg-surface-inset rounded-lg p-4">diff --git a/app/views/doorkeeper/authorized_applications/_delete_form.html.erb b/app/views/doorkeeper/authorized_applications/_delete_form.html.erbindex 512e8ece..7668b397 100644--- a/app/views/doorkeeper/authorized_applications/_delete_form.html.erb+++ b/app/views/doorkeeper/authorized_applications/_delete_form.html.erb@@ -1,4 +1,4 @@-<%- submit_btn_css ||= 'btn btn-link' %>+<%- submit_btn_css ||= "btn btn-link" %><%= form_tag oauth_authorized_application_path(application), method: :delete do %>- <%= submit_tag t('doorkeeper.authorized_applications.buttons.revoke'), onclick: "return confirm('#{ t('doorkeeper.authorized_applications.confirmations.revoke') }')", class: submit_btn_css %>+ <%= submit_tag t("doorkeeper.authorized_applications.buttons.revoke"), onclick: "return confirm('#{ t('doorkeeper.authorized_applications.confirmations.revoke') }')", class: submit_btn_css %><% end %>diff --git a/app/views/doorkeeper/authorized_applications/index.html.erb b/app/views/doorkeeper/authorized_applications/index.html.erbindex a3f5aaac..fe36f954 100644--- a/app/views/doorkeeper/authorized_applications/index.html.erb+++ b/app/views/doorkeeper/authorized_applications/index.html.erb@@ -1,13 +1,13 @@<header class="page-header">- <h1><%= t('doorkeeper.authorized_applications.index.title') %></h1>+ <h1><%= t("doorkeeper.authorized_applications.index.title") %></h1></header><main role="main"><table class="table table-striped"><thead><tr>- <th><%= t('doorkeeper.authorized_applications.index.application') %></th>- <th><%= t('doorkeeper.authorized_applications.index.created_at') %></th>+ <th><%= t("doorkeeper.authorized_applications.index.application") %></th>+ <th><%= t("doorkeeper.authorized_applications.index.created_at") %></th><th></th></tr></thead>@@ -15,8 +15,8 @@<% @applications.each do |application| %><tr><td><%= application.name %></td>- <td><%= application.created_at.strftime(t('doorkeeper.authorized_applications.index.date_format')) %></td>- <td><%= render 'delete_form', application: application %></td>+ <td><%= application.created_at.strftime(t("doorkeeper.authorized_applications.index.date_format")) %></td>+ <td><%= render "delete_form", application: application %></td></tr><% end %></tbody>diff --git a/app/views/layouts/doorkeeper/admin.html.erb b/app/views/layouts/doorkeeper/admin.html.erbindex 3d1aeade..54be4935 100644--- a/app/views/layouts/doorkeeper/admin.html.erb+++ b/app/views/layouts/doorkeeper/admin.html.erb@@ -4,22 +4,22 @@<meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0">- <title><%= t('doorkeeper.layouts.admin.title') %></title>+ <title><%= t("doorkeeper.layouts.admin.title") %></title><%= stylesheet_link_tag "doorkeeper/admin/application" %><%= csrf_meta_tags %></head><body><nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-5">- <%= link_to t('doorkeeper.layouts.admin.nav.oauth2_provider'), oauth_applications_path, class: 'navbar-brand' %>+ <%= link_to t("doorkeeper.layouts.admin.nav.oauth2_provider"), oauth_applications_path, class: "navbar-brand" %><div class="collapse navbar-collapse"><ul class="navbar-nav mr-auto">- <li class="nav-item <%= 'active' if request.path == oauth_applications_path %>">- <%= link_to t('doorkeeper.layouts.admin.nav.applications'), oauth_applications_path, class: 'nav-link' %>+ <li class="nav-item <%= "active" if request.path == oauth_applications_path %>">+ <%= link_to t("doorkeeper.layouts.admin.nav.applications"), oauth_applications_path, class: "nav-link" %></li><% if respond_to?(:root_path) %><li class="nav-item">- <%= link_to t('doorkeeper.layouts.admin.nav.home'), root_path, class: 'nav-link' %>+ <%= link_to t("doorkeeper.layouts.admin.nav.home"), root_path, class: "nav-link" %></li><% end %></ul>diff --git a/app/views/settings/api_keys/created.html.erb b/app/views/settings/api_keys/created.html.erbindex 865b4e19..115e9826 100644--- a/app/views/settings/api_keys/created.html.erb+++ b/app/views/settings/api_keys/created.html.erb@@ -91,4 +91,4 @@) %></div></div>-<% end %>\ No newline at end of file+<% end %>diff --git a/app/views/settings/api_keys/created.turbo_stream.erb b/app/views/settings/api_keys/created.turbo_stream.erbindex b72825ab..b9651cdc 100644--- a/app/views/settings/api_keys/created.turbo_stream.erb+++ b/app/views/settings/api_keys/created.turbo_stream.erb@@ -99,4 +99,4 @@<% end %></div></div>-<% end %>\ No newline at end of file+<% end %>diff --git a/app/views/settings/api_keys/new.html.erb b/app/views/settings/api_keys/new.html.erbindex 3f517262..5c309721 100644--- a/app/views/settings/api_keys/new.html.erb+++ b/app/views/settings/api_keys/new.html.erb@@ -57,4 +57,4 @@) %></div><% end %>-<% end %>\ No newline at end of file+<% end %>diff --git a/app/views/settings/api_keys/show.html.erb b/app/views/settings/api_keys/show.html.erbindex b78c1d43..27786452 100644--- a/app/views/settings/api_keys/show.html.erb+++ b/app/views/settings/api_keys/show.html.erb@@ -189,4 +189,4 @@</div></div><% end %>-<% end %>\ No newline at end of file+<% end %>diff --git a/app/views/transactions/_transaction.html.erb b/app/views/transactions/_transaction.html.erbindex 17b0e44e..d6807adb 100644--- a/app/views/transactions/_transaction.html.erb+++ b/app/views/transactions/_transaction.html.erb@@ -6,9 +6,10 @@<%= turbo_frame_tag dom_id(transaction) do %><div class="grid grid-cols-12 items-center text-primary text-sm font-medium p-4 lg:p-4<%= @focused_record == entry || @focused_record == transaction ?- "border border-gray-900 rounded-lg" : "" %>">+ "border border-gray-900 rounded-lg" : "" %>+ <%= entry.excluded ? "opacity-50 text-gray-400" : "" %>">- <div class="pr-4 lg:pr-10 flex items-center gap-3 lg:gap-4 col-span-8 <%= view_ctx == 'global' ? 'lg:col-span-8' : 'lg:col-span-6' %>">+ <div class="pr-4 lg:pr-10 flex items-center gap-3 lg:gap-4 col-span-8 <%= view_ctx == "global" ? "lg:col-span-8" : "lg:col-span-6" %>"><%= check_box_tag dom_id(entry, "selection"),disabled: transaction.transfer.present?,class: "checkbox checkbox--light",@@ -61,7 +62,7 @@</div><div class="flex items-center gap-1 flex-shrink-0">- <% if entry.excluded %>+ <% if transaction.one_time? %><span class="text-orange-500" title="One-time <%= entry.amount.negative? ? "income" : "expense" %> (excluded from averages)"><%= icon "asterisk", size: "sm", color: "current" %></span>diff --git a/app/views/transactions/show.html.erb b/app/views/transactions/show.html.erbindex d2adc414..bb504536 100644--- a/app/views/transactions/show.html.erb+++ b/app/views/transactions/show.html.erb@@ -106,13 +106,34 @@data: { controller: "auto-submit-form" } do |f| %><div class="flex cursor-pointer items-center gap-4 justify-between"><div class="text-sm space-y-1">- <h4 class="text-primary">One-time <%= @entry.amount.negative? ? "Income" : "Expense" %></h4>- <p class="text-secondary">One-time transactions will be excluded from certain budgeting calculations and reports to help you see what's really important.</p>+ <h4 class="text-primary">Exclude</h4>+ <p class="text-secondary">Excluded transactions will be removed from budgeting calculations and reports.</p></div><%= f.toggle :excluded, { data: { auto_submit_form_target: "auto" } } %></div><% end %>+ </div>++ <div class="pb-4">+ <%= styled_form_with model: @entry,+ url: transaction_path(@entry),+ class: "p-3",+ data: { controller: "auto-submit-form" } do |f| %>+ <%= f.fields_for :entryable do |ef| %>+ <div class="flex cursor-pointer items-center gap-4 justify-between">+ <div class="text-sm space-y-1">+ <h4 class="text-primary">One-time <%= @entry.amount.negative? ? "Income" : "Expense" %></h4>+ <p class="text-secondary">One-time transactions will be excluded from certain budgeting calculations and reports to help you see what's really important.</p>+ </div>++ <%= ef.toggle :kind, {+ checked: @entry.transaction.one_time?,+ data: { auto_submit_form_target: "auto" }+ }, "one_time", "standard" %>+ </div>+ <% end %>+ <% end %><div class="flex items-center justify-between gap-4 p-3"><div class="text-sm space-y-1">diff --git a/db/migrate/20250620204550_update_excluded_transactions_to_one_time.rb b/db/migrate/20250620204550_update_excluded_transactions_to_one_time.rbnew file mode 100644index 00000000..865c0f10--- /dev/null+++ b/db/migrate/20250620204550_update_excluded_transactions_to_one_time.rb@@ -0,0 +1,33 @@+class UpdateExcludedTransactionsToOneTime < ActiveRecord::Migration[7.2]+ def change+ reversible do |dir|+ dir.up do+ # Update all transactions that have excluded entries to be one_time+ # They remain excluded as well since users were using excluded as "one time" before+ execute <<~SQL+ UPDATE transactions+ SET kind = 'one_time'+ FROM entries+ WHERE entries.entryable_id = transactions.id+ AND entries.entryable_type = 'Transaction'+ AND entries.excluded = true+ AND transactions.kind = 'standard'+ SQL+ end++ dir.down do+ # Revert one_time transactions back to standard if their entry is excluded+ # This assumes these were the ones we migrated in the up method+ execute <<~SQL+ UPDATE transactions+ SET kind = 'standard'+ FROM entries+ WHERE entries.entryable_id = transactions.id+ AND entries.entryable_type = 'Transaction'+ AND entries.excluded = true+ AND transactions.kind = 'one_time'+ SQL+ end+ end+ end+enddiff --git a/db/schema.rb b/db/schema.rbindex bca565d1..905bc821 100644--- a/db/schema.rb+++ b/db/schema.rb@@ -10,7 +10,7 @@## It's strongly recommended that you check this file into your version control system.-ActiveRecord::Schema[7.2].define(version: 2025_06_18_120703) do+ActiveRecord::Schema[7.2].define(version: 2025_06_20_204550) do# These are extensions that must be enabled in order to support this databaseenable_extension "pgcrypto"enable_extension "plpgsql"diff --git a/test/models/income_statement_test.rb b/test/models/income_statement_test.rbindex b9b2ce51..a2680ccb 100644--- a/test/models/income_statement_test.rb+++ b/test/models/income_statement_test.rb@@ -204,6 +204,20 @@ class IncomeStatementTest < ActiveSupport::TestCaseassert_equal Money.new(900, @family.currency), totals.expense_moneyend+ test "excludes excluded transactions from income statement calculations" do+ # Create an excluded transaction+ excluded_transaction_entry = create_transaction(account: @checking_account, amount: 250, category: @groceries_category)+ excluded_transaction_entry.update!(excluded: true)++ income_statement = IncomeStatement.new(@family)+ totals = income_statement.totals++ # Should exclude excluded transactions+ assert_equal 4, totals.transactions_count # Only original 4 transactions+ assert_equal Money.new(1000, @family.currency), totals.income_money+ assert_equal Money.new(900, @family.currency), totals.expense_money+ end+# NEW TESTS: Interval-Based Calculationstest "different intervals return different statistical results with multi-period data" do# Clear existing transactionsdiff --git a/test/models/transaction/search_test.rb b/test/models/transaction/search_test.rbindex 404aa42c..c9c660b2 100644--- a/test/models/transaction/search_test.rb+++ b/test/models/transaction/search_test.rb@@ -298,35 +298,4 @@ class Transaction::SearchTest < ActiveSupport::TestCaseassert_equal Money.new(0, "USD"), totals.expense_moneyassert_equal Money.new(0, "USD"), totals.income_moneyend-- test "totals respects excluded transactions filter from search" do- # Create an excluded transaction (should be excluded by default)- excluded_entry = create_transaction(- account: @checking_account,- amount: 100,- kind: "standard"- )- excluded_entry.update!(excluded: true) # Marks it as excluded-- # Create a normal transaction- normal_entry = create_transaction(- account: @checking_account,- amount: 50,- kind: "standard"- )-- # Default behavior should exclude excluded transactions- search = Transaction::Search.new(@family)- totals = search.totals-- assert_equal 1, totals.count- assert_equal Money.new(50, "USD"), totals.expense_money # Only non-excluded transaction-- # Explicitly include excluded transactions- search_with_excluded = Transaction::Search.new(@family, filters: { excluded_transactions: true })- totals_with_excluded = search_with_excluded.totals-- assert_equal 2, totals_with_excluded.count- assert_equal Money.new(150, "USD"), totals_with_excluded.expense_money # Both transactions- endend