61 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import datetime
 | 
						|
from typing import List, Tuple, Optional
 | 
						|
 | 
						|
from enums.profit_table_group_by import ProfitTableGroupBy
 | 
						|
from schemas.base import BaseSchema
 | 
						|
 | 
						|
# region Entities
 | 
						|
 | 
						|
class ProfitChartDataItem(BaseSchema):
 | 
						|
    date: datetime.date
 | 
						|
    revenue: float
 | 
						|
    profit: float
 | 
						|
    expenses: float
 | 
						|
    cards_count: int
 | 
						|
 | 
						|
 | 
						|
class ProfitTableDataItem(BaseSchema):
 | 
						|
    grouped_value: datetime.date | str | int
 | 
						|
    revenue: float
 | 
						|
    profit: float
 | 
						|
    expenses: Optional[float] = 0
 | 
						|
    cards_count: int
 | 
						|
 | 
						|
# endregion
 | 
						|
 | 
						|
# region Requests
 | 
						|
 | 
						|
class CommonProfitFilters(BaseSchema):
 | 
						|
    date_range: Tuple[datetime.date, datetime.date]
 | 
						|
    client_id: int
 | 
						|
    base_marketplace_key: str
 | 
						|
    project_id: int
 | 
						|
    board_id: int
 | 
						|
    card_status_id: int
 | 
						|
    card_tag_id: int
 | 
						|
    manager_id: int
 | 
						|
    expense_tag_id: int
 | 
						|
    income_tag_id: int
 | 
						|
    is_completed_only: bool
 | 
						|
 | 
						|
 | 
						|
class GetProfitChartDataRequest(CommonProfitFilters):
 | 
						|
    pass
 | 
						|
 | 
						|
 | 
						|
class GetProfitTableDataRequest(CommonProfitFilters):
 | 
						|
    group_table_by: ProfitTableGroupBy
 | 
						|
 | 
						|
# endregion
 | 
						|
 | 
						|
# region Responses
 | 
						|
 | 
						|
class GetProfitChartDataResponse(BaseSchema):
 | 
						|
    data: List[ProfitChartDataItem]
 | 
						|
 | 
						|
 | 
						|
class GetProfitTableDataResponse(BaseSchema):
 | 
						|
    data: List[ProfitTableDataItem]
 | 
						|
 | 
						|
# endregion
 |