{% load humanize %} Stock Report — Invoice #{{ invoice_no }} {# ─── HEADER ─── #}

📦 Stock Analysis Report

Android Staging Sale — Pre-Approve Stock Check
Invoice #{{ invoice_no }}
{{ pay.party_descp|default:"—" }}
{{ pay.transaction_date }} • Branch: {{ pay.main_pos_business_id }}
Generated: {% now "Y-m-d H:i" %}
{# ─── INFO GRID ─── #}
Total Amount
{{ pay.total_amount|floatformat:2|intcomma }}
Amount Received
{{ pay.amount_transaction|floatformat:2|intcomma }}
Total Items
{{ items|length }} lines
Total Qty / Bonus
{{ total_qty|floatformat:2 }} / {{ total_bonus|floatformat:2 }}
{# ─── ALERTS ─── #}
{% if zero_stock_items %}
❌ {{ zero_stock_items|length }} item(s) have ZERO stock: {% for item in zero_stock_items %}{{ item.product_name }}{% if not forloop.last %}, {% endif %}{% endfor %}
{% endif %} {% if low_stock_items %}
⚠️ {{ low_stock_items|length }} item(s) have LOW stock (stock < requested qty): {% for item in low_stock_items %}{{ item.product_name }} (have {{ item.legacy_stock|floatformat:1 }}, need {{ item.quantity|floatformat:1 }}){% if not forloop.last %}, {% endif %}{% endfor %}
{% endif %} {% if not zero_stock_items and not low_stock_items %}
✅ All items have sufficient stock for this invoice.
{% endif %}
{# ─── ITEMS TABLE ─── #}
Line Items with Stock Detail
{% for item in items %} {% endfor %}
# Product Sold Qty Bonus Unit Price Total Legacy Stock Variant Layers Stock Status
{{ forloop.counter }} {{ item.product_name|default:"Unknown" }}
Code: {{ item.product_code }} | PPP: {{ item.p_per_pack }}
{{ item.quantity|floatformat:2 }} {{ item.bonus|floatformat:2 }} {{ item.item_price|floatformat:2|intcomma }} {{ item.total_price|floatformat:2|intcomma }} {{ item.legacy_stock|default:0|floatformat:2 }}
(after sale: {{ item.stock_after|floatformat:2 }})
{% for layer in item.stock_layers %} {{ layer.sku_code|default:"Default" }}: {{ layer.on_hand|floatformat:1 }} {% if layer.batch %}[{{ layer.batch }}]{% endif %} {% if layer.expiry %}↯{{ layer.expiry }}{% endif %} {% empty %} — {% endfor %} {% if item.legacy_stock <= 0 %}OUT OF STOCK {% elif item.legacy_stock < item.quantity %}LOW STOCK {% else %}OK{% endif %}
TOTALS {{ total_qty|floatformat:2 }} {{ total_bonus|floatformat:2 }} {{ pay.total_amount|floatformat:2|intcomma }}
{# ─── SUMMARY ─── #}

💰 Financial Summary

Total Amount{{ pay.total_amount|floatformat:2|intcomma }}
Amount Received{{ pay.amount_transaction|floatformat:2|intcomma }}
Discount{{ pay.discount|floatformat:2|intcomma }}
Prev Customer Balance{{ pay.previous_balance|floatformat:2|intcomma }}

📦 Stock Summary

Total Lines{{ items|length }}
Lines with OK Stock{{ ok_stock_count }}
Lines with Low Stock{{ low_stock_items|length }}
Lines with Zero Stock{{ zero_stock_items|length }}
{# ─── FOOTER ─── #}