1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 15:49:39 +02:00
Maybe/app/models/concerns/accountable.rb
Zach Gollwitzer a947db92b2
Account namespace updates: part 1 (#893)
* Rename accountable types

* Merge conflicts

* Fix broken tests

* Add back sidebar changes
2024-06-20 07:26:25 -04:00

20 lines
497 B
Ruby

module Accountable
extend ActiveSupport::Concern
ASSET_TYPES = %w[ Depository Investment Crypto Property Vehicle OtherAsset ]
LIABILITY_TYPES = %w[ CreditCard Loan OtherLiability ]
TYPES = ASSET_TYPES + LIABILITY_TYPES
def self.from_type(type)
return nil unless TYPES.include?(type)
type.constantize
end
def self.by_classification
{ assets: ASSET_TYPES, liabilities: LIABILITY_TYPES }
end
included do
has_one :account, as: :accountable, touch: true
end
end