1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-22 14:49:38 +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

@ -5,7 +5,19 @@ class SettingsController < ApplicationController
end
def update
if Current.user.update(user_params)
user_params_with_family = user_params
# Ensure we're only updating the family associated with the current user
if Current.family
family_attributes = user_params_with_family[:family_attributes].merge({ id: Current.family.id })
user_params_with_family[:family_attributes] = family_attributes
end
# If the family attribute for currency is changed, we need to convert all account balances to the new currency with the ConvertCurrencyJob job
if user_params_with_family[:family_attributes][:currency] != Current.family.currency
ConvertCurrencyJob.perform_later(Current.family)
end
if Current.user.update(user_params_with_family)
redirect_to root_path, notice: "Profile updated successfully."
else
render :edit, status: :unprocessable_entity
@ -16,6 +28,6 @@ class SettingsController < ApplicationController
def user_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation,
family_attributes: [ :name, :id ])
family_attributes: [ :name, :id, :currency ])
end
end