diff --git a/attendance/__init__.py b/attendance/__init__.py index aaa2cd25d..e69de29bb 100644 --- a/attendance/__init__.py +++ b/attendance/__init__.py @@ -1 +0,0 @@ -from attendance import scheduler diff --git a/attendance/scheduler.py b/attendance/scheduler.py deleted file mode 100644 index 402ce5e0d..000000000 --- a/attendance/scheduler.py +++ /dev/null @@ -1,50 +0,0 @@ -import datetime -from datetime import datetime - -from apscheduler.schedulers.background import BackgroundScheduler -from django.utils import timezone as django_timezone - - -def auto_check_out(): - - from attendance.models import AttendanceActivity - from attendance.views.clock_in_out import clock_out_attendance_and_activity - from base.models import EmployeeShiftSchedule - from employee.models import Employee - - try: - today = django_timezone.make_aware(datetime.now()) - shift_schedules = EmployeeShiftSchedule.objects.all() - employees = Employee.objects.all() - for employee in employees: - work_info = getattr(employee, "employee_work_info", None) - shift_id = getattr(work_info, "shift_id", None) - shift_schedule = shift_schedules.filter( - day__day=today.strftime("%A").lower(), shift_id=shift_id - ).first() - attendance_activity = AttendanceActivity.objects.filter( - employee_id=employee, clock_out__isnull=True - ).first() - if ( - shift_schedule - and attendance_activity - and attendance_activity.attendance_date < today.date() - ): - if ( - not attendance_activity.clock_out - and shift_schedule.start_time <= today.time() - ): - attendance = clock_out_attendance_and_activity( - employee=employee, - date_today=today.date(), - now=today.time().strftime("%H:%M"), - out_datetime=today, - ) - - except: - pass - - -scheduler = BackgroundScheduler() -scheduler.add_job(auto_check_out, "interval", seconds=30) -scheduler.start()