# Updated KDS & Order Status APIs

This document lists the APIs that have been updated to support the new status flow:
`Running` -> `Pending` -> `RunningKOT` -> `Preparing` -> `Printed` -> `Ready` -> `Paid` -> `Served`

---

## 1. Order Management APIs

### 1.1 Update Order Status
**Endpoint**: `PATCH /api/orders/:orderId/status`  
**Description**: Admin can manually move an order through the lifecycle.  
**Allowed Statuses**:  
`Running`, `Pending`, `RunningKOT`, `Preparing`, `Printed`, `Ready`, `Paid`, `Served`, `completed`, `cancelled`

---

## 2. Kitchen Display System (KDS) APIs

### 2.1 Send KOT to Kitchen
**Endpoint**: `POST /api/kitchen/kot/send`  
**Action**: Automatically sets the parent Order status to **`Pending`**.

### 2.2 Update KOT Status
**Endpoint**: `PATCH /api/kitchen/kot/:id/status`  
**Action**: Updates the KOT status and **automatically synchronizes** the parent Order status to the same value.  
**Example Sequence**:  
- Move KOT to `Preparing` -> Order status becomes `Preparing`.
- Move KOT to `Ready` -> Order status becomes `Ready`.

### 2.3 Live Kitchen Queue
**Endpoint**: `GET /api/kitchen/live`  
**Action**: Now includes all KOTs with status: `Running`, `Pending`, `RunningKOT`, or `Preparing`.

---

## 3. Table Management APIs

### 3.1 Update Table Status
**Endpoint**: `PATCH /api/tables/:id/status`  
**Description**: Table status transitions now trigger 1:1 synchronization with Order statuses.

| Table Status | Resulting Order Status |
| :--- | :--- |
| `Running` | `Running` |
| `Pending` | `Pending` |
| `RunningKOT` | `RunningKOT` |
| `Preparing` | `Preparing` |
| `Printed` | `Printed` |
| `Ready` | `Ready` |
| `Paid` | `Paid` |
| `Served` | `Served` |

---

## 4. Admin KDS APIs
**Endpoint**: `/api/admin/kitchen/*`  
All admin-level KDS APIs (`/all`, `/history`, `/metrics`) have been updated to recognize the new status names.
