@kansei-link/bantou 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +110 -110
- package/data/exclusion-rules/README.md +104 -104
- package/data/exclusion-rules/jp-tax-baseline-v1.json +185 -185
- package/data/exclusion-rules-schema.json +109 -109
- package/data/keyword-dict/README.md +91 -91
- package/data/keyword-dict/jp-tax-baseline-v1.json +398 -398
- package/data/keyword-dict-schema.json +117 -117
- package/data/tax-rules/jp-tax-rules-v1.json +170 -170
- package/dist/classifier/claude-classifier.js +35 -35
- package/dist/classifier/keyword-classifier.js +5 -2
- package/dist/exclusion/exclusion-checker.js +5 -0
- package/dist/tax-rules/tax-rule-engine.js +5 -0
- package/package.json +74 -74
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Synapse Arrows PTE. LTD.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Synapse Arrows PTE. LTD.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
# @kansei-link/cockpit
|
|
2
|
-
|
|
3
|
-
MCP (Model Context Protocol) server for Japanese tax accountant workflow automation.
|
|
4
|
-
|
|
5
|
-
税理士業務の自動化を実現する MCP サーバー。仕訳分類・消費税判定・インボイス制度チェック・CSV取込を一気通貫で処理します。
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @kansei-link/cockpit
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Quick Start
|
|
14
|
-
|
|
15
|
-
Add to your `claude_desktop_config.json`:
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
{
|
|
19
|
-
"mcpServers": {
|
|
20
|
-
"cockpit": {
|
|
21
|
-
"command": "npx",
|
|
22
|
-
"args": ["@kansei-link/cockpit"],
|
|
23
|
-
"env": {
|
|
24
|
-
"COCKPIT_DATA_DIR": "/path/to/data"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Key Features
|
|
32
|
-
|
|
33
|
-
- **Two-stage classifier** -- Stage 1: keyword matching across 19 categories with 500+ keywords; Stage 2: Claude AI fallback for ambiguous entries
|
|
34
|
-
- **TaxRuleEngine** -- Consumption tax with 8%/10% reduced rate logic, overseas SaaS and ad platform detection, withholding tax calculation, asset tier classification, and invoice system (インボイス制度) checker with transitional period handling
|
|
35
|
-
- **CSV adapters** -- Auto-detect and parse Yayoi (弥生), freee, and generic CSV formats
|
|
36
|
-
- **Persistent memory** -- Linksee Memory integration that learns from corrections and recalls learned patterns
|
|
37
|
-
- **Confidence routing** -- Automatic routing to `auto_register`, `auto_register_with_log`, or `human_review` based on confidence scores and business rules
|
|
38
|
-
- **200 tests** -- Comprehensive test suite including end-to-end integration tests
|
|
39
|
-
|
|
40
|
-
## Architecture
|
|
41
|
-
|
|
42
|
-
The classification pipeline processes each transaction through sequential stages:
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
CSV Input
|
|
46
|
-
|
|
|
47
|
-
v
|
|
48
|
-
[CSV Adapter] -- Auto-detect format (Yayoi / freee / generic)
|
|
49
|
-
|
|
|
50
|
-
v
|
|
51
|
-
[Normalizer] -- Text normalization, full-width/half-width conversion
|
|
52
|
-
|
|
|
53
|
-
v
|
|
54
|
-
[Stage 1: Keyword Classifier] -- 19 categories, 500+ keyword rules
|
|
55
|
-
| (high confidence) | (low confidence)
|
|
56
|
-
v v
|
|
57
|
-
[TaxRuleEngine] [Stage 2: Claude AI Classifier]
|
|
58
|
-
| |
|
|
59
|
-
v v
|
|
60
|
-
[TaxRuleEngine] [TaxRuleEngine]
|
|
61
|
-
| |
|
|
62
|
-
v v
|
|
63
|
-
[Confidence Router] -- auto_register / auto_register_with_log / human_review
|
|
64
|
-
|
|
|
65
|
-
v
|
|
66
|
-
[Memory Store] -- Persist corrections, recall patterns (Linksee Memory)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### TaxRuleEngine Details
|
|
70
|
-
|
|
71
|
-
- **Consumption tax**: Standard 10%, reduced rate 8% (food/beverages, newspapers)
|
|
72
|
-
- **Overseas detection**: SaaS platforms (AWS, Azure, GCP, etc.), advertising (Google Ads, Meta Ads, etc.) -- reverse charge applicable
|
|
73
|
-
- **Withholding tax**: Professional fees, royalties, and other specified payments
|
|
74
|
-
- **Asset classification**: Expense / depreciable asset / lump-sum depreciable asset / small-value asset based on acquisition cost tiers
|
|
75
|
-
- **Invoice checker**: Registration number validation, transitional credit periods (2023-10 through 2029-09)
|
|
76
|
-
|
|
77
|
-
## Configuration
|
|
78
|
-
|
|
79
|
-
### Environment Variables
|
|
80
|
-
|
|
81
|
-
| Variable | Description | Default |
|
|
82
|
-
|---|---|---|
|
|
83
|
-
| `COCKPIT_DATA_DIR` | Path to data directory containing keyword dictionaries and tax rules | `./data` |
|
|
84
|
-
|
|
85
|
-
### Data Files
|
|
86
|
-
|
|
87
|
-
The `data/` directory contains:
|
|
88
|
-
|
|
89
|
-
- `keyword-dict/jp-tax-baseline-v1.json` -- Keyword dictionary for Stage 1 classification (19 categories, 500+ rules)
|
|
90
|
-
- `tax-rules/jp-tax-rules-v1.json` -- Consumption tax rates, overseas SaaS/ad platforms, withholding rules, asset tiers, invoice system config
|
|
91
|
-
- `exclusion-rules/jp-tax-baseline-v1.json` -- Patterns to exclude non-classifiable transactions (ATM, salary, transfers, etc.)
|
|
92
|
-
|
|
93
|
-
## Development
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
# Run in development mode
|
|
97
|
-
npm run dev
|
|
98
|
-
|
|
99
|
-
# Run tests
|
|
100
|
-
npm test
|
|
101
|
-
|
|
102
|
-
# Build
|
|
103
|
-
npm run build
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## License
|
|
107
|
-
|
|
108
|
-
MIT -- see [LICENSE](./LICENSE) for details.
|
|
109
|
-
|
|
110
|
-
Copyright (c) 2026 Synapse Arrows PTE. LTD.
|
|
1
|
+
# @kansei-link/cockpit
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for Japanese tax accountant workflow automation.
|
|
4
|
+
|
|
5
|
+
税理士業務の自動化を実現する MCP サーバー。仕訳分類・消費税判定・インボイス制度チェック・CSV取込を一気通貫で処理します。
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @kansei-link/cockpit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Add to your `claude_desktop_config.json`:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"mcpServers": {
|
|
20
|
+
"cockpit": {
|
|
21
|
+
"command": "npx",
|
|
22
|
+
"args": ["@kansei-link/cockpit"],
|
|
23
|
+
"env": {
|
|
24
|
+
"COCKPIT_DATA_DIR": "/path/to/data"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Key Features
|
|
32
|
+
|
|
33
|
+
- **Two-stage classifier** -- Stage 1: keyword matching across 19 categories with 500+ keywords; Stage 2: Claude AI fallback for ambiguous entries
|
|
34
|
+
- **TaxRuleEngine** -- Consumption tax with 8%/10% reduced rate logic, overseas SaaS and ad platform detection, withholding tax calculation, asset tier classification, and invoice system (インボイス制度) checker with transitional period handling
|
|
35
|
+
- **CSV adapters** -- Auto-detect and parse Yayoi (弥生), freee, and generic CSV formats
|
|
36
|
+
- **Persistent memory** -- Linksee Memory integration that learns from corrections and recalls learned patterns
|
|
37
|
+
- **Confidence routing** -- Automatic routing to `auto_register`, `auto_register_with_log`, or `human_review` based on confidence scores and business rules
|
|
38
|
+
- **200 tests** -- Comprehensive test suite including end-to-end integration tests
|
|
39
|
+
|
|
40
|
+
## Architecture
|
|
41
|
+
|
|
42
|
+
The classification pipeline processes each transaction through sequential stages:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
CSV Input
|
|
46
|
+
|
|
|
47
|
+
v
|
|
48
|
+
[CSV Adapter] -- Auto-detect format (Yayoi / freee / generic)
|
|
49
|
+
|
|
|
50
|
+
v
|
|
51
|
+
[Normalizer] -- Text normalization, full-width/half-width conversion
|
|
52
|
+
|
|
|
53
|
+
v
|
|
54
|
+
[Stage 1: Keyword Classifier] -- 19 categories, 500+ keyword rules
|
|
55
|
+
| (high confidence) | (low confidence)
|
|
56
|
+
v v
|
|
57
|
+
[TaxRuleEngine] [Stage 2: Claude AI Classifier]
|
|
58
|
+
| |
|
|
59
|
+
v v
|
|
60
|
+
[TaxRuleEngine] [TaxRuleEngine]
|
|
61
|
+
| |
|
|
62
|
+
v v
|
|
63
|
+
[Confidence Router] -- auto_register / auto_register_with_log / human_review
|
|
64
|
+
|
|
|
65
|
+
v
|
|
66
|
+
[Memory Store] -- Persist corrections, recall patterns (Linksee Memory)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### TaxRuleEngine Details
|
|
70
|
+
|
|
71
|
+
- **Consumption tax**: Standard 10%, reduced rate 8% (food/beverages, newspapers)
|
|
72
|
+
- **Overseas detection**: SaaS platforms (AWS, Azure, GCP, etc.), advertising (Google Ads, Meta Ads, etc.) -- reverse charge applicable
|
|
73
|
+
- **Withholding tax**: Professional fees, royalties, and other specified payments
|
|
74
|
+
- **Asset classification**: Expense / depreciable asset / lump-sum depreciable asset / small-value asset based on acquisition cost tiers
|
|
75
|
+
- **Invoice checker**: Registration number validation, transitional credit periods (2023-10 through 2029-09)
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
### Environment Variables
|
|
80
|
+
|
|
81
|
+
| Variable | Description | Default |
|
|
82
|
+
|---|---|---|
|
|
83
|
+
| `COCKPIT_DATA_DIR` | Path to data directory containing keyword dictionaries and tax rules | `./data` |
|
|
84
|
+
|
|
85
|
+
### Data Files
|
|
86
|
+
|
|
87
|
+
The `data/` directory contains:
|
|
88
|
+
|
|
89
|
+
- `keyword-dict/jp-tax-baseline-v1.json` -- Keyword dictionary for Stage 1 classification (19 categories, 500+ rules)
|
|
90
|
+
- `tax-rules/jp-tax-rules-v1.json` -- Consumption tax rates, overseas SaaS/ad platforms, withholding rules, asset tiers, invoice system config
|
|
91
|
+
- `exclusion-rules/jp-tax-baseline-v1.json` -- Patterns to exclude non-classifiable transactions (ATM, salary, transfers, etc.)
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Run in development mode
|
|
97
|
+
npm run dev
|
|
98
|
+
|
|
99
|
+
# Run tests
|
|
100
|
+
npm test
|
|
101
|
+
|
|
102
|
+
# Build
|
|
103
|
+
npm run build
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT -- see [LICENSE](./LICENSE) for details.
|
|
109
|
+
|
|
110
|
+
Copyright (c) 2026 Synapse Arrows PTE. LTD.
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
# Cockpit MCP — Exclusion Rules
|
|
2
|
-
|
|
3
|
-
## What this is
|
|
4
|
-
|
|
5
|
-
Cockpit MCP's **Stage 0 filter** runs BEFORE the keyword/AI classifier. It identifies transactions that should NOT be auto-journalized — they get escalated to human review instead.
|
|
6
|
-
|
|
7
|
-
This is the **practitioner-style 7-rule exclusion** pattern. From the reference note:
|
|
8
|
-
|
|
9
|
-
> 自動仕訳で一番怖いのは「本来仕訳すべきでないものを仕訳してしまう」ことです。
|
|
10
|
-
> 「何を自動化して、何を人間が見るか」の線引きを明確にしているからこそ、安全に60社を回せています。
|
|
11
|
-
|
|
12
|
-
The 7 rules:
|
|
13
|
-
|
|
14
|
-
1. **内容不明デビット** — "デビット+数字" だけで店名なし → 人間が利用明細確認
|
|
15
|
-
2. **借入金返済** — 元本+利息 内訳必要 → freee 借入金返済 wizard 推奨
|
|
16
|
-
3. **社会保険料・税金** — 法定福利費 / 預り金 / 租税公課 判断必要
|
|
17
|
-
4. **給与支払い** — 給与計算結果と連動必要 → freee 人事労務 wizard
|
|
18
|
-
5. **投資・資産運用** — 投資有価証券 / 雑所得 / 譲渡益 判断、 税理士判断
|
|
19
|
-
6. **ATM出金・残高調整** — 口座振替別処理、 cash_balance_adjustment workflow へ
|
|
20
|
-
7. **公共料金** — 事業 vs 個人按分必要 → 手動比率設定
|
|
21
|
-
|
|
22
|
-
## How matching works
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
Transaction (= memo, amount, date, partner_name)
|
|
26
|
-
↓
|
|
27
|
-
Stage 0 (Exclusion Rules)
|
|
28
|
-
├─ Rule 1 match? → human_review (rule_id, reason)
|
|
29
|
-
├─ Rule 2 match? → human_review
|
|
30
|
-
├─ ...
|
|
31
|
-
└─ No match → proceed to Stage 1
|
|
32
|
-
↓
|
|
33
|
-
Stage 1 (Keyword Dict)
|
|
34
|
-
├─ Match? → return classification
|
|
35
|
-
└─ No match → Stage 2
|
|
36
|
-
↓
|
|
37
|
-
Stage 2 (Claude API fallback)
|
|
38
|
-
→ return with confidence (high/medium/low)
|
|
39
|
-
→ low confidence → human review
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Action types
|
|
43
|
-
|
|
44
|
-
- **human_review**: Transaction goes to "確認待ち" queue. Tax accountant reviews + manually classifies.
|
|
45
|
-
- **alternative_workflow**: Transaction is routed to a different workflow (e.g., ATM withdrawal → cash_balance_adjustment, NOT auto-journalized but auto-handled).
|
|
46
|
-
- **skip_silently**: Transaction is ignored entirely (= for noise filtering, rare use).
|
|
47
|
-
|
|
48
|
-
## Per-firm overrides
|
|
49
|
-
|
|
50
|
-
Each Cockpit user (= 税理士事務所) can define overrides:
|
|
51
|
-
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"firm_id": "tanaka-tax-office",
|
|
55
|
-
"rule_overrides": [
|
|
56
|
-
{
|
|
57
|
-
"rule_id": "investment",
|
|
58
|
-
"additional_keywords": ["弊社専用ファンド名"],
|
|
59
|
-
"exclude_keywords": ["NISA"]
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"rule_id": "salary_payment",
|
|
63
|
-
"disabled": true,
|
|
64
|
-
"reason": "うちの事務所は freee HR 連動完成済"
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
→ Stored in Cockpit Web Dashboard, applied per-instance via Cockpit MCP.
|
|
71
|
-
|
|
72
|
-
## Validation
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
# Schema validation (TODO: add to CI)
|
|
76
|
-
node scripts/validate-exclusion-rules.js data/exclusion-rules/*.json
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Smoke test scenarios
|
|
80
|
-
|
|
81
|
-
`packages/cockpit-mcp/tests/exclusion-rules.test.ts` covers:
|
|
82
|
-
|
|
83
|
-
1. "デビット 12345" → unknown_debit, human_review
|
|
84
|
-
2. "公庫 利息支払い" → loan_repayment
|
|
85
|
-
3. "源泉所得税納付" → social_insurance_tax
|
|
86
|
-
4. "給与 山田太郎" + freee HR list 含む → salary_payment
|
|
87
|
-
5. "野村證券 譲渡代金" → investment
|
|
88
|
-
6. "セブン銀行ATM出金" → atm_withdrawal → cash_balance_adjustment workflow
|
|
89
|
-
7. "東京水道局" → utilities (公共料金)
|
|
90
|
-
8. "Suica チャージ" → no match → proceed to Stage 1 (= 旅費交通費 にいく)
|
|
91
|
-
|
|
92
|
-
## Partnership note
|
|
93
|
-
|
|
94
|
-
These 7 rules are the canonical practitioner playbook. Year 1 closed beta:
|
|
95
|
-
- Tax practitioner reviews + signs off (= 「これが私の 7 rule で間違いない」)
|
|
96
|
-
- Co-author credit in `maintainer` field
|
|
97
|
-
- His extensions (= 8th, 9th rule) merged via PR
|
|
98
|
-
|
|
99
|
-
## See also
|
|
100
|
-
|
|
101
|
-
- Schema: [`../exclusion-rules-schema.json`](../exclusion-rules-schema.json)
|
|
102
|
-
- Architecture: [`../../docs/architecture.md`](../../docs/architecture.md)
|
|
103
|
-
- keyword-dict (Stage 1): [`../keyword-dict/README.md`](../keyword-dict/README.md)
|
|
104
|
-
- Strategy: [synapse-arrows-playbook Doc 10](https://github.com/michielinksee/synapse-arrows-playbook/blob/main/04-tooling-gaps/10-kansei-link-cockpit-strategy.md)
|
|
1
|
+
# Cockpit MCP — Exclusion Rules
|
|
2
|
+
|
|
3
|
+
## What this is
|
|
4
|
+
|
|
5
|
+
Cockpit MCP's **Stage 0 filter** runs BEFORE the keyword/AI classifier. It identifies transactions that should NOT be auto-journalized — they get escalated to human review instead.
|
|
6
|
+
|
|
7
|
+
This is the **practitioner-style 7-rule exclusion** pattern. From the reference note:
|
|
8
|
+
|
|
9
|
+
> 自動仕訳で一番怖いのは「本来仕訳すべきでないものを仕訳してしまう」ことです。
|
|
10
|
+
> 「何を自動化して、何を人間が見るか」の線引きを明確にしているからこそ、安全に60社を回せています。
|
|
11
|
+
|
|
12
|
+
The 7 rules:
|
|
13
|
+
|
|
14
|
+
1. **内容不明デビット** — "デビット+数字" だけで店名なし → 人間が利用明細確認
|
|
15
|
+
2. **借入金返済** — 元本+利息 内訳必要 → freee 借入金返済 wizard 推奨
|
|
16
|
+
3. **社会保険料・税金** — 法定福利費 / 預り金 / 租税公課 判断必要
|
|
17
|
+
4. **給与支払い** — 給与計算結果と連動必要 → freee 人事労務 wizard
|
|
18
|
+
5. **投資・資産運用** — 投資有価証券 / 雑所得 / 譲渡益 判断、 税理士判断
|
|
19
|
+
6. **ATM出金・残高調整** — 口座振替別処理、 cash_balance_adjustment workflow へ
|
|
20
|
+
7. **公共料金** — 事業 vs 個人按分必要 → 手動比率設定
|
|
21
|
+
|
|
22
|
+
## How matching works
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Transaction (= memo, amount, date, partner_name)
|
|
26
|
+
↓
|
|
27
|
+
Stage 0 (Exclusion Rules)
|
|
28
|
+
├─ Rule 1 match? → human_review (rule_id, reason)
|
|
29
|
+
├─ Rule 2 match? → human_review
|
|
30
|
+
├─ ...
|
|
31
|
+
└─ No match → proceed to Stage 1
|
|
32
|
+
↓
|
|
33
|
+
Stage 1 (Keyword Dict)
|
|
34
|
+
├─ Match? → return classification
|
|
35
|
+
└─ No match → Stage 2
|
|
36
|
+
↓
|
|
37
|
+
Stage 2 (Claude API fallback)
|
|
38
|
+
→ return with confidence (high/medium/low)
|
|
39
|
+
→ low confidence → human review
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Action types
|
|
43
|
+
|
|
44
|
+
- **human_review**: Transaction goes to "確認待ち" queue. Tax accountant reviews + manually classifies.
|
|
45
|
+
- **alternative_workflow**: Transaction is routed to a different workflow (e.g., ATM withdrawal → cash_balance_adjustment, NOT auto-journalized but auto-handled).
|
|
46
|
+
- **skip_silently**: Transaction is ignored entirely (= for noise filtering, rare use).
|
|
47
|
+
|
|
48
|
+
## Per-firm overrides
|
|
49
|
+
|
|
50
|
+
Each Cockpit user (= 税理士事務所) can define overrides:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"firm_id": "tanaka-tax-office",
|
|
55
|
+
"rule_overrides": [
|
|
56
|
+
{
|
|
57
|
+
"rule_id": "investment",
|
|
58
|
+
"additional_keywords": ["弊社専用ファンド名"],
|
|
59
|
+
"exclude_keywords": ["NISA"]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"rule_id": "salary_payment",
|
|
63
|
+
"disabled": true,
|
|
64
|
+
"reason": "うちの事務所は freee HR 連動完成済"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
→ Stored in Cockpit Web Dashboard, applied per-instance via Cockpit MCP.
|
|
71
|
+
|
|
72
|
+
## Validation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Schema validation (TODO: add to CI)
|
|
76
|
+
node scripts/validate-exclusion-rules.js data/exclusion-rules/*.json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Smoke test scenarios
|
|
80
|
+
|
|
81
|
+
`packages/cockpit-mcp/tests/exclusion-rules.test.ts` covers:
|
|
82
|
+
|
|
83
|
+
1. "デビット 12345" → unknown_debit, human_review
|
|
84
|
+
2. "公庫 利息支払い" → loan_repayment
|
|
85
|
+
3. "源泉所得税納付" → social_insurance_tax
|
|
86
|
+
4. "給与 山田太郎" + freee HR list 含む → salary_payment
|
|
87
|
+
5. "野村證券 譲渡代金" → investment
|
|
88
|
+
6. "セブン銀行ATM出金" → atm_withdrawal → cash_balance_adjustment workflow
|
|
89
|
+
7. "東京水道局" → utilities (公共料金)
|
|
90
|
+
8. "Suica チャージ" → no match → proceed to Stage 1 (= 旅費交通費 にいく)
|
|
91
|
+
|
|
92
|
+
## Partnership note
|
|
93
|
+
|
|
94
|
+
These 7 rules are the canonical practitioner playbook. Year 1 closed beta:
|
|
95
|
+
- Tax practitioner reviews + signs off (= 「これが私の 7 rule で間違いない」)
|
|
96
|
+
- Co-author credit in `maintainer` field
|
|
97
|
+
- His extensions (= 8th, 9th rule) merged via PR
|
|
98
|
+
|
|
99
|
+
## See also
|
|
100
|
+
|
|
101
|
+
- Schema: [`../exclusion-rules-schema.json`](../exclusion-rules-schema.json)
|
|
102
|
+
- Architecture: [`../../docs/architecture.md`](../../docs/architecture.md)
|
|
103
|
+
- keyword-dict (Stage 1): [`../keyword-dict/README.md`](../keyword-dict/README.md)
|
|
104
|
+
- Strategy: [synapse-arrows-playbook Doc 10](https://github.com/michielinksee/synapse-arrows-playbook/blob/main/04-tooling-gaps/10-kansei-link-cockpit-strategy.md)
|