{% extends "base.html" %} {% from "_macros.html" import approval_panel, order_badge, progress_badge, picking_badge, state_badge, attachments_card with context %} {% block title %}{{ o.number }}{% endblock %} {% block content %} {% set cur = branch.currency %} {% set sale = kind == 'sale' %}
{{ t(info.title) }}

{{ o.number }} {{ order_badge(o.state, kind) }}{% if po_type %} {{ t(po_type) }}{% endif %} {% if o.ack_state == 'awaiting' %}{{ t('Awaiting vendor confirmation') }}{% elif o.ack_state == 'accepted' %}{{ t('Accepted by vendor') }}{% elif o.ack_state == 'rejected' %}{{ t('Rejected by vendor') }}{% endif %}

{% if o.state == 'confirmed' %}{{ t('Delivery') if sale else t('Receipt') }}: {{ progress_badge(deliv) if deliv else '—' }} · {{ t('Invoicing') }}: {{ progress_badge(inv_status) }}{% endif %}
{% if mr %}{{ mr.number }}{% endif %} {% if pr %}{{ pr.number }}{% endif %} {% if po_type and o.state == 'confirmed' %}{{ icon('file') }}PDF{% endif %} {% if rfq %}{{ rfq.number }}{% endif %} {{ t('Print') }} {% if can_write %} {% if o.state == 'draft' %} {{ t('Edit') }}
{% elif o.state == 'to_approve' %}
{% elif o.state == 'confirmed' %} {% if inv_status != 'full' %}
{% endif %} {% if (stock_open if not sale else (deliv and deliv != 'full')) and not open_picking %}
{% endif %} {% if sale and has('manufacturing') %}
{% endif %} {% if grn_open and can_grn %}{{ t('Receive (GRN)') }}{% endif %} {% if po_type and not o.sent_at %}
{% endif %}
{% elif o.state == 'cancelled' %}
{% endif %} {% endif %}
{% if o.kind == 'sale' and o.state == 'draft' %}{% set ci = credit_issues(o.partner_id, o.amount_total, branch.currency if branch else company.currency) %} {% if ci %}
{{ icon('shield') }}{{ t('Credit control') }}: {{ ci|join('; ') }}.
{% endif %}{% endif %} {% if o.kind == 'purchase' %}{{ approval_panel('po', o.id, url_for('orders.action', order_id=o.id, action='approve'), url_for('orders.action', order_id=o.id, action='reject')) }}{% endif %}
{{ t('Customer') if sale else t('Vendor') }}
{{ nm({'name_en': o.pname_en, 'name_ar': o.pname_ar}) }}
{{ t('Branch') }}
{{ branch.code }} — {{ nm(branch) }}
{{ t('Warehouse') }}
{{ o.wcode or '—' }}
{{ t('Order Date') }}
{{ o.date }}
{{ t('Delivery Date') if sale else t('Expected Arrival') }}
{{ o.expected_date or '—' }}
{{ t('Reference') }}
{{ o.ref or '—' }}
{% if has('projects') and o.project_id %}
{{ t('Project') }}
{{ o.pj_code }} — {{ nm({'name_en': o.pj_en, 'name_ar': o.pj_ar}) }}
{% endif %} {% if o.cc_code %}
{{ t('Cost Centre') }}
{{ o.cc_code }} — {{ nm({'name_en': o.cc_name_en, 'name_ar': o.cc_name_ar}) }}
{% endif %}
{% if o.state == 'confirmed' %}{% endif %} {% for l in lines %}{% set pg = prog[l.id] %} {% if o.state == 'confirmed' %} {% endif %} {% endfor %}
{{ t('Product') }}{{ t('Qty') }}{{ t('Delivered') if sale else t('Received') }}{{ t('Invoiced') }}{{ t('Unit Price') }}{{ t('Tax') }}{{ t('Subtotal') }}
{% if l.product_id %}{{ l.pcode or '' }} {{ nm({'name_en': l.pname_en, 'name_ar': l.pname_ar}) }}
{% endif %}{{ l.description or '' }}
{{ '%g' % l.quantity }} {{ l.uom or '' }}{{ ('%g' % pg.done) if (l.ptype == 'stock' or po_type) else '—' }} {{ '%g' % pg.invoiced }}{{ l.price_unit|money(cur) }} {{ nm({'name_en': l.tname_en, 'name_ar': l.tname_ar}) if l.tname_en else '' }}{{ l.subtotal|money(cur) }}
{{ t('Untaxed Amount') }}{{ o.amount_untaxed|money(cur) }}
{{ t('VAT') }}{{ o.amount_tax|money(cur) }}
{{ t('Total') }} ({{ cur }}){{ o.amount_total|money(cur) }}
{% if pickings or invoices %}

{{ t('Deliveries') if sale else t('Receipts') }}

{% for pk in pickings %} {% else %}{% endfor %}
{{ pk.number }}{{ pk.date }}{{ picking_badge(pk.state) }}
{{ t('Nothing yet.') }}

{{ t('Invoices') if sale else t('Bills') }}

{% for i in invoices %} {% else %}{% endfor %}
{{ i.number or t('Draft') }}{{ i.amount_total|money(cur) }}{{ state_badge(i.state) }}
{{ t('Nothing yet.') }}
{% endif %} {% if po_type and o.state == 'confirmed' and (o.sent_at or o.ack_state) %}

{{ t('Vendor acknowledgement') }}

{% if o.sent_at %}

{{ t('Sent to the vendor') }}: {{ o.sent_at[:16].replace('T', ' ') }}

{% endif %} {% if o.ack_state in ('accepted', 'rejected') %}
{{ t('Status') }}
{{ t('Accepted by vendor') if o.ack_state == 'accepted' else t('Rejected by vendor') }}
{{ t('Vendor reference') }}
{{ o.ack_ref or '—' }}
{{ t('Promised delivery') }}
{{ o.ack_date or '—' }}
{{ t('Recorded') }}
{{ o.ack_at[:16].replace('T', ' ') }}
{% if o.ack_note %}
{{ t('Note') }}
{{ o.ack_note }}
{% endif %}
{% endif %} {% if can_write %}
{% endif %}
{% endif %} {% if grns %}

{{ t('Goods received notes') }}

{% for gr in grns %}{% endfor %}
{{ gr.number }}{{ gr.date }}{{ gr.full_name or '' }}{{ gr.delivery_note or '' }}{{ t('Done') if gr.state == 'done' else t('Cancelled') }}
{% endif %} {% if o.notes %}

{{ t('Notes') }}

{{ o.notes }}
{% endif %} {% if o.terms %}

{{ t('Terms & Conditions') }}

{{ o.terms }}
{% endif %} {{ attachments_card('order', o.id) }} {% endblock %}