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

# Sales Orders

> Create, track, and manage client sales orders from draft to delivery

# Sales Orders

<Info>
  **Status:** Shipped\
  **Linear:** VM-42\
  **Module:** Sales & Commercial
</Info>

## Overview

The Sales Orders module tracks client orders from initial draft through production to final delivery. Each order links to a client, style, and production order, creating a complete chain from commercial to manufacturing.

## User Stories

| ID   | Story                                                                                    | Priority | Status     |
| ---- | ---------------------------------------------------------------------------------------- | -------- | ---------- |
| SO-1 | Create new sales order with client, style, quantities per size/color, and ETD            | P0       | ✅ Shipped  |
| SO-2 | List all orders with filters (status, client, date range) and search by SO#              | P0       | ✅ Shipped  |
| SO-3 | View order details including line items, version history, and linked POs                 | P0       | ✅ Shipped  |
| SO-4 | Update an order (creates a new version for audit trail)                                  | P0       | ✅ Shipped  |
| SO-5 | Change order status: Draft → Submitted → Confirmed → In Production → Shipped → Completed | P0       | ✅ Shipped  |
| SO-6 | Duplicate an existing order as a template for repeat clients                             | P1       | ✅ Shipped  |
| SO-7 | Attach files (client PO, tech pack PDFs) to an order                                     | P1       | ✅ Shipped  |
| SO-8 | Client portal view (external buyers see own orders)                                      | P2       | 🟡 Backlog |

## Status Workflow

```text theme={null}
Draft -> Submitted -> Confirmed -> In Production -> Shipped -> Completed
```

## Screenshots

<Note>
  Screenshots to be added by Thai
</Note>

## API Reference

### Endpoints

| Method | Path                                  | Description             |
| ------ | ------------------------------------- | ----------------------- |
| GET    | `/api/v1/sales-orders`                | List all sales orders   |
| POST   | `/api/v1/sales-orders`                | Create new sales order  |
| GET    | `/api/v1/sales-orders/{id}`           | Get sales order details |
| PUT    | `/api/v1/sales-orders/{id}`           | Update sales order      |
| DELETE | `/api/v1/sales-orders/{id}`           | Delete sales order      |
| POST   | `/api/v1/sales-orders/{id}/duplicate` | Duplicate as template   |

## Qase Test Coverage

<Note>
  Test results pulled from Qase. Run `npx bru run tests/api/sales-orders --env staging` to execute.
</Note>

| Test Case          | Status               | Last Run |
| ------------------ | -------------------- | -------- |
| Create sales order | 🟡 Pending Qase sync | —        |
| Update sales order | 🟡 Pending Qase sync | —        |
| Filter by status   | 🟡 Pending Qase sync | —        |
| Duplicate order    | 🟡 Pending Qase sync | —        |
| File attachment    | 🟡 Pending Qase sync | —        |

## Related Features

* [Production Orders](/features/detail/production-orders) - Manufacturing linked to sales orders
* [Purchase Orders](/features/detail/purchase-orders) - Materials procurement
* [Clients](/features/detail/clients) - Customer management
* [Invoices](/features/detail/invoices) - Billing for completed orders

## Release History

* **v1.0.0** - Initial release with full CRUD, status workflow, and filtering
* **v1.1.0** - Added file attachments (SO-7)
* **v1.2.0** - Added duplicate as template (SO-6)
