@extends('layouts.horizontal', ['title' => 'Payment Slips', 'topbarTitle' => 'Payment Slips']) @section('css') @vite(['node_modules/datatables.net-bs5/css/dataTables.bootstrap5.min.css', 'node_modules/select2/dist/css/select2.min.css']) @endsection @section('content')

Payment Slips

@php $breadcrumb = getCurrentMenuBreadcrumb(); @endphp @if(!empty($breadcrumb)) @endif
@if(session('ho') === 'Yes')
@endif

Generate Payment Slip

@csrf
@if(isset($vouchers) && !empty($vouchers))
@php // Combine all vouchers into one slip $combinedData = []; $staffInfo = null; $earningsTotal = 0; $deductionsTotal = 0; $netPayable = 0; $paidAmount = 0; $paymentDate = null; $paymentVoucherId = null; $paymentMode = null; // Process all vouchers foreach($vouchers as $voucherId => $voucherGroup) { foreach($voucherGroup as $key => $row) { if($key === 'payments') continue; // Skip payments array if(is_array($row)) { // Store staff info from first record if($staffInfo === null) { $staffInfo = $row; } // Calculate earnings (debit amounts for expense accounts) if(($row['debit_amount'] ?? 0) > 0 && ($row['entity_name'] ?? '') !== 'salary_payable' && ($row['entity_name'] ?? '') !== 'provident_fund_payable') { $earningsTotal += $row['debit_amount']; } // Calculate deductions (credit amounts for expense accounts) if(($row['credit_amount'] ?? 0) > 0 && ($row['entity_name'] ?? '') !== 'salary_payable' && ($row['entity_name'] ?? '') !== 'provident_fund_payable') { $deductionsTotal += $row['credit_amount']; } // Check for salary payable entry if(($row['entity_name'] ?? '') === 'salary_payable') { if(($row['credit_amount'] ?? 0) > 0) { // This is the payable amount (accrual) $netPayable = $row['credit_amount']; } elseif(($row['debit_amount'] ?? 0) > 0) { // This is a payment (debit to payable) $paidAmount = $row['debit_amount']; $paymentDate = $row['payment_date'] ?? null; $paymentVoucherId = $row['id_account_vouchers'] ?? null; $paymentMode = $row['payment_mode'] ?? null; } } // Add to combined data $combinedData[] = $row; } } } // Determine payment status $paymentStatus = $paidAmount > 0 ? 'paid' : 'unpaid'; $remainingPayable = max(0, $netPayable - $paidAmount); @endphp @if($staffInfo)
@endif
@elseif(request()->isMethod('post') || request()->has('staff_id'))

No Payment Data Found

Please check the staff, month, and year selection and try again.

@endif
@endsection @section('scripts') @vite(['resources/js/app.js']) @endsection