{% extends "base.html" %} {% from "components/ui.html" import page_header %} {% block content %} {% set breadcrumbs = [ {'text': 'Inventory', 'url': url_for('inventory.list_stock_items')}, {'text': 'Purchase Orders', 'url': url_for('inventory.list_purchase_orders')}, {'text': purchase_order.po_number} ] %} {{ page_header( icon_class='fas fa-shopping-cart', title_text=purchase_order.po_number, subtitle_text=purchase_order.supplier.name, breadcrumbs=breadcrumbs, actions_html=('Back' + ('Edit' if (purchase_order.status != 'received' and purchase_order.status != 'cancelled' and (current_user.is_admin or has_permission('manage_inventory'))) else '') + ('
' if (purchase_order.status == 'draft' and (current_user.is_admin or has_permission('manage_inventory'))) else '') + ('
' if (purchase_order.status not in ['received', 'cancelled'] and (current_user.is_admin or has_permission('manage_inventory'))) else '') + ('
' if (purchase_order.status not in ['received', 'cancelled'] and (current_user.is_admin or has_permission('manage_inventory'))) else '')) if (current_user.is_admin or has_permission('view_inventory')) else None ) }}

{{ _('Purchase Order Details') }}

{{ purchase_order.po_number }}

{% if purchase_order.status == 'draft' %} {{ _('Draft') }} {% elif purchase_order.status == 'sent' %} {{ _('Sent') }} {% elif purchase_order.status == 'confirmed' %} {{ _('Confirmed') }} {% elif purchase_order.status == 'received' %} {{ _('Received') }} {% elif purchase_order.status == 'cancelled' %} {{ _('Cancelled') }} {% endif %}

{{ purchase_order.supplier.name }}

{{ purchase_order.order_date.strftime('%Y-%m-%d') if purchase_order.order_date else '—' }}

{% if purchase_order.expected_delivery_date %}

{{ purchase_order.expected_delivery_date.strftime('%Y-%m-%d') }}

{% endif %} {% if purchase_order.received_date %}

{{ purchase_order.received_date.strftime('%Y-%m-%d') }}

{% endif %} {% if purchase_order.notes %}

{{ purchase_order.notes }}

{% endif %}
{% if purchase_order.items.count() > 0 %}

{{ _('Items') }}

{% for item in purchase_order.items %} {% endfor %} {% if purchase_order.shipping_cost > 0 %} {% endif %} {% if purchase_order.tax_amount > 0 %} {% endif %}
{{ _('Item') }} {{ _('Description') }} {{ _('Quantity Ordered') }} {{ _('Quantity Received') }} {{ _('Unit Cost') }} {{ _('Line Total') }}
{% if item.stock_item %} {{ item.stock_item.sku }} {% else %} {{ item.supplier_sku or '—' }} {% endif %} {{ item.description }} {{ item.quantity_ordered }} {{ item.quantity_received }} {{ "%.2f"|format(item.unit_cost) }} {{ item.currency_code }} {{ "%.2f"|format(item.line_total) }} {{ item.currency_code }}
{{ _('Subtotal') }}: {{ "%.2f"|format(purchase_order.subtotal) }} {{ purchase_order.currency_code }}
{{ _('Shipping') }}: {{ "%.2f"|format(purchase_order.shipping_cost) }} {{ purchase_order.currency_code }}
{{ _('Tax') }}: {{ "%.2f"|format(purchase_order.tax_amount) }} {{ purchase_order.currency_code }}
{{ _('Total') }}: {{ "%.2f"|format(purchase_order.total_amount) }} {{ purchase_order.currency_code }}
{% if purchase_order.status != 'received' and purchase_order.status != 'cancelled' %}

{{ _('Receive Purchase Order') }}

{% for item in purchase_order.items %}
{{ item.description }} Ordered: {{ item.quantity_ordered }}
{% endfor %}
{% endif %} {% else %}

{{ _('No items in this purchase order.') }}

{% endif %}

{{ _('Summary') }}

{{ purchase_order.items.count() }}

{{ "%.2f"|format(purchase_order.total_amount) }} {{ purchase_order.currency_code }}

{{ purchase_order.created_at.strftime('%Y-%m-%d %H:%M') if purchase_order.created_at else '—' }}

{% endblock %}