#ADD SESSION TOKEN IN EVERY API PASS VIA HEADER
"X-Session-Token"
# Api for the team list : https://api.thecaoffice.com/ca/login
# Login Input response
{
        'username': '',
        'password': '',
        'mode': 'app' # ... Required ("cosec")
}

#Login Output response
{
    "code": 1,
    "data": {},
    "message": "Sucessfull",
    "sessionToken": "44e490e2-94c2-47c4-8a02-4ddeb4fea56a",
    "status": 1
}

# Api for the logout : https://api.thecaoffice.com/user/logout
# Logout Input response
{
        "sessionToken" :
}

#Logout Output response
{
    "code": 1,
    "data": null,
    "message": "Session Invalid",
    "status": 1
}

# Call inout register for prev day - credentials in json file 
# call team list using ca office api - credentials in json file 
# Api for the team list : https://api.thecaoffice.com/team/list
# Team List Input response
{
    "idUser":1643
}
# Team List output response:
{
    "code": 1,
    "data": {
        "http_code": 200,
        "numeric_code": 4312,
        "rs0": [
            {
                "authorisations_json": null,
                "department_id": 699,
                "department_name": "Client Management",
                "email": "aramduke@gmail.com",
                "full_name": "Aarm Duke",
                "hierarchy_level": 1,
                "json_notes": "{\n    \"pdf\": \"https://nexcom.ditscentre.in/utils/files/small/download/69315bd0a468dde807890681\",\n    \"salary\": 30000,\n    \"maritalStatus\": \"\",\n    \"dateOfBirth\": \"\",\n    \"dateOfJoin\": \"\",\n    \"accountNumber\": \"\",\n    \"ifsc\": \"\",\n    \"bankName\": \"\",\n    \"esicNumber\": \"\",\n    \"ppfnumber\": \"\",\n    \"emergencyContactNumber\": \"\",\n    \"emergencyContactName\": \"\",\n    \"photoUrl\": \"https://nexcom.ditscentre.in/utils/files/small/download/6900430c77c9b049da378dab\",\n    \"aadhaarUrl\": \"\",\n    \"panCardUrl\": \"\",\n    \"address\": \"\",\n    \"billingRate\": \"\",\n    \"relationship\": \"\",\n    \"city\": \"\",\n    \"pincode\": \"\",\n    \"branchId\": 84,\n    \"weeklyOff\": [],\n    \"weeklyWorkingHours\": 0,\n    \"noOfPaidLeaves\": 0,\n    \"country\": \"India\",\n    \"lastDayOfWorking\": null,\n    \"applicantNotes\": {\n        \"age\": null,\n        \"gender\": \"\",\n        \"educationLevel\": null,\n        \"noChildren\": null,\n        \"spouseWorkingStatus\": null,\n        \"noOfChildrenAbove18\": null,\n        \"noOfChildrenBelow18\": null,\n        \"employmentStatus\": \"\",\n        \"attendanceAllowance\": 0,\n        \"performanceAllowance\": 0,\n        \"adaitechEmail\": null,\n        \"adaitechPassword\": null,\n        \"gearincEmail\": null,\n        \"payrollFor\": null,\n        \"contractStartDate\": null,\n        \"contractEndDate\": null,\n        \"nricNo\": null,\n        \"taxNo\": null,\n        \"epfNo\": null,\n        \"perksoNo\": null,\n        \"Salutation\": null,\n        \"reportingToName\": \"Aditya Shah\",\n        \"outlierId\": null,\n        \"addressProofUrl\": null,\n        \"appointmentLetterUrl\": null,\n        \"offerLetterUrl\": null,\n        \"pfUanNumber\": null,\n        \"panCardNumber\": null,\n        \"aadhaarCardNumber\": null,\n        \"payRollType\": \"onRoll\",\n        \"labourContractorName\": null,\n        \"labourContractorId\": null,\n        \"leaveAfter\": 10\n    },\n    \"userBasicSalary\": 25000,\n    \"houseResidencesAllowance\": 3000,\n    \"dearnessAllowance\": 0,\n    \"conveyance\": 1000,\n    \"allowance\": 1000,\n    \"providentFund\": true,\n    \"employeesInsurance\": true,\n    \"professionalTax\": true,\n    \"salaryType\": \"Monthly\",\n    \"team_master\": true,\n    \"account_master_id\": 43682\n}",
                "phone_number": "+916655665577",
                "pseudonym": "aramduke",
                "reporting_to": 2057.0,
                "role": "Crm Lead",
                "user_id": 2876,
                "user_status": "active"
            }
          ]
    },
    "message": "Team Member List",
    "status": 1
}

# check if any new names in the in out register vs  team list 
# if yes then add team member / branch / department as needed 
# Api for the team add : https://api.thecaoffice.com/team/add
 Payload = {
  'email': 'employee@company.com',  # ... Required (?? or User Name -> to lower and space becomes dot "@velankanigroup.com")
  'name': 'John Smith',  # ... Required (User Name)
  "idDepartment": 1,  # ... Required (??)
  'role': 'Software Engineer', # ... Required (Category Name)
  'phoneNo': '9876543210', # ... Required (?? or "9876543210")
  'username': 'john.smith',  # ... UNIQUE/NON-CHANGEABLE - Required (User ID)
  'password': 'password123',  # ... Required ("9876543210")
  'address': '123 Main St, Mumbai, Maharashtra',
  "website": 'http://company.com',
  "logoUrl": null,
  "companyName": 'Lok Chemicals Pvt. Ltd.',
  "salary": 50000.0,
  "maritalStatus": 'Single',
  "dateOfBirth": '1999-01-01',
  "dateOfJoin": '2025-01-01',
  "accountNumber": '1234567890',
  "ifsc": 'BKID0001234',
  "bankName": 'Bank of India',
  "esicNumber": 'ESIC123456',
  "ppfnumber": 'PPF123456789',
  "emergencyContactNumber": '9998887777',
  "emergencyContactName": 'Jane Doe',
  "photoUrl": 'http://example.com/photo.jpg',
  "aadhaarUrl": 'http://example.com/aadhaar.jpg',
  "panCardUrl": 'http://example.com/pancard.jpg',
  "billingRate": '100.0',
  "hierarchy": 1,
  "branchId": 101,
  "city": 'Mumbai',
  "pinCode": '400001',
  "relationship": 'Single',
  "weeklyOff": 'Saturday',
  "weeklyWorkingHours": 40,
  "noOfPaidLeaves": 12,
  "country": 'India',
  "lastDayOfWorking": '2025-12-31',
  "applicantNotes": applicantNotesParam,
  "reportingTo": 101,
  "userBasicSalary": 30000.0,
  "houseResidencesAllowance": 2000.0,
  "dearnessAllowance": 3000.0,
  "conveyance": 1000.0,
  "allowance": 1500.0,
  "providentFund": true,
  "employeesInsurance": true,
  "professionalTax": true,
  "salaryType": 'Monthly',
};
final applicantNotesParam = {
  "age": 30,
  "gender": 'Male',
  "educationLevel": 'Bachelor\'s Degree',
  "noChildren": 2,
  "spouseWorkingStatus": 'Employed',
  "noOfChildrenAbove18": '1',
  "noOfChildrenBelow18": '2',
  "employmentStatus": 'Full-time',
  "attendanceAllowance": 100.0,
  "performanceAllowance": 200.0,
  "adaitechEmail": 'example@adaitech.com',
  "adaitechPassword": 'password123',
  "gearincEmail": 'example@gearinc.com',
  "payrollFor": 'Employee',
  "contractStartDate": '2025-01-01',
  "contractEndDate": '2025-12-31',
  "nricNo": 'S1234567D',
  "taxNo": 'T123456789',
  "epfNo": 'EPF123456789',
  "perksoNo": 'P123456789',
  "Salutation": 'Mr.',
  "reportingToName": 'Jane Doe',
  "outlierId": 'OUT12345',
  "addressProofUrl": 'http://example.com/addressproof.jpg',
  "appointmentLetterUrl": 'http://example.com/appointmentletter.pdf',
  "offerLetterUrl": 'http://example.com/offerletter.pdf',
  "pfUanNumber": 'PF123456789',
  "panCardNumber": 'ABCDE1234F',
  "aadhaarCardNumber": '1234 5678 9012',
  "payRollType": 'monthly',
  "labourContractorName": 'Contractor XYZ',
  "labourContractorId": 101,
  "leaveAfter": 30,
};


# Api for the branch add : https://api.thecaoffice.com/commons/branch/add
Paylod = {
  'idUser':1643  # ... Required (from session token)
  'branchName': 'Main Branch', # ... Required (Branch Name)
  'address': '123 Street, Mumbai, Maharashtra',
  'branchHead': 'John Doe',
  'branchHeadId': 18,
  'gstNumber': '27ABCDE1234F1Z5',
  'city': 'Mumbai',
  'pincode': '400001',
  'bankName': 'Bank of India',
  'bankAccountNo': '1234567890123456',
  'bankIfscCode': 'BKID0001234',
  'panCard': 'ABCDE1234F',
  'msmeNo': 'MSME1234567890',
}

# Api for the branch list : https://api.thecaoffice.com/commons/branch/list
# branch List Input JSON
{
    "idUser":1643
}
# Branch List output JSON:
{
    "code": 1,
    "data": {
        "http_code": 200,
        "numeric_code": 4201,
        "rs0": [
            {
                "branch_head": null,
                "branch_id": 45,
                "branch_name": "Testing",
                "contact_email": null,
                "contact_phone": null,
                "created_at": 1733405356000,
                "entity_id": 118,
                "notes": "{\n    \"address\": null,\n    \"city\": null,\n    \"pincode\": null,\n    \"branchHead\": \"Sahil Khan\",\n    \"gstNumber\": null,\n    \"bankName\": null,\n    \"bankAccountNo\": null,\n    \"bankIfscCode\": null,\n    \"panCard\": null,\n    \"serviceTaxNo\": null\n}",
                "updated_at": 1733405356000
            }
         ]
    },
    "message": "Department list",
    "status": 1
}

#------------------------------------------------------------

# Api for the department add : https://api.thecaoffice.com/commons/departments/add
 params = {
 'idUser':1643 # ... Required (from session token)
 'departmentName': departmentController.text, # ... Required (Department Name)
};

# Api for the department add : https://api.thecaoffice.com/commons/departments/list
# Department List Input JSON
{
    "idUser":1643
}
# Department List output JSON:
{
    "code": 1,
    "data": {
        "http_code": 200,
        "numeric_code": 4201,
        "rs0": [
            {
                "contact_email": null,
                "contact_phone": null,
                "created_at": 1733123791000,
                "department_head": null,
                "department_id": 395,
                "department_location": null,
                "department_name": "Api",
                "entity_id": 118,
                "updated_at": 1749696986000
            }
          ]
    },
    "message": "Department list",
    "status": 1
}  

#------------------------------------------------------------
# Mark attendance based on in out register time spent and hr rules 
# Api for the attendance mark : https://api.thecaoffice.com/user/attendance/mark
params = {
  "date": '2025-12-31',  
  "idUser": 101,        # ... this Id of the team member whose we are marking attendance  
  "status": 'P',     
  "ot": 0 
};

# Api for the attendance register : https://api.thecaoffice.com/user/attendance/register
# input json
Paylod = {
    "month": '2025-12-31'
}

# Output json
{
    "code": 1,
    "data": {
        "rs0": [
            {
                "allowances": 0.0,
                "amount": 0.0,
                "ar_date": "2026-02-14",
                "basic_salary": 0.0,
                "conveyance": 0.0,
                "da": 0.0,
                "department_name": "Site Admin",
                "full_name": "Girish Jambagi",
                "hra": 0.0,
                "idattendance_register": 96119,
                "json_notes": "{\n    \"totHours\": 0.0,\n    \"firstIn\": null,\n    \"lastOut\": null\n}",
                "ot": 0,
                "ot_amount": 0.0,
                "pseudonym": "VL2294",
                "remarks": null,
                "status": "A",
                "user_id": 7096
            },
            {
                "allowances": 0.0,
                "amount": 0.0,
                "ar_date": "2026-02-16",
                "basic_salary": 0.0,
                "conveyance": 0.0,
                "da": 0.0,
                "department_name": "Site Admin",
                "full_name": "TEK Bahadur Rai",
                "hra": 0.0,
                "idattendance_register": 96159,
                "json_notes": "{\n    \"totHours\": 11.693333333333333,\n    \"firstIn\": 1771206924.0,\n    \"lastOut\": 1771249020.0\n}",
                "ot": 2,
                "ot_amount": 0.0,
                "pseudonym": "VL1214",
                "remarks": null,
                "status": "OT",
                "user_id": 6450
            }
        ]
    },
    "message": "Attendance register for the entity",
    "status": 1
}
# salary register download option. 



/// Added BY Yatmesh on 13.01.2026
/// Team list Response for old records and new records
/// Cause : Team List Not displaying on UI
/// Reason : value of key applicantNotes is getting as string of dictionary("{}")  instead of dictionary({})
///
/// Team List Old response 

{
  "authorisations_json": null,
  "department_id": 699,
  "department_name": "Client Management",
  "email": "aramduke@gmail.com",
  "full_name": "Aarm Duke",
  "hierarchy_level": 1,
  "json_notes": "{\n    \"pdf\": \"https://nexcom.ditscentre.in/utils/files/small/download/69315bd0a468dde807890681\",\n    \"salary\": 30000,\n    \"maritalStatus\": \"\",\n    \"dateOfBirth\": \"\",\n    \"dateOfJoin\": \"\",\n    \"accountNumber\": \"\",\n    \"ifsc\": \"\",\n    \"bankName\": \"\",\n    \"esicNumber\": \"\",\n    \"ppfnumber\": \"\",\n    \"emergencyContactNumber\": \"\",\n    \"emergencyContactName\": \"\",\n    \"photoUrl\": \"https://nexcom.ditscentre.in/utils/files/small/download/6900430c77c9b049da378dab\",\n    \"aadhaarUrl\": \"\",\n    \"panCardUrl\": \"\",\n    \"address\": \"\",\n    \"billingRate\": \"\",\n    \"relationship\": \"\",\n    \"city\": \"\",\n    \"pincode\": \"\",\n    \"branchId\": 84,\n    \"weeklyOff\": [],\n    \"weeklyWorkingHours\": 0,\n    \"noOfPaidLeaves\": 0,\n    \"country\": \"India\",\n    \"lastDayOfWorking\": null,\n    \"applicantNotes\": {\n        \"age\": null,\n        \"gender\": \"\",\n        \"educationLevel\": null,\n        \"noChildren\": null,\n        \"spouseWorkingStatus\": null,\n        \"noOfChildrenAbove18\": null,\n        \"noOfChildrenBelow18\": null,\n        \"employmentStatus\": \"\",\n        \"attendanceAllowance\": 0,\n        \"performanceAllowance\": 0,\n        \"adaitechEmail\": null,\n        \"adaitechPassword\": null,\n        \"gearincEmail\": null,\n        \"payrollFor\": null,\n        \"contractStartDate\": null,\n        \"contractEndDate\": null,\n        \"nricNo\": null,\n        \"taxNo\": null,\n        \"epfNo\": null,\n        \"perksoNo\": null,\n        \"Salutation\": null,\n        \"reportingToName\": \"Aditya Shah\",\n        \"outlierId\": null,\n        \"addressProofUrl\": null,\n        \"appointmentLetterUrl\": null,\n        \"offerLetterUrl\": null,\n        \"pfUanNumber\": null,\n        \"panCardNumber\": null,\n        \"aadhaarCardNumber\": null,\n        \"payRollType\": \"onRoll\",\n        \"labourContractorName\": null,\n        \"labourContractorId\": null,\n        \"leaveAfter\": 10\n    },\n    \"userBasicSalary\": 25000,\n    \"houseResidencesAllowance\": 3000,\n    \"dearnessAllowance\": 0,\n    \"conveyance\": 1000,\n    \"allowance\": 1000,\n    \"providentFund\": true,\n    \"employeesInsurance\": true,\n    \"professionalTax\": true,\n    \"salaryType\": \"Monthly\",\n    \"team_master\": true,\n    \"account_master_id\": 43682\n}",
  "phone_number": "+916655665577",
  "pseudonym": "aramduke",
  "reporting_to": 2057.0,
  "role": "Crm Lead",
  "user_id": 2876,
  "user_status": "active"
}

//Key point to look :
"applicantNotes": {\n        \"age\": null,\n        \"gender\": \"\",\n        \"educationLevel\": null,\n        \"noChildren\": null,\n        \"spouseWorkingStatus\": null,\n        \"noOfChildrenAbove18\": null,\n        \"noOfChildrenBelow18\": null,\n        \"employmentStatus\": \"\",\n        \"attendanceAllowance\": 0,\n        \"performanceAllowance\": 0,\n        \"adaitechEmail\": null,\n        \"adaitechPassword\": null,\n        \"gearincEmail\": null,\n        \"payrollFor\": null,\n        \"contractStartDate\": null,\n        \"contractEndDate\": null,\n        \"nricNo\": null,\n        \"taxNo\": null,\n        \"epfNo\": null,\n        \"perksoNo\": null,\n        \"Salutation\": null,\n        \"reportingToName\": \"Aditya Shah\",\n        \"outlierId\": null,\n        \"addressProofUrl\": null,\n        \"appointmentLetterUrl\": null,\n        \"offerLetterUrl\": null,\n        \"pfUanNumber\": null,\n        \"panCardNumber\": null,\n        \"aadhaarCardNumber\": null,\n        \"payRollType\": \"onRoll\",\n        \"labourContractorName\": null,\n        \"labourContractorId\": null,\n        \"leaveAfter\": 10\n    }

//-------------------------------------------------------------------------------------------------------------------------------


////// Team List New response 

{
  "authorisations_json": null,
  "department_id": 854,
  "department_name": "TRAVEL DESK",
  "email": "adineshkumarreddy@velankanigroup.com",
  "full_name": "A Dinesh Kumar Reddy",
  "hierarchy_level": 1,
  "json_notes": "{\n    \"pdf\": \"https://nexcom.ditscentre.in/utils/files/small/download/6965025e001c9ca7eb605961\",\n    \"salary\": null,\n    \"maritalStatus\": null,\n    \"dateOfBirth\": null,\n    \"dateOfJoin\": null,\n    \"accountNumber\": null,\n    \"ifsc\": null,\n    \"bankName\": null,\n    \"esicNumber\": null,\n    \"ppfnumber\": null,\n    \"emergencyContactNumber\": null,\n    \"emergencyContactName\": null,\n    \"photoUrl\": null,\n    \"aadhaarUrl\": null,\n    \"panCardUrl\": null,\n    \"address\": null,\n    \"billingRate\": null,\n    \"relationship\": null,\n    \"city\": null,\n    \"pincode\": null,\n    \"branchId\": 130,\n    \"weeklyOff\": null,\n    \"weeklyWorkingHours\": null,\n    \"noOfPaidLeaves\": null,\n    \"country\": null,\n    \"lastDayOfWorking\": null,\n    \"applicantNotes\": \"{\\\"cosec\\\":{\\\"User ID\\\":\\\"VL0687\\\",\\\"User Name\\\":\\\"A Dinesh Kumar Reddy\\\",\\\"Category Name\\\":\\\"Contract-Adhaan\\\",\\\"Grade Name\\\":\\\"Worker\\\",\\\"Branch Name\\\":\\\"VISPL-TRAVEL DESK\\\",\\\"Department Name\\\":\\\"TRAVEL DESK\\\",\\\"Direct Reporting\\\":\\\"Nagaraj Patel\\\",\\\"Level-1\\\":\\\"Nagaraj Patel\\\",\\\"Direct Reporting ID\\\":null,\\\"Level-1 ID\\\":null}}\",\n    \"userBasicSalary\": null,\n    \"houseResidencesAllowance\": null,\n    \"dearnessAllowance\": null,\n    \"conveyance\": null,\n    \"allowance\": null,\n    \"providentFund\": null,\n    \"employeesInsurance\": null,\n    \"professionalTax\": null,\n    \"salaryType\": null,\n    \"team_master\": true,\n    \"account_master_id\": 46325\n}",
  "phone_number": "9876543210",
  "pseudonym": "adineshkumarreddy",
  "reporting_to": null,
  "role": "Worker",
  "user_id": 3900,
  "user_status": "active"
}


//Key Point to look 
"applicantNotes": \"{\\\"cosec\\\":{\\\"User ID\\\":\\\"VL0687\\\",\\\"User Name\\\":\\\"A Dinesh Kumar Reddy\\\",\\\"Category Name\\\":\\\"Contract-Adhaan\\\",\\\"Grade Name\\\":\\\"Worker\\\",\\\"Branch Name\\\":\\\"VISPL-TRAVEL DESK\\\",\\\"Department Name\\\":\\\"TRAVEL DESK\\\",\\\"Direct Reporting\\\":\\\"Nagaraj Patel\\\",\\\"Level-1\\\":\\\"Nagaraj Patel\\\",\\\"Direct Reporting ID\\\":null,\\\"Level-1 ID\\\":null}}\"




//----------------------------------------------------------------------
// Team update section

// Team update api
url : https://api.thecaoffice.com/team/update


//mandatory fields.
//1.name
//2.phoneNo
//3.role
//4.idDepartment
//5.email
//6.idUser


//Input json
final teamUpdateParam = {
  'idUser': 12345,   //Pass the id of the user whose details are being updated
  'email': "john.doe@company.com",
  'name': "John Doe",
  "idDepartment": 2,
  'role': "Software Engineer",
  'phoneNo': "9876543210",
  'password': "password123",
  "website": "http://company.com",
  "logoUrl": null,
  "companyName": "Tech Solutions Pvt. Ltd.",
  "salary": 50000.0,
  "maritalStatus": "Single",
  "dateOfBirth": "1990-05-15",
  "dateOfJoin": "2022-01-01",
  "accountNumber": "1234567890",
  "ifsc": "ABC1234567",
  "bankName": "Bank of India",
  "esicNumber": "ESIC123456789",
  "ppfnumber": "PPF123456789",
  "emergencyContactNumber": "9123456789",
  "emergencyContactName": "Jane Doe",
  "photoUrl": "http://example.com/photo.jpg",
  "aadhaarUrl": "http://example.com/aadhaar.jpg",
  "panCardUrl": "http://example.com/pan.jpg",
  "billingRate": 2000.0,
  "hierarchy": 1,
  'address': "1234, XYZ Street, City, State",
  "city": "Mumbai",
  "pincode": "400001",
  "relationship": "Single",
  "branchId": 1,
  "weeklyOff": "Saturday, Sunday",
  "weeklyWorkingHours": 40,
  "noOfPaidLeaves": 15,
  "country": "India",
  "lastDayOfWorking": "2024-12-31",
  "reportingTo": 67890,
  "userBasicSalary": 40000.0,
  "houseResidencesAllowance": 5000.0,
  "dearnessAllowance": 3000.0,
  "conveyance": 2000.0,
  "allowance": 1500.0,
  "providentFund": true,
  "employeesInsurance": true,
  "professionalTax": true,
  "salaryType": "Monthly",
  
  // Adding the applicantNotesParam here
  "applicantNotes": {
    "age": 30,
    "gender": "Male",
    "educationLevel": "Bachelor's",
    "noChildren": 2,
    "spouseWorkingStatus": "Employed",
    "noOfChildrenAbove18": "1",
    "noOfChildrenBelow18": "1",
    "employmentStatus": "Full-time",
    "attendanceAllowance": 100.0,
    "performanceAllowance": 200.0,
    "adaitechEmail": "applicant@adaitech.com",
    "adaitechPassword": "password123",
    "gearincEmail": "applicant@gearinc.com",
    "payrollFor": "Finance",
    "contractStartDate": "2023-01-01",
    "contractEndDate": "2024-01-01",
    "nricNo": "S1234567A",
    "taxNo": "T1234567B",
    "epfNo": "EPF1234567",
    "perksoNo": "PRK1234567",
    "Salutation": "Mr.",
    "reportingToName": "John Doe",
    "outlierId": "OUT12345",
    "addressProofUrl": "http://example.com/address-proof.jpg",
    "appointmentLetterUrl": "http://example.com/appointment-letter.pdf",
    "offerLetterUrl": "http://example.com/offer-letter.pdf",
    "pfUanNumber": "UAN123456789",
    "panCardNumber": "ABCDE1234F",
    "aadhaarCardNumber": "1234 5678 9123",
    "payRollType": "Salaried",
    "labourContractorName": null,
    "labourContractorId": null,
    "leaveAfter": 12,
  }
};







