[h1-request] 同期v2: 締め日(月次・年次)と締め例外の配布、h1由来伝票のunlock禁止 #57

Open
opened 2026-10-09 19:56:39 +00:00 by joe · 1 comment
Owner

背景

締めたら全区分をロックする。年次決算は例外なし、月次締めは例外を設けられる。発行ロックの解除は廃止(訂正は赤黒のみ)。

依頼内容(ADR-0002 §9・§5)

  • closed_through(月次・年次のうち連続して締まった最新期間の末日)と annual_closed_through(年次決算の同値)を AccountingPeriod から算出
  • 締め・取消のたびに pull で fiscal_close を配布(h1 は前進のみ受け入れ)
  • LockException(tenant, period_start, period_end, aggregate_type?, document_type?, aggregate_id?, until, reason, granted_by, revoked_at?) の管理画面と API、付与・更新・取消のたびに lock_exception を配布
    • 効力は annual_closed_through < doc_date <= closed_through のみ。条件は指定したもの全てに一致。条件なしは「その月の全変更」。until 経過で失効
  • v2 push の rejected_fiscal 判定に上記を適用
  • /api/documents/{id}/unlock を h1 由来伝票に対して禁止

受け入れ条件

  • 月次のみ締め/年次締め/取消(後退)/例外の付与・失効・取消のテストと fixture
  • 年次決算済み期間に例外が効かないテスト
  • h1 由来伝票の unlock が拒否されるテスト

契約の正本: ADR-0002(ブランチ docs/adr-0002-offline-first-sync-v2。未マージなら先に main へマージしてから着手)
https://git.cyberius.biz/joe/o2/src/branch/docs/adr-0002-offline-first-sync-v2/docs/adr/0002-offline-first-sync-v2.md

h1 側の内部設計(参考): https://git.cyberius.biz/joe/h1-c2/src/branch/main/docs/superpowers/specs/2026-10-09-offline-first-sync-design.md

前提: h1 は本体単体で完全稼働し、o2 接続時のみ同期する。v1(/api/sync/push|pull・/api/sync/corrections*)は h1 の移行完了まで並行稼働を維持すること(v1 を壊さない)。
検証データ: 入出力例を tests/fixtures/sync_v2/*.json に追加する。h1 は同じ fixture を Dart テストで検証する(sales_calculation fixture と同じ運用)。

## 背景 締めたら全区分をロックする。**年次決算は例外なし、月次締めは例外を設けられる**。発行ロックの解除は廃止(訂正は赤黒のみ)。 ## 依頼内容(ADR-0002 §9・§5) - `closed_through`(月次・年次のうち連続して締まった最新期間の末日)と `annual_closed_through`(年次決算の同値)を `AccountingPeriod` から算出 - 締め・取消のたびに pull で `fiscal_close` を配布(h1 は前進のみ受け入れ) - `LockException(tenant, period_start, period_end, aggregate_type?, document_type?, aggregate_id?, until, reason, granted_by, revoked_at?)` の管理画面と API、付与・更新・取消のたびに `lock_exception` を配布 - 効力は `annual_closed_through < doc_date <= closed_through` のみ。条件は指定したもの全てに一致。条件なしは「その月の全変更」。`until` 経過で失効 - v2 push の `rejected_fiscal` 判定に上記を適用 - `/api/documents/{id}/unlock` を h1 由来伝票に対して禁止 ## 受け入れ条件 - [ ] 月次のみ締め/年次締め/取消(後退)/例外の付与・失効・取消のテストと fixture - [ ] 年次決算済み期間に例外が効かないテスト - [ ] h1 由来伝票の unlock が拒否されるテスト --- **契約の正本**: ADR-0002(ブランチ `docs/adr-0002-offline-first-sync-v2`。未マージなら先に main へマージしてから着手) https://git.cyberius.biz/joe/o2/src/branch/docs/adr-0002-offline-first-sync-v2/docs/adr/0002-offline-first-sync-v2.md **h1 側の内部設計**(参考): https://git.cyberius.biz/joe/h1-c2/src/branch/main/docs/superpowers/specs/2026-10-09-offline-first-sync-design.md **前提**: h1 は本体単体で完全稼働し、o2 接続時のみ同期する。v1(`/api/sync/push|pull`・`/api/sync/corrections*`)は h1 の移行完了まで**並行稼働を維持**すること(v1 を壊さない)。 **検証データ**: 入出力例を `tests/fixtures/sync_v2/*.json` に追加する。h1 は同じ fixture を Dart テストで検証する(`sales_calculation` fixture と同じ運用)。
Author
Owner

実装完了(o2側)— 締め日と例外の配布・h1由来 unlock 禁止

実装

  • closed_through(連続して締まっている最新期間の末日)/annual_closed_through(連続する年次決算の末日)を算出
  • LockException(period_start/period_end、aggregate_type/document_type/aggregate_id、until、revoked_at)
    • 効力: annual_closed_through < doc_date <= closed_through のみ。年次決算済みには例外無効。条件は指定分すべて一致、無指定は全変更許可、until 経過で自動失効
  • 締め・取消・例外付与/取消で fiscal_close/lock_exception を配信、push の rejected_fiscal に反映
  • h1 由来伝票の unlock を拒否(DocumentService ガード+API 409)。発行ロック解除は不受理(訂正は赤黒)
  • API: GET /api/sync/v2/fiscal、POST .../fiscal/close|reopen、GET/POST/PUT/DELETE /api/sync/v2/lock-exceptions
  • Web UI /sync-fiscal(締め設定・例外管理)
  • migration b9c1d2e3f4a5、fixtures(fiscal_close / lock_exception)

インフラ注意: 現在リモートへの git push が SSH タイムアウト(www.cyberius.biz:18)で失敗中。実装はローカル main にマージ済み・o2.db 適用済みで、push は回復後に実施します。回帰確認: 全 6422 passed, 1 skipped。

## 実装完了(o2側)— 締め日と例外の配布・h1由来 unlock 禁止 ### 実装 - `closed_through`(連続して締まっている最新期間の末日)/`annual_closed_through`(連続する年次決算の末日)を算出 - `LockException`(`period_start/period_end`、`aggregate_type/document_type/aggregate_id`、`until`、`revoked_at`) - 効力: `annual_closed_through < doc_date <= closed_through` のみ。**年次決算済みには例外無効**。条件は**指定分すべて一致**、無指定は全変更許可、`until` 経過で自動失効 - 締め・取消・例外付与/取消で `fiscal_close`/`lock_exception` を配信、push の `rejected_fiscal` に反映 - **h1 由来伝票の unlock を拒否**(`DocumentService` ガード+API 409)。発行ロック解除は不受理(訂正は赤黒) - API: `GET /api/sync/v2/fiscal`、`POST .../fiscal/close|reopen`、`GET/POST/PUT/DELETE /api/sync/v2/lock-exceptions` - Web UI `/sync-fiscal`(締め設定・例外管理) - migration `b9c1d2e3f4a5`、fixtures(fiscal_close / lock_exception) --- **インフラ注意**: 現在リモートへの git push が SSH タイムアウト(`www.cyberius.biz:18`)で失敗中。実装はローカル main にマージ済み・`o2.db` 適用済みで、push は回復後に実施します。回帰確認: 全 **6422 passed, 1 skipped**。
Sign in to join this conversation.
No labels
h1-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
joe/o2#57
No description provided.