> ## 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.

# Sale order loading

> Loading existing Odoo sale orders into POS orders for fulfillment.

Sale orders created in Odoo's Sales module can be loaded into the POS for fulfillment. This bridges the back-office order flow with the restaurant POS.

## API endpoints

| Endpoint                            | Purpose                                           |
| ----------------------------------- | ------------------------------------------------- |
| `POST /pos-api/v1/sale-orders/list` | List sale orders for a customer (by `partner_id`) |
| `POST /pos-api/v1/sale-orders/load` | Load a sale order into POS-compatible format      |

## Loading flow

<Steps>
  <Step title="Select customer">
    A customer must be assigned to the order. The system fetches their pending sale orders.
  </Step>

  <Step title="Pick sale order">
    The sale order picker displays pending orders with name, date, and total amount. The user selects one.
  </Step>

  <Step title="Load into POS">
    Calls `/pos-api/v1/sale-orders/load` with the sale order ID and POS config ID. Returns order lines with product, quantity, price, discount, and tax information.
  </Step>

  <Step title="Add to current order">
    The loaded lines are added to the active POS order. Products are matched by ID and taxes are mapped to the POS tax configuration.
  </Step>
</Steps>

## Response format

The `loadSaleOrder` endpoint returns:

```typescript theme={null}
interface LoadSaleOrderResult {
  sale_order: {
    id: number;
    name: string;
  };
  lines: SaleOrderLine[];
}

interface SaleOrderLine {
  productId: number;
  productName: string;
  quantity: number;
  priceUnit: number;
  discount: number;
  taxIds: number[];
}
```

## Error handling

The API client uses a custom `SaleOrderLoadError` class that includes an error code and details, handling both API-level errors and validation failures (e.g., product not found in POS catalog).

## Source files

```
src/domain/sale-orders/api.ts      # API client
src/domain/sale-orders/models.ts   # Type definitions
```
