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

Add accounts management list (#522)

* Add accounts management

* Normalize i18n file

* Get turbo streams working

* Ignore disabled accounts in calculations

* Add empty state
This commit is contained in:
Zach Gollwitzer 2024-03-07 10:55:51 -05:00 committed by GitHub
parent 0e77bab00b
commit ad7136cb63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 164 additions and 25 deletions

View file

@ -42,6 +42,22 @@ class FamilyTest < ActiveSupport::TestCase
assert_equal BigDecimal("24550"), @family.net_worth
end
test "should exclude disabled accounts from calculations" do
assets_before = @family.assets
liabilities_before = @family.liabilities
net_worth_before = @family.net_worth
disabled_checking = accounts(:checking)
disabled_cc = accounts(:credit_card)
disabled_checking.update!(is_active: false)
disabled_cc.update!(is_active: false)
assert_equal assets_before - disabled_checking.balance, @family.assets
assert_equal liabilities_before - disabled_cc.balance, @family.liabilities
assert_equal net_worth_before - disabled_checking.balance + disabled_cc.balance, @family.net_worth
end
test "calculates asset series" do
# Sum of expected balances for all asset accounts in balance_calculator_test.rb
expected_balances = [
@ -108,6 +124,23 @@ class FamilyTest < ActiveSupport::TestCase
)
end
test "calculates balances by type with disabled account" do
disabled_checking = accounts(:checking).update!(is_active: false)
verify_balances_by_type(
period: Period.all,
expected_asset_total: BigDecimal("20550"),
expected_liability_total: BigDecimal("1000"),
expected_asset_groups: {
"Account::OtherAsset" => { end_balance: BigDecimal("550"), start_balance: BigDecimal("400"), allocation: 2.68 },
"Account::Depository" => { end_balance: BigDecimal("20000"), start_balance: BigDecimal("21250"), allocation: 97.32 }
},
expected_liability_groups: {
"Account::Credit" => { end_balance: BigDecimal("1000"), start_balance: BigDecimal("1040"), allocation: 100 }
}
)
end
private
def verify_balances_by_type(period:, expected_asset_total:, expected_liability_total:, expected_asset_groups:, expected_liability_groups:)