mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
* Move accountable partials * Split accountables into separate view partials * Fix test * Add form to permitted partials * Fix failing system tests * Update new account modal views * New sync algorithm implementation * Update account system test assertions to match new behavior * Fix off by 1 date error * Revert new balance sync algorithm * Add missing account overviews
26 lines
555 B
Ruby
26 lines
555 B
Ruby
class Vehicle < ApplicationRecord
|
|
include Accountable
|
|
|
|
attribute :mileage_unit, :string, default: "mi"
|
|
|
|
def mileage
|
|
Measurement.new(mileage_value, mileage_unit) if mileage_value.present?
|
|
end
|
|
|
|
def purchase_price
|
|
first_valuation_amount
|
|
end
|
|
|
|
def trend
|
|
TimeSeries::Trend.new(current: account.balance_money, previous: first_valuation_amount)
|
|
end
|
|
|
|
def color
|
|
"#F23E94"
|
|
end
|
|
|
|
private
|
|
def first_valuation_amount
|
|
account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money
|
|
end
|
|
end
|