mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
* Initial entryable models * Update transfer and tests * Update transaction controllers and tests * Update sync process to use new entries model * Get dashboard working again * Update transfers, imports, and accounts to use Account::Entry * Update system tests * Consolidate transaction management into entries controller * Add permitted partial key helper * Move account transactions list to entries controller * Delegate transaction entries search * Move transfer relation to entry * Update bulk transaction management flows to use entries * Remove test code * Test fix attempt * Update demo data script * Consolidate remaining transaction partials to entries * Consolidate valuations controller to entries controller * Lint fix * Remove unused files, additional cleanup * Add back valuation creation * Make migrations fully reversible * Stale routes cleanup * Migrations reversible fix * Move types to entryable concern * Fix search when no entries found * Remove more unused code
39 lines
980 B
Ruby
39 lines
980 B
Ruby
module Account::EntriesHelper
|
|
def permitted_entryable_partial_path(entry, relative_partial_path)
|
|
"account/entries/entryables/#{permitted_entryable_key(entry)}/#{relative_partial_path}"
|
|
end
|
|
|
|
def unconfirmed_transfer?(entry)
|
|
entry.marked_as_transfer? && entry.transfer.nil?
|
|
end
|
|
|
|
def transfer_entries(entries)
|
|
transfers = entries.select { |e| e.transfer_id.present? }
|
|
transfers.map(&:transfer).uniq
|
|
end
|
|
|
|
def entry_icon(entry, is_oldest: false)
|
|
if is_oldest
|
|
"keyboard"
|
|
elsif entry.trend.direction.up?
|
|
"arrow-up"
|
|
elsif entry.trend.direction.down?
|
|
"arrow-down"
|
|
else
|
|
"minus"
|
|
end
|
|
end
|
|
|
|
def entry_style(entry, is_oldest: false)
|
|
color = is_oldest ? "#D444F1" : entry.trend.color
|
|
|
|
mixed_hex_styles(color)
|
|
end
|
|
|
|
private
|
|
|
|
def permitted_entryable_key(entry)
|
|
permitted_entryable_paths = %w[transaction valuation]
|
|
entry.entryable_name_short.presence_in(permitted_entryable_paths)
|
|
end
|
|
end
|