Transactional return command with idempotency, row-lock concurrency control, odometer-regression handling, vehicle status derivation, outbox event, audit trail. Result-summary UI on booking detail. 26 backend tests passing, ruff clean. Verified end-to-end via browser against S1 demo scenario; fixed two real defects found only through browser testing (UI state loss on status transition, unflushed UUID default).
20 lines
740 B
Python
20 lines
740 B
Python
import uuid
|
|
|
|
from sqlalchemy import ForeignKey, Integer, String
|
|
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.db import Base
|
|
from app.models.mixins import TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
|
|
class IdempotencyRecord(UUIDPrimaryKeyMixin, TimestampMixin, Base):
|
|
__tablename__ = "idempotency_records"
|
|
|
|
idempotency_key: Mapped[str] = mapped_column(String(128), unique=True, nullable=False)
|
|
booking_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("bookings.id"), nullable=False
|
|
)
|
|
response_status: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
response_body: Mapped[dict] = mapped_column(JSONB, nullable=False)
|