{% extends 'base.html' %} {% block content %}

📦 Purchases

{% if current_user.role in ['admin','supplier'] %} ➕ New Purchase {% endif %}
{% if purchases %} {% set total_weight = purchases|sum(attribute='weight_kg') %} {% set total_amount = purchases|sum(attribute='total_amount') %} {% set avg_price = (total_amount / total_weight) if total_weight > 0 else 0 %}
📊
{{ total_weight|kg }}
Total Weight
💰
{{ total_amount|currency }}
Total Spent
📈
{{ avg_price|currency }}
Avg Price/kg
📦
{{ purchases|length }}
Total Purchases
{% endif %}

Purchase History

{% if purchases %} Showing {{ purchases|length }} purchase{{ 's' if purchases|length != 1 else '' }} {% endif %}
{% if purchases %}
{% for p in purchases %} {% endfor %}
📅 Date 👤 Supplier 🏭 Farm ⚖️ Weight 💲 Price/kg 💰 Total
{{ p.date|date_format }} {{ p.supplier.name }} {% if p.farm %} {{ p.farm.name }} {% else %} - {% endif %} {{ p.weight_kg|kg }} {{ p.price_per_kg|currency }} {{ p.total_amount|currency }}
{% else %}
📦

No Purchases Yet

Start by recording your first purchase from a farm.

{% if current_user.role in ['admin','supplier'] %} ➕ Record First Purchase {% endif %}
{% endif %}
{% endblock %}