# 統一發票

## einvoice_allowance_issue

替一張統一發票開折讓（金額含稅）。一定要人核可。

給 Agent 的原文：

> Issue an allowance on an e-invoice (amount including tax).

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | string | 必填 |  |
| `amount` | string | 必填 | Amount including tax, as a string |
| `reason` | string | 必填 | 1 to 20 characters |
| `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. |

授權項目：`einvoices:allowance`

寫入、核可：一定要

## einvoice_allowance_void

作廢一張統一發票的折讓。一定要人核可。

給 Agent 的原文：

> Void an allowance of an e-invoice.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | string | 必填 |  |
| `allowance_id` | string | 必填 |  |
| `reason` | string | 必填 | 1 to 20 characters |
| `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. |

授權項目：`einvoices:void`

寫入、核可：一定要

## einvoice_issue

替一張請款單開統一發票。加值服務中心沒回應時發票是 PENDING，到了 queryable_at 再用 einvoice_sync 查。

給 Agent 的原文：

> Issue an e-invoice for a bill. When the provider does not answer, the e-invoice is PENDING; call einvoice_sync after its
> queryable_at.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `bill` | string | 必填 | Bill number (BL-000001) or id |
| `buyer` | Buyer（可以是 null） |  | Omitted uses the defaults from the order's buyer |
| `buyer.type` | B2B \| B2C（可以是 null） |  |  |
| `buyer.email` | string（可以是 null） |  |  |
| `buyer.carrier_type` | PROVIDER \| MOBILE \| CITIZEN \| DONATION \| PRINT（可以是 null） |  |  |
| `buyer.carrier_code` | string |  |  |
| `buyer.donation_code` | string |  |  |
| `customs_clearance` | NON_CUSTOMS \| CUSTOMS（可以是 null） |  |  |
| `zero_tax_rate_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. |

授權項目：`einvoices:issue`

寫入、核可：不用

## einvoice_search

查統一發票（開立日新的在前，處理中的排最上面），或用 id 查一張和它的折讓；也回自動開立失敗的請款單。

給 Agent 的原文：

> Search e-invoices (newest issue date first, pending ones on top), or get one with its allowances by id. Also returns the
> bills whose automatic issue failed.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | string（可以是 null） |  | Get one e-invoice with its allowances instead of searching |
| `limit` | integer |  | default: 20 |
| `cursor` | string（可以是 null） |  |  |
| `issued_from` | date（可以是 null） |  |  |
| `issued_to` | date（可以是 null） |  |  |
| `statuses` | PENDING \| ISSUED \| VOIDED[]（可以是 null） |  |  |
| `keyword` | string |  | E-invoice number, bill number or buyer; an email or phone needs pii:read |

授權項目：`einvoices:read`；keyword 像 Email 或電話時，另外要 pii:read。

核可：不用

## einvoice_sync

向加值服務中心查一張還在等確認的發票；沒開成的話 einvoice 是 null。

給 Agent 的原文：

> Ask the provider about an e-invoice that is waiting for confirmation. einvoice is null when the issue did not happen.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | 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. |

授權項目：`einvoices:issue`

寫入、核可：不用

## einvoice_void

作廢一張統一發票。一定要人核可。

給 Agent 的原文：

> Void an e-invoice.

| 參數 | 型別 | 必填 | 說明 |
| --- | --- | --- | --- |
| `id` | string | 必填 |  |
| `reason` | string | 必填 | 1 to 20 characters |
| `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. |

授權項目：`einvoices:void`

寫入、核可：一定要
