From b049f23cad26276b19a3703ccd081a345ee1d172 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Tue, 17 Jun 2025 11:31:46 -0400 Subject: [PATCH] Fix method naming conflict --- app/helpers/application_helper.rb | 2 +- app/models/transaction/transferable.rb | 4 - app/views/category/dropdowns/show.html.erb | 92 ++++++++++---------- app/views/transactions/_header.html.erb | 2 +- app/views/transactions/_transaction.html.erb | 12 +-- app/views/transactions/show.html.erb | 4 +- 6 files changed, 56 insertions(+), 60 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a86e374e..1602931c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -110,7 +110,7 @@ module ApplicationHelper private def calculate_total(item, money_method, negate) - items = item.reject { |i| i.respond_to?(:entryable) && i.entryable.transfer? } + items = item.reject { |i| i.respond_to?(:entryable) && i.entryable.transfer.present? } total = items.sum(&money_method) negate ? -total : total end diff --git a/app/models/transaction/transferable.rb b/app/models/transaction/transferable.rb index d839047a..cea7978b 100644 --- a/app/models/transaction/transferable.rb +++ b/app/models/transaction/transferable.rb @@ -14,10 +14,6 @@ module Transaction::Transferable transfer_as_inflow || transfer_as_outflow end - def transfer? - transfer.present? - end - def transfer_match_candidates candidates_scope = if self.entry.amount.negative? family_matches_scope.where("inflow_candidates.entryable_id = ?", self.id) diff --git a/app/views/category/dropdowns/show.html.erb b/app/views/category/dropdowns/show.html.erb index 4329918f..6af8ba45 100644 --- a/app/views/category/dropdowns/show.html.erb +++ b/app/views/category/dropdowns/show.html.erb @@ -9,81 +9,81 @@ class="bg-container placeholder:text-sm placeholder:text-secondary font-normal h-10 relative pl-10 w-full border-none rounded-lg focus:outline-hidden focus:ring-0" data-list-filter-target="input" data-action="list-filter#filter"> - <%= icon("search", class: "absolute inset-0 ml-2 transform top-1/2 -translate-y-1/2") %> + <%= icon("search", class: "absolute inset-0 ml-2 transform top-1/2 -translate-y-1/2") %> + - -
- - <% if @categories.any? %> - <% Category::Group.for(@categories).each do |group| %> - <%= render "category/dropdowns/row", category: group.category %> +
+ + <% if @categories.any? %> + <% Category::Group.for(@categories).each do |group| %> + <%= render "category/dropdowns/row", category: group.category %> - <% group.subcategories.each do |category| %> - <%= render "category/dropdowns/row", category: category %> + <% group.subcategories.each do |category| %> + <%= render "category/dropdowns/row", category: category %> + <% end %> <% end %> - <% end %> - <% else %> -
-
-

<%= t(".empty") %>

+ <% else %> +
+
+

<%= t(".empty") %>

- <%= render ButtonComponent.new( + <%= render ButtonComponent.new( text: t(".bootstrap"), variant: "outline", href: bootstrap_categories_path, method: :post, data: { turbo_frame: :_top }) %> +
-
- <% end %> -
+ <% end %> +
- <%= render "shared/ruler", classes: "my-2" %> + <%= render "shared/ruler", classes: "my-2" %> -
- <% if @transaction.category %> - <%= button_to transaction_path(@transaction.entry), +
+ <% if @transaction.category %> + <%= button_to transaction_path(@transaction.entry), method: :patch, data: { turbo_frame: dom_id(@transaction.entry) }, params: { entry: { entryable_type: "Transaction", entryable_attributes: { id: @transaction.id, category_id: nil } } }, class: "flex text-sm font-medium items-center gap-2 text-secondary w-full rounded-lg p-2 hover:bg-container-inset-hover" do %> - <%= icon("minus") %> + <%= icon("minus") %> - <%= t(".clear") %> + <%= t(".clear") %> + <% end %> <% end %> - <% end %> - <% unless @transaction.transfer? %> - <%= link_to new_transaction_transfer_match_path(@transaction.entry), + <% unless @transaction.transfer.present? %> + <%= link_to new_transaction_transfer_match_path(@transaction.entry), class: "flex text-sm font-medium items-center gap-2 text-secondary w-full rounded-lg p-2 hover:bg-container-inset-hover", data: { turbo_frame: "modal" } do %> - <%= icon("refresh-cw") %> + <%= icon("refresh-cw") %> -

Match transfer/payment

+

Match transfer/payment

+ <% end %> <% end %> - <% end %> -
-
- <%= form_with url: transaction_path(@transaction.entry), +
+
+ <%= form_with url: transaction_path(@transaction.entry), method: :patch, data: { controller: "auto-submit-form" } do |f| %> - <%= f.hidden_field "entry[excluded]", value: !@transaction.entry.excluded %> - <%= f.check_box "entry[excluded]", + <%= f.hidden_field "entry[excluded]", value: !@transaction.entry.excluded %> + <%= f.check_box "entry[excluded]", checked: @transaction.entry.excluded, class: "checkbox checkbox--light", data: { auto_submit_form_target: "auto", autosubmit_trigger_event: "change" } %> - <% end %> + <% end %> +
+ +

One-time <%= @transaction.entry.amount.negative? ? "income" : "expense" %>

+ + + <%= icon("asterisk", color: "current") %> +
- -

One-time <%= @transaction.entry.amount.negative? ? "income" : "expense" %>

- - - <%= icon("asterisk", color: "current") %> -
-
-<% end %> + <% end %> diff --git a/app/views/transactions/_header.html.erb b/app/views/transactions/_header.html.erb index 6c7b1615..e56d2270 100644 --- a/app/views/transactions/_header.html.erb +++ b/app/views/transactions/_header.html.erb @@ -12,7 +12,7 @@ - <% if entry.transaction.transfer? %> + <% if entry.transaction.transfer.present? %> <%= icon "arrow-left-right", class: "mt-1" %> <% end %> diff --git a/app/views/transactions/_transaction.html.erb b/app/views/transactions/_transaction.html.erb index a046915e..ebca40de 100644 --- a/app/views/transactions/_transaction.html.erb +++ b/app/views/transactions/_transaction.html.erb @@ -10,7 +10,7 @@
<%= check_box_tag dom_id(entry, "selection"), - disabled: transaction.transfer?, + disabled: transaction.transfer.present?, class: "checkbox checkbox--light", data: { id: entry.id, @@ -37,8 +37,8 @@
<%= link_to( - transaction.transfer? ? transaction.transfer.name : entry.name, - transaction.transfer? ? transfer_path(transaction.transfer) : entry_path(entry), + transaction.transfer.present? ? transaction.transfer.name : entry.name, + transaction.transfer.present? ? transfer_path(transaction.transfer) : entry_path(entry), data: { turbo_frame: "drawer", turbo_prefetch: false @@ -52,13 +52,13 @@ <% end %> - <% if transaction.transfer? %> + <% if transaction.transfer.present? %> <%= render "transactions/transfer_match", transaction: transaction %> <% end %>