mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-21 14:19:39 +02:00
Invert liability graphs to have correct signage (#1928)
This commit is contained in:
parent
fa0248056d
commit
7c66f16750
1 changed files with 8 additions and 0 deletions
|
@ -14,6 +14,7 @@ module Account::Chartable
|
||||||
])
|
])
|
||||||
|
|
||||||
balances = gapfill_balances(balances)
|
balances = gapfill_balances(balances)
|
||||||
|
balances = invert_balances(balances) if favorable_direction == "down"
|
||||||
|
|
||||||
values = [ nil, *balances ].each_cons(2).map do |prev, curr|
|
values = [ nil, *balances ].each_cons(2).map do |prev, curr|
|
||||||
Series::Value.new(
|
Series::Value.new(
|
||||||
|
@ -69,6 +70,13 @@ module Account::Chartable
|
||||||
SQL
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def invert_balances(balances)
|
||||||
|
balances.map do |balance|
|
||||||
|
balance.balance = -balance.balance
|
||||||
|
balance
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def gapfill_balances(balances)
|
def gapfill_balances(balances)
|
||||||
gapfilled = []
|
gapfilled = []
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue