1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +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:
Josh Pigford 2024-02-10 16:18:56 -06:00 committed by GitHub
parent 94f7b4ea8f
commit aa351ae616
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 634 additions and 176 deletions

View file

@ -64,6 +64,9 @@ Rails.application.configure do
# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true
# Set Active Job queue adapter
config.active_job.queue_adapter = :good_job
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true

View file

@ -62,7 +62,7 @@ Rails.application.configure do
# config.cache_store = :mem_cache_store
# Use a real queuing backend for Active Job (and separate queues per environment).
# config.active_job.queue_adapter = :resque
config.active_job.queue_adapter = :good_job
# config.active_job.queue_name_prefix = "maybe_production"
config.action_mailer.perform_caching = false

View file

@ -0,0 +1,9 @@
Rails.application.configure do
config.good_job.enable_cron = true
config.good_job.cron = {
maintenance: {
cron: "0 22 * * *",
class: "DailyExchangeRateJob"
}
}
end

View file

@ -1,114 +0,0 @@
# encoding : utf-8
MoneyRails.configure do |config|
# To set the default currency
#
config.default_currency = :usd
# Set default bank object
#
# Example:
# config.default_bank = EuCentralBank.new
# Add exchange rates to current money bank object.
# (The conversion rate refers to one direction only)
#
# Example:
# config.add_rate "USD", "CAD", 1.24515
# config.add_rate "CAD", "USD", 0.803115
# To handle the inclusion of validations for monetized fields
# The default value is true
#
# config.include_validations = true
# Default ActiveRecord migration configuration values for columns:
#
# config.amount_column = { prefix: '', # column name prefix
# postfix: '_cents', # column name postfix
# column_name: nil, # full column name (overrides prefix, postfix and accessor name)
# type: :integer, # column type
# present: true, # column will be created
# null: false, # other options will be treated as column options
# default: 0
# }
#
# config.currency_column = { prefix: '',
# postfix: '_currency',
# column_name: nil,
# type: :string,
# present: true,
# null: false,
# default: 'USD'
# }
# Register a custom currency
#
# Example:
# config.register_currency = {
# priority: 1,
# iso_code: "EU4",
# name: "Euro with subunit of 4 digits",
# symbol: "€",
# symbol_first: true,
# subunit: "Subcent",
# subunit_to_unit: 10000,
# thousands_separator: ".",
# decimal_mark: ","
# }
# Specify a rounding mode
# Any one of:
#
# BigDecimal::ROUND_UP,
# BigDecimal::ROUND_DOWN,
# BigDecimal::ROUND_HALF_UP,
# BigDecimal::ROUND_HALF_DOWN,
# BigDecimal::ROUND_HALF_EVEN,
# BigDecimal::ROUND_CEILING,
# BigDecimal::ROUND_FLOOR
#
# set to BigDecimal::ROUND_HALF_EVEN by default
#
config.rounding_mode = BigDecimal::ROUND_HALF_UP
# Set default money format globally.
# Default value is nil meaning "ignore this option".
# Example:
#
# config.default_format = {
# no_cents_if_whole: nil,
# symbol: nil,
# sign_before_symbol: nil
# }
# If you would like to use I18n localization (formatting depends on the
# locale):
config.locale_backend = :i18n
#
# Example (using default localization from rails-i18n):
#
# I18n.locale = :en
# Money.new(10_000_00, 'USD').format # => $10,000.00
# I18n.locale = :es
# Money.new(10_000_00, 'USD').format # => $10.000,00
#
# For the legacy behaviour of "per currency" localization (formatting depends
# only on currency):
# config.locale_backend = :currency
#
# Example:
# Money.new(10_000_00, 'USD').format # => $10,000.00
# Money.new(10_000_00, 'EUR').format # => €10.000,00
#
# In case you don't need localization and would like to use default values
# (can be redefined using config.default_format):
# config.locale_backend = nil
# Set default raise_error_on_money_parsing option
# It will be raise error if assigned different currency
# The default value is false
#
# Example:
# config.raise_error_on_money_parsing = false
end

View file

@ -3,11 +3,11 @@ en:
activerecord:
attributes:
account:
balance: Balance
currency: Currency
family: Family
family_id: Family
name: Name
original_balance: Balance
original_currency: Currency
subtype: Subtype
models:
account: Account

View file

@ -1,4 +1,6 @@
Rails.application.routes.draw do
mount GoodJob::Engine => "jobs"
resource :registration
resource :session
resource :password_reset

18
config/solid_queue.yml Normal file
View file

@ -0,0 +1,18 @@
# default: &default
# dispatchers:
# - polling_interval: 1
# batch_size: 500
# workers:
# - queues: "*"
# threads: 5
# processes: 1
# polling_interval: 0.1
#
# development:
# <<: *default
#
# test:
# <<: *default
#
# production:
# <<: *default