mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 20:14:08 +00: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:
@@ -5,5 +5,15 @@ class Account < ApplicationRecord
|
||||
|
||||
delegate :type_name, to: :accountable
|
||||
|
||||
monetize :balance_cents
|
||||
before_create :check_currency
|
||||
|
||||
def check_currency
|
||||
if self.original_currency == self.family.currency
|
||||
self.converted_balance = self.original_balance
|
||||
self.converted_currency = self.original_currency
|
||||
else
|
||||
self.converted_balance = ExchangeRate.convert(self.original_currency, self.family.currency, self.original_balance)
|
||||
self.converted_currency = self.family.currency
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user