mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-02 20:15:22 +02:00
Add the ability to "rollup" values in a time series (#554)
* Clean up time series models * Add value group rollup class for summarizing hierarchical data * Integrate new classes * Update UI to use new patterns * Update D3 charts to expect new data format * Clean up account model * More cleanup * Money improvements * Use new money fields * Remove invalid fixture data to avoid orphaned accountables * Update time series to work better with collections * Fix tests and UI bugs
This commit is contained in:
parent
0a8518506c
commit
f904d9d062
34 changed files with 687 additions and 391 deletions
|
@ -1,26 +0,0 @@
|
|||
class Trend
|
||||
attr_reader :current, :previous, :type
|
||||
|
||||
def initialize(current: nil, previous: nil, type: "asset")
|
||||
@current = current
|
||||
@previous = previous
|
||||
@type = type # asset means positive trend is good, liability means negative trend is good
|
||||
end
|
||||
|
||||
def direction
|
||||
return "flat" if @current == @previous
|
||||
return "up" if @previous.nil? || (@current && @current > @previous)
|
||||
"down"
|
||||
end
|
||||
|
||||
def amount
|
||||
return 0 if @previous.nil?
|
||||
@current - @previous
|
||||
end
|
||||
|
||||
def percent
|
||||
return 0 if @previous.nil?
|
||||
return Float::INFINITY if @previous == 0
|
||||
((@current - @previous).abs / @previous.abs.to_f * 100).round(1)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue