-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show cash + holdings value for investment account view (#1046)
* Handle missing tickers in security price syncs * Show combined cash and holdings value on account page * Improve partial locals
- Loading branch information
Showing
20 changed files
with
168 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Account::CashesController < ApplicationController | ||
layout :with_sidebar | ||
|
||
before_action :set_account | ||
|
||
def index | ||
end | ||
|
||
private | ||
|
||
def set_account | ||
@account = Current.family.accounts.find(params[:account_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Account::CashesHelper | ||
def brokerage_cash(account) | ||
currency = Money::Currency.new(account.currency) | ||
|
||
account.holdings.build \ | ||
date: Date.current, | ||
qty: account.balance, | ||
price: 1, | ||
amount: account.balance, | ||
currency: account.currency, | ||
security: Security.new(ticker: currency.iso_code, name: currency.name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<%# locals: (holding:) %> | ||
|
||
<%= turbo_frame_tag dom_id(holding) do %> | ||
<div class="grid grid-cols-12 items-center text-gray-900 text-sm font-medium p-4"> | ||
<div class="col-span-9 flex items-center gap-4"> | ||
<%= render "shared/circle_logo", name: holding.name %> | ||
<div> | ||
<%= tag.p holding.name %> | ||
<%= tag.p holding.ticker, class: "text-gray-500 text-xs uppercase" %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-span-3 text-right"> | ||
<% if holding.amount_money %> | ||
<%= tag.p format_money holding.amount_money %> | ||
<% else %> | ||
<%= tag.p "?", class: "text-gray-500" %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= turbo_frame_tag dom_id(@account, "cash") do %> | ||
<div class="bg-white space-y-4 p-5 border border-alpha-black-25 rounded-xl shadow-xs"> | ||
<div class="flex items-center justify-between"> | ||
<%= tag.h2 t(".cash"), class: "font-medium text-lg" %> | ||
</div> | ||
|
||
<div class="rounded-xl bg-gray-25 p-1"> | ||
<div class="grid grid-cols-12 items-center uppercase text-xs font-medium text-gray-500 px-4 py-2"> | ||
<%= tag.p t(".name"), class: "col-span-9" %> | ||
<%= tag.p t(".value"), class: "col-span-3 justify-self-end" %> | ||
</div> | ||
|
||
<div class="rounded-lg bg-white border-alpha-black-25 shadow-xs"> | ||
<%= render partial: "account/cashes/cash", collection: [brokerage_cash(@account)], as: :holding %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
en: | ||
account: | ||
cashes: | ||
index: | ||
cash: Cash | ||
name: Name | ||
value: Total Balance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters