Skip to content

Commit 6173bc3

Browse files
authored
fix(seed): number counterparties sequentially, no CP-0099 gap (#59)
CP-0099 implied counterparty ids are sparse/hand-picked; renumber the disabled supplier to CP-0006 so the seed runs CP-0001..CP-0006 densely, matching how JE ids are assigned in order. Normalize the CP-0099 test fixtures to CP-0003 too; CP-9999 stays as the deliberately-absent not-found id.
1 parent 14d71da commit 6173bc3

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

accounting_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestValidator_Counterparty(t *testing.T) {
110110
for _, c := range []accounting.Counterparty{
111111
{ID: "CP-0001", Name: "Acme", Kind: accounting.CounterpartyCustomer, Active: true},
112112
{ID: "CP-0002", Name: "Beta", Kind: accounting.CounterpartyCustomer, Active: true},
113-
{ID: "CP-0099", Name: "Old", Kind: accounting.CounterpartySupplier, Active: false},
113+
{ID: "CP-0003", Name: "Old", Kind: accounting.CounterpartySupplier, Active: false},
114114
} {
115115
if err := repo.PutCounterparty(ctx, c); err != nil {
116116
t.Fatalf("seed counterparty: %v", err)
@@ -135,7 +135,7 @@ func TestValidator_Counterparty(t *testing.T) {
135135
})
136136
t.Run("inactive counterparty rejected", func(t *testing.T) {
137137
intent := balancedAWSIntent()
138-
intent.Lines[0].Dimensions.CounterpartyID = "CP-0099"
138+
intent.Lines[0].Dimensions.CounterpartyID = "CP-0003"
139139
err := v.Validate(ctx, intent)
140140
if err == nil || !strings.Contains(err.Error(), "inactive") {
141141
t.Fatalf("expected inactive-counterparty error, got %v", err)

agent/tools_internal_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestFindCounterpartiesHandler(t *testing.T) {
5050
for _, c := range []accounting.Counterparty{
5151
{ID: "CP-0001", Name: "台積電", Kind: accounting.CounterpartyCustomer, TaxID: "22099131", Active: true, Aliases: []string{"TSMC"}},
5252
{ID: "CP-0002", Name: "中華電信", Kind: accounting.CounterpartySupplier, Active: true},
53-
{ID: "CP-0099", Name: "舊廠商", Kind: accounting.CounterpartySupplier, Active: false},
53+
{ID: "CP-0003", Name: "舊廠商", Kind: accounting.CounterpartySupplier, Active: false},
5454
} {
5555
if err := repo.PutCounterparty(ctx, c); err != nil {
5656
t.Fatalf("seed counterparty: %v", err)
@@ -83,7 +83,7 @@ func TestFindCounterpartiesHandler(t *testing.T) {
8383
if err != nil {
8484
t.Fatal(err)
8585
}
86-
if !strings.Contains(out, "disabled") || !strings.Contains(out, "CP-0099") {
86+
if !strings.Contains(out, "disabled") || !strings.Contains(out, "CP-0003") {
8787
t.Errorf("inactive counterparty should be flagged disabled:\n%s", out)
8888
}
8989
})

docs/tui-manual-test.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ JE-XXXX 金額打錯了,幫我沖掉,再用正確的含稅 94,500 重新過
208208

209209
## 4. 應收應付(AR/AP)情境
210210

211-
驗證 counterparty(客戶/供應商)、發票單據(`source`)與 `settle` 收款沖銷。種子已含客戶/供應商主檔(`CP-0001` 台積電、`CP-0003` 中華電信、`CP-0099` 旭海貿易[停用]…),可用 `find_counterparties` 解析。
211+
驗證 counterparty(客戶/供應商)、發票單據(`source`)與 `settle` 收款沖銷。種子已含客戶/供應商主檔(`CP-0001` 台積電、`CP-0003` 中華電信、`CP-0006` 旭海貿易[停用]…),可用 `find_counterparties` 解析。
212212

213213
> **重要**`counterparty_id`**選填**。對**未登記/泛稱的客戶**(如「台中客戶」、一次性散客),agent 仍應**照常過帳**、只是 `counterparty_id` 留空(不歸戶),**不該 reject**。只有當使用者指名某個 `find_counterparties` 顯示為**停用**的對象時才 reject(見 T-16)。
214214
@@ -298,7 +298,7 @@ JE-XXXX 金額打錯了,幫我沖掉,再用正確的含稅 94,500 重新過
298298
向「旭海貿易」賒購商品 NT$5,000,記應付帳款。
299299
```
300300

301-
預期:`find_counterparties` 找到 `CP-0099` 但標記為停用(disabled)。agent 不得把它放進分錄的 `counterparty_id`;應 `reject` 並說明該客戶/供應商已停用,由使用者決定,不自行改用別家。
301+
預期:`find_counterparties` 找到 `CP-0006` 但標記為停用(disabled)。agent 不得把它放進分錄的 `counterparty_id`;應 `reject` 並說明該客戶/供應商已停用,由使用者決定,不自行改用別家。
302302

303303
---
304304

seed/taiwan_ledger.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,4 @@ counterparties:
259259
tax_id: "27640903"
260260
active: true
261261
aliases: [全聯, 全聯福利中心]
262-
- { id: CP-0099, name: 旭海貿易(已停業), kind: supplier, active: false, aliases: [旭海] }
262+
- { id: CP-0006, name: 旭海貿易(已停業), kind: supplier, active: false, aliases: [旭海] }

0 commit comments

Comments
 (0)