The personal finance app for everyone
Fix mode bug
Zach Gollwitzer3c0fdd84eefe
diff --git a/app/models/concerns/accountable.rb b/app/models/concerns/accountable.rbindex a7a10284..5f5ce93d 100644--- a/app/models/concerns/accountable.rb+++ b/app/models/concerns/accountable.rb@@ -33,4 +33,8 @@ module Accountablerescue Money::ConversionErrorTimeSeries.new([])end++ def mode_required?+ true+ endenddiff --git a/app/models/other_asset.rb b/app/models/other_asset.rbindex 90ca9e32..29b2048a 100644--- a/app/models/other_asset.rb+++ b/app/models/other_asset.rb@@ -4,4 +4,8 @@ class OtherAsset < ApplicationRecorddef color"#12B76A"end++ def mode_required?+ false+ endenddiff --git a/app/models/other_liability.rb b/app/models/other_liability.rbindex 04a3737b..4be8e38c 100644--- a/app/models/other_liability.rb+++ b/app/models/other_liability.rb@@ -4,4 +4,8 @@ class OtherLiability < ApplicationRecorddef color"#737373"end++ def mode_required?+ false+ endenddiff --git a/app/models/property.rb b/app/models/property.rbindex 304c4d78..02f4b848 100644--- a/app/models/property.rb+++ b/app/models/property.rb@@ -23,6 +23,10 @@ class Property < ApplicationRecord"#06AED4"end+ def mode_required?+ false+ end+privatedef first_valuation_amountaccount.entries.account_valuations.order(:date).first&.amount_money || account.balance_moneydiff --git a/app/models/vehicle.rb b/app/models/vehicle.rbindex 741070c2..92c5b940 100644--- a/app/models/vehicle.rb+++ b/app/models/vehicle.rb@@ -19,6 +19,10 @@ class Vehicle < ApplicationRecord"#F23E94"end+ def mode_required?+ false+ end+privatedef first_valuation_amountaccount.entries.account_valuations.order(:date).first&.amount_money || account.balance_moneydiff --git a/app/views/accounts/_form.html.erb b/app/views/accounts/_form.html.erbindex 65dee8df..b5d17930 100644--- a/app/views/accounts/_form.html.erb+++ b/app/views/accounts/_form.html.erb@@ -3,7 +3,9 @@<%= styled_form_with model: account, url: url, scope: :account, class: "flex flex-col gap-4 justify-between grow", data: { turbo: false } do |f| %><div class="grow space-y-2"><% unless account.new_record? %>- <%= f.select :mode, Account::VALUE_MODES.map { |mode| [mode.titleize, mode] }, { label: t(".mode"), prompt: t(".mode_prompt") } %>+ <% if account.accountable.mode_required? %>+ <%= f.select :mode, Account::VALUE_MODES.map { |mode| [mode.titleize, mode] }, { label: t(".mode"), prompt: t(".mode_prompt") }, required: true %>+ <% end %><% end %><%= f.select :accountable_type, Accountable::TYPES.map { |type| [type.titleize, type] }, { label: t(".accountable_type"), prompt: t(".type_prompt") }, required: true, autofocus: true %>diff --git a/app/views/accounts/accountables/_value_onboarding.html.erb b/app/views/accounts/accountables/_value_onboarding.html.erbindex 26b20b6a..27798add 100644--- a/app/views/accounts/accountables/_value_onboarding.html.erb+++ b/app/views/accounts/accountables/_value_onboarding.html.erb@@ -13,4 +13,4 @@<span>Transactions</span><% end %></div>-</div>\ No newline at end of file+</div>diff --git a/app/views/accounts/accountables/credit_card/_overview.html.erb b/app/views/accounts/accountables/credit_card/_overview.html.erbindex 668326b5..032d8b52 100644--- a/app/views/accounts/accountables/credit_card/_overview.html.erb+++ b/app/views/accounts/accountables/credit_card/_overview.html.erb@@ -28,4 +28,4 @@<div class="flex justify-center py-8"><%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %>-</div>\ No newline at end of file+</div>diff --git a/app/views/accounts/accountables/loan/_overview.html.erb b/app/views/accounts/accountables/loan/_overview.html.erbindex cdd8c131..7d1b19b5 100644--- a/app/views/accounts/accountables/loan/_overview.html.erb+++ b/app/views/accounts/accountables/loan/_overview.html.erb@@ -46,4 +46,4 @@<div class="flex justify-center py-8"><%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %>-</div>\ No newline at end of file+</div>