> ## Documentation Index
> Fetch the complete documentation index at: https://docs.laportenard.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Order lifecycle

> How orders move through states and kitchen statuses.

## Order modes

Orders operate in one of three modes:

| Mode      | Purpose              |
| --------- | -------------------- |
| `order`   | Regular sale         |
| `return`  | Refund / credit note |
| `payment` | Invoice collection   |

## Order states

```
  ┌──────┐    ┌─────────┐    ┌──────────┐    ┌──────┐    ┌───────────┐
  │ idle │───►│ editing │───►│ checkout │───►│ paid │───►│ finalized │
  └──────┘    └─────────┘    └──────────┘    └──────┘    └───────────┘
```

<Steps>
  <Step title="Idle">
    Order created but no items added.
  </Step>

  <Step title="Editing">
    Items being added or modified by the user.
  </Step>

  <Step title="Checkout">
    Order is locked for payment processing.
  </Step>

  <Step title="Paid">
    Payment received, waiting for finalization.
  </Step>

  <Step title="Finalized">
    Order synced to Odoo, invoice created, NCF reserved.
  </Step>
</Steps>

## Kitchen status

Kitchen status tracks the order's progression through the kitchen:

```
  ┌──────┐    ┌──────┐    ┌─────────┐    ┌──────┐
  │ open │───►│ sent │───►│ changed │───►│ paid │
  └──────┘    └──────┘    └─────────┘    └──────┘
```

| Status    | Meaning                                          |
| --------- | ------------------------------------------------ |
| `open`    | Order has items not yet sent to kitchen          |
| `sent`    | All items sent to kitchen                        |
| `changed` | Post-send edits were made (items added/modified) |
| `paid`    | Order has been paid                              |

<Note>
  Editing an order after it has been sent to the kitchen flips the status from `sent` to `changed`, signaling the kitchen that there are updates.
</Note>

## Idempotent creation

Order creation is idempotent — sending the same `pos_reference` returns the existing order rather than creating a duplicate. This is critical for reliability during network issues and sync retries.

## Void flow

Voiding follows different paths depending on whether items have been sent to the kitchen:

* **Pre-send items** — Removed directly, no void record needed
* **Post-send items** — Full void flow: reason selection → optional manager override → void record created with audit trail
