1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-21 14:19:39 +02:00

Fix mode bug

This commit is contained in:
Zach Gollwitzer 2024-10-18 18:25:17 -04:00
parent 263d65ea7e
commit 3c0fdd84ee
9 changed files with 26 additions and 4 deletions

View file

@ -33,4 +33,8 @@ module Accountable
rescue Money::ConversionError
TimeSeries.new([])
end
def mode_required?
true
end
end

View file

@ -4,4 +4,8 @@ class OtherAsset < ApplicationRecord
def color
"#12B76A"
end
def mode_required?
false
end
end

View file

@ -4,4 +4,8 @@ class OtherLiability < ApplicationRecord
def color
"#737373"
end
def mode_required?
false
end
end

View file

@ -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

View file

@ -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

View file

@ -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 %>

View file

@ -13,4 +13,4 @@
<span>Transactions</span>
<% end %>
</div>
</div>
</div>

View file

@ -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>

View file

@ -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>