<%# Redesigned Portfolio Page %>
📙💰

<%= @portfolio.username.upcase %>, PORTFOLIO <%= @portfolio.school_name %>

<% if @portfolio.student? && !@portfolio.trading_enabled? %>

Trading is currently disabled for your classroom.

You cannot place buy or sell orders at this time. Please contact your teacher for more information.

<% end %>
<%= render 'portfolios/portfolio_chart' %>
<%# Total Earnings Card %>
Total Earnings
<%= number_to_currency(@portfolio.cash_balance) %>
<%# Trending up/down this month will go here %>
<%# Total Cash Value %>
Total Cash Value
<%= number_to_currency(@portfolio.cash_balance) %>
<%# Trending up/down this month will go here %>
<%# Total Stocks %>
Total Stocks
<%= @portfolio.portfolio_stocks.sum(:shares).to_i %>
<%# Trending up/down this month will go here %>
<% @portfolio.positions.each do |position| %> <% price = position.stock_current_price %> <% shares = position.shares %> <% change_amount = position.change_amount %> <% total_return_amount = position.total_return_amount %> <% logo_path = "stock_logos/#{position.stock_ticker}-logo.svg" %> <% end %>
Current Holdings Qty. Last Price Change Total Return
<% if File.exist?("app/assets/images/#{logo_path}") %> <%= image_tag asset_path(logo_path), class: "w-10 h-10 rounded-lg flex-shrink-0", alt: "#{position.stock_ticker} logo", loading: "lazy" %> <% end %>
<%= position.stock_ticker %>
<%= shares %> <%= number_to_currency(price) %> <% if change_amount >= 0 %>+<% end %> <%= number_to_currency(change_amount) %> <% if total_return_amount >= 0 %>+<% end %> <%= number_to_currency(total_return_amount) %> <% if current_user.student? %> <%= link_to "Trade", stocks_path, class: "inline-flex items-center justify-center rounded-full bg-sky-800 text-white px-6 py-2 text-xs sm:text-sm font-medium shadow hover:bg-sky-700 focus:outline-none focus:ring-2 focus:ring-sky-500 focus:ring-offset-1 transition-colors" %> <% else %> Trade <% end %>
<%= render 'shared/earnings_to_invest_card' %> <%= render 'portfolios/earnings_summary_card' %>