mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 15:49:39 +02:00
Multi-currency support (#425)
* Initial foundational pass at multi-currency * Default format currency * More work on currency and exchanging * Re-build currencies on change * Currency import/setup * Background job overhaul + cheaper OXR plan support * Lint fixes * Test fixes * Multi-currency setup instructions * Allow decimals in the balance field * Spacing fix for form --------- Signed-off-by: Josh Pigford <josh@joshpigford.com>
This commit is contained in:
parent
94f7b4ea8f
commit
aa351ae616
41 changed files with 634 additions and 176 deletions
6
test/fixtures/accounts.yml
vendored
6
test/fixtures/accounts.yml
vendored
|
@ -1,14 +1,14 @@
|
|||
dylan_checking:
|
||||
family: dylan_family
|
||||
name: Bob's Checking
|
||||
balance_cents: 1200
|
||||
original_balance: 1200
|
||||
|
||||
dylan_roth:
|
||||
family: dylan_family
|
||||
name: Bob's Roth IRA
|
||||
balance_cents: 1200
|
||||
original_balance: 1200
|
||||
|
||||
richards_savings:
|
||||
family: richards_family
|
||||
name: Keef's HYSA
|
||||
balance_cents: 1500
|
||||
original_balance: 1500
|
||||
|
|
9
test/fixtures/currencies.yml
vendored
Normal file
9
test/fixtures/currencies.yml
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# one:
|
||||
# name: MyString
|
||||
# iso_code: MyString
|
||||
|
||||
# two:
|
||||
# name: MyString
|
||||
# iso_code: MyString
|
13
test/fixtures/exchange_rates.yml
vendored
Normal file
13
test/fixtures/exchange_rates.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
base_currency: one
|
||||
converted_currency: one
|
||||
rate: 9.99
|
||||
date: 2024-02-09
|
||||
|
||||
two:
|
||||
base_currency: two
|
||||
converted_currency: two
|
||||
rate: 9.99
|
||||
date: 2024-02-09
|
7
test/jobs/convert_currency_job_test.rb
Normal file
7
test/jobs/convert_currency_job_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class ConvertCurrencyJobTest < ActiveJob::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
test/jobs/daily_exchange_rate_job_test.rb
Normal file
7
test/jobs/daily_exchange_rate_job_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class DailyExchangeRateJobTest < ActiveJob::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -3,7 +3,7 @@ require "test_helper"
|
|||
class AccountTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
depository = Account::Depository.create!
|
||||
@account = Account.create!(family: families(:dylan_family), name: "Explicit Checking", balance_cents: 1200, accountable: depository)
|
||||
@account = Account.create!(family: families(:dylan_family), name: "Explicit Checking", original_balance: 1200, accountable: depository)
|
||||
end
|
||||
|
||||
test "new account should be valid" do
|
||||
|
@ -11,21 +11,4 @@ class AccountTest < ActiveSupport::TestCase
|
|||
assert_not_nil @account.accountable_id
|
||||
assert_not_nil @account.accountable
|
||||
end
|
||||
|
||||
test "balance returns Money object" do
|
||||
@account.balance = 10
|
||||
assert_instance_of Money, @account.balance
|
||||
assert_equal :usd, @account.balance.currency.id
|
||||
end
|
||||
|
||||
test "correctly assigns Money objects to the attribute" do
|
||||
@account.balance = Money.new(2500, "USD")
|
||||
assert_equal 2500, @account.balance_cents
|
||||
end
|
||||
|
||||
test "balance_cents can be updated" do
|
||||
new_balance = Money.new(10000, "USD")
|
||||
@account.balance = new_balance
|
||||
assert_equal new_balance, @account.balance
|
||||
end
|
||||
end
|
||||
|
|
7
test/models/currency_test.rb
Normal file
7
test/models/currency_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class CurrencyTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
test/models/exchange_rate_test.rb
Normal file
7
test/models/exchange_rate_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class ExchangeRateTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue