{{-- Facture, proforma ou avoir (TL-301) — mise en page reprise de Swiver (FAC-000176). UN SEUL GABARIT pour l'aperçu de l'éditeur ($pdf = false, rendu dans une iframe) et pour le PDF ($pdf = true, dompdf). Mise en page en : dompdf ne connaît ni flex ni grid. font-family DejaVu Sans : obligatoire pour les accents sous dompdf. --}} @php $d = (int) config("factures.devises.{$facture->devise}.decimales", 3); $avecQuantite = $lignes->contains(fn ($l) => abs((float) $l->quantite - 1) > 0.0001); $avecRemise = $lignes->contains(fn ($l) => (float) $l->remise_pct > 0); $nbColonnes = 6 + ($avecQuantite ? 1 : 0) + ($avecRemise ? 1 : 0); $echeance = $facture->date_echeance; @endphp {{ $titre }} {{ $facture->numero ?? '' }} {{-- PDF : filigrane et pied sont des enfants DIRECTS de , placés AVANT le contenu — c'est la seule configuration où dompdf répète un élément `fixed` sur chaque page (vérifié sur 3 pages). Dans un bloc, il ne sort qu'une fois. --}} @if ($pdf) @if ($brouillon)
BROUILLON
@endif @include('factures._pied') @endif
@if ($brouillon && ! $pdf)
BROUILLON
@endif
{{ $titre }}
N° : {{ $facture->numero ?? '—' }}
@if ($facture->type === 'proforma')
Document sans valeur fiscale
@endif
CLIENT
{{ $facture->client_nom ?: '—' }}
@if ($facture->client_adresse)
{{ $facture->client_adresse }}
@endif @if ($facture->client_matricule_fiscal)
{{ \App\Models\Facture::IDENTIFIANTS[$facture->client_identifiant_type ?? 'mf'] ?? 'MF' }} : {{ $facture->client_matricule_fiscal }}
@endif @if ($facture->client_email)
{{ $facture->client_email }}
@endif
Date : {{ $facture->date_facture?->format('d/m/Y') }}
@if ($facture->type === 'facture' && $echeance)
Échéance : {{ $facture->echeance_jours > 0 ? $echeance->format('d/m/Y') : 'à réception' }}
@endif @if ($facture->type === 'avoir' && $origine)
Sur la facture : {{ $origine->numero }} du {{ $origine->date_facture?->format('d/m/Y') }}
@endif @if ($facture->note_entete)
{{ $facture->note_entete }}
@endif
@if ($avecQuantite) @endif @if ($avecRemise) @endif @forelse ($lignes as $i => $ligne) {{-- Relevé bancaire : une ligne d'en-tête par versement, au-dessus de ses lignes. --}} @if (filled($ligne->groupe) && ($i === 0 || $ligne->groupe !== $lignes[$i - 1]->groupe)) @endif @if ($avecQuantite) @endif @if ($avecRemise) @endif @empty @endforelse
# Référence DescriptionQtéPU HTRemiseTVA Total HT
{{ $ligne->groupe }}
{{ $i + 1 }} {{ $ligne->reference }} {{ $ligne->designation }} @if ($ligne->montant_origine !== null && $ligne->taux_change !== null)
{{ $fmtNombre((float) $ligne->montant_origine, 2) }} {{ $ligne->devise_origine }} × {{ $fmtNombre((float) $ligne->taux_change, 4) }}{{ $ligne->taux_date ? ' (BCT '.\Illuminate\Support\Carbon::parse($ligne->taux_date)->format('d/m/Y').')' : '' }}
@endif
{{ $fmtNombre((float) $ligne->quantite, fmod((float) $ligne->quantite, 1) == 0 ? 0 : 3) }}{{ $fmt((float) $ligne->prix_unitaire_ht) }}{{ $fmtNombre((float) $ligne->remise_pct, fmod((float) $ligne->remise_pct, 1) == 0 ? 0 : 2) }} %{{ $fmtNombre((float) $ligne->taux_tva, fmod((float) $ligne->taux_tva, 1) == 0 ? 0 : 2) }} % {{ $fmt((float) $totaux['lignes'][$i]) }}
Aucune ligne.
@foreach ($totaux['tva'] as $groupe) @endforeach
TVABaseMontant
{{ $fmtNombre((float) $groupe['taux'], fmod((float) $groupe['taux'], 1) == 0 ? 0 : 2) }} % {{ $fmt((float) $groupe['base']) }} {{ $fmt((float) $groupe['montant']) }}
{{-- Fondement légal d'une ligne à 0 % (exigé à l'émission : FactureService::verifierEmettable). --}} @if ($facture->mention_exoneration) @endif
@if ($totaux['total_remise'] > 0) @endif {{-- Comme Swiver : le TTC avant timbre, puis le timbre, puis le net. --}} @if ($totaux['montant_timbre'] > 0) @endif
TOTAL HT{{ $fmt((float) $totaux['total_ht']) }}
DONT REMISE{{ $fmt((float) $totaux['total_remise']) }}
TOTAL TVA{{ $fmt((float) $totaux['total_tva']) }}
TOTAL TTC{{ $fmt(round((float) $totaux['total_ttc'] - (float) $totaux['montant_timbre'], $d)) }}
TIMBRE FISCAL{{ $fmt((float) $totaux['montant_timbre']) }}
{{-- Code des droits d'enregistrement et de timbre, art. 127 : le timbre d'une facture se paie sur déclaration, et la facture le dit. --}} @if ($totaux['montant_timbre'] > 0) @endif
{{ $facture->type === 'avoir' ? 'MONTANT DE L\'AVOIR' : 'NET À PAYER' }} {{ $fmt((float) $totaux['total_ttc']) }}
Arrêtée la présente {{ $facture->type === 'avoir' ? 'facture d\'avoir' : ($facture->type === 'proforma' ? 'proforma' : 'facture') }} à la somme de :
{{ $lettres }}
@if ($facture->note_pied)
{{ $facture->note_pied }}
@endif @if (! empty($emetteur['mention']))
{{ $emetteur['mention'] }}
@endif @unless ($pdf) @include('factures._pied') @endunless