{% extends 'base.html' %} {% block title %}{{ contract.contract_no }}{% endblock %} {% block content %}
Dashboard / Contracts / {{ contract.contract_no }}
{% if contract.status == 'closed' %}
This contract is closed. Reopen it to add deliveries.
{% elif delivery_due and delivery_due < today %}
Delivery period has passed (due {{ delivery_due }}). This contract is overdue.
{% endif %}
Contract Details {% if creator %}Created by {{ creator }}{% endif %}
Contract No
{{ contract.contract_no }}
Sale Order No
{{ contract.sale_order_no or '–' }}
Customer
{{ contract.customer_name }}
Broker
{{ contract.broker or '–' }}
Price
{{ "{:,.2f}".format(contract.price) if contract.price else '–' }}
Total Declared Qty
{{ "{:,.3f}".format(contract.qty) }} kg
{% if has_cf_alloc %}
Wet Qty (CF)
{{ "{:,.3f}".format(contract.wet_qty) if contract.wet_qty else '–' }}
{% endif %}
Delivery Period
{% if contract.delivery_start %}{{ contract.delivery_start }} – {% endif %}{{ delivery_due or '–' }}
Created
{{ contract.created_at[:10] if contract.created_at else '–' }}
{% if contract.updated_at and contract.updated_at != contract.created_at %}
Last Updated
{{ contract.updated_at[:10] }}
{% endif %}
Materials
{% if contract_mats %}
{% for m in contract_mats %} {{ m.name }}{% if m.mat_qty %} – {{ "{:,.3f}".format(m.mat_qty) }} {{ m.unit }}{% endif %} {% endfor %}
{% else %} No materials specified {% endif %}
{% if contract.notes %}
Notes
{{ contract.notes }}
{% endif %}
{% if allocations %}
Factory Allocations {{ allocations|length }} factor{{ 'y' if allocations|length == 1 else 'ies' }}
{% for a in allocations %} {% set pct = (a.delivered / a.qty * 100)|round(1) if a.qty > 0 else 0 %} {% endfor %}
Factory Allocated Qty Delivered Balance Progress
{{ a.factory_code }} {{ a.factory_name }} {{ "{:,.3f}".format(a.qty) }} {{ "{:,.3f}".format(a.delivered) }} {% if a.balance < 0 %} ({{ "{:,.3f}".format(a.balance|abs) }} over) {% else %}{{ "{:,.3f}".format(a.balance) }}{% endif %}
{{ pct }}%
Total {{ "{:,.3f}".format(contract.qty) }} {{ "{:,.3f}".format(delivered) }} {% if balance < 0 %} ({{ "{:,.3f}".format(balance|abs) }} over) {% else %}{{ "{:,.3f}".format(balance) }}{% endif %}
{% endif %}
{{ "{:,.3f}".format(contract.qty) }}
Declared
kg
{{ "{:,.3f}".format(delivered) }}
Delivered
{{ deliveries|length }} entr{{ 'y' if deliveries|length == 1 else 'ies' }}
{% if balance < 0 %}({{ "{:,.3f}".format(balance|abs) }}){% else %}{{ "{:,.3f}".format(balance) }}{% endif %}
Balance
{% if balance < 0 %}over-delivered{% elif balance == 0 %}complete{% else %}remaining{% endif %}
{% set pct = (delivered / contract.qty * 100)|round(1) if contract.qty > 0 else 0 %}
{{ pct }}%
Progress
{% if contract.status == 'open' and can_edit() %}
Add Delivery
{% if allocations|length > 1 %}
{% elif allocations %} {% endif %}
{% if has_cf_alloc %}
{% endif %}
{% endif %} {% set col_count = 6 + (1 if allocations|length > 1 else 0) + (1 if has_cf_alloc else 0) %}
Delivery History {{ deliveries|length }} entr{{ 'y' if deliveries|length == 1 else 'ies' }}
{% if allocations|length > 1 %}{% endif %} {% if has_cf_alloc %}{% endif %} {% if contract.status == 'open' and can_edit() %}{% endif %} {% for d in deliveries %} {% if allocations|length > 1 %} {% endif %} {% if has_cf_alloc %} {% endif %} {% if contract.status == 'open' and can_edit() %} {% endif %} {% else %} {% endfor %} {% if deliveries %} {% if has_cf_alloc %}{% endif %} {% if contract.status == 'open' and can_edit() %}{% endif %} {% endif %}
# Date Invoice NoFactoryQty (kg)Wet QtyNotes Recorded By
{{ loop.index }} {{ d.delivery_date }} {{ d.invoice_no }} {% if d.alloc_factory %} {{ d.alloc_factory }} {% else %}{% endif %} {{ "{:,.3f}".format(d.qty) }}{{ "{:,.3f}".format(d.wet_qty) if d.wet_qty else '–' }}{{ d.notes or '–' }} {{ d.created_by_name or '–' }} {# SAFE: all delivery values passed via data-* attributes, never inline JS strings #}
No deliveries recorded yet
Total {{ "{:,.3f}".format(delivered) }}{{ "{:,.3f}".format(wet_delivered) }}
{% endblock %} {% block scripts %} {% endblock %}