# 退款

## refund_create

在請款單上記錄一筆退款（只記錄，不會經金流退錢）；issue_allowance 同時開統一發票的折讓。可以先試算看退款之後的請款單。一定要人核可。

給 Agent 的原文：

> Record a refund on a bill (only a record: no money moves). issue_allowance also issues an e-invoice allowance.
> Use dry_run to see the bill after the refund first.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `bill` | string | 必填 | Bill number (BL-000001) or id |
| `amount` | string | 必填 |  |
| `method` | BANK_TRANSFER \| CASH \| CHECK \| CREDIT_CARD \| OTHER | 必填 |  |
| `refund_date` | date | 必填 |  |
| `reason` | string | 必填 |  |
| `reference` | string |  |  |
| `issue_allowance` | boolean |  | Also issue an e-invoice allowance (needs einvoices:allowance) default: false |
| `dry_run` | boolean |  | default: false |
| `idempotency_key` | string |  | Required for every call that writes (not for dry_run). The same key within 24 hours returns the first result instead of doing it again. |

授權項目：`refunds:create`；issue_allowance 是 true 時，另外要 einvoices:allowance。

寫入、可試算、核可：一定要

## refund_search

查退款，退款日新的在前；作廢的要帶 include_voided 才回。

給 Agent 的原文：

> Search refunds, newest refund date first; voided ones only with include_voided.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `limit` | integer |  | 1 to 100 default: 20 |
| `cursor` | string（可以是 null） |  | next_cursor from the previous page |
| `refund_date_from` | date（可以是 null） |  |  |
| `refund_date_to` | date（可以是 null） |  |  |
| `methods` | BANK_TRANSFER \| CASH \| CHECK \| CREDIT_CARD \| OTHER[]（可以是 null） |  |  |
| `customer_ref` | string（可以是 null） |  |  |
| `include_voided` | boolean |  | default: false |

授權項目：`refunds:read`

核可：不用

## refund_void

作廢一筆退款（紀錄留著），回更新後的請款單。一定要人核可。

給 Agent 的原文：

> Void a refund (the record stays). Returns the updated bill.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `refund_id` | string | 必填 |  |
| `reason` | string | 必填 |  |
| `idempotency_key` | string | 必填 | Required for every call that writes (not for dry_run). The same key within 24 hours returns the first result instead of doing it again. |

授權項目：`refunds:void`

寫入、核可：一定要
