Fix mode bug
This commit is contained in:
@@ -33,4 +33,8 @@ module Accountable
|
||||
rescue Money::ConversionError
|
||||
TimeSeries.new([])
|
||||
end
|
||||
|
||||
def mode_required?
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,4 +4,8 @@ class OtherAsset < ApplicationRecord
|
||||
def color
|
||||
"#12B76A"
|
||||
end
|
||||
|
||||
def mode_required?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,4 +4,8 @@ class OtherLiability < ApplicationRecord
|
||||
def color
|
||||
"#737373"
|
||||
end
|
||||
|
||||
def mode_required?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
<span>Transactions</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user