Automated Action 1b9ddb4750 Implement comprehensive HR Management Backend System
- FastAPI application with JWT authentication and role-based access control
- Complete employee management with CRUD operations
- Department management with manager assignments
- Leave management system with approval workflow
- Payroll processing with overtime and deductions calculation
- Attendance tracking with clock in/out functionality
- SQLite database with proper migrations using Alembic
- Role-based permissions (Admin, HR Manager, Manager, Employee)
- Comprehensive API documentation and health checks
- CORS enabled for cross-origin requests

Environment Variables Required:
- SECRET_KEY: JWT secret key for token signing

Features implemented:
- User registration and authentication
- Employee profile management
- Department hierarchy management
- Leave request creation and approval
- Payroll record processing
- Daily attendance tracking
- Hours calculation for attendance
- Proper error handling and validation
2025-06-23 10:06:23 +00:00

40 lines
1.4 KiB
Python

from sqlalchemy import Column, Integer, DateTime, ForeignKey, Date, Text, Enum
from sqlalchemy.sql import func
from sqlalchemy.orm import relationship
from app.db.base import Base
import enum
class LeaveType(enum.Enum):
VACATION = "vacation"
SICK = "sick"
PERSONAL = "personal"
MATERNITY = "maternity"
PATERNITY = "paternity"
EMERGENCY = "emergency"
class LeaveStatus(enum.Enum):
PENDING = "pending"
APPROVED = "approved"
REJECTED = "rejected"
CANCELLED = "cancelled"
class LeaveRequest(Base):
__tablename__ = "leave_requests"
id = Column(Integer, primary_key=True, index=True)
employee_id = Column(Integer, ForeignKey("employees.id"), nullable=False)
leave_type = Column(Enum(LeaveType), nullable=False)
start_date = Column(Date, nullable=False)
end_date = Column(Date, nullable=False)
days_requested = Column(Integer, nullable=False)
reason = Column(Text)
status = Column(Enum(LeaveStatus), default=LeaveStatus.PENDING)
approved_by = Column(Integer, ForeignKey("users.id"))
approved_at = Column(DateTime(timezone=True))
comments = Column(Text)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
# Relationships
employee = relationship("Employee", back_populates="leave_requests")
approver = relationship("User", foreign_keys=[approved_by])