diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index ede280a05..8a5d868a7 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -1217,19 +1217,19 @@ class HolidaysRequestBatch(models.Model): if leave_type_name not in leave_type_mapping or leave_days <= 0: continue type_config = leave_type_mapping[leave_type_name] - remaining_hours = leave_days * 8 + remaining_hours = leave_days * 8 if type_config['prev']: - prev_balance = leave_balance[type_config['prev']] + prev_balance = leave_balance[type_config['prev']] * 8 if prev_balance > 0: deduct = round(min(remaining_hours, prev_balance), 1) - leave_balance[type_config['prev']] = round(leave_balance[type_config['prev']] - deduct, 1) + leave_balance[type_config['prev']] = round((prev_balance - deduct) / 8, 1) remaining_hours = round(remaining_hours - deduct, 1) if remaining_hours > 0 and type_config['curr']: - curr_balance = leave_balance[type_config['curr']] + curr_balance = leave_balance[type_config['curr']] * 8 deduct = round(min(remaining_hours, curr_balance), 1) - leave_balance[type_config['curr']] = round(leave_balance[type_config['curr']] - deduct, 1) + leave_balance[type_config['curr']] = round((curr_balance - deduct) / 8, 1) remaining_hours = round(remaining_hours - deduct, 1) if type_config['prev']: