When requesting regularization, ensure that the check-out time is later than the check-in time. #32

Merged
vikas.nale merged 1 commits from Ashutosh_Bug#127_Regularization_Time_Validation into Feature_Forum 2025-04-30 11:24:52 +00:00
Showing only changes of commit 499fc9e69e - Show all commits

View File

@ -336,8 +336,16 @@ namespace MarcoBMS.Services.Controllers
{
DateTime date = attendance.AttendanceDate;
finalDateTime = GetDateFromTimeStamp(date.Date, recordAttendanceDot.MarkTime);
if (attendance.InTime < finalDateTime)
{
attendance.OutTime = finalDateTime;
attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE;
}
else
{
_logger.LogError("Employee {EmployeeId} sent regularization request but it check-out time is earlier than check-out");
return BadRequest(ApiResponse<object>.ErrorResponse("Check-out time must be later than check-in time", "Check-out time must be later than check-in time", 400));
}
// do nothing
}
else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REGULARIZE)
@ -433,7 +441,13 @@ namespace MarcoBMS.Services.Controllers
{
await transaction.RollbackAsync(); // Rollback on failure
_logger.LogError("{Error} while marking attendance", ex.Message);
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
var response = new
{
message = ex.Message,
detail = ex.StackTrace,
statusCode = StatusCodes.Status500InternalServerError
};
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, response, 400));
}
}
@ -495,8 +509,16 @@ namespace MarcoBMS.Services.Controllers
{
DateTime date = attendance.AttendanceDate;
finalDateTime = GetDateFromTimeStamp(date.Date, recordAttendanceDot.MarkTime);
if (attendance.InTime < finalDateTime)
{
attendance.OutTime = finalDateTime;
attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE;
}
else
{
_logger.LogError("Employee {EmployeeId} sent regularization request but it check-out time is earlier than check-out");
return BadRequest(ApiResponse<object>.ErrorResponse("Check-out time must be later than check-in time", "Check-out time must be later than check-in time", 400));
}
// do nothing
}
else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REGULARIZE)
@ -668,7 +690,13 @@ namespace MarcoBMS.Services.Controllers
{
await transaction.RollbackAsync(); // Rollback on failure
_logger.LogError("{Error} while marking attendance", ex.Message);
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
var response = new
{
message = ex.Message,
detail = ex.StackTrace,
statusCode = StatusCodes.Status500InternalServerError
};
return BadRequest(ApiResponse<object>.ErrorResponse(ex.Message, response, 400));
}
}