mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
* Remove balance mode, sketch out refactor * Activity view checkpoint * Entry partials, checkpoint * Finish txn partial * Give entries context when editing for different turbo responses * Calculate change of balance for each entry * Account tabs consolidation * Translations, linting, brakeman updates * Account actions concern * Finalize forms, get account system tests passing * Get tests passing * Lint, rubocop, schema updates * Improve routing and stream responses * Fix broken routes * Add import option for adding accounts * Fix system test * Fix test specificity * Fix sparklines * Improve account redirects
30 lines
589 B
Ruby
30 lines
589 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
|
|
|
|
def icon
|
|
"car-front"
|
|
end
|
|
|
|
private
|
|
def first_valuation_amount
|
|
account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money
|
|
end
|
|
end
|