def post(self): data = EmployeeLogin.parse.parse_args() employee = AuthenticationModel.find_by_username(data["username"]) # if employee.isAuthenticate: # return { # "success": False, # "error": "You Are Already LoggedIn In Another System Please Logout there.." # } if employee and safe_str_cmp(data["password"], employee.password): # chnage isauthenticate value employee.isAuthenticate = True Attend = AttendanceModel( employee.id, datetime.now().strftime("%H:%M:%S"), datetime.today().strftime("%d/%m/%Y"), ) Attend.save_to_db() # print(employee.id) return { "access_token": create_access_token(identity=employee.id, expires_delta=False), "role": employee.role, "success": True, "authenticate": employee.isAuthenticate, } return {"error": "Username or password incorrent", "success": False}
def post(self): data = Salary.parse.parse_args() employee = AuthenticationModel.find_by_username(data['username']) if employee: basic = GradeModel.query.filter_by(emp_id=employee.id).order_by( GradeModel.emp_id.desc()).first().basic netamount = basic * HRA + basic * DA + basic * TA + basic salary = SalaryModel(data['username'], data['month'], netamount) salary.save_to_db() # salary get mail msg = Message('Salary credited!', recipients=[employee.email]) msg.body = ''' Hello ''' + data['username'].split('.')[0] + ''', Your ''' + data[ 'month'] + ''' month salary is credited. You can download salary slip from HRMS portal.\n If you have any queries, please feel free to contact the Human Resources Department. We look forward to your success in the company\n Thanks & Regards, Name of hr HR Executive Direct: +91 6353235503 | W: www.lanetteam.com 406, Luxuria Business Hub, Nr. VR Mall, Surat, Gujarat - 395007 Ground Floor, I.T.P.I Building, Beside Celebration Mall, Bhuwana, Udaipur, Rajasthan - 313001''' mail.send(msg) return {"Status": "Success"} return {"status": "404/Not Found"}
def delete(self): parse = reqparse.RequestParser() parse.add_argument('username', type=str, required=True, help='username is required') data = parse.parse_args() employee = AuthenticationModel.find_by_username(data['username']) if employee: employee.delete_from_db() return {"status": 200, "message": "Account Deleted"} return { "status": 404, "NotFoundError": "Given Username data not Found.." }
def post(self): data = JoiningDetails.parse.parse_args() employee = AuthenticationModel.find_by_username(data["username"]) if employee: joining_date = datetime.strptime(data["joining_date"], "%d %B %Y") joining_details = JoiningDetailsModel( employee.id, joining_date, ) joining_details.save_to_db() # here grade details grade = GradeModel(employee.id, data["grade"], data["joining_date"], data["basic"]) grade.save_to_db() # here annual leave is set annual_leave = Annual_Leave(employee.id) annual_leave.save_to_db() return {"status": True} else: return {"error": data["username"] + "not Found"}
def post(self): data = EmployeeRegister.parse.parse_args() employee = AuthenticationModel.find_by_username(data["username"]) if employee: return { "AlreadyExistsError": { "status": False, "error": "Username already exists", } } joindate = date.fromisoformat(data['joiningdate'].split('T')[0]) employee = AuthenticationModel(data['username'], data['password'], data['role'], data['email'], joindate) employee.save_to_db() # add joining details joiningdetails = JoiningDetailsModel(employee.id, joindate) print(joiningdetails.json()) joiningdetails.save_to_db() # fetch basic for particular designation des = DesignationModel.find_by_designation(data['designation']) print(des.json()) # add employee level grade grade = GradeModel(employee.id, data['designation'], joindate, des.basic) grade.save_to_db() print(grade.json()) # annual leave annual_leave = Annual_Leave(employee.id) annual_leave.save_to_db() # credential sent to user via email msg = Message('Welcome to LaNet Teams!', recipients=[data['email']]) msg.body = ''' Hello ''' + data['username'].split('.')[0] + ''', We are delighted to have you among us as a part of La net team software solutions Pvt. Ltd. On behalf of all the members and the management, we would like to extend our warmest welcome and good wishes! Your Joining date will be ''' + data[ 'joiningdate'].split('T')[0] + ''' .\n Here your credential for Company HRMS System. username = ''' + data['username'] + ''' password = ''' + data['password'] + ''' HRMS Link = 'http://127.0.0.1:3000/' If you have any queries, please feel free to contact the Human Resources Department. We look forward to your success in the company\n Thanks & Regards, Name of hr HR Executive Direct: +91 6353235503 | W: www.lanetteam.com 406, Luxuria Business Hub, Nr. VR Mall, Surat, Gujarat - 395007 Ground Floor, I.T.P.I Building, Beside Celebration Mall, Bhuwana, Udaipur, Rajasthan - 313001''' mail.send(msg) return { "success": True, "message": "Employee Registerd", "id": employee.id, "Employee": employee.json() }