import os
import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.development")
django.setup()

from apps.accounts.models import User
from apps.hr.services.attendance import AttendanceService

hr_user = User.objects.filter(email="hr@example.com").first()
print(f"Testing check-in for {hr_user.email}...")

employee = getattr(hr_user, "employee_profile", None)
if not employee:
    print("Error: No employee profile found!")
else:
    try:
        attendance = AttendanceService.check_in(
            employee=employee,
            mode_attempted="MANUAL",
            ip_address="127.0.0.1",
            device_info="Test Script"
        )
        print("Success:", attendance)
    except Exception as e:
        import traceback
        traceback.print_exc()
