feat(payroll): DOLE compliant payroll automation
This commit is contained in:
74
app/Http/Controllers/StatutoryBracketController.php
Normal file
74
app/Http/Controllers/StatutoryBracketController.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\StatutoryBracket;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class StatutoryBracketController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = StatutoryBracket::query()
|
||||
->with('creator')
|
||||
->orderBy('type')
|
||||
->orderBy('min_salary');
|
||||
|
||||
// Optional filtering by type
|
||||
if ($request->has('type') && in_array($request->type, ['sss', 'philhealth', 'pagibig'])) {
|
||||
$query->where('type', $request->type);
|
||||
}
|
||||
|
||||
$brackets = $query->get();
|
||||
|
||||
return Inertia::render('hr/statutory-brackets/index', [
|
||||
'brackets' => $brackets,
|
||||
'filters' => $request->only(['type'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'type' => 'required|in:sss,philhealth,pagibig',
|
||||
'min_salary' => 'required|numeric|min:0',
|
||||
'max_salary' => 'nullable|numeric|gt:min_salary',
|
||||
'employee_share_amount' => 'nullable|numeric|min:0',
|
||||
'employee_share_percentage' => 'nullable|numeric|min:0|max:100',
|
||||
'employer_share_amount' => 'nullable|numeric|min:0',
|
||||
'employer_share_percentage' => 'nullable|numeric|min:0|max:100',
|
||||
'is_active' => 'boolean'
|
||||
]);
|
||||
|
||||
$validated['created_by'] = auth()->id() ?? 1;
|
||||
|
||||
StatutoryBracket::create($validated);
|
||||
|
||||
return redirect()->back()->with('success', 'Statutory bracket created successfully.');
|
||||
}
|
||||
|
||||
public function update(Request $request, StatutoryBracket $statutoryBracket)
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'type' => 'required|in:sss,philhealth,pagibig',
|
||||
'min_salary' => 'required|numeric|min:0',
|
||||
'max_salary' => 'nullable|numeric|gt:min_salary',
|
||||
'employee_share_amount' => 'nullable|numeric|min:0',
|
||||
'employee_share_percentage' => 'nullable|numeric|min:0|max:100',
|
||||
'employer_share_amount' => 'nullable|numeric|min:0',
|
||||
'employer_share_percentage' => 'nullable|numeric|min:0|max:100',
|
||||
'is_active' => 'boolean'
|
||||
]);
|
||||
|
||||
$statutoryBracket->update($validated);
|
||||
|
||||
return redirect()->back()->with('success', 'Statutory bracket updated successfully.');
|
||||
}
|
||||
|
||||
public function destroy(StatutoryBracket $statutoryBracket)
|
||||
{
|
||||
$statutoryBracket->delete();
|
||||
return redirect()->back()->with('success', 'Statutory bracket deleted successfully.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user