05
Mechanic assignment and scheduling engine
This dropdown is the centrepiece of the scheduler. When assigning (or reassigning) a mechanic to an order, the system computes that professional’s next available slot within working hours and chains the new job right behind their current queue, with no overlaps possible by construction. The result — start date, end date and estimated date — is audited and generates a notification to the mechanic with their start time.
The order state machine follows the Created → Assigned → In Progress → Finished → Invoiced flow, with two backward transitions deliberately allowed: from Finished to In Progress, to reopen a job if a defect is found after closing, and from In Progress to Assigned, to correct an assignment. Invoiced is the only terminal state. Four business guards protect the flow: an unfinished order cannot be invoiced, an order admits a single invoice, and lines of an already closed order cannot be modified.
Choosing "Invoiced" in the dropdown triggers the creation of the corresponding invoice, and it is the invoice that drags the order into that state — the state is always the consequence of a real business fact, never a direct, isolated change.
The counters (Pending, In Shop, Finished) and the filters by status, mechanic and customer are resolved over the data already loaded on the client, with chained signals — instant filtering, with no round trip to the server.