{# Détection du contexte : readonly ou validation #} {% set is_readonly = is_readonly|default(false) %}
{% if not is_readonly and type != 'technique' %} {# Bouton ajouter pièce en mode validation #}
{% endif %}
{% if is_readonly %} {# Mode readonly : Structure exacte comme demandé #} {# Ligne 1 : Tableau pièces + Tableau récap TVA à droite #}
{% set facture_lignes_pieces = [] %} {% for facture in intervention.factures %} {% for factureLigne in facture.getFactureLignes %} {% if factureLigne.getProduit and factureLigne.getProduit.getProduitType and factureLigne.getProduit.getProduitType.id == 1 %} {% set facture_lignes_pieces = facture_lignes_pieces|merge([factureLigne]) %} {% endif %} {% endfor %} {% endfor %} {% if facture_lignes_pieces|length > 0 %} {% for factureLigne in facture_lignes_pieces %} {% endfor %} {% set emptyRows = 3 - facture_lignes_pieces|length %} {% if emptyRows > 0 %} {% for i in 1..emptyRows %} {% endfor %} {% endif %} {% else %} {% endif %}
Référence Désignation P.U. HT Qté Total HT TVA Aff.
{{ factureLigne.getProduit ? factureLigne.getProduit.code : '' }} {{ factureLigne.getProduit ? factureLigne.getProduit.designation : factureLigne.designation }} {{ factureLigne.getPuHt ? factureLigne.getPuHt|number_format(2, ',', ' ') ~ '€' : '' }} {{ factureLigne.quantite ? factureLigne.quantite : '' }} {{ factureLigne.getPrixTotalHt ? factureLigne.getPrixTotalHt|number_format(2, ',', ' ') ~ '€' : '' }} {{ factureLigne.getTauxTva ? factureLigne.getTauxTva.taux ~ '%' : '' }} {{ factureLigne.getProduitFactureAffectation ? factureLigne.getProduitFactureAffectation.libelleCourt : '' }}
{# Bon de commande en haut à droite #}
{% set tva_totaux = {} %} {# Calcul des totaux TVA pour les pièces #} {% for facture in intervention.factures %} {% for factureLigne in facture.getFactureLignes %} {% if factureLigne.getProduit and factureLigne.getProduit.getProduitType and factureLigne.getProduit.getProduitType.id == 1 %} {% if factureLigne.getProduitFactureAffectation and factureLigne.getProduitFactureAffectation.libelleCourt == 'F' %} {% set tva = factureLigne.getTauxTva ? factureLigne.getTauxTva.taux : 0 %} {% set tva_key = (tva ~ '_tva') %} {% set montant = factureLigne.getPrixTotalHt ? factureLigne.getPrixTotalHt : 0 %} {% set tva_totaux = tva_totaux|merge({ (tva_key): (tva_totaux[tva_key]|default(0) + montant) }) %} {% endif %} {% endif %} {% endfor %} {% endfor %} {# Ajout de la MO si elle existe #} {% if ligne_mo %} {% set tva = ligne_mo.getTauxTva ? ligne_mo.getTauxTva.taux : 0 %} {% set tva_key = (tva ~ '_tva') %} {% set montant = ligne_mo.getPrixTotalHt ? ligne_mo.getPrixTotalHt : 0 %} {% set tva_totaux = tva_totaux|merge({ (tva_key): (tva_totaux[tva_key]|default(0) + montant) }) %} {% endif %} {# Ajout du déplacement s'il existe #} {% if ligne_deplacement %} {% set tva = ligne_deplacement.getTauxTva ? ligne_deplacement.getTauxTva.taux : 0 %} {% set tva_key = (tva ~ '_tva') %} {% set montant = ligne_deplacement.getPrixTotalHt ? ligne_deplacement.getPrixTotalHt : 0 %} {% set tva_totaux = tva_totaux|merge({ (tva_key): (tva_totaux[tva_key]|default(0) + montant) }) %} {% endif %} {% if tva_totaux|length > 0 %} {% set nb_line = 0 %} {% for tva_key, montant in tva_totaux %} {% set taux = tva_key|replace({'_tva':''}) %} {% set nb_line = nb_line + 1 %} {% endfor %} {% set emptyRows = 3 - nb_line %} {% if emptyRows > 0 %} {% for i in 1..emptyRows %} {% endfor %} {% endif %} {% else %} {% endif %}
Base HTTauxMontant
{{ montant|number_format(2, ',', ' ') }} € {{ taux }}% {{ ((montant * taux)/100)|number_format(2, ',', ' ') }}€
{# Tableau récap TVA à droite, collé au tableau principal #}
{# Ligne 2 : Sections Déplacement, Main d'œuvre et Pièces alignées horizontalement #}
Déplacement
{% set deplacement_ttc = 0 %} {% if ligne_deplacement %} {% set tva = ligne_deplacement.getTauxTva ? ligne_deplacement.getTauxTva.taux : 0 %} {% set montant = ligne_deplacement.getPrixTotalHt ? ligne_deplacement.getPrixTotalHt : 0 %} {% set deplacement_ttc = montant + (montant*tva)/100 %} {% endif %}
Main d'oeuvre
{% set mo_ttc = 0 %} {% if ligne_mo %} {% set tva = ligne_mo.getTauxTva ? ligne_mo.getTauxTva.taux : 0 %} {% set montant = ligne_mo.getPrixTotalHt ? ligne_mo.getPrixTotalHt : 0 %} {% set mo_ttc = montant + (montant*tva)/100 %} {% endif %}
Pièces
{% set total_ht_pieces = 0 %} {% for facture in intervention.factures %} {% for factureLigne in facture.getFactureLignes %} {% if factureLigne.getProduit and factureLigne.getProduit.getProduitType and factureLigne.getProduit.getProduitType.id == 1 %} {% set total_ht_pieces = total_ht_pieces + (factureLigne.getPrixTotalHt ? factureLigne.getPrixTotalHt : 0) %} {% endif %} {% endfor %} {% endfor %}
{% set total_tva_pieces = 0 %} {% for facture in intervention.factures %} {% for factureLigne in facture.getFactureLignes %} {% if factureLigne.getProduit and factureLigne.getProduit.getProduitType and factureLigne.getProduit.getProduitType.id == 1 %} {% set tva = factureLigne.getTauxTva ? factureLigne.getTauxTva.taux : 0 %} {% set montant = factureLigne.getPrixTotalHt ? factureLigne.getPrixTotalHt : 0 %} {% set total_tva_pieces = total_tva_pieces + (montant * tva)/100 %} {% endif %} {% endfor %} {% endfor %}
{% set total_ttc_pieces = total_ht_pieces + total_tva_pieces %}
{% else %} {# Mode validation : Grid DevExtreme #}
{% endif %}
{% if not is_readonly %} {# Mode validation : Tableau récap TVA et tableau paiement côte à côte #}
Base HTTauxMontant
{% set nb_line = 0 %} {% if liste_paiement|length > 0 %} {% for paiement in liste_paiement %} {% set nb_line = nb_line + 1 %} {% endfor %} {% set emptyRows = 3 - nb_line %} {% if emptyRows > 0 %} {% for i in 1..emptyRows %} {% endfor %} {% endif %} {% else %} {% endif %}
Date Montant Date prévue enc. Mode paiement Date enc. Perçu
{{ paiement.date|date('d/m/Y') }} {{ paiement.montantTtc }}€ {{ paiement.datePrevisionnelle ? paiement.datePrevisionnelle|date('d/m/Y') : '' }} {{ paiement.moyenPaiement ? paiement.moyenPaiement.libelleCourt : '' }}
{% endif %}
{% if not is_readonly %} {# Mode validation : Sections Déplacement, Main d'œuvre et Pièces à droite #}
Déplacement
Main d'oeuvre
Pièces
{# Mode validation : Espacement et totaux avec IDs pour JS #}
{% endif %}