mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 13:35:21 +02:00
Add Local Development Demo Data (#502)
* Clean up seeds, add development demo data * Handle liability account display and sync * Fix tests
This commit is contained in:
parent
dbf575c02a
commit
14641d16de
12 changed files with 368 additions and 62 deletions
|
@ -11,6 +11,7 @@ class Account::BalanceCalculator
|
|||
oldest_entry = [ valuations.first, transactions.first ].compact.min_by(&:date)
|
||||
|
||||
net_transaction_flows = transactions.sum(&:amount)
|
||||
net_transaction_flows *= -1 if @account.classification == :liability
|
||||
implied_start_balance = oldest_entry.is_a?(Valuation) ? oldest_entry.value : @account.balance + net_transaction_flows
|
||||
|
||||
prior_balance = implied_start_balance
|
||||
|
@ -21,6 +22,7 @@ class Account::BalanceCalculator
|
|||
current_balance = valuation.value
|
||||
else
|
||||
current_day_net_transaction_flows = transactions.select { |t| t.date == date }.sum(&:amount)
|
||||
current_day_net_transaction_flows *= -1 if @account.classification == :liability
|
||||
current_balance = prior_balance - current_day_net_transaction_flows
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue