{# templates/app/achats/index.html.twig #} {% extends 'app/base.html.twig' %} {% set moisNoms = ['', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'] %} {% block title %}Achats {{ moisNoms[mois] }} {{ annee }} — GestRestoSco {% endblock %} {% block body %} {# ── En-tête ───────────────────────────────────────────────────────── #}

Achats

{# ── Navigation mois ───────────────────────────────────────────────── #}
{# Flèches navigation #}
{{ moisNoms[mois] }} {{ annee }}
{# Aller au mois courant #} {# Filtre fournisseur #}
{# ── Totaux ────────────────────────────────────────────────────────── #}
🧾
Achats TTC
{{ totalTTC|number_format(2, ',', ' ') }} €
💰
Achats HT
{{ totalHT|number_format(2, ',', ' ') }} €
📦
Lignes
{{ achats|length }}
🏭
Fournisseurs
{{ nbFournisseurs }}
{# ── Tableau ───────────────────────────────────────────────────────── #}
{% if achats is empty %}

Aucun achat pour {{ moisNoms[mois] }} {{ annee }} {% if fournisseur %} · {{ fournisseur }} {% endif %}

{% else %}
{% set currentFournisseur = null %} {% for achat in achats %} {# ── Ligne de groupe fournisseur ── #} {% if achat.fournisseur != currentFournisseur %} {% set currentFournisseur = achat.fournisseur %} {% endif %} {# ── Ligne achat ── #} {% endfor %}
Date Description Qté Unité PU TTC Total TTC Total HT TVA Stock Actions
{{ achat.fournisseur }}
{% if achat.converti_en_stock %} {% else %} {% endif %} {{ achat.date_achat|date('d/m/Y') }} {{ achat.description }} {{ achat.quantite|number_format(3, ',', ' ')|replace({',000': '', ',00': ''})|trim }} {{ achat.unite ?: '—' }} {{ achat.prix_unitaire|number_format(2, ',', ' ') }} € {{ achat.montant_total|number_format(2, ',', ' ') }} € {{ achat.montant_ht ? achat.montant_ht|number_format(2, ',', ' ') ~ ' €' : '—' }} {{ achat.taux_tva|number_format(1, ',') }}% {% if achat.converti_en_stock %} En stock {% else %} {% endif %}
{% if not achat.is_avoir %} {% endif %}
Total {{ moisNoms[mois] }} : {{ totalTTC|number_format(2, ',', ' ') }} € {{ totalHT|number_format(2, ',', ' ') }} €
{% endif %}
{# ── Section avoirs appliqués (hors tableau achats, non convertibles en stock) ──── #} {% if avoirsLignes is not empty %}
Avoirs appliqués ce mois
{{ avoirsLignes|length }} — Ces lignes ne sont pas convertibles en stock
{% set totalAvoirsHT = 0 %} {% set totalAvoirsTTC = 0 %} {% for av in avoirsLignes %} {% set totalAvoirsHT = totalAvoirsHT + (av.montant_ht ?: 0) %} {% set totalAvoirsTTC = totalAvoirsTTC + av.montant_total %} {% endfor %}
Date Fournisseur Description Montant HT Montant TTC
{{ av.date_achat|date('d/m/Y') }} {{ av.fournisseur }} {{ av.description }} {{ (av.montant_ht ?: 0)|number_format(2, ',', ' ') }} € {{ av.montant_total|number_format(2, ',', ' ') }} €
Total avoirs : {{ totalAvoirsHT|number_format(2, ',', ' ') }} € {{ totalAvoirsTTC|number_format(2, ',', ' ') }} €
Net achats (après avoirs) : {{ (totalHT + totalAvoirsHT)|number_format(2, ',', ' ') }} € {{ (totalTTC + totalAvoirsTTC)|number_format(2, ',', ' ') }} €
{% endif %} {# ── Token CSRF pour la conversion AJAX ───────────────────────────── #} {# ── Modal nouvel achat ────────────────────────────────────────────── #} {# ── Avoirs en attente ─────────────────────────────────────────────── #} {% if avoirsEnAttente is defined and avoirsEnAttente|length > 0 %}
Avoirs en attente d'application Voir tous →
{% for av in avoirsEnAttente %} {% endfor %}
Fournisseur Description Montant TTC Déclaré le Action
{{ av.fournisseur }} {{ av.description }} {{ av.montant_ttc|number_format(2, ',', ' ') }} € {{ av.date_creation|date('d/m/Y') }} Appliquer
{% endif %} {# ── Modal déclarer avoir ──────────────────────────────────────────── #} {% if is_granted('ROLE_TENANT_GESTIONNAIRE') %} {% endif %} {% endblock %} {% block javascripts %} {{ parent() }} {% endblock %}