[FIX] issue with permission remaining balance check in mobile app

This commit is contained in:
younes 2025-08-04 09:34:41 +01:00
parent 3a9488bf07
commit d882830f01
1 changed files with 3 additions and 6 deletions

View File

@ -380,8 +380,7 @@ class PermissionController(http.Controller):
success=False)
try:
permission_type_id = http.request.env['hr.personal.permission.type'].browse(int(body.get('permission_type_id')))
permission_hours = self.permission_number_decrement(employee, body['date_from'], body['date_to'],
permission_type_id)
permission_hours = self.permission_number_decrement(employee, body['date_from'], body['date_to'],permission_type_id)
return http_helper.response(message="Data Found", data={'balance': permission_hours,
'permission_limit': permission_type_id.daily_hours})
@ -398,8 +397,7 @@ class PermissionController(http.Controller):
def permission_number_decrement(self, employee_id, permission_date_from, permission_date_to, permission_type_id):
if employee_id:
if not employee_id.first_hiring_date:
raise Warning(
_('You can not Request Permission The Employee have Not First Hiring Date'))
raise Warning(_('You can not Request Permission The Employee have Not First Hiring Date'))
if permission_date_to:
current_date = datetime.strptime(permission_date_to, DEFAULT_SERVER_DATETIME_FORMAT)
current_month = current_date.month
@ -427,8 +425,7 @@ class PermissionController(http.Controller):
permission_date_to, DEFAULT_SERVER_DATETIME_FORMAT).date()
if permission_date1 == date_to_value1:
raise Warning(
_('Sorry You Have Used All Your Permission In This Day you have one permission per a Day'))
raise Warning(_('Sorry You Have Used All Your Permission In This Day you have one permission per a Day'))
if number_of_per > all_perission:
return round(number_of_per - all_perission, 2)