Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.

Commit 7c66f16

Browse files
authored
Invert liability graphs to have correct signage (#1928)
1 parent fa02480 commit 7c66f16

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/models/account/chartable.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def balance_series(currency:, period: Period.last_30_days, favorable_direction:
1414
])
1515

1616
balances = gapfill_balances(balances)
17+
balances = invert_balances(balances) if favorable_direction == "down"
1718

1819
values = [ nil, *balances ].each_cons(2).map do |prev, curr|
1920
Series::Value.new(
@@ -69,6 +70,13 @@ def balance_series_query
6970
SQL
7071
end
7172

73+
def invert_balances(balances)
74+
balances.map do |balance|
75+
balance.balance = -balance.balance
76+
balance
77+
end
78+
end
79+
7280
def gapfill_balances(balances)
7381
gapfilled = []
7482

0 commit comments

Comments
 (0)