dstpabuaran.com/app/Http/Controllers/Admin/Finance/PayrollPeriodController.php
Yoga Pangestu 6dbe9da581 feat: add payroll management features including payroll periods, adjustments, and payment processing
- Implemented routes for managing payroll periods, including current, close, and reopen functionalities.
- Added payroll payment and cancellation routes.
- Introduced payroll adjustments with store and delete functionalities.
- Created comprehensive feature tests for payroll management, covering authentication, CRUD operations, and business logic.
- Ensured proper handling of payroll adjustments and their impact on payroll totals.
- Developed tests for generating payrolls and managing payroll periods, ensuring accurate status transitions and data integrity.
2026-07-30 17:06:52 +07:00

65 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\Finance;
use App\Enums\PayrollPeriodStatus;
use App\Http\Controllers\Controller;
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(): Response
{
return Inertia::render('admin/finance/payroll-period/index', [
'payrollPeriods' => $this->service->getAll(),
]);
}
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'
);
}
}