Work Orders (SheetProject) are the primary billing documents in Mantis. They consolidate rental charges, maintenance services, custody chains, and shipping guides into a single billable document for invoicing.
A SheetProject represents a billing period for a specific project, typically covering a date range (e.g., monthly billing). It aggregates all billable activities including:
Equipment rentals (daily rates)
Maintenance services
Waste disposal (custody chains)
Logistics (shipping guides)
class SheetProject(BaseModel): id = AutoField(primary_key=True) project = ForeignKey(Project, on_delete=PROTECT) issue_date = DateField() period_start = DateField() period_end = DateField() status = CharField( choices=[ ('IN_PROGRESS', 'EN EJECUCIÓN'), ('LIQUIDATED', 'LIQUIDADO'), ('INVOICED', 'FACTURADO'), ('CANCELLED', 'CANCELADO') ], default='IN_PROGRESS' ) series_code = CharField(max_length=50, default='PSL-PS-0000-0000') service_type = CharField( choices=[ ('ALQUILER', 'ALQUILER'), ('MANTENIMIENTO', 'MANTENIMIENTO'), ('ALQUILER Y MANTENIMIENTO', 'ALQUILER Y MANTENIMIENTO') ], default='ALQUILER Y MANTENIMIENTO' )
# Calculate line totalline_total = quantity * unit_price# Sum all line totals for subtotalsubtotal = sum(detail.total_line for detail in sheet_details)# Apply 15% IVA taxtax_amount = subtotal * 0.15# Calculate final totaltotal = subtotal + tax_amount
from projects.models import Project, SheetProjectfrom datetime import date# Create new work order for billing periodsheet = SheetProject.objects.create( project=project, series_code=SheetProject.get_next_series_code(), issue_date=date.today(), period_start=date(2026, 3, 1), period_end=date(2026, 3, 31), service_type='ALQUILER Y MANTENIMIENTO', status='IN_PROGRESS')
# Mark as liquidated (ready for invoicing)sheet.status = 'LIQUIDATED'sheet.is_closed = Truesheet.save()# After invoicingsheet.status = 'INVOICED'sheet.invoice_reference = 'INV-2026-0123'sheet.invoice_file = invoice_pdf_filesheet.save()