{% extends 'base.html' %} {% load humanize i18n static custom_filters %} {# Template ticket thermique 80 mm. Données : MÊME contexte que facture_detail.html — aucun calcul ici. Données fiscales (CODE DEF, EMCF, QR, TVA par groupe) identiques à l'A4. CSS : print_ticket_80mm.css (classes .t80-*) Export PDF : navigateur uniquement (window.print ou popup — Step 6). #} {% block page_title %}
FACTURE #{{ commande.numero }}
{% endblock %} {# ── CSS dédié ticket 80 mm, dans l'en-tête : le ticket s'affiche d'un seul tenant ── #} {% block extra_css %}{% endblock %} {% block content %} {# ── Masquage du chrome base.html en impression ───────────────────────── #} {# ── Filigrane DUPLICATA (identique à facture_detail.html) ───────────── #} {% if is_duplicata %} {% endif %}
{% trans "Retour aux factures" %}
{% if ventes_factures_ui_permissions.show_print_button %} {% include "facturation/partials/print_format_controls.html" %} {% endif %} {% if ventes_factures_ui_permissions.show_export_pdf_button %} {% trans "Exporter PDF" %} {% endif %} {% if ventes_factures_ui_permissions.show_new_sale_button %} {% trans "Nouvelle facture" %} {% endif %}
{# ── EN-TÊTE SOCIÉTÉ ─────────────────────────────────────────────── #}
Logo
{{ config.nom_entreprise }}
{% if document_point_de_vente %}
PDV : {{ document_point_de_vente.nom }}
{% endif %} {% if document_point_de_vente and document_point_de_vente.adresse %}
Adresse : {{ document_point_de_vente.adresse|linebreaksbr }}
{% endif %}
NIF : {{ config.nif|default:"-" }} | RCCM : {{ config.rccm|default:"-" }}
{% if config.id_nat %}
Id. Nat : {{ config.id_nat }}
{% endif %} {% if config.telephone %}
Tél : {{ config.telephone }}
{% endif %}
RÉGIME FISCAL : {{ config.type_dgi|default:"INV" }}

Caissier : {{ commande.vendeur.username|upper }}
Date : {{ commande.date_commande|date:"d/m/Y H:i" }}

{{ facture_title }}
N° {{ commande.numero }}
{# Infos avoir (FA/EA) #} {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}
{% if commande.avoir_nature_resolue %}
Nature : {{ commande.avoir_nature_label_resolue }}
{% endif %} {% if commande.avoir_reference_resolue %}
Réf : {{ commande.avoir_reference_resolue }}
{% endif %} {% if commande.facture_origine %}
Fact. source : {{ commande.facture_origine.numero }}
{% if commande.facture_origine.codedefdgi %}
DEF origine : {{ commande.facture_origine.codedefdgi|format_def_code }}
{% endif %} {% endif %} {% if commande.avoir_motif_detail_resolu %}
Motif : {{ commande.avoir_motif_detail_resolu }}
{% endif %}
{% elif commande.facture_origine %}
Réf. source : {{ commande.facture_origine.numero }}
{% endif %}
{# /t80-header #} {# ── CLIENT (section affichée seulement si client renseigné) ─────── #} {% if commande.client %}
CLIENT
{{ commande.client.nom_complet|default:"Client Divers"|upper }}
{% if commande.client.nif %}
NIF : {{ commande.client.nif }}
{% endif %} {% if commande.client.telephone %}
Tél : {{ commande.client.telephone }}
{% endif %}
{% endif %} {# ── COMMENTAIRE DGI (si renseigné) ──────────────────────────────── #} {% if commande.commentaire %}
{% for cmt in commande.commentaire|dgi_comments %}
{{ cmt }}
{% endfor %}
{% endif %} {# ── TABLEAU ARTICLES ─────────────────────────────────────────────── #}
{% for ligne in lignes_facture %} {% endfor %}
Désignation Qté PU Total
{# Désignation : retour à la ligne propre sur 72 mm #}
{{ ligne.produit.nom|upper }}{% if ligne.conditionnement_libelle_affiche %} — {{ ligne.conditionnement_libelle_affiche|upper }}{% endif %}
{# Code groupe fiscal — même logique que l'A4 ; -HC distingue le hors champ des anciennes lignes A, avant le groupe S #}
[{{ ligne.tax_group_code_affiche|default:"A" }}{% if ligne.produit.code_sku == 'HORS CHAMP' and ligne.tax_group_code_affiche == 'A' %}-HC{% endif %}]
{% if ligne.remise > 0 %}
Remise : -{{ ligne.remise|money:"FC" }}
{% endif %}
{% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ ligne.quantite }} {{ ligne.prix_unitaire_affiche|money:"FC" }} {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ ligne.montant_affiche|money:"FC" }}
Nb articles : {{ commande.lignes.count }}
{# /t80-lines #} {# ── TOTAUX ───────────────────────────────────────────────────────── #}
{# Remise globale #} {% if commande.remise_globale > 0 %}
Remise globale -{{ commande.remise_globale|money:"FC" }}
{% endif %} {# Répartition TVA par groupe — MÊME SOURCE que facture_detail.html #} {% for tax in tax_details %} {% if tax.rate > 0 or tax.display_as_taxable %}
H.T. [{{ tax.code }}]{% if tax.group_display_label %} {{ tax.group_display_label }}{% endif %} {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ tax.ht|money:"FC" }}
TVA [{{ tax.code }}]{% if tax.group_display_label %} {{ tax.group_display_label }}{% endif %} {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ tax.tva|money:"FC" }}
{% else %}
Total [{{ tax.code }}]{% if tax.group_display_label %} {{ tax.group_display_label }}{% else %} Régime dérogatoire{% endif %} {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ tax.ht|money:"FC" }}
{% endif %} {# Taxe spécifique par groupe #} {% if tax.ts_valeur > 0 %}
T.S. [{{ tax.code }}]{% if tax.group_display_label %} {{ tax.group_display_label }}{% endif %} {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ tax.ts_valeur|money:"FC" }}
{% endif %} {% endfor %} {# Total TVA consolidé #} {% if commande.tva_montant %}
TOTAL TVA {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ commande.tva_montant|money:"FC" }}
{% endif %} {# NET À PAYER (mis en évidence) #}
NET À PAYER (TTC) {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ commande.montant_total|money:"FC" }}
Total payé {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ total_paiements|money:"FC" }}
{% if commande.reste_a_payer < 0 %}
Monnaie rendue {{ commande.reste_a_payer|mul:-1|money:"FC" }}
{% else %}
Reste à payer {% if commande.type_facture == 'FA' or commande.type_facture == 'EA' %}-{% endif %}{{ commande.reste_a_payer|money:"FC" }}
{% endif %} {# Détail des modes de paiement #} {% for p in commande.paiements.all %}
{{ p.mode_paiement|upper }} {{ p.montant_verse|money:p.devise }}
{% empty %}
Paiement—
{% endfor %}
{# /t80-totals #} {# ── ZONE FISCALE DGI / EMCF ──────────────────────────────────────── #} {# DONNÉES IDENTIQUES À L'A4 — même variables, même source de contexte #}
-- ÉLÉMENT SÉCURITÉ FACTURE NORMALISÉE --
ISF : {{ config.isf_dgi|default:"-" }}
CODE DEF/DGI : {{ commande.codedefdgi|format_def_code }}
DEF NID : {{ commande.nim }}
DEF Compteurs : {{ commande.counters }}
DEF Heure : {{ commande.dateTimedgi }}
{# /t80-fiscal #} {# ── QR CODE ──────────────────────────────────────────────────────── #} {% if commande.qrCode %}
QR Code DGI
{% endif %} {# ── CORRECTIONS MCF (si présentes — même logique que l'A4) ──────── #} {% if mcf_modification_security_logs %}
-- CORRECTIONS MCF --
{% for correction in mcf_modification_security_logs %}
MCF du {{ correction.created_at|date:"d/m/Y H:i" }}{% if correction.correction_numero %} — FACTURE : {{ correction.correction_numero }}{% endif %}
DEF : {{ correction.security.code_def_dgi|format_def_code|default:"-" }}
NID : {{ correction.security.nim|default:"-" }}
{% if correction.security.qr_code %}
QR MCF
{% endif %}
{% endfor %}
{% endif %} {# ── PIED DE TICKET ───────────────────────────────────────────────── #}
{# /t80-page #}
{# /t80-screen-wrapper #} {% endblock %} {% block extra_js %} {{ block.super }} {% endblock %}