diff --git a/backend/app/main.py b/backend/app/main.py index e3bcd7f..52d8b77 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -886,8 +886,12 @@ def create_inspection( if not checklist: raise HTTPException(status_code=404, detail="Checklist no encontrado") + # Crear inspección con el employee_code del mecánico actual + inspection_data = inspection.dict() + inspection_data['mechanic_employee_code'] = current_user.employee_code # Agregar código de operario automáticamente + db_inspection = models.Inspection( - **inspection.dict(), + **inspection_data, mechanic_id=current_user.id, max_score=checklist.max_score ) diff --git a/backend/app/models.py b/backend/app/models.py index 059cb66..8072c79 100644 --- a/backend/app/models.py +++ b/backend/app/models.py @@ -110,6 +110,9 @@ class Inspection(Base): vehicle_km = Column(Integer) client_name = Column(String(200)) + # Datos del mecánico + mechanic_employee_code = Column(String(50)) # Código de operario del mecánico + # Scoring score = Column(Integer, default=0) max_score = Column(Integer, default=0) diff --git a/backend/app/schemas.py b/backend/app/schemas.py index 504ccc4..12d5a42 100644 --- a/backend/app/schemas.py +++ b/backend/app/schemas.py @@ -152,6 +152,7 @@ class InspectionBase(BaseModel): vehicle_model: Optional[str] = None vehicle_km: Optional[int] = None client_name: Optional[str] = None + mechanic_employee_code: Optional[str] = None class InspectionCreate(InspectionBase): checklist_id: int @@ -167,6 +168,7 @@ class Inspection(InspectionBase): id: int checklist_id: int mechanic_id: int + mechanic_employee_code: Optional[str] = None score: int max_score: int percentage: float diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 19181d7..abe9912 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -3461,6 +3461,19 @@ function InspectionModal({ checklist, user, onClose, onComplete }) { /> +
+ + +
+