mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
Add start balance to manual accounts (#735)
* Add start_balance to accounts * Add tests * Cleanup * Refactor code and add tests * Update physical cash demo account to be manual * Do not populate start_balance in migration * Cleanup * Review fixes * Revert calc change * Update app/models/exchange_rate.rb Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com> Signed-off-by: Jakub Kottnauer <jk@jakubkottnauer.com> * Add test * Fix syncable bug and update csv tests --------- Signed-off-by: Jakub Kottnauer <jk@jakubkottnauer.com> Co-authored-by: Zach Gollwitzer <zach.gollwitzer@gmail.com>
This commit is contained in:
parent
daf7ff8ef4
commit
3d9ff3ad2a
13 changed files with 50 additions and 17 deletions
|
@ -16,10 +16,20 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
|||
assert_response :ok
|
||||
end
|
||||
|
||||
test "create" do
|
||||
test "should create account" do
|
||||
assert_difference -> { Account.count }, +1 do
|
||||
post accounts_path, params: { account: { accountable_type: "Account::Credit" } }
|
||||
assert_redirected_to accounts_url
|
||||
end
|
||||
end
|
||||
|
||||
test "should create a valuation together with account" do
|
||||
balance = 700
|
||||
start_date = 3.days.ago.to_date
|
||||
post accounts_path, params: { account: { accountable_type: "Account::Credit", balance:, start_date: } }
|
||||
|
||||
new_valuation = Valuation.order(:created_at).last
|
||||
assert new_valuation.value == balance
|
||||
assert new_valuation.date == start_date
|
||||
end
|
||||
end
|
||||
|
|
2
test/fixtures/account/expected_balances.csv
vendored
2
test/fixtures/account/expected_balances.csv
vendored
|
@ -29,4 +29,4 @@ date_offset,collectable,checking,savings_with_valuation_overrides,credit_card,eu
|
|||
-3,550,5000,20500,1000,12000,13046.4,10000
|
||||
-2,550,5000,20500,1000,12000,12982.8,10000
|
||||
-1,550,5000,20500,1000,12000,13014,10000
|
||||
0,550,5000,20000,1000,12000,13000.8,10000
|
||||
0,550,5000,20500,1000,12000,13000.8,10000
|
|
2
test/fixtures/family/expected_snapshots.csv
vendored
2
test/fixtures/family/expected_snapshots.csv
vendored
|
@ -29,4 +29,4 @@ date_offset,net_worth,assets,liabilities,depositories,investments,loans,credits,
|
|||
-3,48096.40,49096.40,1000.00,48546.40,0.00,0.00,1000.00,0.00,0.00,550.00,0.00,0,0,3214.48,2447.715,-0.3132574667
|
||||
-2,48032.80,49032.80,1000.00,48482.80,0.00,0.00,1000.00,0.00,0.00,550.00,0.00,0,0,3214.48,2447.715,-0.3132574667
|
||||
-1,48064.00,49064.00,1000.00,48514.00,0.00,0.00,1000.00,0.00,0.00,550.00,0.00,0,0,3214.48,2447.715,-0.3132574667
|
||||
0,47550.80,48550.80,1000.00,48000.80,0.00,0.00,1000.00,0.00,0.00,550.00,0.00,0,0,3214.48,2447.715,-0.3132574667
|
||||
0,48050.80,49050.80,1000.00,48514.00,0.00,0.00,1000.00,0.00,0.00,550.00,0.00,0,0,3214.48,2447.715,-0.3132574667
|
|
|
@ -78,4 +78,12 @@ class Account::SyncableTest < ActiveSupport::TestCase
|
|||
|
||||
assert_equal 31, account.balances.count
|
||||
end
|
||||
|
||||
test "account balance is updated after sync" do
|
||||
account = accounts(:savings_with_valuation_overrides)
|
||||
|
||||
assert_changes -> { account.balance }, to: 20500 do
|
||||
account.sync
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue