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

* /api/bill/imexs: Tính năng này dùng để lấy danh sách sản phẩm xuất nhập kho của doanh nghiệp.
* Tương đương dữ liệu tại mục: Kho hàng > Xuất nhập kho > [Sản phẩm xuất nhập kho](https://nhanh.vn/inventory/imex/index)

## Request

Xem các [common request params](/v2/readme.md#request-params)

Các key của mảng **data array** dùng để tạo **data** json string:

| Key                   | Type   | Description                                                                                                                         |
| --------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| page                  | Int    | Phân trang (giá trị mặc định là 1)                                                                                                  |
| icpp                  | Int    | Số lượng sản phẩm trên 1 trang. Mặc định là 10. Tối đa không quá 20.                                                                |
| fromDate              | string | Định dạng yyyy-mm-dd. Ngày XNK.                                                                                                     |
| toDate                | string | Định dạng: yyyy-mm-dd. Ngày XNK.                                                                                                    |
| id                    | Int    | ID sản phẩm xuất nhập kho                                                                                                           |
| billId                | Int    | ID phiếu xuất nhập kho                                                                                                              |
| type                  | Int    | Tìm kiếm theo [loại XNK](https://apidocs.nhanh.vn/#inventory)                                                                       |
| mode                  | Int    | Tìm kiếm theo [kiểu XNK](https://apidocs.nhanh.vn/#inventory)                                                                       |
| depotId               | Int    | ID kho                                                                                                                              |
| relatedDepotId        | Int    | ID kho liên quan                                                                                                                    |
| supplierId            | Int    | ID nhà cung cấp                                                                                                                     |
| productStoreId        | Int    | ID sản phẩm xuất nhập kho (Chú ý: deprecated key, nên dùng key productId)                                                           |
| productId             | Int    | ID sản phẩm xuất nhập kho                                                                                                           |
| productStoreName      | string | Tên (mã, mã vạch) sản phẩm xuất nhập kho                                                                                            |
| relatedProductStoreId | Int    | ID sản phẩm XNK liên quan                                                                                                           |
| categoryId            | Int    | ID danh mục sản phẩm                                                                                                                |
| internalCategoryId    | Int    | ID danh mục nội bộ sản phẩm                                                                                                         |
| brandId               | Int    | ID thương hiệu sản phẩm                                                                                                             |
| productStoreTypeId    | Int    | Loại sản phẩm: 1: Sản phẩm 2: Voucher 3: Sản phẩm cân đo 4: Sản phẩm theo IMEI 5: Gói sản phẩm 6: Dịch vụ                           |
| imeiId                | Int    | Tìm theo imeiId                                                                                                                     |
| imei                  | string | Tìm theo IMEI (Chỉ hỗ trợ tìm trong các hóa đơn bán lẻ, các phiếu nhập nhà cung cấp, chuyển kho sẽ không hỗ trợ tìm kiếm theo IMEI) |
| warrantyBillId        | Int    | ID phiếu bảo hành                                                                                                                   |

## Response

JSON decode the response to get the structure:

| Key      | Type  | Description                                   |
| -------- | ----- | --------------------------------------------- |
| code     | int   | 1 = success or 0 = failed                     |
| messages | array | is an array of error messages if code = 0     |
| data     | array | Mảng danh sách sản phẩm yêu cầu xuất nhập kho |

```javascript
data = [
    "totalPage" => int, // Tổng số trang,
    "page" => int, // Trang hiện tại,
    "imexs" => [
        [
            "id" => int, // ID phiếu sản phẩm xuất nhập kho,
            "billId" => int , // ID phiếu xuất nhập kho,
            "type" => int, // Loại xuất nhập kho,
            "typeName" => string, // Tên loại xuất nhập kho,
            "mode" => int, // Kiểu xuất nhập kho,
            "modeName" =>string , // Tên kiểu xuất nhập kho,
            "date" => string, // Ngày xuất nhập kho,
            "depotId" => int, // ID kho,
            "depotName" => string, // Tên kho,
            "relatedDepotId" => int, // ID kho liên quan,
            "relatedDepotName" => string, // Tên kho liên quan
            "supplierId" => int, // ID nhà cung cấp,
            "supplierName" => string, // Tên nhà cung cấp,
            "supplierMobile" => string, // Số điện thoại nhà cung cấp,
            "productStoreId" => int, // ID sản phẩm xuất nhập kho (Chú ý: deprecated key, nên dùng key productId)
            "productId" => int, // ID sản phẩm xuất nhập kho,
            "relatedProductStoreId" => int, // ID sản phẩm xuất nhập kho,
            "proudctStore" => [
                "code" => string, // Mã sản phẩm,
                "barcode" => string, // Mã vạch sản phẩm,
                "name" => string, // tên sản phẩm,
                "importPrice" => double, // Giá nhập sản phẩm,
                "price" => double, // Giá bán sản phẩm,
                "avgCost" => double, // Giá vốn sản phẩm
            ]
            "imeiId" => int, // Imei Id,
            "imei" => string, // Số imei sản phẩm,
            "avgCost" => double, // Giá vốn sản phẩm trong lần xuất nhập kho,
            "productPrice" => double, // Giá sản phẩm trong lần xuất nhập kho,
            "remain" => int, // Số tồn còn lại tính tới lần xuất nhập kho,
            "description" => string, // Mô tả trong lần xuất nhập kho,
            "discount" => double, // Chiết khấu trong lần xuất nhập kho,
            "points" => int, // Số point được tặng trong lần xuất nhập kho của sản phẩm ,
            "usedPoints" => int, // Số point đã tiêu trong lần xuất nhập kho của sản phẩm,
            "createdDateTime" => string, // Thời gian tạo phiếu xuât nhập kho,
            "saleBonus" => double, // Tiền hoa hồng nhân viên bán hàng được hưởng với sản phẩm,
            "extendedWarrantyId" => int, // Id bảo hành mở rộng,
            "extendedWarrantyMoney" => double, // Tiền bảo hành mở rộng,
            "extendedWarrantyMonths" => int, // Số tháng bảo hành mở rộng,
            "warrantyReasonId" => int, // Id lý do bảo hành
        ],
        ...
    ]
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.nhanh.vn/v2/bill/imexs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
