{% extends 'base.html' %} {% load humanize %} {% block title %}Expense Analytics - HAVEN GRAZURI ADVANCE{% endblock %} {% block content %}
โ† Back to Expenses

Expense Analytics

Comprehensive expense analysis and trends across all categories and branches

{% with total_expenses=category_breakdown|length %}

Total Categories

{{ total_expenses }}

๐Ÿท๏ธ
{% endwith %} {% with total_branches=branch_breakdown|length %}

Active Branches

{{ total_branches }}

๐Ÿข
{% endwith %} {% with total_amount=category_breakdown|first %}

Top Category

{% if category_breakdown %} {% with top=category_breakdown|first %} {% if top.category == 'loan_related' %}Loan-Related{% else %}{{ top.category|title }}{% endif %} {% endwith %} {% else %} N/A {% endif %}

๐Ÿ“Š
{% endwith %}

Total Expenses

{% with total=0 %} {% for item in category_breakdown %} {% with total=total|add:item.count %}{% endwith %} {% endfor %} {{ category_breakdown|length|default:0 }} {% endwith %}

๐Ÿงพ

๐Ÿ“Š Expenses by Category

{% if category_breakdown %}
{% for item in category_breakdown %}

{% if item.category == 'loan_related' %} Loan-Related {% else %} {{ item.category|title }} {% endif %}

{{ item.count }} expense{{ item.count|pluralize }}

Total Amount

KES {{ item.total|floatformat:2|intcomma }}

Average

KES {{ item.average|floatformat:2|intcomma }}

{% if item.percentage > 0 %}
{% endif %}
{% endfor %}
{% else %}
๐Ÿ“Š

No expense data available

{% endif %}

๐Ÿข Expenses by Branch

{% if branch_breakdown %}
{% for item in branch_breakdown %}

{{ item.branch__name }}

{{ item.count }} expense{{ item.count|pluralize }}

Total Amount

KES {{ item.total|floatformat:2|intcomma }}

Average

KES {{ item.average|floatformat:2|intcomma }}

{% if item.percentage > 0 %}
{% endif %}
{% endfor %}
{% else %}
๐Ÿข

No branch data available

{% endif %}

๐Ÿ“ˆ Monthly Expense Trend (Last 6 Months)

{% if monthly_trend %}
{% for item in monthly_trend %}
{{ item.month }}
{% if item.percentage > 0 %}
{{ item.percentage|floatformat:0 }}%
{% endif %}
KES {{ item.total|floatformat:2|intcomma }}
{% endfor %}
{% else %}
๐Ÿ“ˆ

No trend data available

{% endif %}

Highest Category

{% if category_breakdown %} {% with top=category_breakdown|first %} KES {{ top.total|floatformat:2|intcomma }} {% endwith %} {% else %} KES 0.00 {% endif %}

๐Ÿ“ˆ

Highest Branch

{% if branch_breakdown %} {% with top=branch_breakdown|first %} KES {{ top.total|floatformat:2|intcomma }} {% endwith %} {% else %} KES 0.00 {% endif %}

๐Ÿข

Average Expense

{% if category_breakdown %} {% with total_avg=0 count=0 %} {% for item in category_breakdown %} {% with total_avg=total_avg|add:item.average count=count|add:1 %}{% endwith %} {% endfor %} KES {{ total_avg|floatformat:2|intcomma }} {% endwith %} {% else %} KES 0.00 {% endif %}

๐Ÿงฎ
{% endblock %}