Overview
Monthly Reports (ReporteMensual) serve as the container for all production activities in a specific month for a work order. They aggregate daily operational reports, production volumes, and evidence files for billing and auditing purposes.Each work order can have only one monthly report per month, enforced by a unique constraint.
ReporteMensual Model
Field Descriptions
Parent work order for this monthly reportRelationship: One work order can have many monthly reports (one per month)
Month number (1-12)Validation: Must be between 1 and 12
Year (e.g., 2025)Format: Four-digit year
Google Drive link to consolidated evidence folderUsage: Points to monthly photo gallery, reports, and documentation
Closure status of the monthly reportConstraint:
nivel_afectacion=5 (monthly closure statuses)Common Values:- Abierto (Open)
- En Revisión (Under Review)
- Cerrado (Closed)
- Facturado (Invoiced)
Timestamp when monthly report was first created
Timestamp of last modification
Monthly Report Lifecycle
Automatic Creation
Monthly report is automatically created when first daily report or production entry is recorded
Data Accumulation
Throughout the month:
- Daily operational reports are added
- Production volumes are recorded
- GPU evidence is uploaded
Saving Evidence Links
The system provides an endpoint to attach Google Drive evidence to monthly reports.Related Data Structures
Child Relationships
Monthly reports have two primary child relationships:- Daily Reports
- Production Records
Monthly Closure Workflow
Pre-Closure Checklist
Data Completeness
Data Completeness
- All working days have daily operational reports
- Production volumes entered for all active budget line items
- GPU evidence uploaded for all C-2/C-3 production
- No pending validation errors or excess flags unresolved
Evidence Management
Evidence Management
- Monthly photo gallery organized in Google Drive
- Daily reports compiled into PDF or spreadsheet
- Special incident reports attached
- Drive folder link tested and accessible
Financial Verification
Financial Verification
- Production totals match daily reported volumes
- No unauthorized production exceeding contracted quantities
- Time classification (TE vs CMA) correctly assigned
- Unit prices current and accurate
Approval Chain
Approval Chain
- Site supervisor reviewed and approved
- Operations manager validated data
- Administrative team confirmed for billing
- Status changed to “Cerrado”
Querying Monthly Reports
Get or Create Pattern
The system uses Django’sget_or_create pattern extensively:
This pattern ensures a monthly report always exists before adding child records (daily reports or production), preventing orphaned data.
Filtering by Status
Integration with Production Grid
The monthly report archives link is displayed in the production grid header:
API Endpoint Reference
POST /produccion/guardar_archivo_mensual/
POST /produccion/guardar_archivo_mensual/
Saves or updates the Google Drive evidence link for a monthly report.Request Body:Response:Error Response:
Database Constraints
Audit Trail
Monthly reports maintain automatic audit timestamps:fecha_creacion
Automatically set when record is first createdUsage: Track when month was opened
fecha_actualizacion
Automatically updated on every saveUsage: Track last modification for audit trails
Best Practices
Regular Status Updates
Update closure status as month progresses:
- Days 1-25: “Abierto”
- Days 26-28: “En Revisión”
- Day 30+: “Cerrado”
Troubleshooting
IntegrityError: Duplicate Monthly Report
IntegrityError: Duplicate Monthly Report
Cause: Attempting to create multiple monthly reports for same OT and month.Solution: Always use
get_or_create() instead of create().Drive Link Returns 403 Forbidden
Drive Link Returns 403 Forbidden
Cause: Google Drive folder permissions not set to “Anyone with link can view”.Solution:
- Open folder in Google Drive
- Click Share button
- Change to “Anyone with the link”
- Set permission to “Viewer”
Monthly Report Shows Wrong Total
Monthly Report Shows Wrong Total
Cause: Production records exist from previous status change or deleted line items.Solution: Filter by
id_partida_anexo__importacion_anexo__es_activo=True to exclude deprecated line items.Related Topics
Daily Reports
Learn about daily operational status tracking
Production Overview
Return to production tracking overview