{% extends "base.html" %} {% from "manufacturing/_macros.html" import mo_badge, qty with context %} {% block title %}{{ mo.number }}{% endblock %} {% block content %} {% set cur = branch.currency if branch else company.currency %} {% set open_state = mo.state in ('confirmed', 'in_progress') %}
{{ t('Production Orders') }}

{{ mo.number }} {{ mo_badge(mo.state) }}

{% if pickings.consume_picking_id %}{{ pickings.consume_picking_id.number }}{% endif %} {% if pickings.produce_picking_id %}{{ pickings.produce_picking_id.number }}{% endif %} {% if mo.conversion_move_id %}{{ t('Labour & overhead entry') }}{% endif %} {% if can_write %} {% if mo.state == 'draft' %} {{ t('Edit') }}
{% elif mo.state == 'confirmed' %}
{% elif mo.state == 'in_progress' %}
{% endif %} {% endif %}
{{ t('Product') }}
{{ nm(mo) }}
{{ mo.code }}
{{ t('Quantity') }}
{{ qty(mo.quantity) }} {{ mo.uom or '' }}{% if mo.state == 'done' %}
{{ t('Produced') }} {{ qty(mo.qty_produced) }}{% if mo.qty_scrapped %} · {{ t('scrap') }} {{ qty(mo.qty_scrapped) }}{% endif %}{% endif %}
{{ t('Warehouse') }}
{{ mo.wcode }} — {{ nm({'name_en': mo.wname_en, 'name_ar': mo.wname_ar}) }}
{{ t('Bill of materials') }}
{{ mo.bom_code or t('View') }} ({{ t('per') }} {{ qty(mo.bom_qty) }})
{{ t('Planned start') }}
{{ mo.planned_date }}
{{ t('Due date') }}
{{ mo.due_date or '—' }}
{% if mo.so_number %}
{{ t('Sales order') }}
{{ mo.so_number }}
{% endif %} {% if mo.started_at %}
{{ t('Started') }}
{{ mo.started_at[:16]|replace('T', ' ') }}
{% endif %} {% if mo.done_at %}
{{ t('Finished') }}
{{ mo.done_at[:16]|replace('T', ' ') }}
{% endif %}
{% if mo.notes %}

{{ mo.notes }}

{% endif %}

{{ t('Components') }}

{% if mo.state != 'done' %}{% endif %} {% if mo.state == 'done' %}{% endif %} {% for c in comps %} {% if mo.state != 'done' %}{% endif %} {% if mo.state == 'done' %}{% endif %} {% endfor %}
{{ t('Component') }}{{ t('Required') }}{{ t('In warehouse') }}{{ t('Used') }}{{ t('Cost') }}
{{ nm(c) }}
{{ c.code }}
{{ qty(c.qty_required) }} {{ c.uom or '' }}{{ qty(c.on_hand) }}{% if c.short %}
{{ t('short') }} {{ qty(c.short) }}{% endif %}
{% if open_state and can_write %}{% else %}{{ qty(c.qty_consumed) }}{% endif %}{{ c.cost|money(cur) }}

{{ t('Operations') }}

{% for op in ops %} {% else %}{% endfor %}
{{ t('Operation') }}{{ t('Work centre') }}{{ t('Planned (min)') }}{{ t('Actual (min)') }}{{ t('Rate / hour') }}
{{ op.name }}{{ op.wc_code }} · {{ nm({'name_en': op.wc_name_en, 'name_ar': op.wc_name_ar}) }} {{ qty(op.planned_minutes) }} {% if op.actual_minutes is not none %}{{ qty(op.actual_minutes) }}{% else %}—{% endif %} {{ op.cost_per_hour|money(cur) }} {% if open_state and can_write %}
{% elif op.state == 'done' %}{{ t('Done') }}{% endif %}
{{ t('No operations on this bill of materials.') }}

{{ t('Quality checks') }}

{% for c in checks %} {% else %}{% endfor %}
{{ t('Check') }}{{ t('Specification') }}{{ t('Result') }}
{{ c.name }}{% if c.notes %}
{{ c.notes }}{% endif %}
{% if c.kind == 'measure' %}{{ c.min_value if c.min_value is not none else '…' }} – {{ c.max_value if c.max_value is not none else '…' }} {{ c.unit or '' }}{% else %}{{ t('Pass / fail') }}{% endif %} {% if c.result %}{{ t('Pass') if c.result == 'pass' else t('Fail') }}{% if c.value is not none %} {{ c.value }} {{ c.unit or '' }}{% endif %}{% else %}{{ t('To check') }}{% endif %} {% if mo.state not in ('done', 'cancelled', 'draft') and can_write %}
{% if c.kind == 'measure' %} {% else %}{% endif %}
{% endif %}
{{ t('No quality points for this product.') }} {% if mo.state == 'draft' %}{{ t('Checks are created when the order is confirmed.') }}{% endif %}
{% if open_state and can_write %}

{{ t('Finish production') }}

{{ t('Consumes the components above, books the labour and machine time, and receives the good pieces into stock at their cost.') }}

{{ t('Their material cost stays in the cost of the good pieces.') }}
{% endif %}

{{ t('Cost') }}

{% if mo.state == 'done' %}{% endif %} {% for key, label in [('material', 'Materials'), ('conversion', 'Labour & machine time'), ('total', 'Total')] %} {% if mo.state == 'done' %}{% endif %} {% endfor %} {% if mo.state == 'done' %}{% endif %}
{{ t('Planned') }}{{ t('Actual') }}{{ t('Difference') }}
{{ t(label) }}{{ planned[key]|money(cur) if planned else '—' }}{{ actual[key]|money(cur) }} {{ (actual[key] - planned[key])|money(cur) if planned else '' }}
{{ t('Per unit') }}{{ (planned.unit|round|int)|money(cur) if planned else '—' }}{{ actual.unit|money(cur) }}

{{ t('Planned: bill of materials at today\'s component costs and work-centre rates. Actual: what was consumed and worked on this order.') }}

{% endblock %}