1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Add Local Development Demo Data (#502)

* Clean up seeds, add development demo data

* Handle liability account display and sync

* Fix tests
This commit is contained in:
Zach Gollwitzer 2024-02-29 16:35:54 -05:00 committed by GitHub
parent dbf575c02a
commit 14641d16de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 368 additions and 62 deletions

View file

@ -21,3 +21,9 @@ savings_with_valuation_overrides:
family: dylan_family
name: Savings account with valuation overrides
balance: 20000
# Liability account
credit_card:
family: dylan_family
name: Credit Card
balance: 1000

View file

@ -53,3 +53,28 @@ savings_four:
date: <%= 29.days.ago.to_date %>
amount: -500
account: savings_with_valuation_overrides
# Credit card account transactions
credit_card_one:
name: Starbucks
date: <%= 5.days.ago.to_date %>
amount: 10
account: credit_card
credit_card_two:
name: Chipotle
date: <%= 12.days.ago.to_date %>
amount: 30
account: credit_card
credit_card_three:
name: Amazon
date: <%= 15.days.ago.to_date %>
amount: 20
account: credit_card
credit_card_four:
name: CC Payment
date: <%= 29.days.ago.to_date %>
amount: -100
account: credit_card

View file

@ -47,4 +47,19 @@ class Account::BalanceCalculatorTest < ActiveSupport::TestCase
assert_equal expected_balances, daily_balances.map { |b| b[:balance] }
end
test "syncs liability account" do
account = accounts(:credit_card)
account.accountable = account_credits(:one)
daily_balances = Account::BalanceCalculator.new(account).daily_balances
expected_balances = [
1040, 940, 940, 940, 940, 940, 940, 940, 940, 940,
940, 940, 940, 940, 940, 960, 960, 960, 990, 990,
990, 990, 990, 990, 990, 1000, 1000, 1000, 1000, 1000,
1000
].map(&:to_d)
assert_equal expected_balances, daily_balances.map { |b| b[:balance] }
end
end