{% load humanize %}

{% if borrower %} Client Analytics Report - {{ borrower.get_full_name }} {% else %} 📈Comprehensive Loan Analytics Report {% endif %}

Generated on {{ stats.generated_at|date:"F d, Y H:i" }}

{% if borrower %}

Client ID

{{ borrower.id_number }}

Registration Date

{{ borrower.date_joined|date:"M d, Y" }}

Business Type

{{ borrower.business_type|default:"N/A" }}

Credit Score

{{ borrower.credit_score|default:"N/A" }}/100

{% endif %}

Total Loans

{{ stats.total_loans|default:0|intcomma }}

{% if stats.loan_growth %}

{{ stats.loan_growth|floatformat:1 }}% from last month

{% endif %}

Total Amount

KES {{ stats.total_amount|default:0|intcomma }}

{% if stats.amount_growth %}

{{ stats.amount_growth|floatformat:1 }}% from last month

{% endif %}

Active Loans

{{ stats.active_loans|default:0|intcomma }}

{{ stats.active_percentage|default:0|floatformat:1 }}% of total

Default Rate

{{ stats.risk_level|default:"Unknown" }}

{% if stats.default_rate_change %}

{{ stats.default_rate_change|floatformat:1 }}% from last month

{% endif %}

Loan Status Distribution

Monthly Disbursement Trend

{% if insights %}

Key Insights

{% for insight in insights %}
💡

{{ insight }}

{% endfor %}
{% endif %} {% if stats.detailed_metrics %}

Detailed Metrics

{% for metric in stats.detailed_metrics %}
{{ metric.name }}
{{ metric.value }}
{% if metric.change %}
{{ metric.change|floatformat:1 }}% from previous period
{% endif %}
{% endfor %}
{% endif %}

🚩Executive Summary

{{ stats.executive_summary|default:"No executive summary available." }}

Portfolio Analysis

Portfolio Composition

Loan Performance

Risk Analysis

Risk Metrics

{% for metric in stats.risk_metrics %}
{{ metric.name }} {{ metric.value }}
{% endfor %}

Risk Factors

    {% for factor in stats.risk_factors %}
  • ⚠️ {{ factor.description }}
  • {% endfor %}

🪙Profitability Analysis

Revenue Metrics

{% for metric in stats.revenue_metrics %}
{{ metric.name }} {{ metric.value }}
{% endfor %}

Revenue Trend

⚙️Operational Metrics

{% for metric in stats.operational_metrics %}

{{ metric.name }}

{{ metric.value }}

{{ metric.description }}

{% endfor %}

💡Recommendations

{% for recommendation in stats.recommendations %}
💡

{{ recommendation.title }}

{{ recommendation.description }}

{% if recommendation.action_items %}
    {% for item in recommendation.action_items %}
  • {{ item }}
  • {% endfor %}
{% endif %}
{% endfor %}