<table>
    <thead>
        <tr>
            <th colspan="4" style="text-align: center; font-weight: bold;">FACTURE {{ $invoice->number }}</th>
        </tr>
        <tr>
            <th>Date:</th>
            <td>{{ $invoice->date }}</td>
            <th>Client:</th>
            <td>{{ $invoice->client->name ?? $invoice->supplier->name }}</td>
        </tr>
        <tr></tr>
        <tr>
            <th>Produit/Service</th>
            <th>Quantité</th>
            <th>Prix unitaire</th>
            <th>Total HT</th>
        </tr>
    </thead>
    <tbody>
        @foreach($invoice->items as $item)
        <tr>
            <td>{{ $item->product_name }}</td>
            <td>{{ $item->quantity }}</td>
            <td>{{ $item->unit_price }}</td>
            <td>{{ $item->total_ht }}</td>
        </tr>
        @endforeach
        <tr></tr>
        <tr>
            <th colspan="3">Total HT:</th>
            <td>{{ $invoice->items->sum('total_ht') }}</td>
        </tr>
        <tr>
            <th colspan="3">TVA:</th>
            <td>{{ $invoice->items->sum('total_vat') }}</td>
        </tr>
        <tr>
            <th colspan="3">Total TTC:</th>
            <td>{{ $invoice->items->sum('total_ttc') }}</td>
        </tr>
    </tbody>
</table>