Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/models/account/chartable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def balance_series(currency:, period: Period.last_30_days, favorable_direction:
])

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(
Expand Down Expand Up @@ -69,6 +70,13 @@ def balance_series_query
SQL
end

def invert_balances(balances)
balances.map do |balance|
balance.balance = -balance.balance
balance
end
end

def gapfill_balances(balances)
gapfilled = []

Expand Down