---
id: spay4-cardholder-overview-api-contract
status: accepted
audience: [backend, bo-frontend, qa]
source_documents:
  - cardholder-overview-verification-matrix.md
  - ../../adr/payment-account.md#adr-0399
  - ../../adr/payment-account.md#adr-0400
  - ../../adr/payment-account.md#adr-0401
---

# SPay4 Cardholder Overview／Activity API Contract

## 1. 結論與 authority

本文件固定 **26 條目標 API**，全部相對 `/bo/v2`。Accepted 表示需求與契約已確認，不表示 handler、schema、menu、B/F/R、部署或 release ready。這是未發布 API 的設計，不遷移既有消費者。驗收依 [驗證矩陣](cardholder-overview-verification-matrix.md)；本文件不授權 Java、DDL／migration、target database、資料修復、GitLab 發布、commit／push、Cloudflare 發布、Legacy 修改或新 App API。

產品 authority／Freeze 決策依使用者交付計畫中的 human-confirmed 結論；金融／初始狀態承續 ADR-0381／0382／0383／0398。型別、長度、selector 組合、固定排序、40054、Activity grain／時間與 CSV snapshot 是本次 delegated、可逆技術設計，不冒稱逐項人工作答。沒有完整 Order workspace、manual Freeze endpoint、自動 Freeze 觸發規則、reconciliation subsystem、Assignable、balance PATCH、帳號 rename／owner reassignment、CSV upload 或 priority mutation。帳戶層 Deposit 限額（每日金額／筆數、Balance Ceiling）依 ADR-0427（此參考僅供內部環境使用，公開版本未提供），由 Superadmin 與 own scope 的 Supplier、Gateway（ADR-0481（此參考僅供內部環境使用，公開版本未提供），#955）以 R23／R24 `GET／PUT /paymentAccounts/{id}/limits` 查詢與覆寫（#411 G17 擴充，採本契約 Overview 錯誤 wire），只影響 Deposit routing；幣別預設 `GET／PUT /bo/v2/paymentAccountCurrencyLimits[/{currencyId}]` 屬 `SYSTEM_CONFIGURATION`，不在本契約內。

Deposit namespace 承續最新 ADR-0397（此參考僅供內部環境使用，公開版本未提供）／[Target-native Deposit contract](deposit-target-native-contract.md#5-api-freeze-目標-不代表-handler-已發布)：唯一 base path 為 `/bo/v2/depositOrders`，取代先前 `/backoffice/v2/depositOrders` 提案，不搬移其他 `/bo/v2` API、不新增 alias。現有 handler 與 namespace 一致，但仍受獨立 readiness／release gate 控制，詳見 §10。此文件僅取代明列 Freeze 條件，不取代 Deposit 其餘 authority 或 Withdrawal NOT_TRANSFERRED／recovery guards。

### 1.1 Actor authority

| Operation | Superadmin | Supplier | Gateway | Policy action（目標） |
| --- | --- | --- | --- | --- |
| Read／Activity／CSV／完整銀行帳號 | 全域 | own Supplier descendants | own Gateway descendants | VIEW |
| Application create | 全域 | own scope | own scope | INSERT |
| Application approve／reject／cancel | 全域 | own scope | own scope | UPDATE |
| Account status | 全域 | own scope | own scope | UPDATE |
| Account direction | 全域 | own scope | own scope | UPDATE |
| Unfreeze | 全域 | own scope | own scope | UPDATE |
| 修改戶名與展示名稱 | 全域 | own scope | own scope | UPDATE |
| 刪除 Account | 全域 | own scope | own scope | DELETE |
| Adjust | 全域 | own scope | own scope | UPDATE |
| 帳戶限額查詢 | 全域 | own scope | own scope | VIEW |
| 帳戶限額覆寫 | 全域 | own scope | own scope | UPDATE |

Prefix 不授權；匿名或 formal session 失效為 401。VIEW 不授予 mutation。每次使用 fresh principal、實際 realm principal identity 與 immutable `Cardholder → Gateway → Supplier` chain；owner IDs、role、menu、JWT decoded claim 不可擴權。Supplier 沿既有 child-resource fixed-profile，不新增 Supplier Admin-only 限制。scope 外、missing、chain 無法驗證統一 404。

Application 建立者不得 approve／reject 自己的申請，以 `principalType + principalId` 比較，不比較整個 Supplier／Gateway owner ID。唯一例外是 Superadmin 且 server 啟動時綁定的 `spay4.dev.self-approval=true`（dev／local yml 開啟；預設與 uat／prd 為 false，uat／prd 生效時開啟即啟動失敗）；Supplier／Gateway 在任何 profile 都不例外。無 bypass request 欄位。Creator 可 cancel 本人申請；其他 scoped actor 也可 cancel。取消不冒充 review。

三角色在 scope 內可讀完整銀行帳號，CSV 同樣包含完整帳號；完整帳號、accountName、搜尋值、ciphertext、fingerprint 不得進 log／audit／telemetry／error。Gateway manual adjustment reason／evidence／operator 始終為 null，金融值不遮掩。

### 1.2 狀態與 Freeze

Pause／Resume 只表示 INACTIVE／ACTIVE，沒有 countdown。INACTIVE 阻擋兩方向新 admission，不改既有 Order、Attempt、reservation、Ledger、counter、session 或方向 flags。Freeze 是 UNFROZEN／FROZEN 的獨立 system gate，可與 ACTIVE 並存；阻擋新 Deposit／Withdrawal **及 Frozen Account 確認既有單**。本期不提供手動 Freeze endpoint；自動 Freeze 觸發本期不做（#396 PM 回覆第 5 項，ADR-0400（此參考僅供內部環境使用，公開版本未提供））：沒有寫入 FROZEN 的 producer、`CARD_FROZEN` 通知或 BO 告警，既有 Freeze 檢查與 R22 Unfreeze 保留。

Frozen 既有單仍依原 Order authority 拒絕／重派；但有可信入款／出款證據時必須保存 evidence／obligation，先解凍再確認，不得直接拒絕／重派。Frozen 重派必須換不同 Cardholder，保留原 Supplier 與 actor scope；無候選或新 reserve 失敗完整保留原狀。普通非 Frozen Deposit 的既有同 Cardholder 規則不因此全面取消。Freeze 不自動釋放 reservation、不改餘額。Unfreeze 不改 status、flags、session、不自動 settle。Adjust 由 Superadmin 與 own scope 的 Supplier、Gateway 執行（ADR-0481（此參考僅供內部環境使用，公開版本未提供）），ACTIVE／INACTIVE 可調整，FROZEN 必須先解凍。

## 2. 共通 wire、錯誤與 concurrency

### 2.1 型別與 parser

下列是所有逐欄字典使用的型別。未標 nullable 的 response 欄位 required／non-null；集合回 `[]`，nullable scalar 固定回 null，不能省略。Request required 欄位不能 null；optional query 未帶是不篩選，空字串不是未帶。

| Type | 規則 |
| --- | --- |
| ID | JSON numeric positive signed Long，1..9223372036854775807；拒絕 string、float、null。Path／query 是相同範圍的十進位整數文字，不接受 sign、decimal、scientific notation。 |
| Long | numeric signed Long；counts 為 0..9223372036854775807。 |
| Version | numeric non-negative Long；mutation expectedVersion required（create 沒有既存 target version）。 |
| int／Page | pageNumber 預設 0、0..2147483647；pageSize 預設 20、1..500，拒絕超限、不 cap。兩欄各自 optional，可只指定其中一欄。 |
| Money | Request 非負 plain decimal string、precision 30／scale≤10／整數最多 20 位；僅 ASCII digits 與單一小數點（小數點後至少一位），拒絕 JSON number、sign、空白、comma、scientific notation。Response canonical plain decimal string，去掉多餘前導／小數 trailing zeros，zero=`"0"`。Aggregate exact sum 可超過單一持久化欄位 precision，不截斷／rounding。 |
| SignedMoney | Ledger delta／net 可帶負號，其他 decimal 規則同 Money；canonical zero 不使用 `-0`。差額可按 before／after exact 計算，不以單一欄位容量截斷。 |
| Instant | UTC ISO-8601，required Z；非 Z／invalid calendar 拒絕，response 例如 `2026-09-14T03:00:00Z`。 |
| Date | `YYYY-MM-DD`，有效曆日。 |
| Offset | canonical `±HH:MM`，-14:00..+14:00，minute 00..59、±14 僅 :00；zero=`+00:00`。 |
| reason | trim 後 1..500 Unicode code points，required、禁止 controls；人工原文僅保存於授權 domain record。 |
| accountName | trim 後 1..100 code points，required、禁止 controls；保留 case／內部空白，非 identity。 |
| idempotencyKey | required，1..160 ASCII letters／digits／`._:-`，case-sensitive、不 trim。不是 Ledger key。 |
| boolean | JSON true／false；query 僅 literal `true`／`false`，非 0／1。 |
| string | readonly display／opaque server value；每個欄位用途於 §5 指定，不是 authorization。 |

JSON unknown／duplicate fields 拒絕，包括 body 中擴權 role／owner／environment。Scalar query 重複拒絕；collection query 只接受 repeated same-name parameters 並去重，不接受 comma-separated、空值或 frontend `ALL`。Enums uppercase。GET 不接受 body；命令只接受 §6 列出的 body，不接受 query；未知 path/query/body 型別與非法組合 400。金額 exact addition、不跨 Currency 加總。Account reservedAmount 僅 Withdrawal book-balance reservation，不能混入 Deposit directional obligation。

帳號 raw input≤200 code points，只接受 ASCII letters/digits/space/tab/`-`/`_`；移除 separators、ASCII uppercase，結果 `[A-Z0-9]{1,100}`，保留 leading zeros。拒絕 Unicode letters/digits、line breaks／其他 controls。accountNumber filter 是 canonical full exact；accountLast4 恰 4 個 ASCII alphanumeric、轉 uppercase、exact suffix；兩者互斥。沒有 arbitrary contains／ciphertext LIKE。

### 2.2 Envelope／error

一般成功 `{code:2000,message:"",data:T}`。PageVo data 為 `records:T[]`、`total:Long`（完整 matching rows）、`size:int`、`number:int`；越界 empty page 仍保留正確 total。Application create HTTP 201，其他成功 200。完整帳號／金融 JSON 固定 `Cache-Control: no-store`。

Error data 是 required object，只有 `field:string|null` 與 `reasonCode:string|null`，兩欄都輸出。message 是安全 server 文字，不 echo request values、帳號、credential 或 SQL。穩定 reasonCode 是 diagnostic，不作授權判定。

| HTTP | code | 適用／reasonCode 範例 |
| --- | --- | --- |
| 400 | 40005 | 欄位、JSON、query、enum、pagination、selector、time 錯誤：INVALID_FIELD／INVALID_COMBINATION／INVALID_TIME_RANGE |
| 401 | 40000 | formal session 缺失／失效：SESSION_REQUIRED |
| 403 | 40001 | operation authority：OPERATION_DENIED；自審：SELF_REVIEW_DENIED |
| 404 | 40002 | missing／scope 外／unverifiable owner chain：NOT_FOUND；同一安全 representation |
| 409 | 40007 | 正式 Account／PENDING Application 已占 canonical identity：IDENTITY_OCCUPIED |
| 409 | 40045 | 同 idempotency key 不同 immutable command：IDEMPOTENCY_CONFLICT |
| 409 | 40051 | expectedVersion stale（含同值）：VERSION_CONFLICT |
| 409 | 40054 | **目標新增 code**，state conflict／FROZEN Adjust／target<reserved：STATE_CONFLICT／ACCOUNT_FROZEN／BALANCE_BELOW_RESERVED；本期不改 SystemCode Java |
| 503 | 40044 | 無法安全提供完整必要 native dependency：NATIVE_DEPENDENCY_UNAVAILABLE；不回假零／假空 |
| 500 | 5000 | 金融／projection／數值 invariant 不一致：FINANCIAL_INVARIANT_FAILED；不公開細節 |

### 2.3 Lock／version／replay

一般設定依序 fresh authority/scope → target lock → version → state → equality。Current-version same-state 是 no-op，回 current projection、不改 version／modify metadata／audit；stale same-state 仍 409。

Idempotent commands 依序 fresh operation authority/scope（review 含自審）→ canonical immutable command replay → 首次才驗 version/state。Actor identity、action、target、完整 canonical payload、原 expectedVersion 都參與 equality；decimal numeric canonicalization、帳號與 trim 欄位 canonicalization 先完成，key 本身不 trim。Create target 是 scoped Cardholder，payload 含 Bank／canonical account／name／reason。Approve/reject/cancel target 是 Application，Adjust target 是 Account。Key 在整個 Overview command domain 唯一且 case-sensitive；跨 action／target／actor 同 key 不同 command 也 409，不藉 scope 外 command 揭露舊資料。

相同 key／command 回首次完整結果與 HTTP status，之後的 Freeze／餘額變動不重新調整或結算；fresh authority 已喪失仍拒絕。Client key 不直接作 Ledger key，Backend factory 產生 namespaced identity。首次 command、Ledger、projection、required audit、notification fact 原子提交；失敗不能留下成功 replay record。No-op 可保存 replay result，不建立 zero Ledger、domain audit、notification。409 version conflict 要 reload／重確認，不盲目更新 version 重送。

Audit 只存安全 actor／target／owner IDs、非秘密狀態、reason category、時間與 request／trace identity；不存 request plaintext、account search、accountName、帳號 fingerprint、任意 raw reason/evidence。必要人工原文只進各自受授權 domain record。Export 為安全 access audit，不將其視為 financial mutation。

## 3. Filters、selectors 與 Overview projection

### 3.1 ScopeFilter（optional query）

| 欄位 | Type | Actor／組合 |
| --- | --- | --- |
| supplierId | ID | 僅 Superadmin；與 gatewayId 同帶時必須同 chain。 |
| gatewayId | ID | Superadmin 任一 scoped；Supplier 僅 own descendants；Gateway 不接受。 |

Supplier 不接受 supplierId，Gateway 不接受兩個 owner selectors（400）；不存在／scope 外 selector 404，不忽略、不變空 page。同 chain selector 組合不一致為 400 INVALID_COMBINATION（前提：個別 selectors 已通過可見性）。

### 3.2 OverviewFilter（全部 optional）

| 欄位 | Type／enum | 用途／限制 |
| --- | --- | --- |
| supplierId／gatewayId | ScopeFilter | 僅縮小 server scope。 |
| cardholderId | ID | exact。 |
| username | string，trim 1..100 | case-insensitive contains、escape wildcard；非 login identity mutation。 |
| displayName | string，trim 1..100 | case-insensitive contains、escape wildcard；不是 verified Real Name。 |
| cardholderStatus | ACTIVE／LOCKED／INACTIVE | exact。 |
| loginStatus | LOGGED_IN／LOGOUT_PENDING／LOGGED_OUT | evaluationTime 下的衍生值。 |
| drainState | NONE／DRAIN／STRANDED | 衍生標籤，不 mutation。 |
| rowType | PAYMENT_ACCOUNT／APPLICATION | child row type。 |
| bankId | ID | exact；須與選定可見 scope 中至少一個 Currency 相容，否則 400；不存在／不可見為 404。 |
| accountStatus | ACTIVE／INACTIVE | 只篩正式 Account。 |
| freezeStatus | UNFROZEN／FROZEN | 只篩正式 Account。 |
| applicationStatus | PENDING／APPROVED／REJECTED／CANCELLED | 只篩 Application；未帶混合列表僅 PENDING。 |
| accountNumber | canonical account string | full exact，正規化見 §2。 |
| accountLast4 | string | exact canonical suffix，與 accountNumber 互斥。 |
| hasBalance | boolean | 正式 Account book balance>0 的有／無；ACCOUNT 是完整 CH aggregate。 |
| hasPendingOrders | boolean | 正式 Account 未解除 obligation count>0 的有／無；ACCOUNT 是完整 CH aggregate。 |

accountStatus／freezeStatus 與 applicationStatus 不可併用；rowType=APPLICATION 配 accountStatus／freezeStatus 拒絕；rowType=PAYMENT_ACCOUNT 配 applicationStatus 拒絕。CARD view 的 balance／pending filters 只選正式 Accounts，Application null 不當零，顯式要求 Application＋這兩 filters 為 400。ACCOUNT view 的 child filters 使用 EXISTS；hasBalance／hasPendingOrders 作用於完整 Cardholder aggregate，與 child predicates 分開。顯式 Application＋aggregate filters 在 ACCOUNT 可用：選出有該 Application 的 CH，再檢查其正式 Account aggregate；不能把 Application 本身當財務來源。

未指定 rowType 且帶 Account-only filters 時只匹配正式 Accounts；帶 Application-only filter 時只匹配 Application；accountNumber／Last4／bank 可匹配兩種 rows。ACCOUNT 無 child filters 時包含無帳戶 CH；有 child filters 必須 EXISTS matching row。CH total balance／reserved／available 永遠含全部正式 Accounts，不隨 Bank／child filter 改寫。terminal Application 要顯式 applicationStatus 或 detail，不擠入預設列表。

### 3.3 Login／DRAIN／STRANDED

同一 request 用一致 snapshot 與 evaluationTime 重算 formal session、absolute expiry、inactivity、scheduled deadline、epoch、owner guards；JWT 存在／persisted ACTIVE 不足。有未排程且有效 session → LOGGED_IN；否則有尚未到 deadline 的有效 scheduled session → LOGOUT_PENDING；其他 → LOGGED_OUT。deadline 相等已到期。多 session 中未排程有效優先；沒有登入歷史亦 LOGGED_OUT。Login 判定只讀，不 renew lastSeen、revoke 或排程。

DRAIN＝LOGOUT_PENDING 且全部正式 Account total book balance>0；STRANDED＝LOGGED_OUT 且該 sum>0；其餘 NONE。pending counts 另列，不參與標籤、不金融 mutation。

### 3.4 Summary、排序與 actions

ACCOUNT summary 選 matching Cardholders，以完整正式 Accounts 作 currency financial sums；child status/chip counts 只計 matching child rows。CARD summary 使用 matching rows，Cardholders distinct，金融 totals 只計 matching 正式 Accounts；pending counts 只計相應正式 Accounts 的 obligation。cardholderStatusCounts／loginStatusCounts／drainCount／strandedCount 以 matching distinct CH 計數；paymentAccountTotal 只計 matching 正式 Accounts，applicationStatusCounts 只計 matching Applications。cardholderTotal 是 distinct CH，零帳戶 CH 仍可出現於 ACCOUNT。

Summary 跟隨全部 filters、不受 page，enum maps 必須含完整鍵（零也輸出）。currencyTotals 依 currencyId ASC、不跨 Currency sum；ACCOUNT 下無正式 Account 的 CH 不憑空產生 Currency 財務 row。空 scope maps 為全零、currencyTotals=[]。reservedAmount 只計 Withdrawal；availableAmount=balance−reservedAmount。

Cardholders：gatewayId ASC、cardholderId ASC。Mixed cards：gatewayId ASC、cardholderId ASC、APPLICATION 先、resourceId ASC（各 row 非 null 的 applicationId／paymentAccountId）。沒有 client sort、Legacy code 或 routing priority。

availableActions 是 fresh actor/state 的 UI hint，Backend 仍重驗。正式 Account 可用值：VIEW_ACTIVITY、SET_ACTIVE／SET_INACTIVE、ENABLE_RECEIVING／DISABLE_RECEIVING、ENABLE_SENDING／DISABLE_SENDING、UNFREEZE、ADJUST_BALANCE、DELETE；Application：APPROVE／REJECT／CANCEL。DELETE 僅 INACTIVE、balance 與 reservedAmount 皆零且無未解除 obligation 時出現，Freeze 不是條件，只是提示，Backend 持鎖後重判（ADR-0462（此參考僅供內部環境使用，公開版本未提供））。以 §1、§6 guards 計算：不提供同值設定，terminal Application 為 []；VIEW_ACTIVITY 可於 inactive／frozen；UNFREEZE 僅 frozen 且 actor 有權；ADJUST_BALANCE 僅未 frozen 且 actor 有權；Superadmin、Supplier、Gateway 在 scope 內提示同一組狀態、方向、解凍與餘額操作（ADR-0481（此參考僅供內部環境使用，公開版本未提供）），VIEW-only 只有 VIEW_ACTIVITY；enable／SET_ACTIVE 仍須 eligible；disable／SET_INACTIVE 可 cleanup。沒有未 ready Order workspace 的假 navigation/action。

## 4. Native Pending／Daily Usage／Activity

Revision 2 沿固定 `ef6673f05fa261f627476363873a19ec6d4556a3` 的 ADR-0403（此參考僅供內部環境使用，公開版本未提供） 與 [Withdrawal contract](withdrawal-target-native-contract.md) 投影；文件採用不代表 producer runtime 已導入。CH assignment 付款 deadline 與 session expiry 分開，expired-held 交 BO explicit disposition／action，不自動 release／redispatch；成功重派後舊 Withdrawal attempt 新付款／proof／evidence／SETTLE 直接拒絕且不保存，既有 committed history 不刪改。House／Order 的 新到期 quota 政策（此參考僅供內部環境使用，公開版本未提供） 是獨立 Agent-owned root 的 owner handoff，不套到本契約 CH Payment Accounts，也不新增 HOUSE Withdrawal routes。

### 4.1 Pending 與原日 Usage

Pending grain＝direction＋formal order＋該 Account immutable attempt 的未解除 obligation，含 expired-held／review-held，不只判 UI statuses。已 release 純歷史排除。Cardholder counts 必須等於 Accounts 明細的合計，不跨卡 distinct。排序 assignedTime ASC、direction ASC、assignmentAttemptId ASC。

Frozen 顯示 processingBlocked=true／processingBlockReason=ACCOUNT_FROZEN；availableActions 仍只作診斷，Frozen 可依法提供 REJECT／REDISPATCH，但 verifiedFundsPresent=true 時兩者都不提供。未 Frozen 時 blocked=false／reason=null，其他原 Order guard 阻擋可回相應安全 code。Pending availableActions 值限 CONFIRM／REJECT／REDISPATCH，僅原 Order authority允許且已有相應 workspace ready 才列出；本期不啟用 workspace。Withdrawal NOT_TRANSFERRED／recovery／emergency guards 保留，不藉 Overview authority 擴權。

Daily businessDate 預設 Supplier current offset local today，未來日拒絕。歷史 assignmentBusinessDate／assignmentBusinessUtcOffset immutable，Supplier 後續 offset 變更不搬移 bucket。reserved 由仍有效原日 reservations；used 由 native confirmed consume／late correction accounting facts，不從全部 Ledger、audit、terminal reservation status 猜測。manual adjustment 不增加 used。Deposit 合法 committed late correction 與既有合法金融歷史歸原 attempt bucket，不復活／改寫 RELEASED history。Withdrawal 成功重派後舊 attempt 新提交不能生成 correction／used／debit／callback，也不保存 late-risk；既有 committed facts 的只讀投影或 exact replay 不授予新寫入權限。Entry contributions exact reconcile 同日同方向 counter；amount sums、countContribution sums 分別核對。合法無 bucket 為零；有 facts 無應有 counter／負值／不一致 500，必要 native source未可用 503，不能假零。

RESERVED entry eventTime 為原 reservation committed reserve time，sourceId=reservation ID；USED 為已確認 accounting fact ID及 committed consume／late-correction time，不以 arbitrary modifyTime代替。sourceId 在 kind內唯一，countContribution 是該 row對 counter 的0或1；多份同一成功 evidence不得重複貢獻一次 count。Entries：eventTime ASC、kind ASC、sourceId ASC。

### 4.2 TimeFilter（optional query）

from／to：Instant，必須成對，UTC `[from,to)`；都未帶則 `[evaluationTime−7 days,evaluationTime)`。from<to、to≤evaluationTime、duration≤90×24h，可以查較早歷史，不要求 from 接近今天。空值、單邊、反向、未來、超過上限 400。Frontend 快捷日期以 Supplier fixed offset轉 UTC，不新增 preset API。

### 4.3 Activity source／grain／status／時間

| type | 一列／sourceId | eventTime | 金額與狀態來源 |
| --- | --- | --- | --- |
| DEPOSIT | 該 Account 一個 native assignment attempt lifecycle projection；attempt ID | SUCCESS committed consume／settlement time；released／rejected／expired 的 committed disposition time；仍 pending assignedTime | own immutable attempt snapshot＋可信 financial/disposition facts；未解除 obligation優先 PENDING |
| WITHDRAWAL | 同上，Withdrawal attempt ID | 同上，不取 BO remark／modifyTime | own immutable facts；依 ADR-0403，不新增 recovery／重派後舊 attempt 金融 effects |
| BALANCE_CHANGE | 獨立 Ledger entry；balanceLogId | Ledger createTime | non-Order independent entry，amount=abs(delta)，sign決定 IN／OUT／NONE；status=entryType、statusKind=INFO |

activityId=`type:sourceId`。不得從 current pointer綁歷史或暴露其他 Gateway後續 attempts；不以 generic audit生成金融事件。Order已表達的同一 credit/debit不再生成 BALANCE_CHANGE；Ledger query仍可查全部 Ledger。獨立非 Order entry／MANUAL_ADJUSTMENT才使用 BALANCE_CHANGE。Order row有對應 Ledger則 balanceDelta／Before／After 回該 own committed financial fact，沒有則三欄 null，不猜餘額；review／history amount=requested，可信成功 amount=confirmed actual。Deposit direction=IN，Withdrawal=OUT，即使尚未成功也表示預期方向、不納現金總額。必需時間／金融 provenance缺失 500，不用 fallback timestamp。

status 是 own attempt lifecycle 的安全 native server status，不直接複製當前 Order status。statusKind：native SETTLED且可信成功 financial disposition→SUCCESS；ASSIGNED／ACCEPTED／PROOF_SUBMITTED／PENDING_REVIEW／PENDING_RECOVERY或其他尚未解除 obligation→PENDING；確認 reject→REJECTED；已終止且無 obligation的 expiry→EXPIRED；cancel→CANCELLED；redispatch release等其他 disposition→INFO。expired-held 即使 attempt result=EXPIRED也 PENDING。獨立 Ledger 的 NONE 僅容許既有合法零 delta source；manual command不生成零 entry。

Modal只用安全結構化欄位，不回 raw entity／provider JSON、新 raw-event/detail替代 API。summary 為安全 server 結構化顯示文字，不拼 reason／evidence／銀行帳號；Order navigation由 workspace再次驗權限，不擴當前 Order scope。

Withdrawal SUCCESS 的 final actual／Ledger equation 使用 immutable BO SETTLE 最終決定，不強制等於原 EVIDENCE 申報；own evidence pointer／tuple 仍須唯一可驗，原 EVIDENCE 不覆寫，合法差額須完整 reason／決定 provenance。Pending 的已存付款申報不是 BO 成功 authority。缺 final-decision link 不拿 current Order actual／MAX evidence／零值代替。

ActivitySummary counts：depositCount／withdrawalCount為 matching rows中的 distinct formal order identity（direction＋orderId）；pendingDeposits／pendingWithdrawals仍是未解除 obligation的 attempt grain；rejectedDeposits／rejectedWithdrawals為相應 REJECTED matching rows的 distinct formal order。totalEventCount為 timeline row count。Cash totalIn/out只加 matching可信成功 Deposit／Withdrawal actual；net=in−out。獨立 Ledger不納Cash totals，不是 balance rebuild／PT Report。types、statusKinds filters同樣作用 summary；只查 BALANCE_CHANGE時Cash totals與Order counts為零，但eventCount可大於零。

### 4.4 Timeline／summary／CSV 一致性

三者共用 filters/source mapping；每 request一致 read-only DB snapshot與evaluationTime，不保證多HTTP requests同一歷史snapshot。Frontend先取得summary實際from/to，再同窗查timeline／CSV，避免 default漂移；併發資料仍需 refresh。

CSV同一consistent snapshot＋bounded keyset traversal，不混入paged traversal間的新狀態、不silent truncate。沒有 page query或row cap。欄位固定：`eventTime,type,direction,amount,currencyCode,status,orderNo,paymentAccountId,bankCode,accountNumber,accountName,summary,balanceBefore,balanceDelta,balanceAfter`。順序與Activity相同；nullable用empty cell，不匯出manual reason/evidence/operator/raw data。Bank/account display取該authorized Account依eventTime當時的值（`effective_to`晚於eventTime的最早一筆`payment_account_identity_history`，查無用目前值；同request只查一次歷史），非其他attempt當前owner。CSV無envelope、UTF-8無BOM、RFC 4180 quoting（comma/quote/CR/LF以雙引號，quote加倍；CRLF rows）。Text cells以首個非空白字元檢查 `=,+,-,@` 或起始tab/CR/LF，危險者前置單引號後正常quoting；Money/SignedMoney僅canonical numeric字符串，不作formula escape。

Canonical account bytes保留leading zeros；不承諾Excel自動識別文字。下載說明要求帳號欄以文字匯入，不用 `="..."` formula。Headers：`Content-Type: text/csv;charset=UTF-8`、安全server filename的Content-Disposition、no-store。Streaming前完成validation/authorization、安全export audit；無法安全完成在headers前回normal error。中途失敗中止stream，不append JSON／假成功；completion/failure telemetry只記安全IDs／counts／classification，不記CSV bytes／帳號。Export audit不帶搜尋PII或人工原文。

## 5. Response DTO 逐欄字典

Top-level DTO名稱是目標contract，不直接序列化Java entity。下列共用組件按明列欄位**展開為flat欄位**；唯一nested欄位為dailyUsage、actor、maps、currencyTotals與approve result。所有string皆readonly，不作authorization／金融authority。Nullable欄位仍required輸出。

### 5.1 Envelope、PageVo、IdentityDisplay

| DTO／欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| Envelope.code | int | 否 | success=2000；error見§2。 |
| Envelope.message | string | 否 | 安全server顯示；success空字串。 |
| Envelope.data | T | 否 | 本route明列的DTO；error為安全ErrorData。 |
| ErrorData.field | string | 是 | 固定schema欄位名稱，不含value；非field錯誤null。 |
| ErrorData.reasonCode | string | 是 | 安全穩定分類，不含原文。 |
| PageVo.records | T[] | 否 | 當頁rows，空=[]。 |
| PageVo.total | Long | 否 | 完整matching row數。 |
| PageVo.size | int | 否 | validated pageSize。 |
| PageVo.number | int | 否 | validated pageNumber。 |
| IdentityDisplay.cardholderId | ID | 否 | canonical CH identity。 |
| IdentityDisplay.gatewayId | ID | 否 | immutable Gateway owner。 |
| IdentityDisplay.supplierId | ID | 否 | immutable Supplier chain。 |
| IdentityDisplay.currencyId | ID | 否 | Gateway-owned Currency identity。 |
| IdentityDisplay.username | string | 否 | 可驗證CH username；display不作scope。 |
| IdentityDisplay.displayName | string | 是 | CH非authority顯示名，非verified Real Name。 |
| IdentityDisplay.gatewayCode | string | 是 | Gateway顯示code。 |
| IdentityDisplay.gatewayName | string | 是 | Gateway顯示name。 |
| IdentityDisplay.supplierLoginId | string | 是 | Supplier owner login display，非actor account。 |
| IdentityDisplay.supplierName | string | 是 | Supplier顯示name。 |
| IdentityDisplay.currencyCode | string | 否 | 可驗證Currency code，金額單位。 |
| IdentityDisplay.businessUtcOffset | Offset | 否 | Supplier當前configured offset。 |

Owner／Currency identity、username／currencyCode／offset必要且可驗證；無法完整提供必要dependency 503、已存在矛盾500。非authority display取不到可null。不要求Frontend逐列master join，不從display推導權限。

### 5.2 OptionRow、OverviewSummary、CurrencyTotal

| DTO／欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| OptionRow.id | ID | 否 | 選項resource identity。 |
| OptionRow.code | string | 否 | Supplier canonical login code／Gateway code／Bank code，用於安全選單顯示。 |
| OptionRow.name | string | 否 | resource顯示name；缺少必要selector display不偽造，503。 |
| OptionRow.status | ACTIVE／INACTIVE | 否 | operational master status，歷史可見不代表create eligible。 |
| OptionRow.currencyId | ID | 是 | Supplier=null；Gateway/Bank有值。 |
| OptionRow.currencyCode | string | 是 | 同上Currency顯示單位。 |
| OptionRow.supplierId | ID | 是 | Gateway有值；Supplier/Bank=null。 |
| OverviewSummary.evaluationTime | Instant | 否 | 本request判定時間。 |
| OverviewSummary.cardholderTotal | Long | 否 | matching distinct CH。 |
| OverviewSummary.paymentAccountTotal | Long | 否 | matching正式Account數。 |
| OverviewSummary.pendingDepositCount | Long | 否 | 所選正式Account未解除Deposit obligations。 |
| OverviewSummary.pendingWithdrawalCount | Long | 否 | 所選正式Account未解除Withdrawal obligations。 |
| OverviewSummary.drainCount | Long | 否 | matching CH DRAIN數。 |
| OverviewSummary.strandedCount | Long | 否 | matching CH STRANDED數。 |
| OverviewSummary.cardholderStatusCounts | map<enum,Long> | 否 | 全鍵ACTIVE／LOCKED／INACTIVE。 |
| OverviewSummary.loginStatusCounts | map<enum,Long> | 否 | 全鍵LOGGED_IN／LOGOUT_PENDING／LOGGED_OUT。 |
| OverviewSummary.paymentAccountStatusCounts | map<enum,Long> | 否 | 全鍵ACTIVE／INACTIVE。 |
| OverviewSummary.freezeStatusCounts | map<enum,Long> | 否 | 全鍵UNFROZEN／FROZEN。 |
| OverviewSummary.applicationStatusCounts | map<enum,Long> | 否 | 全鍵PENDING／APPROVED／REJECTED／CANCELLED。 |
| OverviewSummary.currencyTotals | CurrencyTotal[] | 否 | 依Currency分組，不跨幣別。 |
| CurrencyTotal.currencyId | ID | 否 | group identity。 |
| CurrencyTotal.currencyCode | string | 否 | 金額單位。 |
| CurrencyTotal.balance | Money | 否 | exact book sum。 |
| CurrencyTotal.reservedAmount | Money | 否 | exact Withdrawal reserve sum。 |
| CurrencyTotal.availableAmount | Money | 否 | balance−reserved sum。 |

### 5.3 CardholderOverviewRow

展開全部IdentityDisplay欄位（同上型別／nullable），另逐欄：

| 欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| cardholderStatus | ACTIVE／LOCKED／INACTIVE | 否 | CH operational狀態。 |
| lockReason | string | 是 | 安全CH lock code；非LOCKED時null。 |
| loginStatus | LOGGED_IN／LOGOUT_PENDING／LOGGED_OUT | 否 | §3.3 fresh projection。 |
| scheduledLogoutTime | Instant | 是 | LOGOUT_PENDING時有效scheduled sessions最早deadline；其他null。 |
| drainState | NONE／DRAIN／STRANDED | 否 | §3.3只讀標籤。 |
| paymentAccountCount | Long | 否 | CH全部正式Accounts。 |
| pendingApplicationCount | Long | 否 | CH全部PENDING Applications。 |
| pendingDepositCount | Long | 否 | CH全部Account obligations合計。 |
| pendingWithdrawalCount | Long | 否 | 同上Withdrawal，不跨Account distinct。 |
| balance | Money | 否 | CH全部正式book sum。 |
| reservedAmount | Money | 否 | CH全部Withdrawal reserve sum。 |
| availableAmount | Money | 否 | 完整aggregate差額。 |

### 5.4 OverviewCardRow／PaymentAccountDetail／ApplicationDetail

每個OverviewCardRow展開全部IdentityDisplay（同5.1）；下表「Account／App nullable」各欄都存在。PaymentAccountDetail是rowType=PAYMENT_ACCOUNT的完整row加四bounds；ApplicationDetail是rowType=APPLICATION的完整row加5.5。非對應rowType的欄位回null，不省略，不以false/0代替。

| 欄位 | Type | Account nullable | App nullable | 用途 |
| --- | --- | --- | --- | --- |
| rowType | PAYMENT_ACCOUNT／APPLICATION | 否 | 否 | discriminant。 |
| paymentAccountId | ID | 否 | 是 | 正式identity，與applicationId恰一非null。 |
| applicationId | ID | 是 | 否 | 申請identity。 |
| bankId | ID | 否 | 否 | Bank identity；正式Account僅editScope=FULL可經R25修改，Application immutable。 |
| bankCode | string | 是 | 是 | Bank顯示code。 |
| bankName | string | 是 | 是 | Bank顯示name。 |
| accountNumber | string | 否 | 否 | 完整canonical account，PII，no-store。 |
| accountName | string | 否 | 否 | 受權限帳戶顯示name，非verified姓名。 |
| paymentAccountDisplayName | string | 否 | 否 | 卡片展示名稱，不要求唯一、不影響派單；欄位為NULL時以accountName顯示。IdentityDisplay.displayName仍是Cardholder名稱（#698 G83）。 |
| editScope | FULL／DISPLAY_NAME_ONLY／NONE | 否 | 是 | 卡片可編輯範圍的fresh UI hint，writer持鎖後重新計算（ADR-0461）：FULL為INACTIVE、UNFROZEN、balance與reservedAmount皆零、pending皆零且沒有attempt屬於未終局訂單；其他INACTIVE為DISPLAY_NAME_ONLY；ACTIVE或操作者無UPDATE為NONE；Application為null。 |
| version | Version | 否 | 否 | 此resource root concurrency。 |
| createTime | Instant | 否 | 否 | resource建立時間。 |
| modifyTime | Instant | 否 | 否 | resource最近mutation metadata，非activity時間。 |
| creator | string | 是 | 是 | 建立者 account snapshot（#550）：Account為核准建立的BO操作者，Application為申請的BO操作者或App本人`cardholder:<username>`；本欄上線前的歷史資料為null。 |
| modifier | string | 是 | 是 | 最近實際異動者 account snapshot（#550）：BO操作者或App本人`cardholder:<username>`；no-op、replay與金流reserve／credit／debit／release不改；歷史資料為null。 |
| availableActions | string[] | 否 | 否 | §3.4安全fresh UI hints。 |
| accountStatus | ACTIVE／INACTIVE | 否 | 是 | 獨立new-admission gate。 |
| freezeStatus | UNFROZEN／FROZEN | 否 | 是 | 獨立system gate。 |
| receivingEnabled | boolean | 否 | 是 | Deposit intent flag。 |
| sendingEnabled | boolean | 否 | 是 | Withdrawal intent flag。 |
| balance | Money | 否 | 是 | Ledger-backed book balance。 |
| reservedAmount | Money | 否 | 是 | Withdrawal book reserve。 |
| availableAmount | Money | 否 | 是 | balance−reserved，不能負值。 |
| pendingDepositCount | Long | 否 | 是 | own outstanding obligations。 |
| pendingWithdrawalCount | Long | 否 | 是 | 同上Withdrawal。 |
| dailyUsage | TodayUsage | 否 | 是 | Supplier local today兩方向記帳。 |
| applicationStatus | PENDING／APPROVED／REJECTED／CANCELLED | 是 | 否 | Application lifecycle；正式Account=null。 |
| cardholderPauseStatus | PAUSING／PAUSED | 是 | 是 | Cardholder App暫停狀態（#824 legacy語意，#827唯讀顯示）：PAUSING為倒數中、兩方向已關閉、到點由BO排程重開；PAUSED為到點重開檢查不通過；未暫停為null。不是accountStatus或freezeStatus；BO切方向或改狀態會清除（#824）；Application恆為null。 |
| cardholderPauseDeadline | Instant | 是 | 是 | PAUSING的到點重開時間（UTC Instant）；PAUSED、未暫停與Application為null。 |
| PaymentAccountDetail.depositMinAmount | Money | 否 | 不適用 | Gateway Deposit min，0不限制。 |
| PaymentAccountDetail.depositMaxAmount | Money | 否 | 不適用 | Gateway Deposit max，0不限制。 |
| PaymentAccountDetail.withdrawalMinAmount | Money | 否 | 不適用 | Gateway Withdrawal min，0不限制。 |
| PaymentAccountDetail.withdrawalMaxAmount | Money | 否 | 不適用 | Gateway Withdrawal max，0不限制。 |
| TodayUsage.businessDate | Date | 否 | 不適用 | evaluationTime依Supplier current offset的today。 |
| TodayUsage.deposit | UsageNumbers | 否 | 不適用 | 該日Deposit counters。 |
| TodayUsage.withdrawal | UsageNumbers | 否 | 不適用 | 該日Withdrawal counters。 |

### 5.5 ApplicationDetail、ActorIdentity、ApprovalResult

| DTO／欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| ApplicationDetail.applicant | ActorIdentity | 否 | 建立時實際realm principal，不是owner identity。 |
| ApplicationDetail.reviewer | ActorIdentity | 是 | 僅APPROVED／REJECTED存在，取消為null。 |
| ApplicationDetail.reviewTime | Instant | 是 | 同上committed review時間。 |
| ApplicationDetail.reviewReason | string | 是 | 同上授權domain原文；不寫audit。 |
| ApplicationDetail.linkedPaymentAccountId | ID | 是 | 僅APPROVED有值。 |
| ActorIdentity.principalType | string | 否 | 安全realm principal類型SUPERADMIN／SUPPLIER／GATEWAY，不用owner代替；Cardholder 以 App 自建的 Application（ADR-0041），applicant 為 CARDHOLDER（reviewer 不會是 CARDHOLDER）。 |
| ActorIdentity.principalId | ID | 否 | 實際登入principal identity。 |
| ActorIdentity.account | string | 否 | 該principal登入account顯示，非Supplier loginId。 |
| ApprovalResult.application | ApplicationDetail | 否 | 同transaction APPROVED結果。 |
| ApprovalResult.paymentAccount | PaymentAccountDetail | 否 | 新正式Account初始結果。 |

Create／cancel／command reason若必須保留僅在受授權domain record；本DTO不增未列欄位，不把cancel reason當reviewReason。

### 5.6 UsageNumbers、DailyUsageResult、DailyUsageEntry、PendingOrderRow

| DTO／欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| UsageNumbers.reservedCount | Long | 否 | 有效reserve count。 |
| UsageNumbers.usedCount | Long | 否 | native confirmed consume/correction count。 |
| UsageNumbers.reservedAmount | Money | 否 | 原日方向reserve sum，非必然book reserve。 |
| UsageNumbers.usedAmount | Money | 否 | 原日confirmed amount sum。 |
| DailyUsageResult.paymentAccountId | ID | 否 | target。 |
| DailyUsageResult.currencyId | ID | 否 | 金額單位identity。 |
| DailyUsageResult.currencyCode | string | 否 | 金額單位顯示。 |
| DailyUsageResult.businessDate | Date | 否 | resolved bucket date。 |
| DailyUsageResult.direction | DEPOSIT／WITHDRAWAL | 否 | resolved direction。 |
| DailyUsageResult.evaluationTime | Instant | 否 | 本request時間。 |
| DailyUsageEntry.kind | RESERVED／USED | 否 | contribution種類。 |
| DailyUsageEntry.sourceId | ID | 否 | §4.1 native source，非audit ID。 |
| DailyUsageEntry.orderId | ID | 否 | formal Order identity。 |
| DailyUsageEntry.orderNo | string | 否 | 安全Order display number。 |
| DailyUsageEntry.assignmentAttemptId | ID | 否 | own immutable attempt。 |
| DailyUsageEntry.amount | Money | 否 | 本row counter contribution。 |
| DailyUsageEntry.countContribution | int（0／1） | 否 | 本row count contribution。 |
| DailyUsageEntry.eventTime | Instant | 否 | committed accounting event時間。 |
| DailyUsageEntry.assignmentBusinessDate | Date | 否 | 原attempt immutable bucket。 |
| DailyUsageEntry.assignmentBusinessUtcOffset | Offset | 否 | 原attempt immutable offset。 |
| PendingOrderRow.direction | DEPOSIT／WITHDRAWAL | 否 | obligation方向。 |
| PendingOrderRow.orderId | ID | 否 | formal Order。 |
| PendingOrderRow.orderNo | string | 否 | 安全Order顯示。 |
| PendingOrderRow.orderStatus | string | 否 | native安全狀態，不能用它單獨決定obligation。 |
| PendingOrderRow.assignmentAttemptId | ID | 否 | own attempt identity。 |
| PendingOrderRow.reservationId | ID | 否 | 未解除reservation identity。 |
| PendingOrderRow.reservationStatus | string | 否 | native reservation state，通常RESERVED；不是新review-held enum。 |
| PendingOrderRow.requestedAmount | Money | 否 | immutable requested amount。 |
| PendingOrderRow.actualAmount | Money | 是 | 尚無confirmed actual為null，proof不自動升級。 |
| PendingOrderRow.assignedTime | Instant | 否 | immutable assignment時間。 |
| PendingOrderRow.deadlineTime | Instant | 是 | source若無deadline為null。 |
| PendingOrderRow.reviewReasonCode | string | 是 | 安全structured code。 |
| PendingOrderRow.verifiedFundsPresent | boolean | 否 | 可信入款／出款fact，非未驗proof。 |
| PendingOrderRow.processingBlocked | boolean | 否 | 由Freeze／core guard算出。 |
| PendingOrderRow.processingBlockReason | string | 是 | blocked安全code，否則null。 |
| PendingOrderRow.availableActions | string[] | 否 | §4.1原Order authority hint，不提供假workspace。 |

DailyUsageResult另外flat展開UsageNumbers四欄；DailyUsageEntry page不附counter，與#9相同bucket核對。

### 5.7 ActivityItem、ActivitySummary

| DTO／欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| ActivityItem.activityId | string | 否 | type:sourceId穩定row key。 |
| ActivityItem.type | DEPOSIT／WITHDRAWAL／BALANCE_CHANGE | 否 | source種類。 |
| ActivityItem.sourceId | ID | 否 | own attempt或獨立Ledger ID。 |
| ActivityItem.paymentAccountId | ID | 否 | scoped Account。 |
| ActivityItem.orderId | ID | 是 | Order type必有；獨立Ledger無則null。 |
| ActivityItem.orderNo | string | 是 | 同上安全display。 |
| ActivityItem.assignmentAttemptId | ID | 是 | Order type必有；independent無則null。 |
| ActivityItem.eventTime | Instant | 否 | §4.3 committed source時間。 |
| ActivityItem.status | string | 否 | source-native安全status／Ledger kind。 |
| ActivityItem.statusKind | SUCCESS／PENDING／REJECTED／EXPIRED／CANCELLED／INFO | 否 | disposition mapping。 |
| ActivityItem.direction | IN／OUT／NONE | 否 | Order預期方向或Ledger sign，不等於已完成Cash。 |
| ActivityItem.amount | Money | 否 | requested／successful actual／abs(delta)。 |
| ActivityItem.balanceDelta | SignedMoney | 是 | own committed金融fact delta，無則null。 |
| ActivityItem.balanceBefore | Money | 是 | own金融fact before，無則null。 |
| ActivityItem.balanceAfter | Money | 是 | own金融fact after，無則null。 |
| ActivityItem.summary | string | 否 | 安全structured顯示，不拼raw reason／provider／PII。 |
| ActivityItem.reviewReasonCode | string | 是 | 安全structured code。 |
| ActivityItem.verifiedFundsPresent | boolean | 否 | own可信funds fact；manual adjustment=false。 |
| ActivityItem.bankCode | string | 是 | eventTime當時的Bank code（解析規則同§4.4 CSV，#699）。timeline不依賴Bank／Currency／帳號投影：這三欄無法驗證時皆null並寫一行WARN，列表仍200；CSV與Account read維持原錯誤。 |
| ActivityItem.accountNumber | string | 是 | eventTime當時的完整canonical account，PII，no-store。 |
| ActivityItem.accountName | string | 是 | eventTime當時的帳戶name，非verified姓名。 |
| ActivitySummary.from | Instant | 否 | resolved inclusive bound。 |
| ActivitySummary.to | Instant | 否 | resolved exclusive bound。 |
| ActivitySummary.evaluationTime | Instant | 否 | 本request時間。 |
| ActivitySummary.currencyId | ID | 否 | 單Account Currency。 |
| ActivitySummary.currencyCode | string | 否 | 金額單位。 |
| ActivitySummary.totalIn | Money | 否 | matching可信成功Deposit actual sum。 |
| ActivitySummary.totalOut | Money | 否 | matching可信成功Withdrawal actual sum。 |
| ActivitySummary.net | SignedMoney | 否 | totalIn−totalOut。 |
| ActivitySummary.depositCount | Long | 否 | matching distinct formal Deposit Orders。 |
| ActivitySummary.withdrawalCount | Long | 否 | matching distinct formal Withdrawal Orders。 |
| ActivitySummary.pendingDeposits | Long | 否 | matching未解除Deposit obligations，attempt grain。 |
| ActivitySummary.pendingWithdrawals | Long | 否 | 同上Withdrawal。 |
| ActivitySummary.rejectedDeposits | Long | 否 | matching REJECTED distinct formal Deposit。 |
| ActivitySummary.rejectedWithdrawals | Long | 否 | 同上Withdrawal。 |
| ActivitySummary.totalEventCount | Long | 否 | matching timeline row數。 |

### 5.8 BalanceLogRow／BalanceAdjustmentResult／AccountDeleteResult

| DTO／欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| BalanceLogRow.balanceLogId | ID | 否 | immutable Ledger ID。 |
| BalanceLogRow.paymentAccountId | ID | 否 | scoped target。 |
| BalanceLogRow.entryType | string | 否 | server Ledger kind；非frontend enum替代。 |
| BalanceLogRow.eventTime | Instant | 否 | Ledger createTime。 |
| BalanceLogRow.balanceBefore | Money | 否 | committed before。 |
| BalanceLogRow.balanceAfter | Money | 否 | committed after。 |
| BalanceLogRow.balanceDelta | SignedMoney | 否 | before＋delta＝after。 |
| BalanceLogRow.orderId | ID | 是 | native formal reference；independent null。 |
| BalanceLogRow.assignmentAttemptId | ID | 是 | native attempt reference；independent null。 |
| BalanceLogRow.reasonCategory | string | 是 | manual安全category，非manual null。 |
| BalanceLogRow.reason | string | 是 | 授權manual domain原文；Gateway始終null。 |
| BalanceLogRow.evidenceReference | string | 是 | 授權manual人工reference；Gateway始終null。 |
| BalanceLogRow.operatorAccount | string | 是 | 授權manual actor display；Gateway始終null。 |
| BalanceAdjustmentResult.paymentAccountId | ID | 否 | target。 |
| BalanceAdjustmentResult.currencyId | ID | 否 | Currency identity。 |
| BalanceAdjustmentResult.currencyCode | string | 否 | 金額單位。 |
| BalanceAdjustmentResult.balanceBefore | Money | 否 | locked首次before。 |
| BalanceAdjustmentResult.balanceDelta | SignedMoney | 否 | computed首次delta。 |
| BalanceAdjustmentResult.balanceAfter | Money | 否 | 首次newBalance。 |
| BalanceAdjustmentResult.reservedAmount | Money | 否 | 首次Withdrawal reserved。 |
| BalanceAdjustmentResult.availableAmount | Money | 否 | 首次after−reserved。 |
| BalanceAdjustmentResult.version | Version | 否 | 首次result root version。 |
| BalanceAdjustmentResult.balanceLogId | ID | 是 | 非zero Ledger ID；no-op=null。 |
| BalanceAdjustmentResult.operationTime | Instant | 否 | 首次command server時間。 |
| AccountDeleteResult.paymentAccountId | ID | 否 | target。 |
| AccountDeleteResult.status | string | 否 | 固定 `DELETED`。 |
| AccountDeleteResult.version | Version | 否 | 刪除後的 Account version。 |

Gateway reasonCategory可見，reason/evidence/operator始終null；不以可讀metadata授予Adjust。

### 5.9 PaymentAccountLimit

| DTO／欄位 | Type | Nullable | 用途 |
| --- | --- | --- | --- |
| PaymentAccountLimit.paymentAccountId | ID | 否 | target Account。 |
| PaymentAccountLimit.currencyId | ID | 否 | Account Currency identity。 |
| PaymentAccountLimit.currencyCode | string | 否 | 限額金額單位的 Currency code display。 |
| PaymentAccountLimit.dailyAmountLimit | Money | 是 | Deposit 原 business date 日金額上限；null 不限制。 |
| PaymentAccountLimit.dailyTxLimit | int | 是 | Deposit 原 business date 日筆數上限，1..2147483647；null 不限制。 |
| PaymentAccountLimit.balanceCeiling | Money | 是 | Balance Ceiling；null 不限制。 |
| PaymentAccountLimit.limitOverridden | boolean | 否 | true 為 Superadmin 個別覆寫，幣別預設回補略過。 |
| PaymentAccountLimit.systemMaxCeiling | Money | 是 | 該幣別 System Max Ceiling，覆寫 balanceCeiling 上限；null 不限制。 |
| PaymentAccountLimit.version | Version | 否 | Account root version；覆寫的 expectedVersion。 |

## 6. 26 條 route 與逐欄 request

所有path IDs required ID；path之外未列query／body拒絕。以下共用query組件是**封閉allowlist**，其逐欄型別／optional於§2–3／下表完整定義。不是任意entity binding。

| 共用query | 逐欄型別／default |
| --- | --- |
| PageQuery | pageNumber:int optional default 0；pageSize:int optional default 20。 |
| DailyQuery | direction:DEPOSIT／WITHDRAWAL required；businessDate:Date optional default Supplier today，不接受future。 |
| TimeFilter | from:Instant／to:Instant各optional但成對，default見§4.2。 |
| ActivityFilter | TimeFilter；types:DEPOSIT／WITHDRAWAL／BALANCE_CHANGE repeated optional default三類；statusKinds:SUCCESS／PENDING／REJECTED／EXPIRED／CANCELLED／INFO repeated optional，未帶不篩。 |
| ReviewCommand | expectedVersion:Version required；reason:reason required；idempotencyKey:idempotencyKey required。 |

### 6.1 Overview／detail（#01–#07）

| # | Method | Path（相對 /bo/v2） | Query／body allowlist | data／success |
| --- | --- | --- | --- | --- |
| 01 | GET | /cardholderOverview/options | type required SUPPLIER／GATEWAY／BANK；keyword:string trim1..100 optional；PageQuery；依下述type選擇supplierId／gatewayId／currencyId:ID optional | PageVo<OptionRow>，200 |
| 02 | GET | /cardholderOverview/summary | OverviewFilter；view optional ACCOUNT／CARD default ACCOUNT；無page | OverviewSummary，200 |
| 03 | GET | /cardholderOverview/cardholders | OverviewFilter＋PageQuery；固定ACCOUNT，不接受view | PageVo<CardholderOverviewRow>，200 |
| 04 | GET | /cardholderOverview/cardholders/{cardholderId}/cards | rowType／bankId／accountStatus／freezeStatus／applicationStatus／accountNumber／accountLast4／hasBalance／hasPendingOrders（同OverviewFilter型別）＋PageQuery；固定CARD，不接受person／owner／view | PageVo<OverviewCardRow>，200 |
| 05 | GET | /cardholderOverview/cards | OverviewFilter＋PageQuery；固定CARD，不接受view | PageVo<OverviewCardRow>，200 |
| 06 | GET | /paymentAccounts/{id} | 無query/body | PaymentAccountDetail，200 |
| 07 | GET | /paymentAccountApplications/{id} | 無query/body，terminal可讀 | ApplicationDetail，200 |

Options keyword case-insensitive contains code／name／login display，escape wildcard；code ASC、id ASC。SUPPLIER只允許Superadmin，不接受任何owner／Currency selectors。GATEWAY：Superadmin可supplierId、Supplier own descendants、Gateway僅self；可currencyId，不接受gatewayId。BANK：ScopeFilter＋currencyId，只回可見scope Currency Banks。Currency selector不存在／scope外404，Bank／owner operational INACTIVE可留作歷史查詢，不表示可create。OptionRow nullability見§5.2，不另新增全域master read authority。#04先驗CH target scope再查children，合法無children 200 empty page。

### 6.2 Pending／Daily（#08–#10）

| # | Method | Path | Query／body allowlist | data／success |
| --- | --- | --- | --- | --- |
| 08 | GET | /paymentAccounts/{id}/pendingOrders | direction optional DEPOSIT／WITHDRAWAL，未帶兩方向；PageQuery | PageVo<PendingOrderRow>，200 |
| 09 | GET | /paymentAccounts/{id}/dailyUsage | DailyQuery，不接受page | DailyUsageResult（flat UsageNumbers），200 |
| 10 | GET | /paymentAccounts/{id}/dailyUsage/entries | DailyQuery；kinds repeated optional RESERVED／USED default兩者；PageQuery | PageVo<DailyUsageEntry>，200 |

### 6.3 Ledger／Activity（#11–#14）

| # | Method | Path | Query／body allowlist | data／success |
| --- | --- | --- | --- | --- |
| 11 | GET | /paymentAccounts/{id}/balanceLogs | TimeFilter；entryType optional exact string1..30，ASCII uppercase server kind code（letters/digits/underscore），不做contains；PageQuery | PageVo<BalanceLogRow>，200 |
| 12 | GET | /paymentAccounts/{id}/activities | ActivityFilter＋PageQuery | PageVo<ActivityItem>，200 |
| 13 | GET | /paymentAccounts/{id}/activities/summary | ActivityFilter，不接受page | ActivitySummary，200 |
| 14 | GET | /paymentAccounts/{id}/activities/csv | ActivityFilter，不接受page | UTF-8 CSV，200，無envelope |

Ledger排序eventTime DESC／balanceLogId DESC。Activity排序eventTime DESC／type ASC／sourceId DESC，穩定same timestamp。#11有效但未知server kind可200 empty，不把未知kind當未篩選。

### 6.4 Application lifecycle（#15–#18）

| # | Method | Path | required body（完整allowlist） | data／success |
| --- | --- | --- | --- | --- |
| 15 | POST | /paymentAccountApplications | cardholderId:ID、bankId:ID、accountNumber:帳號string、accountName:accountName、displayName:accountName（可選；未帶時核准以accountName建立卡片）、reason:reason、idempotencyKey:idempotencyKey | ApplicationDetail，201／PENDING |
| 16 | POST | /paymentAccountApplications/{id}/approve | ReviewCommand | ApprovalResult，200 |
| 17 | POST | /paymentAccountApplications/{id}/reject | ReviewCommand | ApplicationDetail，200／REJECTED |
| 18 | POST | /paymentAccountApplications/{id}/cancel | ReviewCommand | ApplicationDetail，200／CANCELLED |

Create／approve要求active intact owner chain、Cardholder、Bank、Gateway Currency一致與canonical Supply-wide uniqueness。正式 `(currencyId,bankId,accountNumber)` 由該Account占用：有attempt或Ledger的卡修改後仍占用舊identity（同卡可改回），從未使用的卡修改時釋放舊identity（ADR-0461（此參考僅供內部環境使用，公開版本未提供））；同identity最多一個PENDING，併發create／approve原子唯一性，不只先查後寫。Reject／cancel只要求intact chain／PENDING，不要求Bank／descendants仍ACTIVE；caller正式權限始終fresh。

PENDING payload immutable，不提供PATCH；錯誤先cancel後重建。Approve原子重驗、建Account、linkedID／application version／audit、释放pending guard。Account初始ACTIVE、UNFROZEN、receiving=false／sending=false、balance/reserved=0、available=0、無Ledger／reservation／used counter，initial version=0。Reject／cancel不建Account、释放pending identity；terminal不重開（同key replay除外）。approve/reject保存reviewer/time/reason；cancel reviewer/time/reason=null。Create version=0；真正review/cancel Application root version升一次。禁止currency/owner override、initial balance/status/direction、reviewer／credential輸入；hidden direct POST /paymentAccounts不作可啟用bypass。

### 6.5 Account commands（#19–#22）

| # | Method | Path | required body（完整allowlist） | data／success |
| --- | --- | --- | --- | --- |
| 19 | PUT | /paymentAccounts/{id}/status | accountStatus:ACTIVE／INACTIVE、expectedVersion:Version、reason:reason | PaymentAccountDetail，200 |
| 20 | PUT | /paymentAccounts/{id}/directionAvailability | direction:DEPOSIT／WITHDRAWAL、enabled:boolean、expectedVersion:Version、reason:reason | PaymentAccountDetail，200 |
| 21 | POST | /paymentAccounts/{id}/balanceAdjustments | newBalance:Money、expectedVersion:Version、idempotencyKey:idempotencyKey、reasonCategory:RECONCILIATION／ACTUAL_AMOUNT_DIFFERENCE／OTHER、reason:reason、evidenceReference:string trim1..200非secret無controls | BalanceAdjustmentResult，200 |
| 22 | POST | /paymentAccounts/{id}/unfreeze | expectedVersion:Version、reason:reason | PaymentAccountDetail，200 |

Status INACTIVE可停止新承接，不要求inactive descendant／Bank先ACTIVE。依 ADR-0461（此參考僅供內部環境使用，公開版本未提供），Gateway 可把 own scope Account 切為 ACTIVE 或 INACTIVE，恢復 ACTIVE 與 Supplier 同樣重驗資格（不符為 409 STATE_CONFLICT）；他 Gateway 的 Account 仍 404。依 ADR-0481（此參考僅供內部環境使用，公開版本未提供）（#955），Gateway 與 Supplier 一樣可在 own scope 切換方向與解凍。status、direction、unfreeze、Adjust 與帳戶限額（#23／#24）的 scope 外拒絕各寫一行 WARN：`payment account command rejected: route=<route> status=404 reason=OUT_OF_SCOPE paymentAccountId=<id> actorType=<type> actorId=<id>`，不含帳號、帳戶名、金額或 reason。ACTIVE前須active intact chain／CH／Bank、Currency invariant；Frozen仍可ACTIVE，Freeze獨立阻擋，不修改flags／existing obligation。Direction DEPOSIT只改receiving，WITHDRAWAL只改sending；enable須Account ACTIVE、active chain／CH／Bank與Currency invariant，不解凍、不保證session／routing；disable不影響另一方向／既有obligation。Unfreeze要求identity chain一致、不要求routing eligibility，FROZEN→UNFROZEN在ACTIVE／INACTIVE均可；current已UNFROZEN no-op，不自動settle。

新Adjust先lock/version/state，從locked before算delta；newBalance<reserved拒絕，同數值no-op。evidenceReference是人工追溯reference，不是verified receipt authority／raw proof。reasonCategory不建立reconciliation流程。Nonzero delta原子append MANUAL_ADJUSTMENT immutable Ledger、更新projection／Account version、required安全audit與恰一次Balance Adjusted notification fact；投遞失敗不rollback已commit金融結果。不能external payout、不改Order/counter/reservation/Freeze/session。Replay回首次result，不拼最新balance。實際status／direction／unfreeze變更各只升Account root version一次；no-op metadata/version/audit不變。

<a id="66-account-limits2324"></a>
### 6.6 Account limits（#23–#24）、修改戶名與展示名稱（#25）、刪除（#26）

| # | Method | Path | Query／body allowlist | data／success |
| --- | --- | --- | --- | --- |
| 23 | GET | /paymentAccounts/{id}/limits | 無query/body | PaymentAccountLimit，200 |
| 24 | PUT | /paymentAccounts/{id}/limits | dailyAmountLimit:Money｜null、dailyTxLimit:int 1..2147483647｜null、balanceCeiling:Money｜null、expectedVersion:Version；四欄皆須出現 | PaymentAccountLimit，200 |
| 25 | PUT | /paymentAccounts/{id}/profile | displayName:accountName（可選）、accountName:accountName（可選）、bankId:ID（可選）、accountNumber:accountNumber（可選）、expectedVersion:Version、reason:reason；未帶的欄位不變 | PaymentAccountDetail，200 |
| 26 | DELETE | /paymentAccounts/{id} | expectedVersion:Version、reason:reason | AccountDeleteResult，200 |

#25 依 ADR-0461（此參考僅供內部環境使用，公開版本未提供），Superadmin、Supplier、Gateway 限 owner chain 範圍，scope 外與 missing 為 404；Cardholder App 不開放。Account 持鎖後先驗 version（stale 409 VERSION_CONFLICT），再以 current read 重新計算範圍：有變更的欄位超出範圍即整筆拒絕（409 STATE_CONFLICT），accountName 只有 FULL 可改，displayName 只有 INACTIVE 可改。同值 no-op 不改 version、modifyTime、modifier 與 audit。狀態維持 INACTIVE，方向、限額、Freeze 與金融值不變。audit 只記動作與 ids，不存展示名稱、戶名與原因原文；範圍不符、版本衝突與範圍外各寫一行 WARN（route、reason、paymentAccountId、actor），不含帳號、戶名、展示名稱或原因原文。

#26 依 ADR-0462（此參考僅供內部環境使用，公開版本未提供），Superadmin、Supplier、Gateway 限 owner chain 範圍，scope 外、missing 與已刪除都是 404；Cardholder App 不開放（`DELETE /cardholder/cards/{id}` 維持 `501/40038`）。Account 持鎖後先驗 version（stale 409 VERSION_CONFLICT），再判 `account_status=INACTIVE`、balance 與 reservedAmount 皆零、無 RESERVED reservation、無 attempt 屬於未終局訂單；不符回 409 STATE_CONFLICT，不改任何資料，ACTIVE 卡不會被順便停用。Freeze 不是條件。同交易寫 `status=DELETED`、原因、恰一筆 `DELETE_PAYMENT_ACCOUNT` audit、清除此卡全部 `payment_account_identity_guard.payment_account_id`（含 ADR-0461 改號留下的舊帳號）與 `CARD_DELETED`（`IN_APP`、`FCM`）；保留 account_status、freeze_status、identity、限額、daily counter、Ledger 與 identity 歷史，不連動 Cardholder、session、Order 或 Attempt，不可恢復。

已刪卡：清單、#6 詳情與其子資源 #8–#10、#23、所有變更操作都回 404；#11 帳本與 #12–#14 Activity／CSV、已核准的 Application 照常可讀，顯示當時的卡片資料。identity 查詢排除已刪卡，任何 Cardholder 可走一般 Application 重新申請，核准建立新列與新 `paymentAccountId`，初始值同一般新卡。

依 ADR-0427（此參考僅供內部環境使用，公開版本未提供） 與 ADR-0481（此參考僅供內部環境使用，公開版本未提供）（#955），Superadmin 全域、Supplier／Gateway 限 own scope；VIEW-only principal 可讀 #23、覆寫 #24 為 403 OPERATION_DENIED；scope 外、missing／不可驗證 owner chain 404。幣別預設限額的寫入仍只限 Superadmin（有 `SYSTEM_CONFIGURATION` VIEW 的 Prefix 可唯讀查詢，ADR-0495（此參考僅供內部環境使用，公開版本未提供））。限額 Money 為正數，零、JSON number 與 Money 文法外輸入 400；null 表示不限制。#24 整組取代三項限額並標記 `limitOverridden=true`，之後幣別預設「回補」略過此帳戶；幣別設有 System Max Ceiling 時 balanceCeiling 必填且不得超過（等於可設），否則 400 `balanceCeiling`。依一般設定順序 fresh authority → lock（幣別預設列 → Account）→ version → equality；current-version 同值且已覆寫為 no-op（不升 version、不寫 audit），實際變更升 Account root version 一次並同交易寫一筆 HIGH audit。限額只影響 Deposit routing，不改 status、Freeze、flags、餘額、Order 或 Withdrawal／HOUSE。

## 7. 共用 errors 的完整 JSON examples

全部使用synthetic fixtures，帳號是測試字串，不含真實PII／secret。每route §8指定成功與代表error；其餘errors依§2與驗證矩陣同shape。

```json
{"code":40005,"message":"欄位驗證失敗","data":{"field":"pageSize","reasonCode":"INVALID_FIELD"}}
```
```json
{"code":40000,"message":"需要有效登入","data":{"field":null,"reasonCode":"SESSION_REQUIRED"}}
```
```json
{"code":40001,"message":"操作未授權","data":{"field":null,"reasonCode":"OPERATION_DENIED"}}
```
```json
{"code":40001,"message":"不可審核本人申請","data":{"field":null,"reasonCode":"SELF_REVIEW_DENIED"}}
```
```json
{"code":40002,"message":"資料不存在","data":{"field":null,"reasonCode":"NOT_FOUND"}}
```
```json
{"code":40007,"message":"金融識別已占用","data":{"field":"accountNumber","reasonCode":"IDENTITY_OCCUPIED"}}
```
```json
{"code":40045,"message":"重試識別衝突","data":{"field":"idempotencyKey","reasonCode":"IDEMPOTENCY_CONFLICT"}}
```
```json
{"code":40051,"message":"資料版本衝突","data":{"field":"expectedVersion","reasonCode":"VERSION_CONFLICT"}}
```
```json
{"code":40054,"message":"狀態不允許操作","data":{"field":null,"reasonCode":"STATE_CONFLICT"}}
```
```json
{"code":40054,"message":"帳戶尚未解凍","data":{"field":null,"reasonCode":"ACCOUNT_FROZEN"}}
```
```json
{"code":40054,"message":"調整後餘額低於預留","data":{"field":"newBalance","reasonCode":"BALANCE_BELOW_RESERVED"}}
```
```json
{"code":40044,"message":"必要來源暫不可用","data":{"field":null,"reasonCode":"NATIVE_DEPENDENCY_UNAVAILABLE"}}
```
```json
{"code":5000,"message":"無法提供一致結果","data":{"field":null,"reasonCode":"FINANCIAL_INVARIANT_FAILED"}}
```

## 8. 逐 route request／response examples

### R01 — GET /cardholderOverview/options

Supplier principal 51，own Gateway 11。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/cardholderOverview/options?type=BANK&gatewayId=11`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"id":31,"code":"BANK_FIXTURE","name":"測試 Bank","status":"ACTIVE","currencyId":7,"currencyCode":"THB","supplierId":null}],"total":1,"size":20,"number":0}}
```

**Error fixture/request**：type=ALL；HTTP 400。

```json
{"code":40005,"message":"操作未完成","data":{"field":"type","reasonCode":"INVALID_FIELD"}}
```

### R02 — GET /cardholderOverview/summary

Supplier principal 51，own Gateway 11。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/cardholderOverview/summary?view=ACCOUNT&gatewayId=11`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"evaluationTime":"2026-09-14T03:00:00Z","cardholderTotal":1,"paymentAccountTotal":1,"pendingDepositCount":0,"pendingWithdrawalCount":1,"drainCount":0,"strandedCount":1,"cardholderStatusCounts":{"ACTIVE":1,"LOCKED":0,"INACTIVE":0},"loginStatusCounts":{"LOGGED_IN":0,"LOGOUT_PENDING":0,"LOGGED_OUT":1},"paymentAccountStatusCounts":{"ACTIVE":1,"INACTIVE":0},"freezeStatusCounts":{"UNFROZEN":1,"FROZEN":0},"applicationStatusCounts":{"PENDING":1,"APPROVED":0,"REJECTED":0,"CANCELLED":0},"currencyTotals":[{"currencyId":7,"currencyCode":"THB","balance":"100","reservedAmount":"20","availableAmount":"80"}]}}
```

**Error fixture/request**：view=ALL；HTTP 400。

```json
{"code":40005,"message":"操作未完成","data":{"field":"view","reasonCode":"INVALID_FIELD"}}
```

### R03 — GET /cardholderOverview/cardholders

Supplier principal 51。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/cardholderOverview/cardholders?gatewayId=11`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","cardholderStatus":"ACTIVE","lockReason":null,"loginStatus":"LOGGED_OUT","scheduledLogoutTime":null,"drainState":"STRANDED","paymentAccountCount":1,"pendingApplicationCount":1,"pendingDepositCount":0,"pendingWithdrawalCount":1,"balance":"100","reservedAmount":"20","availableAmount":"80"}],"total":1,"size":20,"number":0}}
```

**Error fixture/request**：gatewayId=scope外ID；HTTP 404。

```json
{"code":40002,"message":"操作未完成","data":{"field":null,"reasonCode":"NOT_FOUND"}}
```

### R04 — GET /cardholderOverview/cardholders/{cardholderId}/cards

Supplier principal 51，target CH 101。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/cardholderOverview/cardholders/101/cards`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"rowType":"APPLICATION","paymentAccountId":null,"applicationId":301,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":null,"version":0,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_one","modifier":"fixture_supplier_one","availableActions":["CANCEL"],"accountStatus":null,"freezeStatus":null,"receivingEnabled":null,"sendingEnabled":null,"balance":null,"reservedAmount":null,"availableAmount":null,"pendingDepositCount":null,"pendingWithdrawalCount":null,"dailyUsage":null,"applicationStatus":"PENDING","cardholderPauseStatus":null,"cardholderPauseDeadline":null},{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":201,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST201","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":"NONE","version":4,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_INACTIVE","ENABLE_RECEIVING","ENABLE_SENDING"],"accountStatus":"ACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":false,"sendingEnabled":false,"balance":"100","reservedAmount":"20","availableAmount":"80","pendingDepositCount":0,"pendingWithdrawalCount":1,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":1,"usedCount":0,"reservedAmount":"20","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null}],"total":2,"size":20,"number":0}}
```

**Error fixture/request**：supplierId=1；HTTP 400。

```json
{"code":40005,"message":"操作未完成","data":{"field":"supplierId","reasonCode":"INVALID_FIELD"}}
```

### R05 — GET /cardholderOverview/cards

Supplier principal 51。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/cardholderOverview/cards?gatewayId=11`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"rowType":"APPLICATION","paymentAccountId":null,"applicationId":301,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":null,"version":0,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_one","modifier":"fixture_supplier_one","availableActions":["CANCEL"],"accountStatus":null,"freezeStatus":null,"receivingEnabled":null,"sendingEnabled":null,"balance":null,"reservedAmount":null,"availableAmount":null,"pendingDepositCount":null,"pendingWithdrawalCount":null,"dailyUsage":null,"applicationStatus":"PENDING","cardholderPauseStatus":null,"cardholderPauseDeadline":null},{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":201,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST201","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":"NONE","version":4,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_INACTIVE","ENABLE_RECEIVING","ENABLE_SENDING"],"accountStatus":"ACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":false,"sendingEnabled":false,"balance":"100","reservedAmount":"20","availableAmount":"80","pendingDepositCount":0,"pendingWithdrawalCount":1,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":1,"usedCount":0,"reservedAmount":"20","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null}],"total":2,"size":20,"number":0}}
```

**Error fixture/request**：rowType=APPLICATION&hasBalance=true；HTTP 400。

```json
{"code":40005,"message":"操作未完成","data":{"field":"rowType","reasonCode":"INVALID_COMBINATION"}}
```

### R06 — GET /paymentAccounts/{id}

Superadmin，target Account 201。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":201,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST201","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":"NONE","version":4,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_INACTIVE","ENABLE_RECEIVING","ENABLE_SENDING","ADJUST_BALANCE"],"accountStatus":"ACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":false,"sendingEnabled":false,"balance":"100","reservedAmount":"20","availableAmount":"80","pendingDepositCount":0,"pendingWithdrawalCount":1,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":1,"usedCount":0,"reservedAmount":"20","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null,"depositMinAmount":"0","depositMaxAmount":"0","withdrawalMinAmount":"0","withdrawalMaxAmount":"0"}}
```

**Error fixture/request**：path ID指向scope外Account；HTTP 404。

```json
{"code":40002,"message":"操作未完成","data":{"field":null,"reasonCode":"NOT_FOUND"}}
```

### R07 — GET /paymentAccountApplications/{id}

Supplier principal 51，target Application 301。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccountApplications/301`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"APPLICATION","paymentAccountId":null,"applicationId":301,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":null,"version":0,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_one","modifier":"fixture_supplier_one","availableActions":["CANCEL"],"accountStatus":null,"freezeStatus":null,"receivingEnabled":null,"sendingEnabled":null,"balance":null,"reservedAmount":null,"availableAmount":null,"pendingDepositCount":null,"pendingWithdrawalCount":null,"dailyUsage":null,"applicationStatus":"PENDING","cardholderPauseStatus":null,"cardholderPauseDeadline":null,"applicant":{"principalType":"SUPPLIER","principalId":51,"account":"fixture_supplier_one"},"reviewer":null,"reviewTime":null,"reviewReason":null,"linkedPaymentAccountId":null}}
```

**Error fixture/request**：path ID指向scope外Application；HTTP 404。

```json
{"code":40002,"message":"操作未完成","data":{"field":null,"reasonCode":"NOT_FOUND"}}
```

### R08 — GET /paymentAccounts/{id}/pendingOrders

Gateway own Account 201；workspace未ready所以actions=[]。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201/pendingOrders?direction=WITHDRAWAL`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"direction":"WITHDRAWAL","orderId":401,"orderNo":"W-FIXTURE-401","orderStatus":"PENDING_REVIEW","assignmentAttemptId":501,"reservationId":601,"reservationStatus":"RESERVED","requestedAmount":"20","actualAmount":null,"assignedTime":"2026-09-14T02:00:00Z","deadlineTime":"2026-09-14T02:30:00Z","reviewReasonCode":"ASSIGNMENT_EXPIRED","verifiedFundsPresent":false,"processingBlocked":false,"processingBlockReason":null,"availableActions":[]}],"total":1,"size":20,"number":0}}
```

**Error fixture/request**：必要native Withdrawal source不可提供；HTTP 503。

```json
{"code":40044,"message":"操作未完成","data":{"field":null,"reasonCode":"NATIVE_DEPENDENCY_UNAVAILABLE"}}
```

### R09 — GET /paymentAccounts/{id}/dailyUsage

Gateway own Account 201。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201/dailyUsage?direction=WITHDRAWAL`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"paymentAccountId":201,"currencyId":7,"currencyCode":"THB","businessDate":"2026-09-14","direction":"WITHDRAWAL","evaluationTime":"2026-09-14T03:00:00Z","reservedCount":1,"usedCount":0,"reservedAmount":"20","usedAmount":"0"}}
```

**Error fixture/request**：native obligation有fact但counter缺失；HTTP 500。

```json
{"code":5000,"message":"操作未完成","data":{"field":null,"reasonCode":"FINANCIAL_INVARIANT_FAILED"}}
```

### R10 — GET /paymentAccounts/{id}/dailyUsage/entries

Gateway own Account 201。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201/dailyUsage/entries?direction=WITHDRAWAL&kinds=RESERVED&kinds=USED`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"kind":"RESERVED","sourceId":601,"orderId":401,"orderNo":"W-FIXTURE-401","assignmentAttemptId":501,"amount":"20","countContribution":1,"eventTime":"2026-09-14T02:00:00Z","assignmentBusinessDate":"2026-09-14","assignmentBusinessUtcOffset":"+07:00"}],"total":1,"size":20,"number":0}}
```

**Error fixture/request**：kinds=ALL；HTTP 400。

```json
{"code":40005,"message":"操作未完成","data":{"field":"kinds","reasonCode":"INVALID_FIELD"}}
```

### R11 — GET /paymentAccounts/{id}/balanceLogs

Gateway；manual原文／operator為null。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201/balanceLogs`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"balanceLogId":701,"paymentAccountId":201,"entryType":"MANUAL_ADJUSTMENT","eventTime":"2026-09-14T02:00:00Z","balanceBefore":"80","balanceAfter":"100","balanceDelta":"20","orderId":null,"assignmentAttemptId":null,"reasonCategory":"OTHER","reason":null,"evidenceReference":null,"operatorAccount":null}],"total":1,"size":20,"number":0}}
```

**Error fixture/request**：僅from沒有to；HTTP 400。

```json
{"code":40005,"message":"操作未完成","data":{"field":"from","reasonCode":"INVALID_TIME_RANGE"}}
```

### R12 — GET /paymentAccounts/{id}/activities

Gateway own Account 201。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201/activities?types=WITHDRAWAL&types=DEPOSIT`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"records":[{"activityId":"WITHDRAWAL:501","type":"WITHDRAWAL","sourceId":501,"paymentAccountId":201,"orderId":401,"orderNo":"W-FIXTURE-401","assignmentAttemptId":501,"eventTime":"2026-09-14T02:00:00Z","status":"EXPIRED","statusKind":"PENDING","direction":"OUT","amount":"20","balanceDelta":null,"balanceBefore":null,"balanceAfter":null,"summary":"取款義務待處理","reviewReasonCode":"ASSIGNMENT_EXPIRED","verifiedFundsPresent":false,"bankCode":"BANK_FIXTURE","accountNumber":"000TEST201","accountName":"測試戶名"}],"total":1,"size":20,"number":0}}
```

**Error fixture/request**：必要native source不可提供；HTTP 503。

```json
{"code":40044,"message":"操作未完成","data":{"field":null,"reasonCode":"NATIVE_DEPENDENCY_UNAVAILABLE"}}
```

### R13 — GET /paymentAccounts/{id}/activities/summary

Gateway own Account 201。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201/activities/summary?types=WITHDRAWAL&types=DEPOSIT`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"from":"2026-09-07T03:00:00Z","to":"2026-09-14T03:00:00Z","evaluationTime":"2026-09-14T03:00:00Z","currencyId":7,"currencyCode":"THB","totalIn":"0","totalOut":"0","net":"0","depositCount":0,"withdrawalCount":1,"pendingDeposits":0,"pendingWithdrawals":1,"rejectedDeposits":0,"rejectedWithdrawals":0,"totalEventCount":1}}
```

**Error fixture/request**：pageSize=20；HTTP 400。

```json
{"code":40005,"message":"操作未完成","data":{"field":"pageSize","reasonCode":"INVALID_FIELD"}}
```

### R14 — GET /paymentAccounts/{id}/activities/csv

Gateway own Account 201；只顯示matching WITHDRAWAL row。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`GET /bo/v2/paymentAccounts/201/activities/csv?types=WITHDRAWAL&types=DEPOSIT`。

**Success**：HTTP 200；Cache-Control: no-store。

Content-Type: text/csv;charset=UTF-8；Content-Disposition: attachment; filename="cardholder-activity-201.csv"。

```csv
eventTime,type,direction,amount,currencyCode,status,orderNo,paymentAccountId,bankCode,accountNumber,accountName,summary,balanceBefore,balanceDelta,balanceAfter
2026-09-14T02:00:00Z,WITHDRAWAL,OUT,20,THB,EXPIRED,W-FIXTURE-401,201,BANK_FIXTURE,000TEST201,測試帳戶,取款義務待處理,,,
```

**Error fixture/request**：Prefix direct call（headers尚未送出）；HTTP 403。

```json
{"code":40001,"message":"操作未完成","data":{"field":null,"reasonCode":"OPERATION_DENIED"}}
```

### R15 — POST /paymentAccountApplications

Supplier principal 51，新PENDING；201。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`POST /bo/v2/paymentAccountApplications`。

```json
{"cardholderId":101,"bankId":31,"accountNumber":"000-test_301","accountName":" 測試帳戶 ","reason":"測試建立","idempotencyKey":"fixture.create.301"}
```

**Success**：HTTP 201；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"APPLICATION","paymentAccountId":null,"applicationId":301,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":null,"version":0,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_one","modifier":"fixture_supplier_one","availableActions":["CANCEL"],"accountStatus":null,"freezeStatus":null,"receivingEnabled":null,"sendingEnabled":null,"balance":null,"reservedAmount":null,"availableAmount":null,"pendingDepositCount":null,"pendingWithdrawalCount":null,"dailyUsage":null,"applicationStatus":"PENDING","cardholderPauseStatus":null,"cardholderPauseDeadline":null,"applicant":{"principalType":"SUPPLIER","principalId":51,"account":"fixture_supplier_one"},"reviewer":null,"reviewTime":null,"reviewReason":null,"linkedPaymentAccountId":null}}
```

**Error fixture/request**：另一command已占同canonical identity；HTTP 409。

```json
{"code":40007,"message":"操作未完成","data":{"field":"accountNumber","reasonCode":"IDENTITY_OCCUPIED"}}
```

### R16 — POST /paymentAccountApplications/{id}/approve

Supplier principal 52（非creator），獨立初始fixture。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`POST /bo/v2/paymentAccountApplications/301/approve`。

```json
{"expectedVersion":0,"reason":"測試審核","idempotencyKey":"fixture.approve.301"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"application":{"rowType":"APPLICATION","paymentAccountId":null,"applicationId":301,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":null,"version":1,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_one","modifier":"fixture_supplier_two","availableActions":[],"accountStatus":null,"freezeStatus":null,"receivingEnabled":null,"sendingEnabled":null,"balance":null,"reservedAmount":null,"availableAmount":null,"pendingDepositCount":null,"pendingWithdrawalCount":null,"dailyUsage":null,"applicationStatus":"APPROVED","cardholderPauseStatus":null,"cardholderPauseDeadline":null,"applicant":{"principalType":"SUPPLIER","principalId":51,"account":"fixture_supplier_one"},"reviewer":{"principalType":"SUPPLIER","principalId":52,"account":"fixture_supplier_two"},"reviewTime":"2026-09-14T03:00:00Z","reviewReason":"測試審核","linkedPaymentAccountId":202},"paymentAccount":{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":202,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":"NONE","version":0,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_INACTIVE","ENABLE_RECEIVING","ENABLE_SENDING"],"accountStatus":"ACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":false,"sendingEnabled":false,"balance":"0","reservedAmount":"0","availableAmount":"0","pendingDepositCount":0,"pendingWithdrawalCount":0,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null,"depositMinAmount":"0","depositMaxAmount":"0","withdrawalMinAmount":"0","withdrawalMaxAmount":"0"}}}
```

**Error fixture/request**：creator本人approve（非dev Superadmin）；HTTP 403。

```json
{"code":40001,"message":"操作未完成","data":{"field":null,"reasonCode":"SELF_REVIEW_DENIED"}}
```

### R17 — POST /paymentAccountApplications/{id}/reject

Supplier principal 52（非creator），獨立PENDING fixture。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`POST /bo/v2/paymentAccountApplications/301/reject`。

```json
{"expectedVersion":0,"reason":"測試審核","idempotencyKey":"fixture.reject.301"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"APPLICATION","paymentAccountId":null,"applicationId":301,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":null,"version":1,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_one","modifier":"fixture_supplier_two","availableActions":[],"accountStatus":null,"freezeStatus":null,"receivingEnabled":null,"sendingEnabled":null,"balance":null,"reservedAmount":null,"availableAmount":null,"pendingDepositCount":null,"pendingWithdrawalCount":null,"dailyUsage":null,"applicationStatus":"REJECTED","cardholderPauseStatus":null,"cardholderPauseDeadline":null,"applicant":{"principalType":"SUPPLIER","principalId":51,"account":"fixture_supplier_one"},"reviewer":{"principalType":"SUPPLIER","principalId":52,"account":"fixture_supplier_two"},"reviewTime":"2026-09-14T03:00:00Z","reviewReason":"測試審核","linkedPaymentAccountId":null}}
```

**Error fixture/request**：新key對terminal Application reject；HTTP 409。

```json
{"code":40054,"message":"操作未完成","data":{"field":null,"reasonCode":"STATE_CONFLICT"}}
```

### R18 — POST /paymentAccountApplications/{id}/cancel

Supplier principal 51（creator），獨立PENDING fixture。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`POST /bo/v2/paymentAccountApplications/301/cancel`。

```json
{"expectedVersion":0,"reason":"測試審核","idempotencyKey":"fixture.cancel.301"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"APPLICATION","paymentAccountId":null,"applicationId":301,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST301","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":null,"version":1,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_one","modifier":"fixture_supplier_one","availableActions":[],"accountStatus":null,"freezeStatus":null,"receivingEnabled":null,"sendingEnabled":null,"balance":null,"reservedAmount":null,"availableAmount":null,"pendingDepositCount":null,"pendingWithdrawalCount":null,"dailyUsage":null,"applicationStatus":"CANCELLED","cardholderPauseStatus":null,"cardholderPauseDeadline":null,"applicant":{"principalType":"SUPPLIER","principalId":51,"account":"fixture_supplier_one"},"reviewer":null,"reviewTime":null,"reviewReason":null,"linkedPaymentAccountId":null}}
```

**Error fixture/request**：同key改reason後cancel；HTTP 409。

```json
{"code":40045,"message":"操作未完成","data":{"field":"idempotencyKey","reasonCode":"IDEMPOTENCY_CONFLICT"}}
```

### R19 — PUT /paymentAccounts/{id}/status

Superadmin；原ACTIVE/false/false。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`PUT /bo/v2/paymentAccounts/201/status`。

```json
{"accountStatus":"INACTIVE","expectedVersion":4,"reason":"測試暫停"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":201,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST201","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":"DISPLAY_NAME_ONLY","version":5,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_ACTIVE","ADJUST_BALANCE"],"accountStatus":"INACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":false,"sendingEnabled":false,"balance":"100","reservedAmount":"20","availableAmount":"80","pendingDepositCount":0,"pendingWithdrawalCount":1,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":1,"usedCount":0,"reservedAmount":"20","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null,"depositMinAmount":"0","depositMaxAmount":"0","withdrawalMinAmount":"0","withdrawalMaxAmount":"0"}}
```

**Error fixture/request**：expectedVersion=3；HTTP 409。

```json
{"code":40051,"message":"操作未完成","data":{"field":"expectedVersion","reasonCode":"VERSION_CONFLICT"}}
```

### R20 — PUT /paymentAccounts/{id}/directionAvailability

Superadmin；eligible未Frozen Account。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`PUT /bo/v2/paymentAccounts/201/directionAvailability`。

```json
{"direction":"DEPOSIT","enabled":true,"expectedVersion":4,"reason":"測試啟用"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":201,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST201","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":"NONE","version":5,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_INACTIVE","DISABLE_RECEIVING","ENABLE_SENDING","ADJUST_BALANCE"],"accountStatus":"ACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":true,"sendingEnabled":false,"balance":"100","reservedAmount":"20","availableAmount":"80","pendingDepositCount":0,"pendingWithdrawalCount":1,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":1,"usedCount":0,"reservedAmount":"20","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null,"depositMinAmount":"0","depositMaxAmount":"0","withdrawalMinAmount":"0","withdrawalMaxAmount":"0"}}
```

**Error fixture/request**：VIEW-only Supplier principal direct mutation；HTTP 403。

```json
{"code":40001,"message":"操作未完成","data":{"field":null,"reasonCode":"OPERATION_DENIED"}}
```

### R21 — POST /paymentAccounts/{id}/balanceAdjustments

Superadmin；原balance100/reserved20。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`POST /bo/v2/paymentAccounts/201/balanceAdjustments`。

```json
{"newBalance":"125","expectedVersion":4,"idempotencyKey":"fixture.adjust.201","reasonCategory":"OTHER","reason":"測試帳務調整","evidenceReference":"fixture-reference-201"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"paymentAccountId":201,"currencyId":7,"currencyCode":"THB","balanceBefore":"100","balanceDelta":"25","balanceAfter":"125","reservedAmount":"20","availableAmount":"105","version":5,"balanceLogId":702,"operationTime":"2026-09-14T03:00:00Z"}}
```

**Error fixture/request**：新command對FROZEN Account；HTTP 409。

```json
{"code":40054,"message":"操作未完成","data":{"field":null,"reasonCode":"ACCOUNT_FROZEN"}}
```

### R22 — POST /paymentAccounts/{id}/unfreeze

Superadmin；獨立FROZEN/version4 fixture。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`POST /bo/v2/paymentAccounts/201/unfreeze`。

```json
{"expectedVersion":4,"reason":"測試解凍"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":201,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST201","accountName":"測試帳戶","paymentAccountDisplayName":"測試帳戶","editScope":"NONE","version":5,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_INACTIVE","ENABLE_RECEIVING","ENABLE_SENDING","ADJUST_BALANCE"],"accountStatus":"ACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":false,"sendingEnabled":false,"balance":"100","reservedAmount":"20","availableAmount":"80","pendingDepositCount":0,"pendingWithdrawalCount":1,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":1,"usedCount":0,"reservedAmount":"20","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null,"depositMinAmount":"0","depositMaxAmount":"0","withdrawalMinAmount":"0","withdrawalMaxAmount":"0"}}
```

**Error fixture/request**：expectedVersion=3；HTTP 409。

```json
{"code":40051,"message":"操作未完成","data":{"field":"expectedVersion","reasonCode":"VERSION_CONFLICT"}}
```

### R23 — GET /paymentAccounts/{id}/limits

Superadmin；Account 201 已覆寫，THB 幣別設有 System Max Ceiling。

**Request**：`GET /bo/v2/paymentAccounts/201/limits`。

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"paymentAccountId":201,"currencyId":7,"currencyCode":"THB","dailyAmountLimit":"50000","dailyTxLimit":30,"balanceCeiling":"200000","limitOverridden":true,"systemMaxCeiling":"500000","version":4}}
```

**Error fixture/request**：Supplier 讀 scope 外 Account；HTTP 404。

```json
{"code":40002,"message":"操作未完成","data":{"field":null,"reasonCode":"NOT_FOUND"}}
```

### R24 — PUT /paymentAccounts/{id}/limits

Superadmin；Account 201 version4，THB System Max Ceiling 500000。各mutation examples使用獨立初始fixture，不是依序操作同一資料。

**Request**：`PUT /bo/v2/paymentAccounts/201/limits`。

```json
{"dailyAmountLimit":"80000","dailyTxLimit":null,"balanceCeiling":"300000","expectedVersion":4}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"paymentAccountId":201,"currencyId":7,"currencyCode":"THB","dailyAmountLimit":"80000","dailyTxLimit":null,"balanceCeiling":"300000","limitOverridden":true,"systemMaxCeiling":"500000","version":5}}
```

**Error fixture/request**：balanceCeiling=600000 超過 System Max Ceiling；HTTP 400。

```json
{"code":40005,"message":"欄位驗證失敗","data":{"field":"balanceCeiling","reasonCode":"INVALID_FIELD"}}
```

### R25 — PUT /paymentAccounts/{id}/profile

Superadmin；獨立INACTIVE、UNFROZEN、金融值零／version4 fixture。

**Request**：`PUT /bo/v2/paymentAccounts/201/profile`。

```json
{"displayName":"測試展示名稱","accountName":"測試新戶名","bankId":31,"accountNumber":"000TEST201","expectedVersion":4,"reason":"測試修改"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"rowType":"PAYMENT_ACCOUNT","paymentAccountId":201,"applicationId":null,"cardholderId":101,"gatewayId":11,"supplierId":1,"currencyId":7,"username":"fixture_ch_101","displayName":"測試 Cardholder","gatewayCode":"GW_FIXTURE","gatewayName":"測試 Gateway","supplierLoginId":"SUP_FIXTURE","supplierName":"測試 Supplier","currencyCode":"THB","businessUtcOffset":"+07:00","bankId":31,"bankCode":"BANK_FIXTURE","bankName":"測試 Bank","accountNumber":"000TEST201","accountName":"測試新戶名","paymentAccountDisplayName":"測試展示名稱","editScope":"FULL","version":5,"createTime":"2026-09-14T02:00:00Z","modifyTime":"2026-09-14T03:00:00Z","creator":"fixture_supplier_two","modifier":"fixture_supplier_two","availableActions":["VIEW_ACTIVITY","SET_ACTIVE","ADJUST_BALANCE"],"accountStatus":"INACTIVE","freezeStatus":"UNFROZEN","receivingEnabled":false,"sendingEnabled":false,"balance":"0","reservedAmount":"0","availableAmount":"0","pendingDepositCount":0,"pendingWithdrawalCount":0,"dailyUsage":{"businessDate":"2026-09-14","deposit":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"},"withdrawal":{"reservedCount":0,"usedCount":0,"reservedAmount":"0","usedAmount":"0"}},"applicationStatus":null,"cardholderPauseStatus":null,"cardholderPauseDeadline":null,"depositMinAmount":"0","depositMaxAmount":"0","withdrawalMinAmount":"0","withdrawalMaxAmount":"0"}}
```

**Error fixture/request**：同 body，balance=100（editScope=DISPLAY_NAME_ONLY）；HTTP 409，整筆不寫入。

```json
{"code":40054,"message":"操作未完成","data":{"field":null,"reasonCode":"STATE_CONFLICT"}}
```

**修改 Bank 與帳號（#699，ADR-0461（此參考僅供內部環境使用，公開版本未提供））**：`bankId`、`accountNumber` 可選，僅 editScope=FULL；`accountNumber` 依 §2 正規化，正規化後同值不算變更。修改立即生效，id 不變，維持 INACTIVE；方向、限額、daily counter、Ledger 不變。

- 新 Bank 查無回 404／40002 `NOT_FOUND`；非 ACTIVE 或幣別不等於 Gateway Currency 回 409／40054 `STATE_CONFLICT`。
- 目標 identity 被其他卡或 PENDING Application 占用回 409／40007，`data.field=accountNumber`、`reasonCode=IDENTITY_OCCUPIED`；同一張卡改回自己仍占用的 identity 允許。
- 舊 identity：這張卡有任何 attempt 或 Ledger 時續由此卡占用，否則釋放，他人可重新申請。
- 銀行、帳號或戶名有變更時，同交易寫入 `payment_account_identity_history`（舊值、`effective_to`、操作者），並發 `CARD_UPDATED`（`IN_APP`、`FCM`），內容不含帳號或戶名；只改展示名稱不寫歷史、不通知。
- 被拒時寫一行 WARN（route、status、reason、paymentAccountId、actor），reason 為 `EDIT_SCOPE_EXCEEDED`、`BANK_NOT_ELIGIBLE`、`IDENTITY_OCCUPIED` 或 `VERSION_CONFLICT`；不含帳號、fingerprint、戶名或原因原文。

### R26 — DELETE /paymentAccounts/{id}

Superadmin；獨立INACTIVE、金融值零、無未解除obligation／version4 fixture。

**Request**：`DELETE /bo/v2/paymentAccounts/201`。

```json
{"expectedVersion":4,"reason":"測試刪除"}
```

**Success**：HTTP 200；Cache-Control: no-store。

```json
{"code":2000,"message":"","data":{"paymentAccountId":201,"status":"DELETED","version":5}}
```

**Error fixture/request**：同 body，balance=100；HTTP 409，整筆不寫入。

```json
{"code":40054,"message":"操作未完成","data":{"field":null,"reasonCode":"STATE_CONFLICT"}}
```

## 9. 後續實作與驗收

**26 條 API 已具 source handlers，#403 已完成本機 isolated MySQL 驗收**（[issue403-overview-verification.json](../evidence/issue403-overview-verification.json)，61 classes 3315 cases，含 Freeze 兩方向 guards）。 `PaymentAccountController` 的九個 commands 經 `OverviewCommandServiceImpl` 交付 create／review／status／direction／Adjust／Unfreeze；`PaymentAccountLimitController` 交付帳戶限額查詢／覆寫（R23／R24，#411）；六個 own-resource reads、五個 browse reads 與三個 Activity／summary／CSV mappings 亦具來源。沒有 direct-create route；來源存在本身不等於驗收，驗收範圍與限制以該 report 為準，operator／deployed acceptance 仍未取得。逐能力證據與剩餘 gate 以 [現行 readiness](cardholder-overview-readiness.md) 為準。

#368 已翻 READY：`SUPPLY_CARDHOLDER_OVERVIEW` 為 **READY/READY/ENABLED**，canonical context 剛好註冊 26 條 mappings（#411 擴充 R23／R24，#698 擴充 R25，#715 擴充 R26）、Prefix 一律 403、沒有 direct create。這不是 deployed acceptance：target 啟用前須 Operator 完成 migration（#367）、部署與 smoke，取得實際 evidence 後才可記錄；本文件不批准 migration／部署。本文件的 exact 24-route wire、scope、安全／privacy／replay 限制保持有效，局部實作不縮減 accepted 需求。

## 10. 來源切片與剩餘 gate

| 項目 | 現行來源切片 | 仍須核對／不得推定 |
| --- | --- | --- |
| Application／identity | create／approve／reject／cancel 已有 command use-cases，encrypted identity／permanent/PENDING guard 已有 source | #403 已驗 actor/profile、self-review 與 create／approve concurrency；舊資料 canonical compatibility／migration 仍屬 Operator |
| Replay／金融 | root coordinator 的 fresh authority／review 先於 replay；encrypted first result／MANDATORY store、MANUAL_ADJUSTMENT Ledger／safe Audit／notification facts 已有 source | #403 已驗矩陣 O08／O09／M06 race、flush 後 fault rollback 與 privacy；reject／cancel 雙 request 互競未另設測試 |
| Reads／Activity／CSV | 專責 controllers 與 native source slices、safe projections 已有 source | #403 已驗 native actors、provenance fail closed、stream failure／telemetry；dependency 不足仍 fail closed |
| Freeze／release | status／direction／Unfreeze 與 core guard 依 ADR-0400 分開 | 沒有 manual Freeze／automatic trigger authority；#403 已驗兩方向 admission／confirm／redispatch／CLOSE guards，operator／release evidence 尚未閉合 |
| Deposit／policy | Deposit 唯一 `/bo/v2/depositOrders`，menu／B/F/R 與 conditional registration 獨立 | namespace 一致或文件 gate 不等於產品／readiness 完成，不新增 alias／grant |

金融不變條件承續ADR-0381（此參考僅供內部環境使用，公開版本未提供）、ADR-0382（此參考僅供內部環境使用，公開版本未提供）、ADR-0383（此參考僅供內部環境使用，公開版本未提供）、ADR-0398（此參考僅供內部環境使用，公開版本未提供）。局部supersession與來源見ADR-0399（此參考僅供內部環境使用，公開版本未提供）、ADR-0400（此參考僅供內部環境使用，公開版本未提供）、ADR-0401（此參考僅供內部環境使用，公開版本未提供）；歷史ADR不整份刪改。
