diff --git a/app/models/concerns/accountable.rb b/app/models/concerns/accountable.rb index a7a10284..5f5ce93d 100644 --- a/app/models/concerns/accountable.rb +++ b/app/models/concerns/accountable.rb @@ -33,4 +33,8 @@ module Accountable rescue Money::ConversionError TimeSeries.new([]) end + + def mode_required? + true + end end diff --git a/app/models/other_asset.rb b/app/models/other_asset.rb index 90ca9e32..29b2048a 100644 --- a/app/models/other_asset.rb +++ b/app/models/other_asset.rb @@ -4,4 +4,8 @@ class OtherAsset < ApplicationRecord def color "#12B76A" end + + def mode_required? + false + end end diff --git a/app/models/other_liability.rb b/app/models/other_liability.rb index 04a3737b..4be8e38c 100644 --- a/app/models/other_liability.rb +++ b/app/models/other_liability.rb @@ -4,4 +4,8 @@ class OtherLiability < ApplicationRecord def color "#737373" end + + def mode_required? + false + end end diff --git a/app/models/property.rb b/app/models/property.rb index 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 + private def first_valuation_amount account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money diff --git a/app/models/vehicle.rb b/app/models/vehicle.rb index 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 + private def first_valuation_amount account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money diff --git a/app/views/accounts/_form.html.erb b/app/views/accounts/_form.html.erb index 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| %>
<% 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.erb index 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 @@ Transactions <% end %>
- \ No newline at end of file + diff --git a/app/views/accounts/accountables/credit_card/_overview.html.erb b/app/views/accounts/accountables/credit_card/_overview.html.erb index 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 @@
<%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %> -
\ No newline at end of file + diff --git a/app/views/accounts/accountables/loan/_overview.html.erb b/app/views/accounts/accountables/loan/_overview.html.erb index 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 @@
<%= link_to "Edit account details", edit_account_path(account), class: "btn btn--ghost", data: { turbo_frame: :modal } %> -
\ No newline at end of file +