{% extends 'base.html' %} {% load static %} {% block page_title %}Analytics Dashboard{% endblock %} {% block header_actions %}
Back
{% endblock %} {% block content %}
Total Products
{{ total_products|default:"0" }}
In inventory
Total Customers
{{ total_customers|default:"0" }}
Unique buyers
Stock Value
KSh {{ stock_value|default:"0"|floatformat:2 }}
Inventory worth
Overdue Loans
{{ overdue_loans.count|default:"0" }}
Require attention
Sales Trend - Last 30 Days
Top 5 Products
{% for product in top_products|slice:":5" %}
{{ product.product__name|truncatechars:20 }}
{{ product.total_sold }} units sold
KSh {{ product.total_revenue|floatformat:2 }}
{% empty %}

No sales data available

{% endfor %}
Category Distribution
{% for category in category_distribution|slice:":4" %}
{{ category.name|truncatechars:15 }} {{ category.percentage|floatformat:1 }}%
{% endfor %}
Payment Methods
Cash {{ payment_stats.cash|default:"0" }}%
M-Pesa {{ payment_stats.mpesa|default:"0" }}%
Card {{ payment_stats.card|default:"0" }}%
Credit {{ payment_stats.credit|default:"0" }}%
Overdue Loans
{% if overdue_loans %}
{% for loan in overdue_loans|slice:":5" %} {% endfor %}
Borrower Amount Due Date Days Overdue
{{ loan.borrower_name|truncatechars:15 }} KSh {{ loan.total_due|floatformat:2 }} {{ loan.due_date|date:"M d, Y" }} {% if loan.days_remaining < 0 %} {{ loan.days_remaining|stringformat:"d"|slice:"1:" }} days {% else %} 0 days {% endif %}
{% if overdue_loans.count > 5 %} {% endif %} {% else %}

No overdue loans

{% endif %}
Low Stock Alert
{% if low_stock_products %}
{% for product in low_stock_products|slice:":5" %} {% endfor %}
Product Current Stock Min Level Status
{{ product.name|truncatechars:20 }} {{ product.quantity_in_stock }} {{ product.minimum_stock_level }} {% if product.quantity_in_stock == 0 %} Out of Stock {% else %} Low Stock {% endif %}
{% if low_stock_products.count > 5 %} {% endif %} {% else %}

All products are well stocked

{% endif %}
Business Insights
Sales Insights

{% if daily_sales|length > 0 %} Average daily sales: KSh {{ average_daily_sales|default:"0"|floatformat:2 }} {% else %} Start recording sales to generate insights. {% endif %}

Inventory Insights

{{ low_stock_products.count|default:"0" }} products need restocking. Total inventory value: KSh {{ stock_value|default:"0"|floatformat:2 }}

Loan Insights

{{ overdue_loans.count|default:"0" }} overdue loans require attention. Total active loans: KSh {{ total_active_loans|default:"0"|floatformat:2 }}

{% endblock %}