{% for line in program.budgetLines %}
{# === Variables sûres avec fallbacks === #} {% set _currency = line.currency|default(program.currency)|default('XOF') %} {% set _allocated = line.allocatedBudget|default(0) %} {% set _committed = line.committedAmount|default(0) %} {% set _disbursed = line.disbursedAmount|default(0) %} {% set _remaining = line.remainingBudget|default(_allocated - _disbursed) %} {% set _utilRate = line.utilizationRate is not null ? line.utilizationRate : (_allocated > 0 ? (_disbursed / _allocated * 100) : 0) %} {% set _projectName = (line.project and line.project.name is defined) ? line.project.name : '—' %} {% set _projectAcr = (line.project and line.project.acronym is defined) ? line.project.acronym : null %} {# === En‑tête : titre + badges + utilisation === #}
{{ line.title|default('Ligne budgétaire') }}
{% if line.identityNumber %} {{ line.identityNumber }} {% endif %} {% if line.fundingPartner %} {{ line.fundingPartner }} {% endif %} {% if line.fundingType %} {{ line.fundingType }} {% endif %} {% if _projectName %} {% if _projectAcr %}{{ _projectAcr }}{% endif %} {{ _projectName }} {% endif %}
Taux d'engagement
{{ _utilRate|number_format(1, '.', ' ') }}%
{# === Description courte (dépliable) === #} {% if line.comment %} {% set _cleanComment = line.comment|striptags %} {% set _isLong = _cleanComment|length > 180 %}
Description

{{ _isLong ? (_cleanComment|slice(0,180) ~ '…') : _cleanComment }}

{% if _isLong %} Voir plus
{{ _cleanComment }}
{% endif %}
{% endif %} {# === KPI chips (Alloué / Engagé / Décaissé / Restant) === #}
Alloué
{{ _allocated | format_currency(_currency, {fraction_digit: 0}) }}
Engagé
{{ _committed | format_currency(_currency, {fraction_digit: 0}) }}
Décaissé
{{ _disbursed | format_currency(_currency, {fraction_digit: 0}) }}
Restant
{{ _remaining | format_currency(_currency, {fraction_digit: 0}) }}
{# === Deux colonnes : Exécution + Répartition annuelle === #}
Exécution budgétaire
Budget alloué
{{ _allocated | format_currency(_currency, {fraction_digit: 0}) }}
Budget restant
{{ _remaining | format_currency(_currency, {fraction_digit: 0}) }}
Engagé
{{ _committed | format_currency(_currency, {fraction_digit: 0}) }}
Décaissé
{{ _disbursed | format_currency(_currency, {fraction_digit: 0}) }}
Répartition annuelle
{# === Actions (placeholder pour futurs liens) === #}
{# Lecture seule pour l'instant #}
{% endfor %}