mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Add Property Details View (#1116)
* Add backend for property account details
* Rubocop updates
* Add property form with details
* Revert "Rubocop updates"
This reverts commit 05b0b8f3a4
.
* Bump brakeman to latest version
* Add overview section to property view
* Lint fixes
This commit is contained in:
parent
4433488562
commit
e856691c86
30 changed files with 547 additions and 81 deletions
|
@ -1,3 +1,30 @@
|
|||
class Property < ApplicationRecord
|
||||
include Accountable
|
||||
|
||||
has_one :address, as: :addressable, dependent: :destroy
|
||||
|
||||
accepts_nested_attributes_for :address
|
||||
|
||||
attribute :area_unit, :string, default: "sqft"
|
||||
|
||||
def area
|
||||
Measurement.new(area_value, area_unit) if area_value.present?
|
||||
end
|
||||
|
||||
def purchase_price
|
||||
first_valuation_amount
|
||||
end
|
||||
|
||||
def equity_value
|
||||
account.balance_money
|
||||
end
|
||||
|
||||
def trend
|
||||
TimeSeries::Trend.new(current: account.balance_money, previous: first_valuation_amount)
|
||||
end
|
||||
|
||||
private
|
||||
def first_valuation_amount
|
||||
account.entries.account_valuations.order(:date).first&.amount_money || account.balance_money
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue