- 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.
36 lines
995 B
PHP
36 lines
995 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Finance;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Payroll;
|
|
use App\Services\Admin\Finance\PayrollPeriodService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
class PayrollController extends Controller
|
|
{
|
|
public function __construct(
|
|
private PayrollPeriodService $service
|
|
) {}
|
|
|
|
public function pay(Payroll $payroll): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->pay($payroll),
|
|
'Gaji berhasil dibayar.',
|
|
'admin.finance.payroll-periods.show',
|
|
['payroll_period' => $payroll->payroll_period_id]
|
|
);
|
|
}
|
|
|
|
public function cancel(Payroll $payroll): RedirectResponse
|
|
{
|
|
return $this->handleAction(
|
|
fn () => $this->service->cancel($payroll),
|
|
'Gaji berhasil dibatalkan.',
|
|
'admin.finance.payroll-periods.show',
|
|
['payroll_period' => $payroll->payroll_period_id]
|
|
);
|
|
}
|
|
}
|