@extends('layouts.sidebar') @section('title', 'billings') @section('content') @if (in_array('Billing Checking' || 'Client Interface', $privileges))
{{ $client->client->agency->name }}
{{ $client->client->agency->address }}
Tel: {{ $client->client->agency->contact_phone }}
Client Name: {{ $client->client->business_name }}
Address: {{ $client->client->address }}
@if ($hasBillingRecords)Billing Ref. #: {{ $hasBillingRecords->id }}
@endifPeriod Covered: {{ \Carbon\Carbon::parse($payPeriodStart)->format('F d, Y') }} - {{ \Carbon\Carbon::parse($payPeriodEnd)->format('F d, Y') }}
Employee Name | Days | Rate | Amount | @foreach ($uniqueHeaders['others'] ?? [] as $header){{ $header }} | @endforeach @foreach ($uniqueHeaders['deductions'] ?? [] as $header){{ $header }} | @endforeach @foreach ($uniqueHeaders['benefits'] ?? [] as $header){{ $header }} | @endforeachGrand Total | |
---|---|---|---|---|---|---|---|---|
|
{{ $payroll->employee->first_name }} {{ substr($payroll->employee->middle_name, 0, 1) }}. {{ $payroll->employee->last_name }} | {{ $days }} @php // Initialize $total_days if it hasn't been defined earlier if (!isset($total_days)) { $total_days = 0; } // Add the value of $days to $total_days $total_days += $days; @endphp | {{ $valuerate }} | {{ $earnings }} | @foreach ($uniqueHeaders['others'] ?? [] as $header) @php $amount = '-'; // Find the benefit with the given header type $others = $payroll->othersForPayroll->firstWhere('name', $header); // Check if the benefit exists if ($others) { // If 'er_adjustment' is null or $value is null or 0, use 'employer_share' if ($others->amount_adj === null || $value == null || $value == 0) { $amount = $others->amount ?? '-'; } elseif ($value == 1) { // If $value is 1, use 'er_adjustment' $amount = $others->amount_adj ?? '-'; } } @endphp{{ is_numeric($amount) ? number_format($amount, 2) : $amount }} | @endforeach @foreach ($uniqueHeaders['deductions'] ?? [] as $header) @php $amount = $payroll->trxConstantDeductions->firstWhere( fn($earning) => optional( App\Models\TrxCode::find( $earning->trxConstant->group_code_id, ), )->description === $header, )?->E_Amount ?? '-'; @endphp{{ is_numeric($amount) ? number_format($amount, 2) : $amount }} | @endforeach @foreach ($uniqueHeaders['benefits'] ?? [] as $header) @php // Default value is '-' $amount = '-'; // Find the benefit with the given header type $benefit = $payroll->benefits->firstWhere('type', $header); // Check if the benefit exists if ($benefit) { // If 'er_adjustment' is null or $value is null or 0, use 'employer_share' if ( $benefit->er_adjustment === null || $value == null || $value == 0 ) { $amount = $benefit->employer_share ?? '-'; } elseif ($value == 1) { // If $value is 1, use 'er_adjustment' $amount = $benefit->er_adjustment ?? '-'; } } @endphp{{ is_numeric($amount) ? number_format($amount, 2) : $amount }} | @endforeach{{ number_format($rowTotal, 2) }} |
Total | {{ $total_days}} | @foreach ($uniqueHeaders['others'] ?? [] as $header) | {{ is_numeric($totals['others'][$header]) ? number_format($totals['others'][$header], 2) : '-' }} | @endforeach @foreach ($uniqueHeaders['deductions'] ?? [] as $header){{ is_numeric($totals['deductions'][$header]) ? number_format($totals['deductions'][$header], 2) : '-' }} | @endforeach @foreach ($uniqueHeaders['benefits'] ?? [] as $header){{ is_numeric($totals['benefits'][$header]) ? number_format($totals['benefits'][$header], 2) : '-' }} | @endforeach{{ number_format($totals['grand_total'], 2) }} |
Prepared by: {{ $hasBillingRecords->user->name }}
@endifThis billing is already finalized.
@else @endifchecked by: {{ $checked->user->name }}
{{ session('success') }}