{#--Onglet Tarif & Promotions--#} {# Contexte promo #} {% set now = date() %} {% set promo = produit.promotion %} {% set promoActive = promo and promo.startAt <= now and promo.endAt >= now %} {% set discount = promoActive ? promo.discountValue : 0 %} {% set discountType = promoActive ? promo.discountType : null %} {# Prix après remise #} {% set ht_remise = promoActive ? (discountType == 'percent' ? (produit.priceHt - (produit.priceHt * discount / 100)) : (produit.priceHt - discount)) : produit.priceHt %} {% set ttc_remise = promoActive ? (discountType == 'percent' ? (produit.priceTtc - (produit.priceTtc * discount / 100)) : (produit.priceTtc - discount)) : produit.priceTtc %} {# % remisé calculé même si remise fixe #} {% set pct_ht = promoActive and produit.priceHt > 0 ? (100 * (produit.priceHt - ht_remise) / produit.priceHt) : 0 %} {% set pct_ttc = promoActive and produit.priceTtc > 0 ? (100 * (produit.priceTtc - ttc_remise) / produit.priceTtc) : 0 %} {#-- Onglet Tarif et Promotion Amélioré --#}
{# --- Bloc Prix --- #}
Tarification
Resume des prix et promotions
HT: {{ produit.priceHt|number_format(3,'.',',') }} TND
TTC: {{ produit.priceTtc|number_format(3,'.',',') }} TND
{% if promoActive %}
Eco HT: -{{ pct_ht|number_format(0) }}%
Eco TTC: -{{ pct_ttc|number_format(0) }}%
{% else %}
Aucune remise active
{% endif %}
{# === KPIs Tarif & TVA === #} {# === Section TARIFS === #}
{# ==== KPIs Achat + Vente sur une ligne ==== #}
{% if is_granted('ROLE_SUPER_ADMIN') %}
Achat Prix d'achat HT
{{ produit.buyingPriceHt|number_format(3,'.',',') }} TND
Achat TVA Achat
{% if produit.tvaBuy is null %}Aucune{% else %}{{ produit.tvaBuy.number }} %{% endif %}
Achat Prix d'achat TTC
{{ produit.buyingPriceTtc|number_format(3,'.',',') }} TND
{% endif %}
Vente Prix de vente HT
{% if promoActive %} -{{ pct_ht|number_format(0) }}% {{ produit.priceHt|number_format(3,'.',',') }} TND {{ ht_remise|number_format(3,'.',',') }} TND {% else %} {{ produit.priceHt|number_format(3,'.',',') }} TND {% endif %}
Vente TVA Vente
{% if produit.tva is null %}Aucune{% else %}{{ produit.tva.number }} %{% endif %}
Vente Prix de vente TTC
{% if promoActive %} -{{ pct_ttc|number_format(0) }}% {{ produit.priceTtc|number_format(3,'.',',') }} TND {{ ttc_remise|number_format(3,'.',',') }} TND {% else %} {{ produit.priceTtc|number_format(3,'.',',') }} TND {% endif %}
{% if "PRODUIT_UPDATE" in rights %} {# Bloc promotion #}
Promotion
Seules les promotions actives et en cours de validité sont affichées dans cette liste.
{% if promo %} {# Bouton : mettre fin ? la promotion en cours #} {% if promoActive %} {# Promo encore valable -> ouvrir la modale #} {% else %} {# Promo expir?e -> POST direct sans modale #} {% endif %} {% endif %} {# Bouton : appliquer la promotion s?lectionn?e #} {# Bouton : afficher l?historique des promotions #}
{% set today = "now"|date("Y-m-d") %} {% set percentPromotions = [] %} {% set amountPromotions = [] %} {% for promotion in promotions %} {% if promotion.isEnabled and promotion.startAt|date("Y-m-d") <= today and promotion.endAt|date("Y-m-d") >= today %} {% if promotion.discountType == 'percent' %} {% set percentPromotions = percentPromotions|merge([promotion]) %} {% else %} {% set amountPromotions = amountPromotions|merge([promotion]) %} {% endif %} {% endif %} {% endfor %} {% set percentPromotions = percentPromotions|sort((a, b) => a.discountValue <=> b.discountValue) %} {% set amountPromotions = amountPromotions|sort((a, b) => a.discountValue <=> b.discountValue) %}
Remises en %
{% for promotion in percentPromotions %} {% else %}
Aucune remise en pourcentage.
{% endfor %}
Remises en montant
{% for promotion in amountPromotions %} {% else %}
Aucune remise en montant.
{% endfor %}
{% endif %} {% if promo %} {% set total = (promo.endAt|date('U') - promo.startAt|date('U')) %} {% set elapsed = (now|date('U') - promo.startAt|date('U')) %} {% set ratio = total > 0 ? (100 * (elapsed / total)) : 0 %} {% set ratio = ratio < 0 ? 0 : (ratio > 100 ? 100 : ratio) %} {% set jours_restant = ((promo.endAt|date('U') - now|date('U')) / 86400)|round(0,'ceil') %} {% if produit.promotion %} {# --- Bloc Détails Promotion (séparé visuellement) --- #}
{% set now = date() %} {% set jours_restant = ((produit.promotion.endAt|date('U') - now|date('U')) / 86400)|round(0, 'ceil') %} {% if promoActive %}
Promotion en cours
{{ jours_restant }} jour{% if jours_restant>1 %}s{% endif %} restants
{% else %} {% endif %} {% endif %}
Nom {{ produit.promotion.name }}
Remise {{ produit.promotion.discountValue }} {% if produit.promotion.discountType == 'percent' %}%{% else %}TND{% endif %}
Description {{ produit.promotion.description }}
Début {{ produit.promotion.startAt|date("d/m/Y H:i") }}
Fin {{ produit.promotion.endAt|date("d/m/Y H:i") }}
{% endif %}