@if ($filter_from_date && $filter_to_date)
| {{ __('Date') }} | {{ __('Invoice') }} | {{ __('Supplier') }} | {{ __('Tax Number') }} | {{ __('Total Amount') }} | {{ __('Payment Method') }} | {{ __('Discount') }} | @foreach ($vats as $vat){{ $vat->name . '@' . $vat->rate . '%' }} | @endforeach
|---|---|---|---|---|---|---|---|
| {{ formatted_date($purchase->created_at) }} | {{ $purchase->invoiceNumber }} | {{ $purchase->party->name ?? '' }} | {{ $purchase->party->tax_no ?? '' }} | {{ currency_format($purchase->totalAmount, currency: business_currency()) }} | @if ($purchase->transactions && $purchase->transactions->isNotEmpty()) {{ $purchase->transactions->map(function($transaction) { if ($transaction->transaction_type === 'bank_payment' && !empty($transaction->paymentType?->name)) { return $transaction->paymentType->name; } return $transaction->transaction_type ? ucfirst(explode('_', $transaction->transaction_type)[0]) : ''; })->unique()->implode(', ') }} @elseif ($purchase->payment_type_id) {{ $purchase->payment_type?->name }} @else {{ $purchase->paymentType }} @endif | {{ currency_format($purchase->discountAmount, currency: business_currency()) }} | {{-- VAT Columns --}} @foreach ($vats as $vat) @php // Product level VAT $productVat = $purchaseVatRowMap[$purchase->id][$vat->id] ?? 0; // Returned VAT $returnVat = $purchaseReturnVatRowMap[$purchase->id][$vat->id] ?? 0; // Invoice level VAT $invoiceVat = ($purchase->vat_id == $vat->id) ? $purchase->vat_amount : 0; // Final VAT $totalVat = $productVat + $invoiceVat - $returnVat; @endphp$totalVat > 0])> {{ currency_format($totalVat, currency: business_currency()) }} | @endforeach
| {{ __('Total') }} | {{ currency_format($purchases->sum('totalAmount'), currency: business_currency()) }} | {{ currency_format($purchases->sum('discountAmount'), currency: business_currency()) }} {{-- VAT Totals --}} @foreach ($vats as $vat) @php $grandVatTotal = (($purchasesVatTotals[$vat->id] ?? 0) - ($purchaseReturnVatTotals[$vat->id] ?? 0)) + $purchases->where('vat_id', $vat->id)->sum('vat_amount'); @endphp | {{ currency_format($grandVatTotal, currency: business_currency()) }} | @endforeach