Files

84 lines
4.1 KiB
PHP

<table class="table" id="datatable">
<thead>
<tr>
<th class="d-print-none">{{ __('SL') }}.</th>
@if (auth()->user()->accessToMultiBranch())
<th class="text-start">{{ __('Branch') }}</th>
@endif
<th class="text-start">{{ __('Invoice No') }}</th>
<th class="text-start">{{ __('Party Name') }}</th>
<th class="text-start">{{ __('Total') }}</th>
<th class="text-start">{{ __('Discount') }}</th>
<th class="text-start">{{ __('Paid') }}</th>
<th class="text-start">{{ __('Due') }}</th>
<th class="text-start">{{ __('Vat') }}</th>
<th class="text-start">{{ __('Payment Type') }}</th>
<th class="text-start">{{ __('Purchase Date') }}</th>
</tr>
</thead>
<tbody>
@foreach ($purchases as $purchase)
<tr>
<td class="d-print-none">{{ $loop->iteration }}</td>
@if (auth()->user()->accessToMultiBranch())
<td class="text-start">{{ $purchase->branch->name ?? '' }}</td>
@endif
<td class="text-start">{{ $purchase->invoiceNumber }}</td>
<td class="text-start">{{ $purchase->party?->name }}</td>
<td class="text-start">{{ currency_format($purchase->totalAmount, currency: business_currency()) }}
</td>
<td class="text-start d-print-none">
{{ currency_format($purchase->discountAmount, currency: business_currency()) }}</td>
<td class="text-start">{{ currency_format($purchase->paidAmount, currency: business_currency()) }}
</td>
<td class="text-start">{{ currency_format($purchase->dueAmount, currency: business_currency()) }}
</td>
<td class="text-start d-print-none">{{ currency_format($purchase->vat_amount, currency: business_currency()) }}
</td>
<td class="text-start d-print-none">
@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
</td>
<td class="text-start">{{ formatted_date($purchase->purchaseDate) }}</td>
</tr>
@endforeach
</tbody>
@if ($purchases->count() > 0)
<tr class="table-footer" style="font-weight: bold; background: #F5F5F5;">
<td class=" text-start">{{ __('Total') }}</td>
@if (auth()->user()->accessToMultiBranch())
<td></td>
@endif
<td></td>
<td></td>
<td class="text-start">
{{ currency_format($purchases->sum('totalAmount'), currency: business_currency()) }}
</td>
<td class="text-start d-print-none">
{{ currency_format($purchases->sum('discountAmount'), currency: business_currency()) }}
</td>
<td class="text-start">
{{ currency_format($purchases->sum('paidAmount'), currency: business_currency()) }}
</td>
<td class="text-start">
{{ currency_format($purchases->sum('dueAmount'), currency: business_currency()) }}
</td>
<td class="d-print-none">
{{ currency_format($purchases->sum('vat_amount'), currency: business_currency()) }}
</td>
<td class="d-print-none"></td>
<td></td>
</tr>
@endif
</table>