mirror of
https://github.com/we-promise/sure.git
synced 2026-04-17 11:04:14 +00:00
* Initial data objects * Remove trend calculator * Fill in balance reconciliation for entry group * Initial tooltip component * Balance trends in activity view * Lint fixes * trade partial alignment fix * Tweaks to balance calculation to acknowledge holdings value better * More lint fixes * Bump brakeman dep * Test fixes * Remove unused class
52 lines
1008 B
Ruby
52 lines
1008 B
Ruby
class UI::Account::ActivityDate < ApplicationComponent
|
|
attr_reader :account, :data
|
|
|
|
delegate :date, :entries, :balance_trend, :cash_balance_trend, :holdings_value_trend, :transfers, to: :data
|
|
|
|
def initialize(account:, data:)
|
|
@account = account
|
|
@data = data
|
|
end
|
|
|
|
def id
|
|
dom_id(account, "entries_#{date}")
|
|
end
|
|
|
|
def broadcast_channel
|
|
account
|
|
end
|
|
|
|
def start_balance_money
|
|
balance_trend.previous
|
|
end
|
|
|
|
def cash_change_money
|
|
cash_balance_trend.value
|
|
end
|
|
|
|
def holdings_change_money
|
|
holdings_value_trend.value
|
|
end
|
|
|
|
def end_balance_before_adjustments_money
|
|
balance_trend.previous + cash_change_money + holdings_change_money
|
|
end
|
|
|
|
def adjustments_money
|
|
end_balance_money - end_balance_before_adjustments_money
|
|
end
|
|
|
|
def end_balance_money
|
|
balance_trend.current
|
|
end
|
|
|
|
def broadcast_refresh!
|
|
Turbo::StreamsChannel.broadcast_replace_to(
|
|
broadcast_channel,
|
|
target: id,
|
|
renderable: self,
|
|
layout: false
|
|
)
|
|
end
|
|
end
|