mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
parent
e8e100e1d8
commit
263d65ea7e
24 changed files with 146 additions and 73 deletions
8
test/fixtures/accounts.yml
vendored
8
test/fixtures/accounts.yml
vendored
|
@ -5,6 +5,7 @@ other_asset:
|
|||
currency: USD
|
||||
accountable_type: OtherAsset
|
||||
accountable: one
|
||||
mode: balance
|
||||
|
||||
other_liability:
|
||||
family: dylan_family
|
||||
|
@ -13,6 +14,7 @@ other_liability:
|
|||
currency: USD
|
||||
accountable_type: OtherLiability
|
||||
accountable: one
|
||||
mode: balance
|
||||
|
||||
depository:
|
||||
family: dylan_family
|
||||
|
@ -22,6 +24,7 @@ depository:
|
|||
accountable_type: Depository
|
||||
accountable: one
|
||||
institution: chase
|
||||
mode: transactions
|
||||
|
||||
credit_card:
|
||||
family: dylan_family
|
||||
|
@ -31,6 +34,7 @@ credit_card:
|
|||
accountable_type: CreditCard
|
||||
accountable: one
|
||||
institution: chase
|
||||
mode: transactions
|
||||
|
||||
investment:
|
||||
family: dylan_family
|
||||
|
@ -39,6 +43,7 @@ investment:
|
|||
currency: USD
|
||||
accountable_type: Investment
|
||||
accountable: one
|
||||
mode: transactions
|
||||
|
||||
loan:
|
||||
family: dylan_family
|
||||
|
@ -47,6 +52,7 @@ loan:
|
|||
currency: USD
|
||||
accountable_type: Loan
|
||||
accountable: one
|
||||
mode: transactions
|
||||
|
||||
property:
|
||||
family: dylan_family
|
||||
|
@ -55,6 +61,7 @@ property:
|
|||
currency: USD
|
||||
accountable_type: Property
|
||||
accountable: one
|
||||
mode: transactions
|
||||
|
||||
vehicle:
|
||||
family: dylan_family
|
||||
|
@ -63,3 +70,4 @@ vehicle:
|
|||
currency: USD
|
||||
accountable_type: Vehicle
|
||||
accountable: one
|
||||
mode: transactions
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -96,7 +96,10 @@ class AccountsTest < ApplicationSystemTestCase
|
|||
visit accounts_url
|
||||
assert_text account_name
|
||||
|
||||
visit account_url(Account.order(:created_at).last)
|
||||
created_account = Account.order(:created_at).last
|
||||
created_account.update!(mode: "transactions")
|
||||
|
||||
visit account_url(created_account)
|
||||
|
||||
within "header" do
|
||||
find('button[data-menu-target="button"]').click
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue