2024-02-02 23:09:35 +00:00
|
|
|
module Accountable
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2024-06-20 07:26:25 -04:00
|
|
|
ASSET_TYPES = %w[ Depository Investment Crypto Property Vehicle OtherAsset ]
|
|
|
|
LIABILITY_TYPES = %w[ CreditCard Loan OtherLiability ]
|
2024-03-19 09:10:40 -04:00
|
|
|
TYPES = ASSET_TYPES + LIABILITY_TYPES
|
2024-02-09 14:26:54 +00:00
|
|
|
|
|
|
|
def self.from_type(type)
|
2024-06-20 07:26:25 -04:00
|
|
|
return nil unless TYPES.include?(type)
|
|
|
|
type.constantize
|
2024-02-09 14:26:54 +00:00
|
|
|
end
|
|
|
|
|
2024-03-19 09:10:40 -04:00
|
|
|
def self.by_classification
|
|
|
|
{ assets: ASSET_TYPES, liabilities: LIABILITY_TYPES }
|
|
|
|
end
|
|
|
|
|
2024-02-02 23:09:35 +00:00
|
|
|
included do
|
|
|
|
has_one :account, as: :accountable, touch: true
|
|
|
|
end
|
|
|
|
end
|