Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: Sidebar only displays cash balance for investment accounts, not full value #1438

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def by_group(period: Period.all, currency: Money.default_currency.iso_code)
accounts.each do |account|
group.add_value_node(
account,
account.balance_money.exchange_to(currency, fallback_rate: 0),
account.value,
account.series(period: period, currency: currency)
)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/family.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def net_worth
end

def assets
Money.new(accounts.active.assets.map { |account| account.balance_money.exchange_to(currency, fallback_rate: 0) }.sum, currency)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these two places, we will need to call account.value.exchange_to(currency, fallback_rate: 0) so that users with accounts in multiple currencies can be "rolled up" properly.

Money.new(accounts.active.assets.map { |account| account.value }.sum, currency)
end

def liabilities
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/_account_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<% end %>
</div>
<div class="flex flex-col items-end font-medium text-right ml-auto">
<p><%= format_money account.balance_money %></p>
<p><%= format_money account.value %></p>
<div class="flex items-center gap-1">
<div class="h-3 w-8">
<%= render "shared/sparkline", series: account_value_node.series, id: dom_id(account, :list_sparkline) %>
Expand Down