@extends('layouts.app')
@section('content')
@php
$selectedEmployee = $employees->firstWhere('id', old('employee_id', $salary->employee_id));
$baseSalaryValue = (int) old(
'base_salary',
(int) round($selectedEmployee->base_salary ?? $salary->base_salary ?? 0)
);
$uiPositionAllowance = (int) old('ui_position_allowance', 0);
$uiAttendanceAllowance = (int) old('ui_attendance_allowance', 0);
$uiMealAllowance = (int) old('ui_meal_allowance', 0);
$uiTransportAllowance = (int) old('ui_transport_allowance', 0);
$uiBpjsAllowance = (int) old('ui_bpjs_allowance', 0);
$usedBreakdownAllowance =
$uiPositionAllowance +
$uiAttendanceAllowance +
$uiMealAllowance +
$uiTransportAllowance +
$uiBpjsAllowance;
$uiOtherAllowance = (int) old(
'ui_other_allowance',
max(0, (int) round(($salary->allowance ?? 0) - $usedBreakdownAllowance))
);
$uiOvertimeAmount = (int) old('ui_overtime_amount', (int) round($salary->overtime ?? 0));
$uiPerformanceBonus = (int) old('ui_performance_bonus', 0);
$uiOtherBonus = (int) old(
'ui_other_bonus',
max(0, (int) round(($salary->bonus ?? 0) - $uiPerformanceBonus))
);
$uiLateDeduction = (int) old('ui_late_deduction', 0);
$uiAbsentDeduction = (int) old('ui_absent_deduction', 0);
$uiAdvanceDeduction = (int) old('ui_advance_deduction', 0);
$usedBreakdownDeduction =
$uiLateDeduction +
$uiAbsentDeduction +
$uiAdvanceDeduction;
$uiOtherDeduction = (int) old(
'ui_other_deduction',
max(0, (int) round(($salary->deduction ?? 0) - $usedBreakdownDeduction))
);
$employeeSalaryMap = $employees->mapWithKeys(function ($employee) {
return [
$employee->id => [
'base_salary' => (int) round($employee->base_salary ?? 0),
]
];
});
@endphp
Form ini memakai breakdown payroll yang lebih umum dipakai di perusahaan dan otomatis menghitung total akhir.