{# At a loss — Phase 2 dedicated table (§3.3 of UI/UX redesign spec). Reads `rows` (list of HarvestOpportunity), `only_harvestable` (bool), and `budget` from context — passed by `routes/positions.py` when `selected_view == 'at-loss'`. The harvestable-only checkbox uses `harvest_form_action` and `harvest_form_target` from context (Phase 1 review-fix Critical #1) so HTMX targets work on the new home. Phase 3 polishes: stacked mini-bar in the summary strip (T5-style), inline sim preview on hover, replacement detail (gain/loss for substitute), and density-aware row height. #}
{{ rows|length }} lots at a loss {% if budget is defined and budget %} · loss-harvest budget {{ fmt_currency(budget.net_realized) }} / {{ fmt_currency(budget.cap_against_ordinary) }} cap {% endif %}
{% if not rows %} {% else %} {% for row in rows %} {% endfor %} {% endif %}
SYM ACCT QTY MKT BASIS UNREAL LOCKOUT-CLEAR REPLACEMENT
No at-loss positions — every open position is at or above its cost basis.
{{ row.symbol }} {{ row.account_label }} {{ fmt_quantity(row.qty) }} {{ fmt_currency(row.open_basis + row.loss) }} {{ fmt_currency(row.open_basis) }} {{ fmt_currency(row.loss) }} {% if row.lockout_clear and row.lockout_clear > today %} {{ fmt_date(row.lockout_clear) }} {% else %} clear {% endif %} {% if row.suggested_replacements %} {{ row.suggested_replacements[0] }} {% else %} none {% endif %} {% with sym=row.symbol, qty=row.qty, account=row.account_label, account_id=row.account_id %} {% include "_row_actions.html" %} {% endwith %}