Skip to content
Pilot phase – not yet a commercial offer. The first 500 users join free of charge and share feedback to help us improve. The first pricing round starts in May 2027
Firmspace
Back to blog

Seven Order Statuses and One Way Back: What the AI May Change in an Order — and What It Cannot Undo

A status looks like a label on a card. On a sales order it is closer to a promise: whether the goods are reserved for this customer, whether they left the warehouse, whether the money arrived, and whether the story is finished. Firmspace keeps those promises in a small state machine — seven statuses and a fixed list of moves between them. The assistant can change the status, and that is exactly why the machine matters: the same gate that stops a person from turning a shipped order back into a draft also stops a robot.

The seven statuses are draft, confirmed, fulfilled, invoiced, paid, closed and cancelled. A draft exists but is not promised yet. Confirmed means the firm has accepted the order. Fulfilled means the goods were handed over and the warehouse was written off. Invoiced means a customer invoice exists for the order. Paid means the money arrived. Closed ends the story after delivery or payment; cancelled ends it without them. None of these words describes a deal stage or a delivery note — they describe the order document itself.

The allowed moves are short and mostly one-directional. A draft may become confirmed, invoiced, paid or cancelled. A confirmed order may go back to draft, or forward to fulfilled, invoiced, paid or cancelled. A fulfilled order may be invoiced, paid, closed or cancelled, but never returned to draft. An invoiced order may become fulfilled, paid, closed or cancelled. A paid order may only become fulfilled or closed — there is no way to cancel it. Closed and cancelled have no exits at all. Two doors look odd until one thinks about prepayment: a draft may jump straight to paid, and a paid order may still be fulfilled.

The table was not always there. In an earlier version any status could be placed on any other: a delivered order could be moved back to draft, the warehouse was not replenished, and a cancellation after delivery did not bring the goods back. The allowed-transition map closed those holes. It lives in one function, and the same function serves the button in the interface, the API route and the assistant's tool. A guardrail that exists in three copies is not a guardrail; this one has a single copy.

Fulfilled is the status that touches the physical world. The transition runs inside a database transaction: first the order's reservation, if any, is released; then the code reads the stock journal for this order, adds up the sales and subtracts the returns, and writes off only the quantity that has not been written off yet; finally the status changes. If one step fails, none of them remains. That is why the journal, not the status, is the source of truth for what actually left the warehouse.

Reservation depends on the road that created the order. An order created from a deal reserves stock immediately: the quantity stays physically on the shelf but is no longer available, because a movement with the reason reserve reduces the balance. An order created from an accepted quote does not reserve anything — it appears as a draft and the stock is untouched until it is fulfilled. Two orders can look identical on the screen and still behave differently, which is worth knowing before promising a delivery date.

Shipping does not refuse when stock is short. The comment in the code is explicit: a partial shortage does not block the process, it simply goes into minus, so that a real shortage does not stop the work; the negative balance is visible on the dashboard. The assistant can therefore mark an order fulfilled even when the warehouse cannot cover it. The minus is the alarm, not a locked door — and somebody still has to read it.

Cancelling after shipping walks the same journal backwards. The code sums what was sold on this order, subtracts what was already returned, and writes the difference back to the warehouse with the reason return. A reservation that still exists is released first. Repeating the operation does not add goods twice, because a cancelled order has no exit and a repeated request for the same status changes nothing. The goods come back exactly once, in the quantity the journal recorded.

The same idempotency protects shipping. If somebody presses fulfilled twice, the second run sees that the journal already contains the sale and writes off only the remainder — zero. The status route also compares the target with the current status and returns without an event when they are equal. These are small details, but they are the difference between a warehouse that can be trusted and one that needs a monthly correction.

The assistant reaches this machine through one tool, update_order_status. It takes an order number and a status. The tool description names confirmed, fulfilled, invoiced, closed and cancelled; the parameter schema accepts all seven values, and the shared function rejects anything that is unknown or not allowed from the current status. In the ordinary chat the change waits for a confirmation card. A robot working in automatic mode can act without that card, which is a reason to decide in advance which statuses a robot may touch at all.

There is one road around the table. When an order is turned into an invoice, the invoicing action does not call the status function: it checks that the order has line items and no invoice yet, creates the invoice, and writes the status invoiced directly. In the code reviewed for this article that write does not consult the current status, so a cancelled order that still has lines would not be stopped by the table on this path. It is a narrow hole, but it is the kind of detail that makes the sentence “the status is validated” incomplete.

Money also moves the order, but only at the end. When a customer invoice is paid in full, the payment code calls the status function and asks for paid; the move is allowed from draft, confirmed, fulfilled or invoiced, and a closed or cancelled order is left alone. A partial payment does not change the order status. And because a paid order cannot be cancelled, a refund is not an order-status operation: the document chain has to be corrected in accounting, not by dragging the card back.

Every change leaves two traces. The automation event order_status is emitted with the order id, number, new status and customer name, so a rule can react — send a message, create a task, notify the manager. A feed entry is written to the deal, contact and company cards. What is not written is an audit-log record for the status change itself, unlike an invoice edit or a deletion. The feed says what happened; it does not say who pressed the button.

That asymmetry defines a sensible delegation policy. A robot may confirm an order, prepare an invoice, mark a delivery or move an order to paid after a confirmed payment — those steps are either reversible or backed by a document. A robot should not be the one who decides that an order is closed or cancelled, because both are one-way doors. And the “pay everything” style shortcuts deserve a human look before they run, even when the assistant offers them in one line.

A practical routine is short. Before fulfilling, look at the stock column and at the reservation; after fulfilling, check that a delivery note exists. Cancel before the money arrives, not after. Do not use the status as a note — a comment belongs in the order notes or the feed. When a status looks impossible, read the table instead of looking for a hidden button: the refusal is the feature, and the message names both the current and the requested status.

What this article does not claim: it gives no statistics about how often orders are cancelled or how much stock goes negative, no legal or tax interpretation of a delivery, and no promise that every screen behaves exactly like the code reviewed here. It describes the state machine and the routes that use it in the Firmspace codebase at the time of writing. The useful part is smaller and firmer: seven statuses, a fixed map, one transaction around the warehouse, and an assistant that must respect the same map as everyone else — except on the one path that writes its own value.

Let us automate your next process together.

Describe a recurring workflow to us. Together we will check whether and how it can be automated sensibly.