Fix: Employee attendance was not showing
This commit is contained in:
parent
ca99aa00ed
commit
fa6aa514bc
@ -26,13 +26,13 @@ router = APIRouter()
|
||||
def show_blank(
|
||||
request: Request,
|
||||
user: UserToken = Security(get_user, scopes=["attendance"]),
|
||||
):
|
||||
return {
|
||||
"startDate": get_start_date(request.session),
|
||||
"finishDate": get_finish_date(request.session),
|
||||
"employee": None,
|
||||
"body": [],
|
||||
}
|
||||
) -> schemas.EmployeeAttendance:
|
||||
return schemas.EmployeeAttendance(
|
||||
startDate=get_start_date(request.session),
|
||||
finishDate=get_finish_date(request.session),
|
||||
employee=None,
|
||||
body=[],
|
||||
)
|
||||
|
||||
|
||||
@router.get("/{id_}", response_model=schemas.EmployeeAttendance)
|
||||
@ -47,16 +47,16 @@ def employee_attendance_report(
|
||||
employee: Employee = db.execute(select(Employee).where(Employee.id == id_)).scalar_one()
|
||||
start_date = datetime.strptime(s or get_start_date(request.session), "%d-%b-%Y").date()
|
||||
finish_date = datetime.strptime(f or get_finish_date(request.session), "%d-%b-%Y").date()
|
||||
info = schemas.EmployeeAttendance(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
employee=schemas.AccountLink(id=employee.id, name=employee.name),
|
||||
)
|
||||
start_date = employee.joining_date if employee.joining_date > start_date else start_date
|
||||
finish_date = (
|
||||
employee.leaving_date if not employee.is_active and employee.leaving_date < finish_date else finish_date
|
||||
)
|
||||
info.body = employee_attendance(employee, start_date, finish_date, db)
|
||||
info = schemas.EmployeeAttendance(
|
||||
startDate=start_date,
|
||||
finishDate=finish_date,
|
||||
employee=schemas.AccountLink(id=employee.id, name=employee.name),
|
||||
body=employee_attendance(employee, start_date, finish_date, db),
|
||||
)
|
||||
return info
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user