Files

138 lines
9.3 KiB
PHP

@extends('layouts.business.pdf.pdf_layout')
@section('pdf_title')
<div class="table-header justify-content-center border-0 d-none d-block d-print-block text-center">
@include('business::print.header')
<h4 style="text-align: center; margin: 0; padding: 0; font-size: 16px;" class="">{{ __('Day Book Report List') }}</h4>
{{-- <p style="text-align: center; margin: 0; padding: 0; font-weight: 400; font-size: 14px;" class="">{{ __('Duration: 14-12-2025 to 24-12-2025') }}</p> --}}
</div>
@endsection
@section('pdf_content')
<table width="100%" cellpadding="6" cellspacing="0" style="border-collapse: collapse; border: 1px solid gainsboro; font-size:12px;">
<thead>
<tr style="background-color: #C52127; color: white;">
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Name') }}</th>
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Date') }}</th>
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Reference') }}</th>
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Type') }}</th>
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Total') }}</th>
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Money In') }}</th>
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Money Out') }}</th>
<th style="border:1px solid gainsboro; color:white;" class="text-start">{{ __('Payment') }}</th>
</tr>
</thead>
<tbody>
@foreach ($day_books as $day_book)
<tr style="background-color: {{ $loop->even ? '#F5F5F5' : '#FFFFFF' }};">
@if ($day_book->platform == 'sale')
<td style="border:1px solid gainsboro; text-align:center;">{{ $day_book->sale?->party?->name ?? 'Guest' }}</td>
@elseif ($day_book->platform == 'sale_return')
<td style="border:1px solid gainsboro; text-align:center;">{{ $day_book->saleReturn?->sale?->party?->name ?? 'Guest' }}</td>
@elseif ($day_book->platform == 'purchase')
<td style="border:1px solid gainsboro; text-align:center;">{{ $day_book->purchase?->party?->name ?? 'Guest' }}</td>
@elseif ($day_book->platform == 'purchase_return')
<td style="border:1px solid gainsboro; text-align:center;">{{ $day_book->purchaseReturn?->purchase?->party?->name ?? 'Guest' }}</td>
@elseif ($day_book->platform == 'due_collect' || $day_book->platform == 'due_pay')
<td style="border:1px solid gainsboro; text-align:center;">{{ $day_book->dueCollect?->party?->name ?? 'Guest' }}</td>
@else
<td style="border:1px solid gainsboro; text-align:center;">N/A</td>
@endif
<td style="border:1px solid gainsboro; text-align:center;">{{ formatted_date($day_book->date) }}</td>
<td style="border:1px solid gainsboro; text-align:center;">{{ $day_book->invoice_no }}</td>
<td style="border:1px solid gainsboro; text-align:center;">{{ ucwords(str_replace('_', ' ', $day_book->platform)) }}</td>
@if ($day_book->platform == 'sale')
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format($day_book->sale?->totalAmount ?? 0, currency: business_currency()) }}</td>
@elseif ($day_book->platform == 'sale_return')
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format($day_book->saleReturn?->sale?->totalAmount ?? 0, currency: business_currency()) }}</td>
@elseif ($day_book->platform == 'purchase')
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format($day_book->purchase?->totalAmount ?? 0, currency: business_currency()) }}</td>
@elseif ($day_book->platform == 'purchase_return')
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format($day_book->purchaseReturn?->purchase?->totalAmount ?? 0, currency: business_currency()) }}</td>
@elseif ($day_book->platform == 'due_collect' || $day_book->platform == 'due_pay')
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format($day_book->dueCollect?->totalDue ?? 0, currency: business_currency()) }}</td>
@else
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format(0, currency: business_currency()) }}</td>
@endif
@php
$total_amount = match($day_book->platform) {
'sale' => $day_book->sale?->totalAmount ?? 0,
'sale_return' => $day_book->saleReturn?->sale?->totalAmount ?? 0,
'purchase' => $day_book->purchase?->totalAmount ?? 0,
'purchase_return' => $day_book->purchaseReturn?->purchase?->totalAmount ?? 0,
'due_collect', 'due_pay' => $day_book->dueCollect?->totalDue ?? 0,
default => 0
};
@endphp
@if ($day_book->type === 'credit')
<td style="border:1px solid gainsboro; text-align:center; color:green;">{{ currency_format($total_amount, currency: business_currency()) }}</td>
@else
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format(0, currency: business_currency()) }}</td>
@endif
@if ($day_book->type === 'debit')
<td style="border:1px solid gainsboro; text-align:center; color:red;">{{ currency_format($day_book->amount, currency: business_currency()) }}</td>
@else
<td style="border:1px solid gainsboro; text-align:center;">{{ currency_format(0, currency: business_currency()) }}</td>
@endif
@if ($day_book->payment_type_id)
<td style="border:1px solid gainsboro; text-align:center;">{{ $day_book->paymentType?->name }}</td>
@else
<td style="border:1px solid gainsboro; text-align:center;">{{ ucfirst(explode('_', $day_book->transaction_type)[0]) }}</td>
@endif
</tr>
@endforeach
</tbody>
@php
$page_total_amount = $day_books->sum(function ($day_book) {
return match($day_book->platform) {
'sale' => $day_book->sale?->totalAmount ?? 0,
'sale_return' => $day_book->saleReturn?->sale?->totalAmount ?? 0,
'purchase' => $day_book->purchase?->totalAmount ?? 0,
'purchase_return' => $day_book->purchaseReturn?->purchase?->totalAmount ?? 0,
'due_collect', 'due_pay' => $day_book->dueCollect?->totalDue ?? 0,
default => 0
};
});
$page_money_in_new = $day_books->where('type', 'credit')->sum(function ($day_book) {
return match($day_book->platform) {
'sale' => $day_book->sale?->totalAmount ?? 0,
'sale_return' => $day_book->saleReturn?->sale?->totalAmount ?? 0,
'purchase' => $day_book->purchase?->totalAmount ?? 0,
'purchase_return' => $day_book->purchaseReturn?->purchase?->totalAmount ?? 0,
'due_collect', 'due_pay' => $day_book->dueCollect?->totalDue ?? 0,
default => 0
};
});
$page_money_in = $day_books->where('type', 'credit')->sum('amount');
$page_money_out = $day_books->where('type', 'debit')->sum('amount');
@endphp
@if ($day_books->count() > 0)
<tfoot>
<tr style="background-color:#C52127; color:white; font-weight:bold;">
<td style="border:1px solid gainsboro; text-align:center; color: white; font-weight: 600;">{{__('Total')}}</td>
<td style="border:1px solid gainsboro; text-align:center;"></td>
<td style="border:1px solid gainsboro; text-align:center;"></td>
<td style="border:1px solid gainsboro; text-align:center;"></td>
<td style="border:1px solid gainsboro; text-align:center; color: white; font-weight: 600;">{{ currency_format($page_total_amount, currency: business_currency()) }}</td>
<td style="border:1px solid gainsboro; text-align:center; color: white; font-weight: 600;">{{ currency_format($page_money_in, currency: business_currency()) }}</td>
<td style="border:1px solid gainsboro; text-align:center; color: white; font-weight: 600;">{{ currency_format($page_money_out, currency: business_currency()) }}</td>
<td style="border:1px solid gainsboro; text-align:center;"></td>
</tr>
</tfoot>
@endif
</table>
@endsection