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

Basic account onboarding (#1328)

* Basic account onboarding

* Cleanup
This commit is contained in:
Zach Gollwitzer 2024-10-18 17:18:54 -04:00 committed by GitHub
parent e8e100e1d8
commit 263d65ea7e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 146 additions and 73 deletions

View file

@ -35,7 +35,7 @@ class Account::Balance::SyncerTest < ActiveSupport::TestCase
assert_equal [ 19600, 19500, 19500, 20000, 20000, 20000 ], @account.balances.chronological.map(&:balance)
end
test "syncs account with valuations and transactions" do
test "syncs account with valuations and transactions when valuation starts" do
create_valuation(account: @account, date: 5.days.ago.to_date, amount: 20000)
create_transaction(account: @account, date: 3.days.ago.to_date, amount: -500)
create_transaction(account: @account, date: 2.days.ago.to_date, amount: 100)
@ -47,6 +47,17 @@ class Account::Balance::SyncerTest < ActiveSupport::TestCase
assert_equal [ 20000, 20000, 20500, 20400, 25000, 25000 ], @account.balances.chronological.map(&:balance)
end
test "syncs account with valuations and transactions when transaction starts" do
new_account = families(:empty).accounts.create!(name: "Test Account", balance: 1000, currency: "USD", accountable: Depository.new)
create_transaction(account: new_account, date: 2.days.ago.to_date, amount: 250)
create_valuation(account: new_account, date: Date.current, amount: 1000)
run_sync_for(new_account)
assert_equal 1000, new_account.balance
assert_equal [ 1250, 1000, 1000, 1000 ], new_account.balances.chronological.map(&:balance)
end
test "syncs account with transactions in multiple currencies" do
ExchangeRate.create! date: 1.day.ago.to_date, from_currency: "EUR", to_currency: "USD", rate: 1.2