- Updated RoleIndex component to handle pagination, sorting, and searching for roles. - Adjusted data structure for roles to include pagination details. - Enhanced tests for various admin features (Finance, HR, Master) to validate pagination and data structure. - Ensured all relevant tests check for data structure consistency, including total counts and pagination details.
66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Finance;
|
|
|
|
use App\Enums\PayrollPeriodStatus;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\PaginatedRequest;
|
|
use App\Models\PayrollPeriod;
|
|
use App\Services\Admin\Finance\PayrollPeriodService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class PayrollPeriodController extends Controller
|
|
{
|
|
public function __construct(
|
|
private PayrollPeriodService $service
|
|
) {}
|
|
|
|
public function index(PaginatedRequest $request): Response
|
|
{
|
|
return Inertia::render('admin/finance/payroll-period/index', [
|
|
'payrollPeriods' => $this->service->paginated(...$request->validatedWithDefaults()),
|
|
]);
|
|
}
|
|
|
|
public function current(): RedirectResponse
|
|
{
|
|
$now = now();
|
|
|
|
$period = PayrollPeriod::firstOrCreate(
|
|
['year' => $now->year, 'month' => $now->month],
|
|
['status' => PayrollPeriodStatus::OPEN]
|
|
);
|
|
|
|
return to_route('admin.finance.payroll-periods.show', ['payroll_period' => $period->id]);
|
|
}
|
|
|
|
public function show(PayrollPeriod $payrollPeriod): Response
|
|
{
|
|
$period = $this->service->getDetail($payrollPeriod);
|
|
|
|
return Inertia::render('admin/finance/payroll-period/show', [
|
|
'payrollPeriod' => $period,
|
|
]);
|
|
}
|
|
|
|
public function close(PayrollPeriod $payrollPeriod): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->close($payrollPeriod),
|
|
'Periode gaji berhasil ditutup.',
|
|
'admin.finance.payroll-periods.index'
|
|
);
|
|
}
|
|
|
|
public function reopen(PayrollPeriod $payrollPeriod): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->reopen($payrollPeriod),
|
|
'Periode gaji berhasil dibuka kembali.',
|
|
'admin.finance.payroll-periods.index'
|
|
);
|
|
}
|
|
}
|