- add ledger consolidation migration and remove ledger_trades usage - return portfolio state after v1 ledger trade writes - deprecate legacy buy/sell endpoints with deprecation headers - add BAT-016, DCY-006, and REQ-036~038 documentation - update repository models and tests for unified ledger entries
1.8 KiB
1.8 KiB
BAT-016 Verification
- Status: passed
- Batch: BAT-016
Acceptance Mapping
- REQ-036:
- AC-1~3:
ledger_tradesapplication references removed; new migration20260605_0025_ledger_consolidation.pyandensure_schema()consolidate trade columns intoportfolio_ledger. - AC-4~5: repository write/read path uses
portfolio_ledger; recent trade mapping isLedgerEntry-based. - AC-6~7: full regression passes under the project venv.
- AC-1~3:
- REQ-037:
- AC-1~2:
POST /v1/portfolios/{portfolio_id}/ledger/tradesis the authoritative trade write endpoint. - AC-3~5: response includes
ledger_entry_id,order_id,execution_id,side,fee_amount,tax_amount,cash_balance_after, andasset_quantity_after. - AC-6: duplicate broker identifiers are resolved via repository idempotency lookup.
- AC-7: tests cover buy/sell, negative asset quantity, duplicate request behavior, and response state fields.
- AC-1~2:
- REQ-038:
- AC-1~2: legacy buy/sell route decorators use
deprecated=True. - AC-3~4: legacy buy/sell responses/errors emit
Deprecation: true;tests/test_auth.py::test_legacy_buy_sell_routes_emit_deprecation_headerverifies this behavior.
- AC-1~2: legacy buy/sell route decorators use
Evidence
- Test:
.venv/bin/python -m pytest -q tests/test_domain_services.py tests/test_v1_portfolios_ledger.py tests/test_daemon_assignment.py tests/test_v1.py- Result:
47 passed in 3.66s .venv/bin/python -m pytest -q- Result:
373 passed, 3 warnings in 14.78s
- Manual:
- Confirmed legacy routes return
Deprecation: trueusingTestClientwithPORTFOLIOHUB_DB_ENABLED=falseand trade-write token. - Confirmed app code no longer contains
LedgerTrade; only transitional schema-cleanup references remain for dropping oldledger_trades/actionstructures.
- Confirmed legacy routes return
- Logs:
- Full pytest output captured in terminal execution.
Result
- Ready for Release: true
- Blocking Issues: none