Ship fleet, availability, pricing, dispatch, routing, tracking, and settlement on delivery-service 0.10.8.0 with migrations and phase tests green. Co-authored-by: Cursor <cursoragent@cursor.com>
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
"""Settlement command handlers — Phase 10.8."""
|
|
from __future__ import annotations
|
|
|
|
from uuid import UUID
|
|
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.schemas.settlement import (
|
|
SettlementActionRequest,
|
|
SettlementIntentCreate,
|
|
SettlementIntentUpdate,
|
|
SettlementLineCreate,
|
|
)
|
|
from app.services.settlement import SettlementService
|
|
from shared.security import CurrentUser
|
|
|
|
|
|
class SettlementCommands:
|
|
def __init__(self, session: AsyncSession) -> None:
|
|
self.service = SettlementService(session)
|
|
|
|
async def create(
|
|
self, tenant_id: UUID, body: SettlementIntentCreate, *, actor: CurrentUser | None
|
|
):
|
|
return await self.service.create(tenant_id, body, actor=actor)
|
|
|
|
async def update(
|
|
self,
|
|
tenant_id: UUID,
|
|
intent_id: UUID,
|
|
body: SettlementIntentUpdate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.update(tenant_id, intent_id, body, actor=actor)
|
|
|
|
async def submit(
|
|
self,
|
|
tenant_id: UUID,
|
|
intent_id: UUID,
|
|
body: SettlementActionRequest,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.submit(tenant_id, intent_id, body, actor=actor)
|
|
|
|
async def settle(
|
|
self,
|
|
tenant_id: UUID,
|
|
intent_id: UUID,
|
|
body: SettlementActionRequest,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.settle(tenant_id, intent_id, body, actor=actor)
|
|
|
|
async def fail(
|
|
self,
|
|
tenant_id: UUID,
|
|
intent_id: UUID,
|
|
body: SettlementActionRequest,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.fail(tenant_id, intent_id, body, actor=actor)
|
|
|
|
async def cancel(
|
|
self,
|
|
tenant_id: UUID,
|
|
intent_id: UUID,
|
|
body: SettlementActionRequest,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.cancel(tenant_id, intent_id, body, actor=actor)
|
|
|
|
async def add_line(
|
|
self,
|
|
tenant_id: UUID,
|
|
intent_id: UUID,
|
|
body: SettlementLineCreate,
|
|
*,
|
|
actor: CurrentUser | None,
|
|
):
|
|
return await self.service.add_line(tenant_id, intent_id, body, actor=actor)
|