<%= admin_breadcrumbs(@breadcrumbs) %>

<%= @student.username %>

<%= link_to edit_admin_student_path(@student), class: "inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50" do %> Edit <% end %> <%= link_to admin_student_path(@student), data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to archive this student?" }, class: "inline-flex items-center px-4 py-2 border border-red-300 shadow-sm text-sm font-medium rounded-md text-red-700 bg-white hover:bg-red-50" do %> Archive <% end %>
Id
<%= @student.id %>
Username
<%= @student.username %>
Classroom
<%= @student.classroom.name %>
Created at
<%= @student.created_at.strftime("%B %d, %Y") %>
Updated at
<%= @student.updated_at.strftime("%B %d, %Y") %>
<% if @student.portfolio.present? %>

Portfolio Details

Cash Balance
<%= number_to_currency(@student.portfolio.cash_balance) %>
Total Portfolio Worth
<%= number_to_currency(@student.portfolio.total_portfolio_worth) %>
Total Stocks
<%= @student.portfolio.portfolio_stocks.sum(:shares).to_i %>
<%= link_to portfolio_path(@student.portfolio), class: "bg-gray-50 p-4 rounded-lg block hover:bg-gray-100 transition-colors" do %>
Portfolio ID
#<%= @student.portfolio.id %>
<% end %>

Earnings Summary

Category Amount
Attendance Earnings <%= number_to_currency(@earnings_summary.attendance_earnings_cents / 100.0) %>
Math Earnings <%= number_to_currency(@earnings_summary.math_earnings_cents / 100.0) %>
Rewards <%= number_to_currency(@earnings_summary.awards_cents / 100.0) %>
Total Earnings <%= number_to_currency(@earnings_summary.total_earnings_cents / 100.0) %>
Transaction Fees <%= number_to_currency(@earnings_summary.transaction_fees_cents / 100.0) %>
<% transactions = @student.portfolio.portfolio_transactions.order(created_at: :desc) %> <% if transactions.any? %>

All Transactions (<%= transactions.count %>)

<% transactions.each do |transaction| %> <% end %>
Date Type Reason Amount
<%= transaction.created_at.strftime("%m/%d/%Y") %> <%= transaction.transaction_type.capitalize %> <%= transaction.reason&.humanize || 'N/A' %> <%= number_to_currency(transaction.amount_cents / 100.0) %>
<% else %>

No transactions yet.

<% end %>
<% else %>

No portfolio associated with this student.

<% end %>

Attendance

<% if @attendance_entries.any? %>
<% @attendance_entries.each do |entry| %> <% end %>
Year Quarter Attendance Days Perfect Attendance
<%= entry.year_name %> <%= entry.quarter_name %> <%= entry.attendance_days_display %> <% if entry.perfect_attendance? %> Yes <% else %> No <% end %>
<% else %>

No attendance records found.

<% end %>
<%= link_to "Back to Students", admin_students_path, class: "inline-flex items-center px-4 py-2 border border-gray-300 shadow-sm text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50" %>