# Sản phẩm xuất nhập kho nháp

* Tính năng này dùng để lấy danh sách [sản phẩm xuất nhập kho nháp](https://nhanh.vn/inventory/requirement/index).

## Request

* Xem các [common request params](https://apidocs.nhanh.vn/v3/readme#request-params)

```curl
curl --location 'http://pos.open.nhanh.vn/v3.0/bill/draftproducts?appId={{appId}}&businessId={{businessId}}' \
--header 'Authorization: {{accessToken}}' \
--header 'Content-Type: application/json'
--data '{
    "filters": {
        "modes": [2],
        "lastUpdatedAtFrom": 1753981239,
        "lastUpdatedAtTo": 1756659639,
        "depotIds": [31010]
    },
    "paginator": {
        "size": 50
    }
}'
```

### Filters

| Key               | Type  | Description                                                                    |
| ----------------- | ----- | ------------------------------------------------------------------------------ |
| billIds           | array | List ID phiếu xuất nhập kho nháp                                               |
| types             | array | [Loại xuất nhập kho](https://apidocs.nhanh.vn/v3/modelconstant#inventory-type) |
| modes             | array | [Kiểu xuất nhập kho](https://apidocs.nhanh.vn/v3/modelconstant#inventory-mode) |
| depotIds          | array | Mảng ID kho hàng                                                               |
| statuses          | array | List trạng thái phiếu nháp                                                     |
| lastUpdatedAtFrom | int   | Thời gian cập nhật cuối từ (timestamp)                                         |
| lastUpdatedAtTo   | int   | Thời gian cập nhật cuối đến (timestamp)                                        |

## Response

* Xem cấu trúc chung [tại đây](https://apidocs.nhanh.vn/v3/readme#response).

### Failed response

* Xem các mã lỗi chung [tại đây](https://apidocs.nhanh.vn/v3/readme#failed-response).

### Successful response

```json
{
  "code": 1,
  "paginator": {
    "next": "Dùng để lấy dữ liệu trang tiếp theo"
  },
  "data": [
    {
      "id": "(int) ID bản ghi sản phẩm xuất nhập kho nháp",
      "billId": "(int) ID hóa đơn xuất nhập kho nháp",
      "type": "(int) Loại xuất nhập kho",
      "mode": "(int) Kiểu xuất nhập kho",
      "status": "(int) Trạng thái",
      "damagedQuantity": "(double) Số lượng lỗi",
      "discount": "(int) Chiết khấu",
      "fromDepot": {
        "id": "(int) ID kho hàng",
        "name": "(string) Tên kho hàng"
      },
      "toDepot": {
        "id": "(int) Id kho hàng",
        "name": "(string) Tên kho hàng"
      },
      "supplier": {
        "id": "(int) ID nhà cung cấp",
        "name": "(string) Tên nhà cung cấp",
        "mobile": "(string) Số điện thoại nhà cung cấp"
      },
      "product": {
        "id": "(int) ID sản phẩm",
        "code": "(string) Mã sản phẩm",
        "barcode": "(string) Mã vạch sản phẩm",
        "name": "(string) Tên sản phẩm",
        "prices": {
          "retail": "(double) Giá bán",
          "import": "(double) Giá nhập",
          "avgCost": "(double) Giá vốn"
        },
        "batchId": "(int) ID lô sản phẩm",
        "imeiId": "(int) ID IMEI",
        "imei": "(string) Số IMEI"
      },
      "required": {
        "quantity": "(int) Số lượng yêu cầu",
        "price": "(int) Giá yêu cầu",
        "description": "(string) Ghi chú",
        "userId": "(int) ID người yêu cầu",
        "userName": "(string) Tên người yêu cầu",
        "datetime": "(string) Thời gian yêu cầu"
      },
      "approved": {
        "quantity": "(int) Số lượng duyệt",
        "price": "(int) Giá duyệt",
        "description": "(string) Ghi chú",
        "userId": "(int) ID người duyệt",
        "userName": "(string) Tên người duyệt",
        "approvedAt": "(int) Thời gian duyệt (định dạng timestamp)"
      },
      "confirmed": {
        "quantity": "(int) Số lượng xác nhận",
        "confirmedAt": "(int) Thời gian xác nhận (định dạng timestamp)"
      }
    }
  ]
}
```
