Merge remote-tracking branch 'origin/cards'
This commit is contained in:
		
							
								
								
									
										85
									
								
								schemas/attribute.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								schemas/attribute.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,85 @@
 | 
			
		||||
import pickle
 | 
			
		||||
from datetime import datetime, date
 | 
			
		||||
from typing import Optional
 | 
			
		||||
 | 
			
		||||
from pydantic import field_validator
 | 
			
		||||
 | 
			
		||||
from schemas.base import BaseSchema, OkMessageSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# region Entities
 | 
			
		||||
 | 
			
		||||
class AttributeTypeSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    type: str
 | 
			
		||||
    name: str
 | 
			
		||||
    is_deleted: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BaseAttributeSchema(BaseSchema):
 | 
			
		||||
    label: str
 | 
			
		||||
    name: str
 | 
			
		||||
    is_applicable_to_group: bool
 | 
			
		||||
    is_nullable: bool
 | 
			
		||||
    default_value: Optional[bool | int | float | str | date | datetime]
 | 
			
		||||
    type_id: int
 | 
			
		||||
    description: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class AttributeSchema(BaseAttributeSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    type: AttributeTypeSchema
 | 
			
		||||
    is_deleted: bool
 | 
			
		||||
 | 
			
		||||
    @field_validator("default_value", mode="before")
 | 
			
		||||
    def validate_default_value(cls, value: Optional[bytes]):
 | 
			
		||||
        if not isinstance(value, bytes):
 | 
			
		||||
            return value
 | 
			
		||||
        return pickle.loads(value) if value else None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAttributeSchema(BaseSchema):
 | 
			
		||||
    value: Optional[bool | int | float | str | date | datetime]
 | 
			
		||||
    card_id: int
 | 
			
		||||
    attribute: AttributeSchema
 | 
			
		||||
 | 
			
		||||
    @field_validator("value", mode="before")
 | 
			
		||||
    def validate_value(cls, value: Optional[bytes]):
 | 
			
		||||
        return pickle.loads(value) if value else None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Requests
 | 
			
		||||
 | 
			
		||||
class CreateAttributeRequest(BaseSchema):
 | 
			
		||||
    attribute: BaseAttributeSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateAttributeRequest(BaseSchema):
 | 
			
		||||
    attribute: AttributeSchema
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Responses
 | 
			
		||||
 | 
			
		||||
class GetAttributesResponse(BaseSchema):
 | 
			
		||||
    attributes: list[AttributeSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GetAttributeTypesResponse(BaseSchema):
 | 
			
		||||
    types: list[AttributeTypeSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateAttributeResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateAttributeResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DeleteAttributeResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
@@ -81,8 +81,8 @@ class GetProductBarcodePdfRequest(GetProductBarcodeRequest):
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GetDealProductsBarcodesPdfRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
class GetCardProductsBarcodesPdfRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
@@ -131,7 +131,7 @@ class GetProductBarcodePdfResponse(BaseSchema):
 | 
			
		||||
    mime_type: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GetDealProductsBarcodesPdfResponse(BaseSchema):
 | 
			
		||||
class GetCardProductsBarcodesPdfResponse(BaseSchema):
 | 
			
		||||
    base64_string: str
 | 
			
		||||
    filename: str
 | 
			
		||||
    mime_type: str
 | 
			
		||||
 
 | 
			
		||||
@@ -3,14 +3,16 @@ from typing import Optional
 | 
			
		||||
 | 
			
		||||
from schemas.base import BaseSchema, OkMessageSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# region Entities
 | 
			
		||||
class DealBillRequestSchema(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
class CardBillRequestSchema(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    created_at: datetime.datetime
 | 
			
		||||
    paid: bool
 | 
			
		||||
    pdf_url: Optional[str]
 | 
			
		||||
    invoice_number: Optional[str]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GroupBillRequestSchema(BaseSchema):
 | 
			
		||||
    group_id: int
 | 
			
		||||
    created_at: datetime.datetime
 | 
			
		||||
@@ -18,28 +20,30 @@ class GroupBillRequestSchema(BaseSchema):
 | 
			
		||||
    pdf_url: Optional[str]
 | 
			
		||||
    invoice_number: Optional[str]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Requests
 | 
			
		||||
class CreateDealBillRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
class CreateCardBillRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CancelDealBillRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
class CancelCardBillRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Responses
 | 
			
		||||
class CreateDealBillResponse(OkMessageSchema):
 | 
			
		||||
class CreateCardBillResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CancelDealBillResponse(OkMessageSchema):
 | 
			
		||||
class CancelCardBillResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GetDealBillById(BaseSchema):
 | 
			
		||||
    deal_bill: DealBillRequestSchema
 | 
			
		||||
class GetCardBillById(BaseSchema):
 | 
			
		||||
    card_bill: CardBillRequestSchema
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ class BaseBoardSchema(BaseSchema):
 | 
			
		||||
class BoardSchema(BaseBoardSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    ordinal_number: int
 | 
			
		||||
    deal_statuses: list[StatusSchema]
 | 
			
		||||
    statuses: list[StatusSchema]
 | 
			
		||||
    project: ProjectSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										453
									
								
								schemas/card.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										453
									
								
								schemas/card.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,453 @@
 | 
			
		||||
from datetime import datetime, date
 | 
			
		||||
from typing import List, Optional, Union
 | 
			
		||||
 | 
			
		||||
from pydantic import constr
 | 
			
		||||
 | 
			
		||||
from schemas.attribute import CardAttributeSchema
 | 
			
		||||
from schemas.base import BaseSchema, OkMessageSchema
 | 
			
		||||
from schemas.billing import CardBillRequestSchema
 | 
			
		||||
from schemas.board import BoardSchema
 | 
			
		||||
from schemas.card_tag import CardTagSchema
 | 
			
		||||
from schemas.client import ClientSchema
 | 
			
		||||
from schemas.group import CardGroupSchema
 | 
			
		||||
from schemas.marketplace import BaseMarketplaceSchema
 | 
			
		||||
from schemas.product import ProductSchema
 | 
			
		||||
from schemas.service import ServiceSchema
 | 
			
		||||
from schemas.shipping import PalletSchema, BoxSchema
 | 
			
		||||
from schemas.shipping_warehouse import ShippingWarehouseSchema, BaseShippingWarehouseSchema
 | 
			
		||||
from schemas.status import StatusSchema, CardStatusHistorySchema
 | 
			
		||||
from schemas.user import UserSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# region Entities
 | 
			
		||||
 | 
			
		||||
class BaseSchemaWithAttributes(BaseSchema):
 | 
			
		||||
    attributes: dict[str, Union[bool, str, int, float, date, datetime, None]] = None
 | 
			
		||||
 | 
			
		||||
    def validate_attributes(cls, value):
 | 
			
		||||
        for attr_name, attr_value in value.items():
 | 
			
		||||
            if not isinstance(attr_value, (str, int, float, date, datetime, None)):
 | 
			
		||||
                raise ValueError(f"Invalid type for attribute '{attr_name}': {type(attr_value)}")
 | 
			
		||||
        return value
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardSummary(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    name: str
 | 
			
		||||
    client_name: Optional[str]
 | 
			
		||||
    created_at: datetime
 | 
			
		||||
    status: StatusSchema
 | 
			
		||||
    board: BoardSchema
 | 
			
		||||
    total_price: int
 | 
			
		||||
    rank: int
 | 
			
		||||
    base_marketplace: Optional[BaseMarketplaceSchema] = None
 | 
			
		||||
    total_products: int
 | 
			
		||||
    tags: list[CardTagSchema]
 | 
			
		||||
 | 
			
		||||
    shipment_warehouse_id: Optional[int]
 | 
			
		||||
    shipment_warehouse_name: Optional[str]
 | 
			
		||||
 | 
			
		||||
    bill_request: Optional[CardBillRequestSchema] = None
 | 
			
		||||
    group: Optional[CardGroupSchema] = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardServiceSchema(BaseSchema):
 | 
			
		||||
    service: ServiceSchema
 | 
			
		||||
    quantity: int
 | 
			
		||||
    price: int
 | 
			
		||||
    employees: List[UserSchema]
 | 
			
		||||
    is_fixed_price: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardProductServiceSchema(BaseSchema):
 | 
			
		||||
    service: ServiceSchema
 | 
			
		||||
    price: int
 | 
			
		||||
    employees: List[UserSchema]
 | 
			
		||||
    is_fixed_price: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardProductSchema(BaseSchema):
 | 
			
		||||
    product: ProductSchema
 | 
			
		||||
    services: List[CardProductServiceSchema]
 | 
			
		||||
    quantity: int
 | 
			
		||||
    comment: str = ""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardEmployeesSchema(BaseSchema):
 | 
			
		||||
    user: UserSchema
 | 
			
		||||
    created_at: datetime
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BaseCardSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    name: str
 | 
			
		||||
    comment: str
 | 
			
		||||
    created_at: datetime
 | 
			
		||||
    status: StatusSchema
 | 
			
		||||
    board: BoardSchema
 | 
			
		||||
    status_history: List[CardStatusHistorySchema]
 | 
			
		||||
    is_deleted: bool
 | 
			
		||||
    is_completed: bool
 | 
			
		||||
 | 
			
		||||
    is_services_profit_accounted: bool
 | 
			
		||||
    is_locked: bool
 | 
			
		||||
    services: List[CardServiceSchema]
 | 
			
		||||
    products: List[CardProductSchema]
 | 
			
		||||
    client_id: Optional[int]
 | 
			
		||||
    client: Optional[ClientSchema]
 | 
			
		||||
    shipping_warehouse: Optional[Union[ShippingWarehouseSchema, str]] = None
 | 
			
		||||
    bill_request: Optional[CardBillRequestSchema] = None
 | 
			
		||||
    group: Optional[CardGroupSchema] = None
 | 
			
		||||
    manager: Optional[UserSchema] = None
 | 
			
		||||
    pallets: List[PalletSchema] = []
 | 
			
		||||
    boxes: List[BoxSchema] = []
 | 
			
		||||
    employees: List[CardEmployeesSchema] = []
 | 
			
		||||
    tags: List[CardTagSchema] = []
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardSchema(BaseCardSchema):
 | 
			
		||||
    attributes: list[CardAttributeSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardGeneralInfoSchema(BaseSchemaWithAttributes):
 | 
			
		||||
    name: str
 | 
			
		||||
    is_deleted: bool
 | 
			
		||||
    is_completed: bool
 | 
			
		||||
    comment: str
 | 
			
		||||
    manager: Optional[UserSchema] = None
 | 
			
		||||
    board_id: int
 | 
			
		||||
    status_id: int
 | 
			
		||||
    client_id: Optional[int]
 | 
			
		||||
    tags: List[str]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProductsAndServicesGeneralInfoSchema(BaseSchema):
 | 
			
		||||
    shipping_warehouse: Optional[str] = None
 | 
			
		||||
    is_services_profit_accounted: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class OptionalShippingWarehouseSchema(BaseShippingWarehouseSchema):
 | 
			
		||||
    id: Optional[int] = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ParsedCityBreakdownSchema(BaseSchema):
 | 
			
		||||
    base_marketplace: BaseMarketplaceSchema
 | 
			
		||||
    shipping_warehouse: OptionalShippingWarehouseSchema
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ParsedProductRowSchema(BaseSchema):
 | 
			
		||||
    barcode: str
 | 
			
		||||
    products: list[ProductSchema]
 | 
			
		||||
    breakdowns: list[ParsedCityBreakdownSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CityBreakdownFromExcelSchema(BaseSchema):
 | 
			
		||||
    base_marketplace: BaseMarketplaceSchema
 | 
			
		||||
    shipping_warehouse: OptionalShippingWarehouseSchema
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProductFromExcelSchema(BaseSchema):
 | 
			
		||||
    product_id: int
 | 
			
		||||
    cities_breakdown: list[CityBreakdownFromExcelSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion Entities
 | 
			
		||||
 | 
			
		||||
# region Requests
 | 
			
		||||
class CardChangeStatusRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    new_status: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardCreateRequest(BaseSchema):
 | 
			
		||||
    name: str
 | 
			
		||||
    status_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardQuickCreateRequest(BaseSchema):
 | 
			
		||||
    name: constr(strip_whitespace=True)
 | 
			
		||||
    client_name: Optional[constr(strip_whitespace=True)]
 | 
			
		||||
    comment: str
 | 
			
		||||
    acceptance_date: datetime
 | 
			
		||||
    shipping_warehouse: Optional[constr(strip_whitespace=True)]
 | 
			
		||||
    base_marketplace: Optional[BaseMarketplaceSchema]
 | 
			
		||||
    status_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddServicesRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    services: list[CardServiceSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateServiceQuantityRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    service_id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateServiceRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    service: CardServiceSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddServiceRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    service_id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
    price: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteServiceRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    service_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteServicesRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    service_ids: List[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateProductQuantityRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    product_id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddProductRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    product: CardProductSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteProductRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    product_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteProductsRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    product_ids: List[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateGeneralInfoRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    data: CardGeneralInfoSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProductsAndServicesGeneralInfoRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    data: ProductsAndServicesGeneralInfoSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateCardManagerRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    manager_id: Optional[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateCardClientRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    client_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardSummaryReorderRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    status_id: int
 | 
			
		||||
    index: int
 | 
			
		||||
    deadline: datetime | None = None
 | 
			
		||||
    comment: str | None = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateProductRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    product: CardProductSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardServicesCopyRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    source_product_id: int
 | 
			
		||||
    destination_product_ids: List[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardProductAddKitRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    product_id: int
 | 
			
		||||
    kit_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddKitRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    kit_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardCreateGuestUrlRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardCompleteRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardPrefillRequest(BaseSchema):
 | 
			
		||||
    old_card_id: int
 | 
			
		||||
    new_card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardRecalculatePriceRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ManageEmployeeRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    user_id: int
 | 
			
		||||
    is_assign: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateCardsFromExcelRequest(BaseSchema):
 | 
			
		||||
    client_id: int
 | 
			
		||||
    status_id: int
 | 
			
		||||
    products: list[ProductFromExcelSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion Requests
 | 
			
		||||
 | 
			
		||||
# region Responses
 | 
			
		||||
class CardUpdateProductQuantityResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteServicesResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardGetAllResponse(BaseSchema):
 | 
			
		||||
    cards: List[CardSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardChangeStatusResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardCreateResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardQuickCreateResponse(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardSummaryResponse(BaseSchema):
 | 
			
		||||
    summaries: List[CardSummary]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddServicesResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
    message: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateServiceQuantityResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
    message: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateServiceResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddServiceResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteServiceResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteProductResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteProductsResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddProductResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateGeneralInfoResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProductsAndServicesGeneralInfoResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateCardManagerResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateCardClientResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardSummaryReorderResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardDeleteResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardUpdateProductResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardServicesCopyResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardProductAddKitResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardAddKitResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardCreateGuestUrlResponse(OkMessageSchema):
 | 
			
		||||
    url: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardCompleteResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardPrefillResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardRecalculatePriceResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ManageEmployeeResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GetAvailableEmployeesToAssignResponse(BaseSchema):
 | 
			
		||||
    employees: list[UserSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ParseCardsExcelResponse(BaseSchema):
 | 
			
		||||
    rows: list[ParsedProductRowSchema]
 | 
			
		||||
    errors: list[str]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateCardsFromExcelResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
# endregion Responses
 | 
			
		||||
							
								
								
									
										53
									
								
								schemas/card_tag.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								schemas/card_tag.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
from typing import Optional
 | 
			
		||||
 | 
			
		||||
from schemas.base import BaseSchema, OkMessageSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# region Entities
 | 
			
		||||
 | 
			
		||||
class BaseCardTagSchema(BaseSchema):
 | 
			
		||||
    name: str
 | 
			
		||||
    project_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CardTagSchema(BaseCardTagSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Requests
 | 
			
		||||
 | 
			
		||||
class CreateTagRequest(BaseSchema):
 | 
			
		||||
    tag: BaseCardTagSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateTagRequest(BaseSchema):
 | 
			
		||||
    tag: CardTagSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SwitchTagRequest(BaseSchema):
 | 
			
		||||
    tag_id: int
 | 
			
		||||
    card_id: Optional[int] = None
 | 
			
		||||
    group_id: Optional[int] = None
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Responses
 | 
			
		||||
 | 
			
		||||
class CreateTagResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateTagResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DeleteTagResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class SwitchTagResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
							
								
								
									
										420
									
								
								schemas/deal.py
									
									
									
									
									
								
							
							
						
						
									
										420
									
								
								schemas/deal.py
									
									
									
									
									
								
							@@ -1,420 +0,0 @@
 | 
			
		||||
import datetime
 | 
			
		||||
from typing import List, Optional, Union
 | 
			
		||||
 | 
			
		||||
from pydantic import constr
 | 
			
		||||
 | 
			
		||||
from schemas.base import BaseSchema, OkMessageSchema
 | 
			
		||||
from schemas.billing import DealBillRequestSchema
 | 
			
		||||
from schemas.board import BoardSchema
 | 
			
		||||
from schemas.client import ClientSchema
 | 
			
		||||
from schemas.group import DealGroupSchema
 | 
			
		||||
from schemas.marketplace import BaseMarketplaceSchema
 | 
			
		||||
from schemas.product import ProductSchema
 | 
			
		||||
from schemas.service import ServiceSchema
 | 
			
		||||
from schemas.shipping import PalletSchema, BoxSchema
 | 
			
		||||
from schemas.shipping_warehouse import ShippingWarehouseSchema, BaseShippingWarehouseSchema
 | 
			
		||||
from schemas.status import StatusSchema, DealStatusHistorySchema
 | 
			
		||||
from schemas.user import UserSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# region Entities
 | 
			
		||||
class FastDeal(BaseSchema):
 | 
			
		||||
    name: str
 | 
			
		||||
    client: ClientSchema
 | 
			
		||||
    comment: str
 | 
			
		||||
    acceptance_date: datetime.datetime
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealSummary(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    name: str
 | 
			
		||||
    client_name: str
 | 
			
		||||
    created_at: datetime.datetime
 | 
			
		||||
    status: StatusSchema
 | 
			
		||||
    board: BoardSchema
 | 
			
		||||
    total_price: int
 | 
			
		||||
    rank: int
 | 
			
		||||
    base_marketplace: Optional[BaseMarketplaceSchema] = None
 | 
			
		||||
    total_products: int
 | 
			
		||||
 | 
			
		||||
    shipment_warehouse_id: Optional[int]
 | 
			
		||||
    shipment_warehouse_name: Optional[str]
 | 
			
		||||
 | 
			
		||||
    delivery_date: Optional[datetime.datetime] = None
 | 
			
		||||
    receiving_slot_date: Optional[datetime.datetime] = None
 | 
			
		||||
    bill_request: Optional[DealBillRequestSchema] = None
 | 
			
		||||
    group: Optional[DealGroupSchema] = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealServiceSchema(BaseSchema):
 | 
			
		||||
    service: ServiceSchema
 | 
			
		||||
    quantity: int
 | 
			
		||||
    price: int
 | 
			
		||||
    employees: List[UserSchema]
 | 
			
		||||
    is_fixed_price: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealProductServiceSchema(BaseSchema):
 | 
			
		||||
    service: ServiceSchema
 | 
			
		||||
    price: int
 | 
			
		||||
    employees: List[UserSchema]
 | 
			
		||||
    is_fixed_price: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealProductSchema(BaseSchema):
 | 
			
		||||
    product: ProductSchema
 | 
			
		||||
    services: List[DealProductServiceSchema]
 | 
			
		||||
    quantity: int
 | 
			
		||||
    comment: str = ""
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealEmployeesSchema(BaseSchema):
 | 
			
		||||
    user: UserSchema
 | 
			
		||||
    created_at: datetime.datetime
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    name: str
 | 
			
		||||
    client_id: int
 | 
			
		||||
    created_at: datetime.datetime
 | 
			
		||||
    status: StatusSchema
 | 
			
		||||
    board: BoardSchema
 | 
			
		||||
    services: List[DealServiceSchema]
 | 
			
		||||
    products: List[DealProductSchema]
 | 
			
		||||
    status_history: List[DealStatusHistorySchema]
 | 
			
		||||
    is_deleted: bool
 | 
			
		||||
    is_completed: bool
 | 
			
		||||
    is_locked: bool
 | 
			
		||||
    is_accounted: bool
 | 
			
		||||
    client: ClientSchema
 | 
			
		||||
    comment: str
 | 
			
		||||
    shipping_warehouse: Optional[Union[ShippingWarehouseSchema, str]] = None
 | 
			
		||||
    bill_request: Optional[DealBillRequestSchema] = None
 | 
			
		||||
    group: Optional[DealGroupSchema] = None
 | 
			
		||||
    manager: Optional[UserSchema] = None
 | 
			
		||||
    pallets: List[PalletSchema] = []
 | 
			
		||||
    boxes: List[BoxSchema] = []
 | 
			
		||||
    employees: List[DealEmployeesSchema] = []
 | 
			
		||||
 | 
			
		||||
    delivery_date: Optional[datetime.datetime] = None
 | 
			
		||||
    receiving_slot_date: Optional[datetime.datetime] = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealGeneralInfoSchema(BaseSchema):
 | 
			
		||||
    name: str
 | 
			
		||||
    is_deleted: bool
 | 
			
		||||
    is_completed: bool
 | 
			
		||||
    is_accounted: bool
 | 
			
		||||
    comment: str
 | 
			
		||||
    shipping_warehouse: Optional[str] = None
 | 
			
		||||
    delivery_date: Optional[datetime.datetime] = None
 | 
			
		||||
    receiving_slot_date: Optional[datetime.datetime] = None
 | 
			
		||||
    manager: Optional[UserSchema] = None
 | 
			
		||||
    board: BoardSchema
 | 
			
		||||
    status: StatusSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class OptionalShippingWarehouseSchema(BaseShippingWarehouseSchema):
 | 
			
		||||
    id: Optional[int] = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ParsedCityBreakdownSchema(BaseSchema):
 | 
			
		||||
    base_marketplace: BaseMarketplaceSchema
 | 
			
		||||
    shipping_warehouse: OptionalShippingWarehouseSchema
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ParsedProductRowSchema(BaseSchema):
 | 
			
		||||
    barcode: str
 | 
			
		||||
    products: list[ProductSchema]
 | 
			
		||||
    breakdowns: list[ParsedCityBreakdownSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CityBreakdownFromExcelSchema(BaseSchema):
 | 
			
		||||
    base_marketplace: BaseMarketplaceSchema
 | 
			
		||||
    shipping_warehouse: OptionalShippingWarehouseSchema
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProductFromExcelSchema(BaseSchema):
 | 
			
		||||
    product_id: int
 | 
			
		||||
    cities_breakdown: list[CityBreakdownFromExcelSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion Entities
 | 
			
		||||
 | 
			
		||||
# region Requests
 | 
			
		||||
class DealChangeStatusRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    new_status: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealCreateRequest(BaseSchema):
 | 
			
		||||
    name: str
 | 
			
		||||
    status_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealQuickCreateRequest(BaseSchema):
 | 
			
		||||
    name: constr(strip_whitespace=True)
 | 
			
		||||
    client_name: constr(strip_whitespace=True)
 | 
			
		||||
    comment: str
 | 
			
		||||
    acceptance_date: datetime.datetime
 | 
			
		||||
    shipping_warehouse: constr(strip_whitespace=True)
 | 
			
		||||
    base_marketplace: BaseMarketplaceSchema
 | 
			
		||||
    status_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealSummaryRequest(BaseSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddServicesRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    services: list[DealServiceSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateServiceQuantityRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    service_id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateServiceRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    service: DealServiceSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddServiceRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    service_id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
    price: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealDeleteServiceRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    service_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealDeleteServicesRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    service_ids: List[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateProductQuantityRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    product_id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddProductRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    product: DealProductSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealDeleteProductRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    product_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealDeleteProductsRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    product_ids: List[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateGeneralInfoRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    data: DealGeneralInfoSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealSummaryReorderRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    status_id: int
 | 
			
		||||
    index: int
 | 
			
		||||
    deadline: datetime.datetime | None = None
 | 
			
		||||
    comment: str | None = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealDeleteRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateProductRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    product: DealProductSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealServicesCopyRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    source_product_id: int
 | 
			
		||||
    destination_product_ids: List[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealProductAddKitRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    product_id: int
 | 
			
		||||
    kit_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddKitRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    kit_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealCreateGuestUrlRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealCompleteRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealPrefillRequest(BaseSchema):
 | 
			
		||||
    old_deal_id: int
 | 
			
		||||
    new_deal_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealRecalculatePriceRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ManageEmployeeRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
    user_id: int
 | 
			
		||||
    is_assign: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateDealsFromExcelRequest(BaseSchema):
 | 
			
		||||
    client_id: int
 | 
			
		||||
    status_id: int
 | 
			
		||||
    products: list[ProductFromExcelSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion Requests
 | 
			
		||||
 | 
			
		||||
# region Responses
 | 
			
		||||
class DealUpdateProductQuantityResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealDeleteServicesResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealGetAllResponse(BaseSchema):
 | 
			
		||||
    deals: List[DealSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealChangeStatusResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealCreateResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealQuickCreateResponse(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealSummaryResponse(BaseSchema):
 | 
			
		||||
    summaries: List[DealSummary]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddServicesResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
    message: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateServiceQuantityResponse(BaseSchema):
 | 
			
		||||
    ok: bool
 | 
			
		||||
    message: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateServiceResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealUpdateProductResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealServicesCopyResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealProductAddKitResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddKitResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealCreateGuestUrlResponse(OkMessageSchema):
 | 
			
		||||
    url: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealCompleteResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealPrefillResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealRecalculatePriceResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ManageEmployeeResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GetAvailableEmployeesToAssignResponse(BaseSchema):
 | 
			
		||||
    employees: list[UserSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ParseDealsExcelResponse(BaseSchema):
 | 
			
		||||
    rows: list[ParsedProductRowSchema]
 | 
			
		||||
    errors: list[str]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateDealsFromExcelResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion Responses
 | 
			
		||||
@@ -6,7 +6,7 @@ from schemas.billing import GroupBillRequestSchema
 | 
			
		||||
 | 
			
		||||
# region Entities
 | 
			
		||||
 | 
			
		||||
class DealGroupSchema(BaseSchema):
 | 
			
		||||
class CardGroupSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    name: Optional[str] = None
 | 
			
		||||
    lexorank: str
 | 
			
		||||
@@ -17,50 +17,50 @@ class DealGroupSchema(BaseSchema):
 | 
			
		||||
 | 
			
		||||
# region Requests
 | 
			
		||||
 | 
			
		||||
class DealGroupUpdateRequest(BaseSchema):
 | 
			
		||||
    data: DealGroupSchema
 | 
			
		||||
class CardGroupUpdateRequest(BaseSchema):
 | 
			
		||||
    data: CardGroupSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealCreateGroupRequest(BaseSchema):
 | 
			
		||||
    dragging_deal_id: int
 | 
			
		||||
    hovered_deal_id: int
 | 
			
		||||
class CreateCardGroupRequest(BaseSchema):
 | 
			
		||||
    dragging_card_id: int
 | 
			
		||||
    hovered_card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealGroupChangeStatusRequest(BaseSchema):
 | 
			
		||||
class CardGroupChangeStatusRequest(BaseSchema):
 | 
			
		||||
    group_id: int
 | 
			
		||||
    new_status: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddToGroupRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
class CardAddToGroupRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
    group_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealRemoveFromGroupRequest(BaseSchema):
 | 
			
		||||
    deal_id: int
 | 
			
		||||
class CardRemoveFromGroupRequest(BaseSchema):
 | 
			
		||||
    card_id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
# region Responses
 | 
			
		||||
 | 
			
		||||
class DealCreateGroupResponse(OkMessageSchema):
 | 
			
		||||
class CardCreateGroupResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealGroupUpdateResponse(OkMessageSchema):
 | 
			
		||||
class CardGroupUpdateResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealGroupChangeStatusResponse(OkMessageSchema):
 | 
			
		||||
class CardGroupChangeStatusResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealAddToGroupResponse(OkMessageSchema):
 | 
			
		||||
class CardAddToGroupResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealRemoveFromGroupResponse(OkMessageSchema):
 | 
			
		||||
class CardRemoveFromGroupResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,8 @@
 | 
			
		||||
from typing import Optional
 | 
			
		||||
 | 
			
		||||
from schemas.attribute import AttributeSchema
 | 
			
		||||
from schemas.base import BaseSchema, OkMessageSchema
 | 
			
		||||
from schemas.card_tag import CardTagSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# region Entities
 | 
			
		||||
@@ -8,11 +12,25 @@ class BaseProjectSchema(BaseSchema):
 | 
			
		||||
    name: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProjectSchema(BaseProjectSchema):
 | 
			
		||||
class ProjectGeneralInfoSchema(BaseProjectSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProjectSchemaWithCount(ProjectSchema):
 | 
			
		||||
class ModuleSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    key: str
 | 
			
		||||
    label: str
 | 
			
		||||
    icon_name: Optional[str] = None
 | 
			
		||||
    is_deleted: bool
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProjectSchema(ProjectGeneralInfoSchema):
 | 
			
		||||
    attributes: list[AttributeSchema]
 | 
			
		||||
    modules: list[ModuleSchema]
 | 
			
		||||
    tags: list[CardTagSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class FullProjectSchema(ProjectSchema):
 | 
			
		||||
    boards_count: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -25,7 +43,18 @@ class CreateProjectRequest(BaseSchema):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateProjectRequest(BaseSchema):
 | 
			
		||||
    project: ProjectSchema
 | 
			
		||||
    project: ProjectGeneralInfoSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateModulesRequest(BaseSchema):
 | 
			
		||||
    project_id: int
 | 
			
		||||
    module_ids: list[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateAttributesRequest(BaseSchema):
 | 
			
		||||
    project_id: int
 | 
			
		||||
    attribute_ids: list[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
@@ -33,7 +62,7 @@ class UpdateProjectRequest(BaseSchema):
 | 
			
		||||
# region Responses
 | 
			
		||||
 | 
			
		||||
class GetProjectsResponse(BaseSchema):
 | 
			
		||||
    projects: list[ProjectSchemaWithCount]
 | 
			
		||||
    projects: list[FullProjectSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateProjectResponse(OkMessageSchema):
 | 
			
		||||
@@ -47,4 +76,16 @@ class UpdateProjectResponse(OkMessageSchema):
 | 
			
		||||
class DeleteProjectResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class GetAllModulesResponse(BaseSchema):
 | 
			
		||||
    modules: list[ModuleSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateModulesResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateAttributesResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ class ServicePriceRangeSchema(BaseSchema):
 | 
			
		||||
class ServiceCategorySchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    name: str
 | 
			
		||||
    deal_service_rank: str
 | 
			
		||||
    card_service_rank: str
 | 
			
		||||
    product_service_rank: str
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,19 +11,19 @@ class ProductAndQuantitySchema(BaseSchema):
 | 
			
		||||
    quantity: Optional[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BoxSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
    product: Optional[ProductSchema]
 | 
			
		||||
    pallet_id: Optional[int]
 | 
			
		||||
    deal_id: Optional[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ShippingProductSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    quantity: int
 | 
			
		||||
    product: ProductSchema
 | 
			
		||||
    pallet_id: int
 | 
			
		||||
    pallet_id: Optional[int]
 | 
			
		||||
    box_id: Optional[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class BoxSchema(BaseSchema):
 | 
			
		||||
    id: int
 | 
			
		||||
    pallet_id: Optional[int]
 | 
			
		||||
    card_id: Optional[int]
 | 
			
		||||
    shipping_products: list[ShippingProductSchema]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class PalletSchema(BaseSchema):
 | 
			
		||||
@@ -33,7 +33,8 @@ class PalletSchema(BaseSchema):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateShippingProductSchema(ProductAndQuantitySchema):
 | 
			
		||||
    pallet_id: int
 | 
			
		||||
    pallet_id: Optional[int] = None
 | 
			
		||||
    box_id: Optional[int] = None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateShippingProductSchema(ProductAndQuantitySchema):
 | 
			
		||||
@@ -44,12 +45,8 @@ class CreateBoxInPalletSchema(BaseSchema):
 | 
			
		||||
    pallet_id: Optional[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CreateBoxInDealSchema(BaseSchema):
 | 
			
		||||
    deal_id: Optional[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateBoxSchema(ProductAndQuantitySchema):
 | 
			
		||||
    box_id: Optional[int]
 | 
			
		||||
class CreateBoxInCardSchema(BaseSchema):
 | 
			
		||||
    card_id: Optional[int]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
@@ -60,8 +57,8 @@ class UpdateShippingProductRequest(BaseSchema):
 | 
			
		||||
    data: CreateShippingProductSchema | UpdateShippingProductSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateBoxRequest(BaseSchema):
 | 
			
		||||
    data: CreateBoxInDealSchema | CreateBoxInPalletSchema | UpdateBoxSchema
 | 
			
		||||
class CreateBoxRequest(BaseSchema):
 | 
			
		||||
    data: CreateBoxInCardSchema | CreateBoxInPalletSchema
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
@@ -80,7 +77,7 @@ class UpdateShippingProductResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class UpdateBoxResponse(OkMessageSchema):
 | 
			
		||||
class CreateBoxResponse(OkMessageSchema):
 | 
			
		||||
    pass
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ class ProfitChartDataItem(BaseSchema):
 | 
			
		||||
    revenue: float
 | 
			
		||||
    profit: float
 | 
			
		||||
    expenses: float
 | 
			
		||||
    deals_count: int
 | 
			
		||||
    cards_count: int
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class ProfitTableDataItem(BaseSchema):
 | 
			
		||||
@@ -19,7 +19,7 @@ class ProfitTableDataItem(BaseSchema):
 | 
			
		||||
    revenue: float
 | 
			
		||||
    profit: float
 | 
			
		||||
    expenses: Optional[float] = 0
 | 
			
		||||
    deals_count: int
 | 
			
		||||
    cards_count: int
 | 
			
		||||
 | 
			
		||||
# endregion
 | 
			
		||||
 | 
			
		||||
@@ -31,7 +31,8 @@ class CommonProfitFilters(BaseSchema):
 | 
			
		||||
    base_marketplace_key: str
 | 
			
		||||
    project_id: int
 | 
			
		||||
    board_id: int
 | 
			
		||||
    deal_status_id: int
 | 
			
		||||
    card_status_id: int
 | 
			
		||||
    card_tag_id: int
 | 
			
		||||
    manager_id: int
 | 
			
		||||
    expense_tag_id: int
 | 
			
		||||
    income_tag_id: int
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ class StatusSchema(BaseStatusSchema):
 | 
			
		||||
    is_deleted: bool = False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DealStatusHistorySchema(BaseSchema):
 | 
			
		||||
class CardStatusHistorySchema(BaseSchema):
 | 
			
		||||
    user: UserSchema
 | 
			
		||||
    changed_at: datetime
 | 
			
		||||
    from_status: StatusSchema
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user