Обновление приложения
This commit is contained in:
43
backend/app/schemas/budget.py
Normal file
43
backend/app/schemas/budget.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from datetime import datetime, date
|
||||
from decimal import Decimal
|
||||
from pydantic import BaseModel, Field
|
||||
from app.schemas.category import CategoryOut
|
||||
from app.schemas.currency import CurrencyOut
|
||||
|
||||
|
||||
class BudgetCreate(BaseModel):
|
||||
category_id: int
|
||||
name: str = Field(..., max_length=200)
|
||||
amount: Decimal = Field(..., gt=0)
|
||||
currency_id: int
|
||||
period_type: str = Field(..., pattern="^(monthly|weekly|yearly|custom)$")
|
||||
start_date: date
|
||||
end_date: date | None = None
|
||||
is_active: bool = True
|
||||
|
||||
|
||||
class BudgetUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
amount: Decimal | None = Field(None, gt=0)
|
||||
period_type: str | None = None
|
||||
end_date: date | None = None
|
||||
is_active: bool | None = None
|
||||
|
||||
|
||||
class BudgetOut(BaseModel):
|
||||
id: int
|
||||
user_id: int
|
||||
category_id: int
|
||||
category: CategoryOut
|
||||
name: str
|
||||
amount: Decimal
|
||||
currency_id: int
|
||||
currency: CurrencyOut
|
||||
period_type: str
|
||||
start_date: date
|
||||
end_date: date | None = None
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
spent: Decimal | None = None # computed field
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
Reference in New Issue
Block a user