mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 03:54:08 +00:00
* Add tax treatment support for accounts, investments, and cryptos * Replace hardcoded region labels with I18n translations * Add I18n support for subtype labels with fallback to hardcoded values * fixed schema --------- Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
27 lines
801 B
Ruby
27 lines
801 B
Ruby
module TaxTreatable
|
|
extend ActiveSupport::Concern
|
|
|
|
# Delegates tax treatment to the accountable (Investment or Crypto)
|
|
# Returns nil for account types that don't support tax treatment
|
|
def tax_treatment
|
|
return nil unless accountable.respond_to?(:tax_treatment)
|
|
accountable.tax_treatment&.to_sym
|
|
end
|
|
|
|
# Returns the i18n label for the tax treatment
|
|
def tax_treatment_label
|
|
return nil unless tax_treatment
|
|
I18n.t("accounts.tax_treatments.#{tax_treatment}")
|
|
end
|
|
|
|
# Returns true if the account has tax advantages (deferred, exempt, or advantaged)
|
|
def tax_advantaged?
|
|
tax_treatment.in?(%i[tax_deferred tax_exempt tax_advantaged])
|
|
end
|
|
|
|
# Returns true if gains in this account are taxable
|
|
def taxable?
|
|
tax_treatment == :taxable || tax_treatment.nil?
|
|
end
|
|
end
|