111 lines
5.7 KiB
PHP
111 lines
5.7 KiB
PHP
|
|
<table>
|
||
|
|
<thead>
|
||
|
|
<tr>
|
||
|
|
<th>{{ __('Date') }}</th>
|
||
|
|
<th>{{ __('Invoice') }}</th>
|
||
|
|
<th>{{ __('Customer') }}</th>
|
||
|
|
<th>{{ __('Total Amount') }}</th>
|
||
|
|
<th>{{ __('Payment Method') }}</th>
|
||
|
|
<th>{{ __('Discount') }}</th>
|
||
|
|
@foreach ($vats as $vat)
|
||
|
|
<th>{{ $vat->name }}</th>
|
||
|
|
@endforeach
|
||
|
|
</tr>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
<!-- Show sales data if sales tab is active -->
|
||
|
|
@if (Request::get('type') == 'sales')
|
||
|
|
@foreach ($sales as $sale)
|
||
|
|
<tr>
|
||
|
|
<td>{{ formatted_date($sale->created_at) }}</td>
|
||
|
|
<td>{{ $sale->invoiceNumber }}</td>
|
||
|
|
<td>{{ $sale->party->name ?? '' }}</td>
|
||
|
|
<td>{{ currency_format($sale->totalAmount, currency: business_currency()) }}</td>
|
||
|
|
<td>
|
||
|
|
@if ($sale->transactions && $sale->transactions->isNotEmpty())
|
||
|
|
{{ $sale->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 ($sale->payment_type_id)
|
||
|
|
{{ $sale->payment_type?->name }}
|
||
|
|
@else
|
||
|
|
{{ $sale->paymentType }}
|
||
|
|
@endif
|
||
|
|
</td>
|
||
|
|
<td>{{ currency_format($sale->discountAmount, currency: business_currency()) }}</td>
|
||
|
|
@foreach ($vats as $vat)
|
||
|
|
<td>{{ $sale->vat_id == $vat->id ? currency_format($sale->vat_amount, currency: business_currency()) : '0' }}</td>
|
||
|
|
@endforeach
|
||
|
|
</tr>
|
||
|
|
@endforeach
|
||
|
|
@if ($sales->count() > 0)
|
||
|
|
<tr class="table-footer">
|
||
|
|
<td class="text-start fw-bold">{{ __('Total') }}</td>
|
||
|
|
<td></td>
|
||
|
|
<td></td>
|
||
|
|
<td class="text-center fw-bold">
|
||
|
|
{{ currency_format($sales->sum('totalAmount'), currency: business_currency()) }}
|
||
|
|
</td>
|
||
|
|
<td class="d-print-none"></td>
|
||
|
|
<td class="text-center fw-bold">
|
||
|
|
{{ currency_format($sales->sum('discountAmount'), currency: business_currency()) }}
|
||
|
|
</td>
|
||
|
|
@foreach ($vats as $vat)
|
||
|
|
<td class="text-center fw-bold">
|
||
|
|
{{ currency_format($salesVatTotals[$vat->id] ?? 0, currency: business_currency()) }}
|
||
|
|
</td>
|
||
|
|
@endforeach
|
||
|
|
</tr>
|
||
|
|
@endif
|
||
|
|
@endif
|
||
|
|
|
||
|
|
<!-- Show purchase data if purchase tab is active -->
|
||
|
|
@if (Request::get('type') == 'purchases')
|
||
|
|
@foreach ($purchases as $purchase)
|
||
|
|
<tr>
|
||
|
|
<td>{{ formatted_date($purchase->created_at) }}</td>
|
||
|
|
<td>{{ $purchase->invoiceNumber }}</td>
|
||
|
|
<td>{{ $purchase->party->name ?? '' }}</td>
|
||
|
|
<td>{{ currency_format($purchase->totalAmount, currency: business_currency()) }}</td>
|
||
|
|
<td>
|
||
|
|
@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>{{ currency_format($purchase->discountAmount, currency: business_currency()) }}</td>
|
||
|
|
@foreach ($vats as $vat)
|
||
|
|
<td>{{ $purchase->vat_id == $vat->id ? currency_format($purchase->vat_amount, currency: business_currency()) : '0' }}</td>
|
||
|
|
@endforeach
|
||
|
|
</tr>
|
||
|
|
@endforeach
|
||
|
|
@if ($purchases->count() > 0)
|
||
|
|
<tr class="table-footer">
|
||
|
|
<td class="text-start fw-bold">{{ __('Total') }}</td>
|
||
|
|
<td></td>
|
||
|
|
<td></td>
|
||
|
|
<td class="text-center fw-bold">{{ currency_format($purchases->sum('totalAmount'), currency: business_currency()) }}</td>
|
||
|
|
<td class="d-print-none"></td>
|
||
|
|
<td class="text-center fw-bold">{{ currency_format($purchases->sum('discountAmount'), currency: business_currency()) }}</td>
|
||
|
|
@foreach ($vats as $vat)
|
||
|
|
<td class="text-center fw-bold">
|
||
|
|
{{ currency_format($purchasesVatTotals[$vat->id] ?? 0, currency: business_currency()) }}
|
||
|
|
</td>
|
||
|
|
@endforeach
|
||
|
|
</tr>
|
||
|
|
@endif
|
||
|
|
@endif
|
||
|
|
</tbody>
|
||
|
|
</table>
|