{% extends "pos/base.html" %} {% load static humanize %} {% block content %} {# ══════════════════════════════════════════════════════════════════════════ #} {# Department-wise Comprehensive Production Report #} {# ══════════════════════════════════════════════════════════════════════════ #} {# ── Page Title ──────────────────────────────────────────────────────────── #}

Department-wise Production Report

Raw material consumption, production output, aur BOM compliance — department by department
{# ── Filter Form ─────────────────────────────────────────────────────────── #}
Filters
{% if has_results %} {# ── Export Buttons ──────────────────────────────────────────────────────── #}
Export Excel (5 Sheets) Export PDF
{# ════════════════════════════════════════════════════════════════════════════ #} {# SECTION A — GRAND SUMMARY #} {# ════════════════════════════════════════════════════════════════════════════ #}
A. Department Summary — {{ date_from }} to {{ date_to }}
{% for dept_name, d in dept_data.items %} {% empty %} {% endfor %}
# Department Runs Raw Material Cost Labour Fuel Other Grand Total
{{ forloop.counter }} {{ dept_name }} {{ d.runs|length }} {{ d.raw_cost|floatformat:2|intcomma }} {{ d.labour|floatformat:2|intcomma }} {{ d.fuel|floatformat:2|intcomma }} {{ d.other|floatformat:2|intcomma }} {{ d.grand|floatformat:2|intcomma }}
No data.
GRAND TOTAL {{ gt_runs }} {{ gt_raw_cost|floatformat:2|intcomma }} {{ gt_labour|floatformat:2|intcomma }} {{ gt_fuel|floatformat:2|intcomma }} {{ gt_other|floatformat:2|intcomma }} {{ gt_grand|floatformat:2|intcomma }}
{# ════════════════════════════════════════════════════════════════════════════ #} {# PER-DEPARTMENT DETAILED CARDS #} {# ════════════════════════════════════════════════════════════════════════════ #} {% for dept_name, d in dept_data.items %}
{# ── Department Card Header ────────────────────────────────────────────── #}
{{ dept_name }}
{{ d.runs|length }} Runs Grand Total: {{ d.grand|floatformat:2|intcomma }}
{# ── Mini KPI Cards ────────────────────────────────────────────────── #}
Raw Material {{ d.raw_cost|floatformat:2|intcomma }}
Labour {{ d.labour|floatformat:2|intcomma }}
Fuel {{ d.fuel|floatformat:2|intcomma }}
Grand Total {{ d.grand|floatformat:2|intcomma }}
{# ── Section B: Raw Material Consumption ─────────────────────────── #}
B. Raw Material Consumption — is department mein jo raw material use hua
{% for pid, raw in d.raw_map.items %} {% empty %} {% endfor %} {% if d.raw_map %} {% with raw_tot_qty=0 raw_tot_cost=0 %} {% endwith %} {% endif %}
# Code Raw Material Name Company Total Qty Used Total Cost
{{ forloop.counter }} {{ raw.code }} {{ raw.name }} {{ raw.company }} {{ raw.qty|floatformat:4|intcomma }} {{ raw.cost|floatformat:2|intcomma }}
No raw material data.
Total {% with total=d.raw_map.values %} {# We compute in JS below for display; Django template can't sum nested dicts easily #} — {% endwith %} —
{# ── Section C: Finished Goods Produced ──────────────────────────── #}
C. Finished Goods Produced — is department mein jo manufacture hua
{% for pid, fin in d.fin_map.items %} {% empty %} {% endfor %}
# Code Finished Item Name Qty Produced Total Cost Avg Unit Cost
{{ forloop.counter }} {{ fin.code }} {{ fin.name }} {{ fin.qty|floatformat:4|intcomma }} {{ fin.cost|floatformat:2|intcomma }} {% if fin.qty %} {{ fin.cost|floatformat:2 }} {% else %}—{% endif %}
No finished goods data.
{# ── Section D: BOM Compliance / Variance ────────────────────────── #}
D. BOM Compliance — Expected vs Actual Raw Material — BOM k hisab se kitna hona chahiye tha, aur kitna actually use hua
{% if d.variance_rows %} {# ── Variance Legend ── #}
Normal (±3%) Extra Used Less Used Not in BOM Not Used
{% for vr in d.variance_rows %} {% endfor %}
# Raw Code Raw Material BOM Expected Qty
(production k hisab se)
Actual Used Qty Difference Diff % Actual Cost Status
{{ forloop.counter }} {{ vr.raw_code }} {{ vr.raw_name }} {{ vr.expected|floatformat:4|intcomma }} {{ vr.actual|floatformat:4|intcomma }} {% if vr.diff > 0 %}+{% endif %}{{ vr.diff|floatformat:4 }} {% if vr.diff_pct > 0 %}+{% endif %}{{ vr.diff_pct|floatformat:2 }}% {{ vr.act_cost|floatformat:2|intcomma }} {% if vr.status == "Normal" %} ✓ Normal {% elif vr.status == "Extra Used" %} Extra Used {% elif vr.status == "Less Used" %} Less Used {% elif vr.status == "Not in BOM" %} Not in BOM {% else %} Not Used {% endif %}
TOTAL {% with tot=0 %} {# Totals computed via JS below for display; Python passes dept-level sums #} {% endwith %} — —
{% else %}
Koi BOM define nahi hua is department ke finished items ke liye.
{% endif %}
{# ── Run Detail Collapsible ───────────────────────────────────────── #}
{% for run in d.runs %} {% endfor %}
Run # Date Staff Raw Cost Labour Fuel Other Grand Total
#{{ run.invoice_no }} {{ run.run_date }} {{ run.staff }} {{ run.raw_cost|floatformat:2 }} {{ run.labour|floatformat:2 }} {{ run.fuel|floatformat:2 }} {{ run.other|floatformat:2 }} {{ run.grand|floatformat:2 }}
{# /card-body #}
{# /dept card #} {% endfor %}{# /for dept_data #} {% elif request.GET.date_from %} {# Date filter diya tha lekin koi data nahi #}
Selected date range mein koi production run nahi mila. {% if dept_id_filter %} (Selected department mein){% endif %}
{% else %} {# Pehli visit — abhi tak filter nahi lagaya #}
Date range select karein aur Generate Report press karein.
{% endif %} {# ── Help Modal ──────────────────────────────────────────────────────────── #} {% endblock %}