{% if not weeklyClaim.available and weeklyClaim.nextClaimAt %}
Prochaine récompense dans …
{% endif %}
{% endif %}
{% if not isCancelled %}
{# Le changement de plan passe par l'API PayPal "revise" — indisponible pour un abonnement payé en crédits (pas d'ID PayPal). #}
{# Si l'abonné est annuel, on ne propose que des plans annuels (règle métier : annual → annual seulement) #}
{% set otherPlans = isCreditsSub ? [] : plans|filter(p =>
p.id != activeSub.plan.id
and p.paypalPlanId
and (not activeSub.plan.isAnnual or p.isAnnual)
) %}
{% if otherPlans|length > 0 %}
Changer de plan
Le changement prend effet au prochain cycle de facturation ({{ activeSub.currentPeriodEnd|date('d/m/Y') }}).
Aucune double facturation ni remboursement pour la période déjà payée.
{% if activeSub.plan.isAnnual %}
Votre engagement annuel vous donne accès aux autres plans annuels uniquement. Une bascule vers le mensuel n'est pas possible.
{% set readyPlans = plans|filter(p => p.paypalPlanId or p.creditsPrice > 0) %}
{% if readyPlans|length > 0 %}
{# Pré-calcule un map tier → priceCents mensuel pour les économies des cartes annuelles #}
{% set monthlyByTier = {} %}
{% for p in readyPlans|filter(p => p.billingPeriod == 'monthly') %}
{% set monthlyByTier = monthlyByTier|merge({(p.tier): p.priceCents}) %}
{% endfor %}
{% for plan in readyPlans %}
{% set monthlyPrice = monthlyByTier[plan.tier] ?? 0 %}
{% set annualSavings = plan.billingPeriod == 'annual' and monthlyPrice > 0 ? (monthlyPrice * 12 - plan.priceCents) : 0 %}