# Công nợ khách hàng

* API này dùng để lấy [danh sách công nợ khách hàng](https://nhanh.vn/accounting/debts/customer).

## Request

* Xem [common request params](/v3/readme.md#request-params).

```curl
curl --location 'https://pos.open.nhanh.vn/v3.0/accounting/debts?appId={{appId}}&businessId={{businessId}}' \
--header 'Authorization: {{accessToken}}' \
--header 'Content-Type: application/json' \
--data '{
    "filters": {
        "itemSubType": 1 
    },
    "paginator": {
        "size": 30
    }
}'
```

### Filters

| Key         | Type   | Description                                                       |
| ----------- | ------ | ----------------------------------------------------------------- |
| id          | int    | ID đối tượng khách hàng                                           |
| fromDate    | date   | Thời gian bắt đầu từ ngày định dạng (yyyy-mm-dd). VD: 2022-09-25  |
| toDate      | date   | Thời gian đến ngày (yyyy-mm-dd). VD: 2022-09-25                   |
| code        | string | Mã khách hàng                                                     |
| name        | string | Tên khách hàng/ ID khách hàng                                     |
| address     | string | Địa chỉ khách hàng                                                |
| mobile      | string | Số điện thoại khách hàng                                          |
| itemSubType | int    | Loại khách hàng.Giá trị 1: Khách lẻ,2: Khách sỉ,3: Đại lý         |
| debtType    | int    | Loại công nợ.Giá trị 1: Phải thu,2: Phải trả,3: Phải thu/Phải trả |
| lastRemain  | string | json encode {"from": "Tồn từ", "to": "Tồn đến"}                   |

## Response

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

### Failed response

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

### Successful response

```json
{
    "code": 1,
    "paginator": {
        "next": "Giá trị để lấy dữ liệu trang tiếp theo"
    },
    "data": [
        {
          "id": "(int) ID đối tượng 1",
          "code": "(string) Mã đối tượng 1",
          "name": "(string) Tên đối tượng 1",
          "mobile": "(string) Số điện thoại",
          "address": "(string) Địa chỉ",
          "firstDebit": "(double) Nợ (đầu kỳ)",
          "firstCredit": "(double) Có (đầu kỳ)",
          "debit": "(double) Nợ (trong kỳ)",
          "credit": "(double) Có (trong kỳ)",
          "receive": "(double) Phải thu (cuối kỳ)",
          "pay": "(double) Phải trả (cuối kỳ)",
          "debtLimit": "(double) Giới hạn công nợ"
        },
        {
          "id": "(int) ID đối tượng 2",
          "code": "(string) Mã đối tượng 2",
          "name": "(string) Tên đối tượng 2",
          "mobile": "(string) Số điện thoại",
          "address": "(string) Địa chỉ",
          "firstDebit": "(double) Nợ (đầu kỳ)",
          "firstCredit": "(double) Có (đầu kỳ)",
          "debit": "(double) Nợ (trong kỳ)",
          "credit": "(double) Có (trong kỳ)",
          "receive": "(double) Phải thu (cuối kỳ)",
          "pay": "(double) Phải trả (cuối kỳ)",
          "debtLimit": "(double) Giới hạn công nợ"
        }
    ]
}
```


---

# 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/v3/accounting/debts.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.
