{% extends "base.html" %} {% block title %}Department Twin{% endblock %} {% block page_title %}Department Twin{% endblock %} {% block content %}
Total Headcount
{{ total_headcount }}
Across {{ dept_count }} departments
Total Payroll
{{ total_payroll | format_currency }}
Salaries + Benefits
Avg Salary
{{ avg_salary | format_currency }}
Company-wide average
Budget Utilization
{% if total_budget > 0 %}{{ "%.1f"|format((total_spent / total_budget) * 100) }}%{% else %}0%{% endif %}
{{ total_spent | format_currency }} of {{ total_budget | format_currency }}
Employee Directory
{% if departments %} {% set sorted_by_payroll = departments | sort(attribute='total_payroll', reverse=true) %} {% set highest_payroll = sorted_by_payroll | first %} {% set sorted_by_headcount = departments | sort(attribute='headcount', reverse=true) %} {% set largest_dept = sorted_by_headcount | first %} {% set over_budget = departments | selectattr("utilization", "gt", 100) | list %}
Department Insights
{{ largest_dept.name }} is the largest department with {{ largest_dept.headcount }} employees ({{ "%.1f"|format((largest_dept.headcount / total_headcount) * 100) if total_headcount > 0 else 0 }}% of total headcount).
{{ highest_payroll.name }} has the highest payroll at {{ highest_payroll.total_payroll | format_currency }} ({{ "%.1f"|format((highest_payroll.total_payroll / total_payroll) * 100) if total_payroll > 0 else 0 }}% of total payroll).
{% if over_budget | length > 0 %}
{{ over_budget | length }} department{{ 's' if over_budget|length > 1 else '' }} {{ 'are' if over_budget|length > 1 else 'is' }} over budget. Review spending in: {{ over_budget | map(attribute='name') | join(', ') }}.
{% endif %}
Company-wide payroll efficiency: {{ avg_salary | format_currency }} average salary across {{ total_headcount }} active employees.
{% endif %}
Headcount Distribution
Payroll Breakdown by Department
Department Overview

Cost centers, headcount, and budget health

{{ departments|length }} departments
{% if departments %}
{% for d in departments %}
{{ d.name[0] }}
{{ d.name }}
{{ d.code }} {% if d.head_name %}· Head: {{ d.head_name }}{% endif %}
{{ 'Over Budget' if d.utilization > 100 else 'Critical' if d.utilization > 90 else 'High' if d.utilization > 70 else 'Normal' if d.utilization > 40 else 'Low' }}
{{ "%.0f"|format(d.utilization) }}% budget
Headcount {{ d.headcount }}
Avg Salary {{ d.avg_salary | format_currency }}
Payroll {{ d.total_payroll | format_currency }}
Budget {{ d.budget | format_currency }}
Spent {{ d.spent | format_currency }}
Remaining {{ d.remaining | format_currency }}
{% endfor %}
{% else %}

No departments found.

{% endif %}
Department Detail
{% if departments %}
{% for d in departments %} {% endfor %}
Department Headcount Avg Salary Total Payroll Budget Spent Remaining Utilization Status
{{ d.name }} ({{ d.code }})
{{ d.headcount }} {{ d.avg_salary | format_currency }} {{ d.total_payroll | format_currency }} {{ d.budget | format_currency }} {{ d.spent | format_currency }} {{ d.remaining | format_currency }}
{{ "%.1f"|format(d.utilization) }}%
{% if d.utilization > 100 %} Over Budget {% elif d.utilization > 90 %} Critical {% elif d.utilization > 70 %} High {% elif d.utilization > 40 %} Normal {% else %} Low {% endif %}
{% else %}

No department data available.

{% endif %}
{% endblock %} {% block extra_js %} {% endblock %}