1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-08 06:55:21 +02:00

Fix method naming conflict

This commit is contained in:
Zach Gollwitzer 2025-06-17 11:31:46 -04:00
parent ae4a4e22b2
commit b049f23cad
6 changed files with 56 additions and 60 deletions

View file

@ -110,7 +110,7 @@ module ApplicationHelper
private private
def calculate_total(item, money_method, negate) 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) total = items.sum(&money_method)
negate ? -total : total negate ? -total : total
end end

View file

@ -14,10 +14,6 @@ module Transaction::Transferable
transfer_as_inflow || transfer_as_outflow transfer_as_inflow || transfer_as_outflow
end end
def transfer?
transfer.present?
end
def transfer_match_candidates def transfer_match_candidates
candidates_scope = if self.entry.amount.negative? candidates_scope = if self.entry.amount.negative?
family_matches_scope.where("inflow_candidates.entryable_id = ?", self.id) family_matches_scope.where("inflow_candidates.entryable_id = ?", self.id)

View file

@ -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" 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-list-filter-target="input"
data-action="list-filter#filter"> 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") %>
</div>
</div> </div>
</div> <div data-list-filter-target="list" class="flex flex-col gap-0.5 p-1.5 mt-0.5 mr-2 max-h-64 overflow-y-scroll scrollbar">
<div data-list-filter-target="list" class="flex flex-col gap-0.5 p-1.5 mt-0.5 mr-2 max-h-64 overflow-y-scroll scrollbar"> <div class="pb-2 pl-4 mr-2 text-secondary hidden" data-list-filter-target="emptyMessage">
<div class="pb-2 pl-4 mr-2 text-secondary hidden" data-list-filter-target="emptyMessage"> <%= t(".no_categories") %>
<%= t(".no_categories") %> </div>
</div> <% if @categories.any? %>
<% if @categories.any? %> <% Category::Group.for(@categories).each do |group| %>
<% Category::Group.for(@categories).each do |group| %> <%= render "category/dropdowns/row", category: group.category %>
<%= render "category/dropdowns/row", category: group.category %>
<% group.subcategories.each do |category| %> <% group.subcategories.each do |category| %>
<%= render "category/dropdowns/row", category: category %> <%= render "category/dropdowns/row", category: category %>
<% end %>
<% end %> <% end %>
<% end %> <% else %>
<% else %> <div class="flex justify-center items-center py-12">
<div class="flex justify-center items-center py-12"> <div class="text-center flex flex-col items-center max-w-[500px]">
<div class="text-center flex flex-col items-center max-w-[500px]"> <p class="text-sm text-secondary font-normal mb-4"><%= t(".empty") %></p>
<p class="text-sm text-secondary font-normal mb-4"><%= t(".empty") %></p>
<%= render ButtonComponent.new( <%= render ButtonComponent.new(
text: t(".bootstrap"), text: t(".bootstrap"),
variant: "outline", variant: "outline",
href: bootstrap_categories_path, href: bootstrap_categories_path,
method: :post, method: :post,
data: { turbo_frame: :_top }) %> data: { turbo_frame: :_top }) %>
</div>
</div> </div>
</div> <% end %>
<% end %> </div>
</div>
<%= render "shared/ruler", classes: "my-2" %> <%= render "shared/ruler", classes: "my-2" %>
<div class="relative p-1.5 w-full"> <div class="relative p-1.5 w-full">
<% if @transaction.category %> <% if @transaction.category %>
<%= button_to transaction_path(@transaction.entry), <%= button_to transaction_path(@transaction.entry),
method: :patch, method: :patch,
data: { turbo_frame: dom_id(@transaction.entry) }, data: { turbo_frame: dom_id(@transaction.entry) },
params: { entry: { entryable_type: "Transaction", entryable_attributes: { id: @transaction.id, category_id: nil } } }, 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 %> 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 %>
<% end %>
<% unless @transaction.transfer? %> <% unless @transaction.transfer.present? %>
<%= link_to new_transaction_transfer_match_path(@transaction.entry), <%= 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", 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 %> data: { turbo_frame: "modal" } do %>
<%= icon("refresh-cw") %> <%= icon("refresh-cw") %>
<p>Match transfer/payment</p> <p>Match transfer/payment</p>
<% end %>
<% end %> <% end %>
<% end %>
<div class="flex text-sm font-medium items-center gap-2 text-secondary w-full rounded-lg p-2"> <div class="flex text-sm font-medium items-center gap-2 text-secondary w-full rounded-lg p-2">
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<%= form_with url: transaction_path(@transaction.entry), <%= form_with url: transaction_path(@transaction.entry),
method: :patch, method: :patch,
data: { controller: "auto-submit-form" } do |f| %> data: { controller: "auto-submit-form" } do |f| %>
<%= f.hidden_field "entry[excluded]", value: !@transaction.entry.excluded %> <%= f.hidden_field "entry[excluded]", value: !@transaction.entry.excluded %>
<%= f.check_box "entry[excluded]", <%= f.check_box "entry[excluded]",
checked: @transaction.entry.excluded, checked: @transaction.entry.excluded,
class: "checkbox checkbox--light", class: "checkbox checkbox--light",
data: { auto_submit_form_target: "auto", autosubmit_trigger_event: "change" } %> data: { auto_submit_form_target: "auto", autosubmit_trigger_event: "change" } %>
<% end %> <% end %>
</div>
<p>One-time <%= @transaction.entry.amount.negative? ? "income" : "expense" %></p>
<span class="text-orange-500 ml-auto">
<%= icon("asterisk", color: "current") %>
</span>
</div> </div>
<p>One-time <%= @transaction.entry.amount.negative? ? "income" : "expense" %></p>
<span class="text-orange-500 ml-auto">
<%= icon("asterisk", color: "current") %>
</span>
</div> </div>
</div> </div>
</div> <% end %>
<% end %>

View file

@ -12,7 +12,7 @@
</span> </span>
</h3> </h3>
<% if entry.transaction.transfer? %> <% if entry.transaction.transfer.present? %>
<%= icon "arrow-left-right", class: "mt-1" %> <%= icon "arrow-left-right", class: "mt-1" %>
<% end %> <% end %>

View file

@ -10,7 +10,7 @@
<div class="pr-4 lg:pr-10 flex items-center gap-3 lg:gap-4 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 lg:col-span-6">
<%= check_box_tag dom_id(entry, "selection"), <%= check_box_tag dom_id(entry, "selection"),
disabled: transaction.transfer?, disabled: transaction.transfer.present?,
class: "checkbox checkbox--light", class: "checkbox checkbox--light",
data: { data: {
id: entry.id, id: entry.id,
@ -37,8 +37,8 @@
<div class="space-y-0.5"> <div class="space-y-0.5">
<div class="flex items-center gap-1"> <div class="flex items-center gap-1">
<%= link_to( <%= link_to(
transaction.transfer? ? transaction.transfer.name : entry.name, transaction.transfer.present? ? transaction.transfer.name : entry.name,
transaction.transfer? ? transfer_path(transaction.transfer) : entry_path(entry), transaction.transfer.present? ? transfer_path(transaction.transfer) : entry_path(entry),
data: { data: {
turbo_frame: "drawer", turbo_frame: "drawer",
turbo_prefetch: false turbo_prefetch: false
@ -52,13 +52,13 @@
</span> </span>
<% end %> <% end %>
<% if transaction.transfer? %> <% if transaction.transfer.present? %>
<%= render "transactions/transfer_match", transaction: transaction %> <%= render "transactions/transfer_match", transaction: transaction %>
<% end %> <% end %>
</div> </div>
<div class="text-secondary text-xs font-normal hidden lg:block"> <div class="text-secondary text-xs font-normal hidden lg:block">
<% if transaction.transfer? %> <% if transaction.transfer.present? %>
<%= render "transfers/account_links", <%= render "transfers/account_links",
transfer: transaction.transfer, transfer: transaction.transfer,
is_inflow: transaction.transfer_as_inflow.present? %> is_inflow: transaction.transfer_as_inflow.present? %>
@ -81,7 +81,7 @@
<div class="col-span-4 lg:col-span-2 ml-auto text-right"> <div class="col-span-4 lg:col-span-2 ml-auto text-right">
<%= content_tag :p, <%= content_tag :p,
transaction.transfer? && view_ctx == "global" ? "+/- #{format_money(entry.amount_money.abs)}" : format_money(-entry.amount_money), transaction.transfer.present? && view_ctx == "global" ? "+/- #{format_money(entry.amount_money.abs)}" : format_money(-entry.amount_money),
class: ["text-green-600": entry.amount.negative?] %> class: ["text-green-600": entry.amount.negative?] %>
</div> </div>

View file

@ -21,7 +21,7 @@
disabled: @entry.linked?, disabled: @entry.linked?,
"data-auto-submit-form-target": "auto" %> "data-auto-submit-form-target": "auto" %>
<% unless @entry.transaction.transfer? %> <% unless @entry.transaction.transfer.present? %>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<%= f.select :nature, <%= f.select :nature,
[["Expense", "outflow"], ["Income", "inflow"]], [["Expense", "outflow"], ["Income", "inflow"]],
@ -57,7 +57,7 @@
url: transaction_path(@entry), url: transaction_path(@entry),
class: "space-y-2", class: "space-y-2",
data: { controller: "auto-submit-form" } do |f| %> data: { controller: "auto-submit-form" } do |f| %>
<% unless @entry.transaction.transfer? %> <% unless @entry.transaction.transfer.present? %>
<%= f.select :account, <%= f.select :account,
options_for_select( options_for_select(
Current.family.accounts.alphabetically.pluck(:name, :id), Current.family.accounts.alphabetically.pluck(:name, :id),