@php $logoPath = storage_path('app/public/logo/logo.png'); $logoBase64 = ''; if (file_exists($logoPath)) { $logoBase64 = 'data:image/png;base64,' . base64_encode(file_get_contents($logoPath)); } @endphp @if($logoBase64) @endif
{{ $entreprise['nom'] ?? 'PISTON GABON' }}
{{ $entreprise['adresse'] ?? '' }}
Tél: {{ $entreprise['telephone'] ?? '' }} | Email: {{ $entreprise['email'] ?? '' }}
FACTURE N° {{ $facture->reference }} @php $statusClass = 'status-impayee'; $statusText = 'IMPAYÉE'; if ($facture->statut === 'payee') { $statusClass = 'status-payee'; $statusText = 'PAYÉE'; } elseif ($facture->montant_paye > 0 && $facture->montant_paye < $facture->montant_ttc) { $statusClass = 'status-partielle'; $statusText = 'PARTIELLE'; } @endphp {{ $statusText }}
Informations Facture
Date: {{ \Carbon\Carbon::parse($facture->date)->format('d/m/Y') }}
Échéance: {{ \Carbon\Carbon::parse($facture->date_echeance)->format('d/m/Y') }}
Référence: {{ $facture->reference }}
Client
@if($facture->client)
Nom: {{ $facture->client->raison_sociale ?? $facture->client->nom ?? 'N/A' }}
@if($facture->client->adresse)
Adresse: {{ $facture->client->adresse }}
@endif @if($facture->client->nif)
NIF: {{ $facture->client->nif }}
@endif @else
Client non spécifié
@endif
@foreach($facture->lignes as $ligne) @endforeach
Désignation Qté P.U. HT Remise Total HT
{{ $ligne->produit->nom ?? 'Produit' }} @if($ligne->produit && $ligne->produit->code_barres)
{{ $ligne->produit->code_barres }} @endif
{{ $ligne->quantite }} {{ number_format($ligne->prix_unitaire, 0, ',', ' ') }} @php $remiseAffichee = '-'; $clientRemise = $facture->client ? floatval($facture->client->remise_defaut ?? 0) : 0; // Remise globale du document (nouveau champ) $docRemiseType = $facture->remise_globale_type ?? 'pourcentage'; $docRemiseValeur = floatval($facture->remise_globale_valeur ?? 0); $ligneRemise = floatval($ligne->remise_valeur ?? 0); // Priorité 1: remise sur la ligne elle-même if ($ligneRemise > 0) { $remiseAffichee = $ligne->remise_type === 'pourcentage' ? number_format($ligneRemise, 0) . '%' : number_format($ligneRemise, 0, ',', ' '); } // Priorité 2: remise globale du document elseif ($docRemiseValeur > 0) { $remiseAffichee = $docRemiseType === 'pourcentage' ? number_format($docRemiseValeur, 0) . '%' : number_format($docRemiseValeur, 0, ',', ' '); } // Priorité 3: remise par défaut du client elseif ($clientRemise > 0) { $remiseAffichee = number_format($clientRemise, 0) . '%'; } @endphp {{ $remiseAffichee }} {{ number_format($ligne->montant_ht ?? ($ligne->quantite * $ligne->prix_unitaire), 0, ',', ' ') }}
Sous-total HT
{{ number_format($facture->montant_ht, 0, ',', ' ') }} FCFA
@php $remiseGlobale = floatval($facture->remise_globale_valeur ?? 0); $remiseGlobaleType = $facture->remise_globale_type ?? 'pourcentage'; @endphp @if($remiseGlobale > 0)
Remise globale ({{ $remiseGlobaleType === 'pourcentage' ? $remiseGlobale . '%' : '' }})
-{{ number_format($facture->total_remises ?? 0, 0, ',', ' ') }} FCFA
@endif @if($facture->taxes && $facture->taxes->count() > 0) @foreach($facture->taxes as $taxe)
{{ $taxe->nom }} ({{ $taxe->taux }}%)
{{ number_format(($facture->montant_ht - ($facture->remise_globale ?? 0)) * $taxe->taux / 100, 0, ',', ' ') }} FCFA
@endforeach @endif
TOTAL TTC
{{ number_format($facture->montant_ttc, 0, ',', ' ') }} FCFA
@if($facture->montant_paye > 0)
Montant payé
{{ number_format($facture->montant_paye, 0, ',', ' ') }} FCFA
@endif @if(($facture->montant_ttc - $facture->montant_paye) > 0)
Reste à payer
{{ number_format($facture->montant_ttc - $facture->montant_paye, 0, ',', ' ') }} FCFA
@endif
@if($facture->paiements && $facture->paiements->count() > 0)
Historique des paiements
@foreach($facture->paiements as $paiement)
• {{ ucfirst(str_replace('_', ' ', $paiement->mode_paiement)) }}: {{ number_format($paiement->montant, 0, ',', ' ') }} FCFA @if($paiement->reference) (Réf: {{ $paiement->reference }}) @endif - {{ \Carbon\Carbon::parse($paiement->date_paiement)->format('d/m/Y') }}
@endforeach
@endif @if($facture->notes)
Notes
{{ $facture->notes }}
@endif