mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Plaid portfolio sync algorithm and calculation improvements (#1526)
* Start tests rework * Cash balance on schema * Add reverse syncer * Reverse balance sync with holdings * Reverse holdings sync * Reverse holdings sync should work with only trade entries * Consolidate brokerage cash * Add forward sync option * Update new balance info after syncs * Intraday balance calculator and sync fixes * Show only balance for trade entries * Tests passing * Update Gemfile.lock * Cleanup, performance improvements * Remove account reloads for reliable sync outputs * Simplify valuation view logic * Special handling for Plaid cash holding
This commit is contained in:
parent
a59ca5b7c6
commit
49c353e10c
72 changed files with 1152 additions and 1046 deletions
|
@ -43,13 +43,10 @@ class Account::EntryTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test "triggers sync with correct start date when transaction deleted" do
|
||||
current_entry = create_transaction(date: 1.day.ago.to_date)
|
||||
prior_entry = create_transaction(date: current_entry.date - 1.day)
|
||||
@entry.destroy!
|
||||
|
||||
current_entry.destroy!
|
||||
|
||||
current_entry.account.expects(:sync_later).with(start_date: prior_entry.date)
|
||||
current_entry.sync_account_later
|
||||
@entry.account.expects(:sync_later).with(start_date: nil)
|
||||
@entry.sync_account_later
|
||||
end
|
||||
|
||||
test "can search entries" do
|
||||
|
@ -99,26 +96,4 @@ class Account::EntryTest < ActiveSupport::TestCase
|
|||
assert create_transaction(amount: -10).inflow?
|
||||
assert create_transaction(amount: 10).outflow?
|
||||
end
|
||||
|
||||
test "balance_after_entry skips account valuations" do
|
||||
family = families(:empty)
|
||||
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
|
||||
|
||||
new_valuation = create_valuation(account: account, amount: 1)
|
||||
transaction = create_transaction(date: new_valuation.date, account: account, amount: -100)
|
||||
|
||||
|
||||
assert_equal Money.new(100), transaction.balance_after_entry
|
||||
end
|
||||
|
||||
test "prior_entry_balance returns last transaction entry balance" do
|
||||
family = families(:empty)
|
||||
account = family.accounts.create! name: "Test", balance: 0, currency: "USD", accountable: Depository.new
|
||||
|
||||
new_valuation = create_valuation(account: account, amount: 1)
|
||||
transaction = create_transaction(date: new_valuation.date, account: account, amount: -100)
|
||||
|
||||
|
||||
assert_equal Money.new(100), transaction.prior_entry_balance
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue