# Phiếu xuất kho

> Base URL: `https://pos.pages.fm/api/v1`. Xác thực bằng tham số truy vấn `api_key`.

## Danh sách phiếu xuất kho

`GET /shops/{SHOP_ID}/export`

Lấy danh sách phiếu xuất kho

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |
| `page` | query | integer |  | Số trang |
| `page_size` | query | integer |  | Kích thước trang |
| `status` | query | integer |  | Trạng thái Values: `-1` Tất cả trạng thái, `0` Mới, `1` Đã hoàn thành, `2` Đã hủy. |
| `type` | query | integer |  | Loại phiếu xuất kho Values: `0` Phiếu xuất thường, `1` Xuất hàng lỗi. |

### Phản hồi

- `200` Success (object)

```json
{
  "success": true,
  "data": [
    {
      "id": "8095ca3c-a485-4378-9914-5013e1179d55",
      "display_id": 472,
      "status": 0,
      "type": 0,
      "total": 1,
      "total_price": 0,
      "note": "Xuất bán hàng",
      "warehouse_id": "c52e67ad-d9d0-4276-abe4-e0c9f1f7d2da",
      "supplier_products_id": 400037328,
      "tags": [
        1
      ],
      "export_items": [
        {
          "id": "78dfe47a-a3dd-4d47-8f8b-16eb1ccd69ee",
          "imported_price": 0,
          "quantity": 1,
          "variation_id": "76887a5b-8a27-472c-a15a-661ea59434dd",
          "display_id": 0,
          "inserted_at": "2024-01-25T16:18:20Z"
        }
      ],
      "images": [
        "https://content.pancake.vn/user-content-dev2.pancake.vn/2022/7/7/eb376f0bf90f47d25396d49e4d547700f182981b.jpg"
      ],
      "user_id": "d6e6a545-f102-439e-9943-8ac8369f9735",
      "user": {
        "id": "d6e6a545-f102-439e-9943-8ac8369f9735",
        "name": "vudzung12",
        "fb_id": "1286585024855632",
        "avatar_url": null
      },
      "inserted_at": "2024-01-25T16:18:20Z",
      "updated_at": "2024-01-25T16:18:20Z"
    }
  ]
}
```

## Tạo phiếu xuất kho

`POST /shops/{SHOP_ID}/export`

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |

### Nội dung yêu cầu

Thông tin yêu cầu chứa thông tin xuất kho cần tạo

- `export_list` (object, required): 
  - `note` (string): Ghi chú
  - `supplier_products_id` (integer): Mã nhà cung cấp
  - `tags` (integer[]): Thẻ phiếu xuất kho
  - `status` (integer, required): Trạng thái phiếu xuất Values: `0` Mới (type 0) / Xuất hàng lỗi (type 1), `1` Hoàn tất (type 0) / Xuất bỏ (type 1), `2` Đã hủy.
  - `type` (integer): Loại phiếu xuất kho Values: `0` Phiếu xuất thường, `1` Xuất hàng lỗi.
  - `shop_id` (integer): Mã shop
  - `warehouse_id` (string, required): Mã kho
  - `change_inserted_at` (boolean): Đổi ngày tạo phiếu xuất kho
  - `inserted_at` (integer): Ngày tạo phiếu xuất kho
  - `images` (string (uri)[]): Link hình ảnh phiếu xuất kho
  - `export_items` (object[], required): Danh sách sản phẩm

```json
{
  "export_list": {
    "note": "",
    "supplier_products_id": 169,
    "tags": [
      1
    ],
    "status": 0,
    "type": 0,
    "shop_id": 20,
    "warehouse_id": "c52e67ad-d9d0-4276-abe4-e0c9f1f7d2da",
    "change_inserted_at": true,
    "inserted_at": 1651683600,
    "images": [
      "https://statics.pancake.vn/user-content-dev2.pancake.vn/2021/12/27/18c4500c320cb2e993b3ff4b3be81165df64d3ba.png"
    ],
    "export_items": [
      {
        "id": "13d7ddf6-4cd9-4e1f-a5c1-ac3cd7a7fc17",
        "imported_price": 100000,
        "quantity": 1,
        "variation_id": "29044dcf-2f4c-492f-a0a9-e447b20e21da"
      }
    ]
  }
}
```

### Phản hồi

- `200` Success (object)

```json
{
  "success": true
}
```

## Chi tiết phiếu xuất kho

`GET /shops/{SHOP_ID}/export/{EXPORT_ID}`

Lấy một phiếu xuất kho theo mã hoặc mã hiển thị, cùng dạng một phần tử của danh sách phiếu xuất. Phiếu thuộc kho mà người gọi không được xem trả về không tìm thấy.

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |
| `EXPORT_ID` | path | string | yes | Mã phiếu xuất kho (UUID) hoặc mã hiển thị |

### Phản hồi

- `200` Success (object)
- `404` Phiếu xuất không tồn tại hoặc người gọi không được xem (ErrorResponse)

```json
{
  "success": true,
  "data": {
    "id": "8095ca3c-a485-4378-9914-5013e1179d55",
    "display_id": 472,
    "status": 0,
    "type": 0,
    "total": 1,
    "total_price": 0,
    "note": "Xuất bán hàng",
    "warehouse_id": "c52e67ad-d9d0-4276-abe4-e0c9f1f7d2da",
    "supplier_products_id": 400037328,
    "tags": [
      1
    ],
    "export_items": [
      {
        "id": "78dfe47a-a3dd-4d47-8f8b-16eb1ccd69ee",
        "imported_price": 0,
        "quantity": 1,
        "variation_id": "76887a5b-8a27-472c-a15a-661ea59434dd",
        "display_id": 0,
        "inserted_at": "2024-01-25T16:18:20Z"
      }
    ],
    "user_id": "d6e6a545-f102-439e-9943-8ac8369f9735",
    "inserted_at": "2024-01-25T16:18:20Z",
    "updated_at": "2024-01-25T16:18:20Z"
  }
}
```

## Cập nhật phiếu xuất kho

`PUT /shops/{SHOP_ID}/export/{EXPORT_ID}`

### Tham số

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `SHOP_ID` | path | integer | yes | Mã shop |
| `EXPORT_ID` | path | string | yes | Mã phiếu xuất kho |

### Nội dung yêu cầu

Thông tin yêu cầu chứa thông tin xuất kho cần tạo

- `export_list` (object, required): 
  - `images` (string (uri)[]): Link hình ảnh phiếu xuất kho
  - `inserted_at` (integer): Ngày tạo phiếu xuất kho
  - `note` (string): Ghi chú
  - `status` (integer): Trạng thái phiếu xuất Values: `0` Mới (type 0) / Xuất hàng lỗi (type 1), `1` Hoàn tất (type 0) / Xuất bỏ (type 1), `2` Đã hủy.
  - `supplier_products_id` (integer): Mã nhà cung cấp
  - `tags` (integer[]): Thẻ phiếu xuất kho
  - `type` (integer): Loại phiếu xuất kho Values: `0` Phiếu xuất thường, `1` Xuất hàng lỗi.
  - `export_items` (object[]): Danh sách sản phẩm

```json
{
  "export_list": {
    "images": [
      "https://content.pancake.vn/user-content-dev2.pancake.vn/2022/5/27/ee3be79d1574735ed35539ca48f7f6e9d7137706.jpg"
    ],
    "inserted_at": 1695142800,
    "note": "xuất bán hàng",
    "status": 0,
    "supplier_products_id": 319,
    "tags": [
      1
    ],
    "export_items": [
      {
        "id": "13d7ddf6-4cd9-4e1f-a5c1-ac3cd7a7fc17",
        "imported_price": 1000,
        "quantity": 1,
        "variation_id": "d1e522eb-2f6f-4d22-b8a1-ec25df4a33a4"
      }
    ]
  }
}
```

### Phản hồi

- `200` Success (object)

```json
{
  "success": true
}
```
