import datetime from typing import List from schemas.base import CustomModelCamel, OkMessageSchema from schemas.client import ClientSchema from schemas.product import ProductSchema from schemas.service import ServiceSchema from schemas.user import UserSchema # region Entities class FastDeal(CustomModelCamel): name: str client: ClientSchema comment: str acceptance_date: datetime.datetime class DealSummary(CustomModelCamel): id: int name: str client_name: str changed_at: datetime.datetime deadline: datetime.datetime status: int total_price: int rank: int class DealServiceSchema(CustomModelCamel): service: ServiceSchema quantity: int price: int class DealProductServiceSchema(CustomModelCamel): service: ServiceSchema price: int class DealProductSchema(CustomModelCamel): product: ProductSchema services: List[DealProductServiceSchema] quantity: int class DealStatusHistorySchema(CustomModelCamel): user: UserSchema changed_at: datetime.datetime from_status: int to_status: int next_status_deadline: datetime.datetime | None comment: str | None = None class DealSchema(CustomModelCamel): id: int name: str client_id: int created_at: datetime.datetime current_status: int services: List[DealServiceSchema] products: List[DealProductSchema] status_history: List[DealStatusHistorySchema] is_deleted: bool is_completed: bool client: ClientSchema comment: str class DealGeneralInfoSchema(CustomModelCamel): name: str is_deleted: bool is_completed: bool comment: str # endregion Entities # region Requests class DealChangeStatusRequest(CustomModelCamel): deal_id: int new_status: int class DealCreateRequest(CustomModelCamel): name: str class DealQuickCreateRequest(CustomModelCamel): name: str client_name: str comment: str acceptance_date: datetime.datetime class DealSummaryRequest(CustomModelCamel): pass class DealAddServicesRequest(CustomModelCamel): deal_id: int services: list[DealServiceSchema] class DealUpdateServiceQuantityRequest(CustomModelCamel): deal_id: int service_id: int quantity: int class DealAddServiceRequest(CustomModelCamel): deal_id: int service_id: int quantity: int class DealDeleteServiceRequest(CustomModelCamel): deal_id: int service_id: int class DealDeleteServicesRequest(CustomModelCamel): deal_id: int service_ids: List[int] class DealUpdateProductQuantityRequest(CustomModelCamel): deal_id: int product_id: int quantity: int class DealAddProductRequest(CustomModelCamel): deal_id: int product: DealProductSchema class DealDeleteProductRequest(CustomModelCamel): deal_id: int product_id: int class DealDeleteProductsRequest(CustomModelCamel): deal_id: int product_ids: List[int] class DealUpdateGeneralInfoRequest(CustomModelCamel): deal_id: int data: DealGeneralInfoSchema class DealSummaryReorderRequest(CustomModelCamel): deal_id: int status: int index: int deadline: datetime.datetime | None = None comment: str | None = None class DealDeleteRequest(CustomModelCamel): deal_id: int # endregion Requests # region Responses class DealUpdateProductQuantityResponse(OkMessageSchema): pass class DealDeleteServicesResponse(OkMessageSchema): pass class DealGetAllResponse(CustomModelCamel): deals: List[DealSchema] class DealChangeStatusResponse(CustomModelCamel): ok: bool class DealCreateResponse(CustomModelCamel): ok: bool class DealQuickCreateResponse(CustomModelCamel): deal_id: int class DealSummaryResponse(CustomModelCamel): summaries: List[DealSummary] class DealAddServicesResponse(CustomModelCamel): ok: bool message: str class DealUpdateServiceQuantityResponse(CustomModelCamel): ok: bool message: str class DealAddServiceResponse(OkMessageSchema): pass class DealDeleteServiceResponse(OkMessageSchema): pass class DealDeleteProductResponse(OkMessageSchema): pass class DealDeleteProductsResponse(OkMessageSchema): pass class DealAddProductResponse(OkMessageSchema): pass class DealUpdateGeneralInfoResponse(OkMessageSchema): pass class DealSummaryReorderResponse(OkMessageSchema): pass class DealDeleteResponse(OkMessageSchema): pass # endregion Responses