mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 13:49:39 +02:00
* Start tests rework * Cash balance on schema * Add reverse syncer * Reverse balance sync with holdings * Reverse holdings sync * Reverse holdings sync should work with only trade entries * Consolidate brokerage cash * Add forward sync option * Update new balance info after syncs * Intraday balance calculator and sync fixes * Show only balance for trade entries * Tests passing * Update Gemfile.lock * Cleanup, performance improvements * Remove account reloads for reliable sync outputs * Simplify valuation view logic * Special handling for Plaid cash holding
29 lines
681 B
Ruby
29 lines
681 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
|
|
|
|
def post_sync
|
|
broadcast_replace_to(
|
|
account,
|
|
target: "chart_account_#{account.id}",
|
|
partial: "accounts/show/chart",
|
|
locals: { account: account }
|
|
)
|
|
end
|
|
end
|