fix corporate action runtime blockers

This commit is contained in:
2026-09-13 14:22:41 +09:00
parent 925c6b4fa4
commit fa824dfd36
4 changed files with 70 additions and 4 deletions
+2 -1
View File
@@ -24,6 +24,7 @@ from app.core.auth import AuthContext, Permission, require_read, require_trade_w
from app.core.config import get_settings
from app.domain.errors import DaemonInactiveError, DaemonNotFoundError
from app.domain.models import CorporateAction, Portfolio, PortfolioComment
from app.domain.services import PORTFOLIO_NOT_FOUND_MESSAGE
from app.domain.pnl import calculate_current_wac, calculate_realized_pnl
from app.repositories.factory import get_portfolio_repository_from_settings
from app.schemas.v1 import (
@@ -1332,7 +1333,7 @@ def create_corporate_action(portfolio_id: str, payload: CorporateActionRequest,
return CorporateActionResponse(**saved.__dict__)
except ValueError as exc:
code = str(exc)
if code == "portfolio not found":
if code == PORTFOLIO_NOT_FOUND_MESSAGE:
raise HTTPException(status_code=404, detail="Portfolio not found") from exc
raise HTTPException(status_code=409 if code.startswith(("IDEMPOTENCY", "CORPORATE_ACTION_")) else 400, detail=code) from exc
finally: