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

Multi-Currency Part 2 (#543)

* Support all currencies, handle outside DB

* Remove currencies from seed

* Fix account balance namespace

* Set default currency on authentication

* Cache currency instances

* Implement multi-currency syncs with tests

* Series fallback, passing tests

* Fix conflicts

* Make value group concrete class that works with currency values

* Fix migration conflict

* Update tests to expect multi-currency results

* Update account list to use group method

* Namespace updates

* Fetch unknown exchange rates from API

* Fix date range bug

* Ensure demo data works without external API

* Enforce cascades only at DB level
This commit is contained in:
Zach Gollwitzer 2024-03-21 13:39:10 -04:00 committed by GitHub
parent de0cba9fed
commit 110855d077
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
55 changed files with 1226 additions and 714 deletions

View file

@ -1,61 +0,0 @@
require "test_helper"
class Account::BalanceCalculatorTest < ActiveSupport::TestCase
test "syncs account with only valuations" do
account = accounts(:collectable)
daily_balances = Account::BalanceCalculator.new(account).daily_balances
expected_balances = [
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 700, 700,
700, 700, 700, 700, 700, 700, 550, 550, 550, 550,
550
].map(&:to_d)
assert_equal expected_balances, daily_balances.map { |b| b[:balance] }
end
test "syncs account with only transactions" do
account = accounts(:checking)
daily_balances = Account::BalanceCalculator.new(account).daily_balances
expected_balances = [
4000, 3985, 3985, 3985, 3985, 3985, 3985, 3985, 5060, 5060,
5060, 5060, 5060, 5060, 5060, 5040, 5040, 5040, 5010, 5010,
5010, 5010, 5010, 5010, 5010, 5000, 5000, 5000, 5000, 5000,
5000
].map(&:to_d)
assert_equal expected_balances, daily_balances.map { |b| b[:balance] }
end
test "syncs account with both valuations and transactions" do
account = accounts(:savings_with_valuation_overrides)
daily_balances = Account::BalanceCalculator.new(account).daily_balances
expected_balances = [
21250, 21750, 21750, 21750, 21750, 21000, 21000, 21000, 21000, 21000,
21000, 21000, 19000, 19000, 19000, 19000, 19000, 19000, 19500, 19500,
19500, 19500, 19500, 19500, 19500, 19700, 19700, 20500, 20500, 20500,
20000
].map(&:to_d)
assert_equal expected_balances, daily_balances.map { |b| b[:balance] }
end
test "syncs liability account" do
account = accounts(:credit_card)
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