Overview
The Close Project API allows you to validate whether a project can be closed and execute the closure process. When a project is closed, all active equipment is released back to available inventory, associated services are retired, and the project is marked as closed.Endpoints
Validate Project Closure
Check if a project can be closed and get a list of any issues that need to be resolved.Path Parameters
ID of the project to validate
Response
Indicates if the validation request was successful
Whether the project can be closed (true if no errors)
Overall status message
Array of alert objects with validation results
Example Request
Example Response - Can Close
Example Response - Cannot Close (Errors)
Example Response - Already Closed
Close Project
Execute the project closure process, releasing all resources and marking the project as closed.Path Parameters
ID of the project to close
Response
Whether the closure was successful
Success or error message
List of equipment that was released
Number of equipment items released
Validation alerts from the closure process
Example Request
Example Response - Success
Example Response - Validation Error
What Happens When a Project Closes
When you close a project, the system performs the following actions automatically:1. Equipment Release
All active equipment (type_resource="EQUIPO") that is not already retired is released:
-
ProjectResourceItem changes:
is_retired→Trueretirement_date→ Current dateretirement_reason→ “Cierre de proyecto #”
-
ResourceItem (physical equipment) changes:
stst_status_disponibility→"DISPONIBLE"stst_current_location→Nonestst_current_project_id→Nonestst_commitment_date→Nonestst_release_date→None
2. Service Retirement
All services linked to equipment are retired:- Services linked via
physical_equipment_codeare retired - Standalone services (not linked to equipment) are also retired
- ProjectResourceItem changes:
is_retired→Trueretirement_date→ Current dateretirement_reason→ “Cierre de proyecto #“
3. Project Closure
The project itself is marked as closed:- Project changes:
is_closed→Trueend_date→ Set to current date if not already set
Validation Rules
The following validations are performed before a project can be closed:Error-Level Validations (Must Pass)
Condition: Any work sheet (planilla) with
status="IN_PROGRESS"Resolution: Liquidate or cancel all in-progress work sheets before closing the project.Example: “La planilla #125 (WS-2025-0045) está en ejecución. Debe liquidarla o cancelarla antes de cerrar el proyecto.”Warning-Level Validations (Recommended)
Condition: Work sheets that are liquidated but not closed (
is_closed=False, status≠CANCELLED)Resolution: Review and close all work sheets. This doesn’t block closure but should be addressed.Example: “La planilla #122 (WS-2025-0042) no está cerrada (Estado: Liquidada).”Informational Messages
Lists all equipment that will be released when the project closes.Example: “Se liberarán 3 equipo(s) al cerrar el proyecto: BS-001 - Batería Sanitaria Hombre, LV-002 - Lavamanos, TQ-005 - Tanque de Agua.”
Indicates how many service entries will be retired.Example: “Se retirarán 3 servicio(s) activo(s) al cerrar el proyecto.”
Shown when project is ready to close with no warnings or errors.Example: “El proyecto está listo para cerrarse. No se encontraron impedimentos.”
Error Codes
Validation or closure completed successfully
- Project is already closed
- Validation errors prevent closure (work sheets in progress)
- Project not found
- Project is inactive (
is_active=False) - Project is soft-deleted (
is_deleted=True)
Unexpected error during validation or closure (check server logs)
Workflow Example
Here’s a typical workflow for closing a project:Step 1: Validate the Project
error type alerts.
Step 2: Resolve Any Errors
If there are work sheets in progress:- Complete and liquidate them
- Or cancel them if they’re no longer needed
Step 3: Review Warnings
If there are open work sheets:- Close them properly
- Or document why they remain open
Step 4: Execute Closure
Step 5: Verify Closure
Check that:- Project
is_closedisTrue - Equipment status is back to
DISPONIBLE - All project resources are marked as
is_retired=True
Related Endpoints
These endpoints are commonly used together with project closure:Project Resources
View all resources assigned to a project before closing
Work Sheets
Manage work sheets that must be completed before closure
Release Resources
Manually release specific resources without closing the project
Equipment Availability
Check which equipment becomes available after closure
Best Practices
Validate Before Closing
Always call the GET endpoint first to validate the project state and identify any issues before attempting to close.
Handle Work Sheets First
Ensure all work sheets are properly liquidated and closed. This is the most common reason projects cannot be closed.
Review Equipment Status
After closure, verify that equipment has been properly released and is showing as available for new projects.
Document Closure Reason
While not captured by the API, maintain external documentation of why and when projects were closed for audit purposes.
Preserve Historical Data
The system uses soft deletion and retirement flags to preserve all historical data. Never attempt to bypass this by deleting records directly.
Handle Services Automatically
Don’t manually release services before closing - they’re automatically handled during the closure process.
Technical Notes
Transaction Safety
The closure endpoint uses database transactions to ensure atomicity. If any step fails, all changes are rolled back.Related Resources
When equipment is released:- The system identifies related services by matching
physical_equipment_code - Both the equipment’s resource ID and its
physical_equipment_codeare checked - All matching services are automatically retired
Soft Delete Pattern
Mantis uses a soft delete pattern for audit trail preservation:- Records are marked
is_deleted=Trueinstead of being removed - Resources are marked
is_retired=Truewhen released - Project closure sets
is_closed=True
Date Handling
- If
end_dateis not set on the project, it’s automatically set to the current date during closure - All retirement dates use the current date at time of closure
- Timezone handling uses Django’s
timezone.now().date()for consistency