Merge pull request 'fix calculate onleave day' (#126) from vi.ticket-email into dev
Reviewed-on: #126
This commit is contained in:
commit
b1e7aaa1ea
|
|
@ -553,7 +553,7 @@ class TicketController extends Controller
|
|||
// Ngày phép còn lại < ngày yêu cầu (Không đủ phép)
|
||||
else if ($remainingOnleaveDaysInMonth < $monthData['days_requested']) {
|
||||
// Vượt limit
|
||||
if ($remainingOnleaveDaysInMonth >= $maxDaysPerMonth) {
|
||||
if ($onleaveDaysInMonth >= $maxDaysPerMonth) {
|
||||
$hasInsufficientDays = true;
|
||||
$month_data_status = 'exceed_max_days';
|
||||
$onleave_days_will_use = $maxDaysPerMonth - $onleaveDaysInMonth;
|
||||
|
|
@ -708,7 +708,7 @@ class TicketController extends Controller
|
|||
->first();
|
||||
|
||||
$totalAllocated = 0;
|
||||
if ($leaveDaysInfo) {
|
||||
if ($leaveDaysInfo && $user->is_permanent) {
|
||||
$currentMonth = Carbon::now()->month;
|
||||
$totalAllocated = $leaveDaysInfo->ld_day_total;
|
||||
|
||||
|
|
@ -738,8 +738,6 @@ class TicketController extends Controller
|
|||
$totalAllocated = $month;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log::warning("No LeaveDays record found for user ID: {$user->id}, year: {$year}. Assuming 0 allocated days.");
|
||||
}
|
||||
$totalAllocated = $totalAllocated + $leaveDaysInfo->ld_additional_day + $leaveDaysInfo->ld_special_leave_day;
|
||||
return $totalAllocated;
|
||||
|
|
|
|||
|
|
@ -63,9 +63,10 @@ class UserController extends Controller
|
|||
}
|
||||
$userLeaveDay->save();
|
||||
}
|
||||
|
||||
$payload['permanent_date'] = Carbon::now()->toDateString();
|
||||
}
|
||||
|
||||
$payload['permanent_date'] = Carbon::now()->toDateString();
|
||||
$user->update($payload);
|
||||
return response()->json(['data' => $user, 'status' => true, 'message' => 'Update successful']);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,12 @@ class DeductLeaveDays implements ShouldQueue
|
|||
->where('n_reason', 'ONLEAVE')
|
||||
->sum('categories.c_value');
|
||||
|
||||
$existingData->ld_additional_day = $usedOnleaveDaysTotal ?? 0;
|
||||
if($usedOnleaveDaysTotal) {
|
||||
$existingData->ld_additional_day = $existingData->ld_additional_day >= $usedOnleaveDaysTotal ? $usedOnleaveDaysTotal : $existingData->ld_additional_day;
|
||||
} else {
|
||||
$existingData->ld_additional_day = 0;
|
||||
}
|
||||
|
||||
$existingData->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue