1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 13:19:39 +02:00

Invert liability graphs to have correct signage (#1928)

This commit is contained in:
Zach Gollwitzer 2025-02-28 12:17:25 -05:00 committed by GitHub
parent fa0248056d
commit 7c66f16750
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,7 @@ module Account::Chartable
])
balances = gapfill_balances(balances)
balances = invert_balances(balances) if favorable_direction == "down"
values = [ nil, *balances ].each_cons(2).map do |prev, curr|
Series::Value.new(
@ -69,6 +70,13 @@ module Account::Chartable
SQL
end
def invert_balances(balances)
balances.map do |balance|
balance.balance = -balance.balance
balance
end
end
def gapfill_balances(balances)
gapfilled = []