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:
parent
263d65ea7e
commit
3c0fdd84ee
9 changed files with 26 additions and 4 deletions
|
@ -33,4 +33,8 @@ module Accountable
|
||||||
rescue Money::ConversionError
|
rescue Money::ConversionError
|
||||||
TimeSeries.new([])
|
TimeSeries.new([])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mode_required?
|
||||||
|
true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,4 +4,8 @@ class OtherAsset < ApplicationRecord
|
||||||
def color
|
def color
|
||||||
"#12B76A"
|
"#12B76A"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mode_required?
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,4 +4,8 @@ class OtherLiability < ApplicationRecord
|
||||||
def color
|
def color
|
||||||
"#737373"
|
"#737373"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mode_required?
|
||||||
|
false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,10 @@ class Property < ApplicationRecord
|
||||||
"#06AED4"
|
"#06AED4"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mode_required?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def first_valuation_amount
|
def first_valuation_amount
|
||||||
account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money
|
account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money
|
||||||
|
|
|
@ -19,6 +19,10 @@ class Vehicle < ApplicationRecord
|
||||||
"#F23E94"
|
"#F23E94"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mode_required?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def first_valuation_amount
|
def first_valuation_amount
|
||||||
account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money
|
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| %>
|
<%= 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">
|
<div class="grow space-y-2">
|
||||||
<% unless account.new_record? %>
|
<% 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 %>
|
<% end %>
|
||||||
|
|
||||||
<%= f.select :accountable_type, Accountable::TYPES.map { |type| [type.titleize, type] }, { label: t(".accountable_type"), prompt: t(".type_prompt") }, required: true, autofocus: true %>
|
<%= f.select :accountable_type, Accountable::TYPES.map { |type| [type.titleize, type] }, { label: t(".accountable_type"), prompt: t(".type_prompt") }, required: true, autofocus: true %>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue