(20260119) Attendance now captures total hours, over-time hours, first in time, and last out time.
This commit is contained in:
+77
-6
@@ -376,7 +376,7 @@ def team_add(
|
||||
role: str,
|
||||
username: str,
|
||||
password: str,
|
||||
application_notes: dict | list | str = None
|
||||
applicant_notes: dict | list | str = None
|
||||
) -> bool:
|
||||
|
||||
"""
|
||||
@@ -391,13 +391,13 @@ def team_add(
|
||||
:param role: The role of the team member in the organization.
|
||||
:param username: The unique username of the team member. Cannot be the same as anyone else.
|
||||
:param password: The password for this team member's login.
|
||||
:param application_notes: Optional notes about the team member.
|
||||
:param applicant_notes: Optional notes about the team member.
|
||||
:return: True if successful, else False.
|
||||
"""
|
||||
|
||||
# Ensure that JSON notes are converted to string:
|
||||
if isinstance(application_notes, (list, dict)):
|
||||
application_notes = json.to_string(application_notes, no_space = True)
|
||||
# # Ensure that JSON notes are converted to string:
|
||||
# if isinstance(applicant_notes, (list, dict)):
|
||||
# applicant_notes = json.to_string(applicant_notes, no_space = True)
|
||||
|
||||
# Make the API call:
|
||||
response = requests.post(
|
||||
@@ -414,7 +414,7 @@ def team_add(
|
||||
"username": username,
|
||||
"password": password,
|
||||
"hierarchy": 1,
|
||||
"applicantNotes": application_notes
|
||||
"applicantNotes": applicant_notes
|
||||
}
|
||||
)
|
||||
|
||||
@@ -437,12 +437,79 @@ def team_add(
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def team_update(
|
||||
tcaoff_creds: dict,
|
||||
user_id: int,
|
||||
branch_id: int,
|
||||
dept_id: int,
|
||||
reporting_to: int | None,
|
||||
team_name: str,
|
||||
email: str,
|
||||
phone_no: str,
|
||||
role: str,
|
||||
applicant_notes: dict | list | str = None
|
||||
) -> bool:
|
||||
|
||||
"""
|
||||
Add a new team member.
|
||||
:param tcaoff_creds: The set of credentials to use with the API call.
|
||||
:param dept_id: The id of the department that this team member is working in.
|
||||
:param branch_id: The id of the branch that this team member is working in.
|
||||
:param reporting_to: The id of the senior to whom this team member will report.
|
||||
:param team_name: The name of the team member. This is the full display name. Can be the same as others.
|
||||
:param email: The email id of the team member.
|
||||
:param phone_no: The phone no. of the team member.
|
||||
:param role: The role of the team member in the organization.
|
||||
:param applicant_notes: Optional notes about the team member.
|
||||
:return: True if successful, else False.
|
||||
"""
|
||||
|
||||
# # Ensure that JSON notes are converted to string:
|
||||
# if isinstance(applicant_notes, (list, dict)):
|
||||
# applicant_notes = json.to_string(applicant_notes, no_space = True)
|
||||
|
||||
# Make the API call:
|
||||
response = requests.post(
|
||||
url = tcaoff_creds["urls"]["teamUpdate"],
|
||||
headers = {"X-Session-Token": tcaoff_creds["creds"]["sessionToken"]},
|
||||
json = {
|
||||
"branchId": branch_id,
|
||||
"idDepartment": dept_id,
|
||||
"reportingTo": reporting_to,
|
||||
"name": team_name,
|
||||
"email": email,
|
||||
"phoneNo": phone_no,
|
||||
"role": role,
|
||||
"applicantNotes": applicant_notes
|
||||
}
|
||||
)
|
||||
|
||||
# Debugging:
|
||||
if response.status_code not in [200]:
|
||||
response_json = response.json()
|
||||
print("TCAOFF Team-Update:", json.to_string(response_json))
|
||||
|
||||
# If the call succeeded:
|
||||
if response.status_code in [200]:
|
||||
print(f"TCAOFF: team '{user_id}' updated")
|
||||
return True
|
||||
|
||||
# If the call failed:
|
||||
else:
|
||||
print(f"TCAOFF: team '{user_id}' NOT updated")
|
||||
return False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def attendance_mark(
|
||||
tcaoff_creds: dict,
|
||||
user_id: int,
|
||||
status: Literal["P", "H", "A", "OT"],
|
||||
over_time: int | float,
|
||||
attendance_date: datetime.datetime | None = None,
|
||||
json_notes: dict = None
|
||||
) -> bool:
|
||||
|
||||
"""
|
||||
@@ -470,6 +537,10 @@ def attendance_mark(
|
||||
"ot": over_time,
|
||||
}
|
||||
|
||||
# Add JSON notes is needed:
|
||||
if json_notes:
|
||||
json_payload["jsonNotes"] = json_notes
|
||||
|
||||
# Make the API call:
|
||||
response = requests.post(
|
||||
url = tcaoff_creds["urls"]["attendanceMark"],
|
||||
|
||||
Reference in New Issue
Block a user