feat: enhance deal management with CRUD operations and improve payload handling
This commit is contained in:
@@ -5,16 +5,29 @@ from decimal import Decimal
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.models.deal import DealCreate, DealStage, DealStatus
|
||||
|
||||
|
||||
class DealCreatePayload(BaseModel):
|
||||
contact_id: int
|
||||
title: str
|
||||
amount: Decimal | None = None
|
||||
currency: str | None = None
|
||||
owner_id: int | None = None
|
||||
|
||||
def to_domain(self, *, organization_id: int, fallback_owner: int) -> DealCreate:
|
||||
return DealCreate(
|
||||
organization_id=organization_id,
|
||||
contact_id=self.contact_id,
|
||||
owner_id=self.owner_id or fallback_owner,
|
||||
title=self.title,
|
||||
amount=self.amount,
|
||||
currency=self.currency,
|
||||
)
|
||||
|
||||
|
||||
class DealUpdatePayload(BaseModel):
|
||||
status: str | None = None
|
||||
stage: str | None = None
|
||||
status: DealStatus | None = None
|
||||
stage: DealStage | None = None
|
||||
amount: Decimal | None = None
|
||||
currency: str | None = None
|
||||
|
||||
Reference in New Issue
Block a user