{{-- resources/views/payroll/show.blade.php --}} @extends('layouts.app') @section('content') @php // تعريف المتغيرات العامة لاستخدامها في جميع الأقسام $components = $payroll->payrollSalaryComponents ?? collect(); $additionsTotal = 0; $deductionsTotal = 0; foreach($components as $comp) { if ($comp->value > 0) { $additionsTotal += $comp->value; } else { $deductionsTotal += abs($comp->value); } } @endphp
| الراتب الأساسي | {{ number_format($payroll->basic_salary, 2) }} {{ $currency_name }} |
| الحوافز | {{ number_format($payroll->incentives, 2) }} {{ $currency_name }} |
| {{ $label }} | + {{ number_format($comp->value, 2) }} {{ $currency_name }} |
| إجمالي الإضافات | {{ number_format($payroll->basic_salary + $payroll->incentives + $additionsTotal, 2) }} {{ $currency_name }} |
| الخصومات النشطة | - {{ number_format($payroll->active_deductions, 2) }} {{ $currency_name }} |
| أقساط القروض | - {{ number_format($payroll->loan_installments, 2) }} {{ $currency_name }} |
| خصم الإجازات | - {{ number_format($payroll->leave_deduction, 2) }} {{ $currency_name }} |
| {{ $label }} | {{ number_format($comp->value, 2) }} {{ $currency_name }} |
| إجمالي الخصومات | - {{ number_format($payroll->active_deductions + $payroll->loan_installments + $payroll->leave_deduction + $deductionsTotal, 2) }} {{ $currency_name }} |
| التاريخ | ساعات النقص | قيمة الخصم ({{ $currency_name }}) | ساعات الأوفر تايم | قيمة الأوفر تايم ({{ $currency_name }}) | أيام العطلات المدفوعة | أجر اليوم ({{ $currency_name }}) |
|---|---|---|---|---|---|---|
| {{ \Carbon\Carbon::parse($detail['date'])->format('Y-m-d') }} | @php $uw = $detail['underworked_hours'] ?? 0; @endphp {{ $uw > 0 ? number_format($uw, 2) . ' ساعة' : '-' }} | @php $uwv = $detail['underworked_value'] ?? 0; @endphp {{ $uwv > 0 ? number_format($uwv, 2) . ' ' . $currency_name : '-' }} | @php $ot = $detail['overtime_hours'] ?? 0; @endphp {{ $ot > 0 ? number_format($ot, 2) . ' ساعة' : '-' }} | @php $otv = $detail['overtime_value'] ?? 0; @endphp {{ $otv > 0 ? number_format($otv, 2) . ' ' . $currency_name : '-' }} | - | - |
| {{ \Carbon\Carbon::parse($attendance->date)->format('Y-m-d') }} | - | - | - | - | يوم عطلة مدفوع | @php // حساب أجر اليوم المدفوع $dailyRatePaidOff = 0; if (!empty($payroll->employee->default_paid_off_amount) && $payroll->employee->default_paid_off_amount > 0) { $dailyRatePaidOff = $payroll->employee->default_paid_off_amount; } elseif (!empty($dailyRate) && $dailyRate > 0) { $dailyRatePaidOff = $dailyRate; } @endphp {{ number_format($dailyRatePaidOff, 2) }} {{ $currency_name }} |
لا توجد أيام بها نقص في ساعات العمل أو أوفر تايم خلال هذا الشهر.
@endif| نوع الاستقطاع | الوصف | التاريخ | التكرار | المبلغ ({{ $currency_name }}) |
|---|---|---|---|---|
| {{ $deduction->type_arabic ?? $deduction->type }} | {{ $deduction->description ?? '-' }} | {{ \Carbon\Carbon::parse($deduction->deduction_date)->format('Y-m-d') }} | @if($deduction->frequency === 'monthly' || $deduction->is_monthly) شهري @elseif($deduction->frequency === 'yearly') سنوي @else مرة واحدة @endif | {{ number_format($deduction->amount, 2) }} |
| إجمالي الاستقطاعات | {{ number_format($actualDeductions->sum('amount'), 2) }} {{ $currency_name }} | |||
لا توجد استقطاعات نشطة لهذا الشهر.
@endif| نوع القرض | رقم القرض | تاريخ الاستحقاق | قيمة القسط ({{ $currency_name }}) |
|---|---|---|---|
| {{ $installment->loan->loan_type_arabic ?? $installment->loan->loan_type }} | {{ $installment->loan->id }} | {{ \Carbon\Carbon::parse($installment->due_date)->format('Y-m-d') }} | {{ number_format($installment->amount, 2) }} |
| إجمالي أقساط القروض | {{ number_format($loanInstallments->sum('amount'), 2) }} {{ $currency_name }} | ||
| الوصف | المبلغ ({{ $currency_name }}) | التفاصيل |
|---|---|---|
| @php $label = $comp->name; if ($label === 'Overtime') { $label = 'أوفر تايم'; } elseif ($label === 'Paid Off-day Compensation') { $label = 'تعويض أيام الحضور المدفوعة'; } elseif (\Illuminate\Support\Str::contains($label ?? '', 'Underworked')) { $label = 'خصم نقصان ساعات'; } @endphp {{ $label }} | {{ number_format($comp->value, 2) }} | @if(!empty($comp->meta) && is_array($comp->meta)) @php $m = $comp->meta; @endphp @if(isset($m['type']) && $m['type'] === 'underworked') ساعات النقص: {{ ($m['hours'] ?? 0) }} ساعة × {{ number_format($m['hourly_rate'] ?? 0, 4) }} @elseif(isset($m['type']) && $m['type'] === 'overtime') ساعات الأوفر تايم: {{ ($m['hours'] ?? 0) }} ساعة × {{ number_format($m['hourly_rate'] ?? 0, 4) }} @elseif(isset($m['type']) && $m['type'] === 'paid_off_days') @php // محاولة ذكية لإظهار عدد الأيام الفعلي للحضور المدفوع $paidDays = null; $paidDaysMeta = $m['days'] ?? null; // 1) إذا كانت days في الميتا موجودة وموجبة استخدمها كما هي if ($paidDaysMeta !== null && (!is_numeric($paidDaysMeta) || (float)$paidDaysMeta > 0.0)) { $paidDays = $paidDaysMeta; } // 2) وإلا استخدم القيمة القادمة من الكنترولر إذا كانت أكبر من صفر elseif (!empty($paidOffDays) && $paidOffDays > 0) { $paidDays = $paidOffDays; } // 3) وإذا لم تتوفر أي من القيم السابقة، استنتج الأيام من مبلغ التعويض else { $amountSource = 0; if (!empty($paidOffAmount) && $paidOffAmount > 0) { $amountSource = $paidOffAmount; } elseif (!empty($payroll->paid_off_amount) && $payroll->paid_off_amount > 0) { $amountSource = $payroll->paid_off_amount; } elseif (!empty($comp->value) && $comp->value > 0) { // fallback أخير: استخدم قيمة المكوّن نفسها $amountSource = $comp->value; } if ($amountSource > 0 && !empty($dailyRate) && $dailyRate > 0) { $paidDays = round($amountSource / $dailyRate, 2); } else { $paidDays = 0; } } @endphp أيام الحضور المدفوعة: {{ $paidDays }} يوم @else {{ json_encode($m) }} @endif @else - @endif |
لا توجد مكونات مرتب مضافة لهذا الراتب.
@endif{{ $payroll->employee->position->name ?? 'غير محدد' }}
{{ $payroll->employee->department->name ?? 'غير محدد' }}
| الرصيد قبل الخصم: | {{ $payroll->leave_balance_before_deduction }} يوم |
|---|---|
| الأيام المستخدمة: | {{ $cumulativeLeaveInfo['current_month_used'] ?? 0 }} يوم |
| الأيام الممنوحة: | {{ $payroll->leave_granted_this_month }} يوم |
| الأيام الزائدة: | {{ $cumulativeLeaveInfo['current_month_excess'] ?? 0 }} يوم |
| قيمة خصم الإجازات: | {{ number_format($payroll->leave_deduction, 2) }} {{ $currency_name }} |
| الرصيد بعد الخصم: | {{ $payroll->leave_balance_after }} يوم |
| نوع الإجازة | تاريخ البداية | تاريخ النهاية | عدد الأيام | الحالة |
|---|---|---|---|---|
| {{ $leave->leaveTypeModel->name ?? 'غير محدد' }} | {{ \Carbon\Carbon::parse($leave->start_date)->format('Y-m-d') }} | {{ \Carbon\Carbon::parse($leave->end_date)->format('Y-m-d') }} | {{ $leave->number_of_days ?? 0 }} يوم | @if($leave->status === 'approved') موافق عليها @elseif($leave->status === 'modified') معدلة @else {{ $leave->status }} @endif |
لا توجد إجازات مستخدمة خلال هذا الشهر
@endif| الشهر والسنة | إجمالي الراتب (الخام) | حالة الدفع | الإجراءات |
|---|---|---|---|
| {{ \Carbon\Carbon::create()->month($prev->month)->translatedFormat('F') }} {{ $prev->year }} | {{ number_format($grossRaw, 2) }} {{ get_currency_code() }} | @if($prev->paid_at) مدفوع @else قيد الدفع @endif | عرض التفاصيل |
لا توجد رواتب سابقة
@endif| إجمالي الإضافات | {{ number_format($payroll->basic_salary + $payroll->incentives + $additionsTotal, 2) }} {{ $currency_name }} |
|---|---|
| إجمالي الخصومات | - {{ number_format($payroll->active_deductions + $payroll->loan_installments + $payroll->leave_deduction + $deductionsTotal, 2) }} {{ $currency_name }} |
| الراتب الصافي المستحق | @php $totalAdditions = $payroll->basic_salary + $payroll->incentives + $additionsTotal; $totalDeductions = $payroll->active_deductions + $payroll->loan_installments + $payroll->leave_deduction + $deductionsTotal; $netSalary = $totalAdditions - $totalDeductions; @endphp{{ number_format($netSalary, 2) }} {{ $currency_name }} |