mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 20:59:39 +02:00
* Add kind field to valuation * Fix schema conflict * Add kind to valuation * Scaffold opening balance manager * Opening balance manager implementation * Update account import to use opening balance manager + tests * Update account to use opening balance manager * Fix test assertions, usage of current balance manager * Lint fixes * Add Opening Balance manager, add tests to forward calculator * Add credit card to "all cash" designation * Simplify valuation model * Add current balance manager with tests * Add current balance logic to reverse calculator and plaid sync * Tweaks to initial calc logic * Ledger testing helper, tweak assertions for reverse calculator * Update test assertions * Extract balance transformer, simplify calculators * Algo simplifications * Final tweaks to calculators * Cleanup * Fix error, propagate sync errors up to parent * Update migration script, valuation naming
57 lines
1.2 KiB
Ruby
57 lines
1.2 KiB
Ruby
class Valuation::Name
|
|
def initialize(valuation_kind, accountable_type)
|
|
@valuation_kind = valuation_kind
|
|
@accountable_type = accountable_type
|
|
end
|
|
|
|
def to_s
|
|
case valuation_kind
|
|
when "opening_anchor"
|
|
opening_anchor_name
|
|
when "current_anchor"
|
|
current_anchor_name
|
|
else
|
|
recon_name
|
|
end
|
|
end
|
|
|
|
private
|
|
attr_reader :valuation_kind, :accountable_type
|
|
|
|
def opening_anchor_name
|
|
case accountable_type
|
|
when "Property", "Vehicle"
|
|
"Original purchase price"
|
|
when "Loan"
|
|
"Original principal"
|
|
when "Investment", "Crypto", "OtherAsset"
|
|
"Opening account value"
|
|
else
|
|
"Opening balance"
|
|
end
|
|
end
|
|
|
|
def current_anchor_name
|
|
case accountable_type
|
|
when "Property", "Vehicle"
|
|
"Current market value"
|
|
when "Loan"
|
|
"Current loan balance"
|
|
when "Investment", "Crypto", "OtherAsset"
|
|
"Current account value"
|
|
else
|
|
"Current balance"
|
|
end
|
|
end
|
|
|
|
def recon_name
|
|
case accountable_type
|
|
when "Property", "Investment", "Vehicle", "Crypto", "OtherAsset"
|
|
"Manual value update"
|
|
when "Loan"
|
|
"Manual principal update"
|
|
else
|
|
"Manual balance update"
|
|
end
|
|
end
|
|
end
|