feat: initial commit
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
# --- Category ---
|
||||
class CategoryBase(BaseModel):
|
||||
name: str
|
||||
|
||||
class CategoryCreate(CategoryBase):
|
||||
pass
|
||||
|
||||
class CategoryResponse(CategoryBase):
|
||||
id: int
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# --- PiggyBank ---
|
||||
class PiggyBankBase(BaseModel):
|
||||
name: str
|
||||
target_amount: float = Field(gt=0)
|
||||
currency: str = "USD"
|
||||
category_id: Optional[int] = None
|
||||
|
||||
class PiggyBankCreate(PiggyBankBase):
|
||||
pass
|
||||
|
||||
class PiggyBankUpdate(BaseModel):
|
||||
name: Optional[str] = None
|
||||
target_amount: Optional[float] = Field(default=None, gt=0)
|
||||
currency: Optional[str] = None
|
||||
category_id: Optional[int] = None
|
||||
|
||||
class PiggyBankResponse(PiggyBankBase):
|
||||
id: int
|
||||
current_amount: float
|
||||
progress_percent: float
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# --- Transaction ---
|
||||
class TransactionCreate(BaseModel):
|
||||
amount: float = Field(ne=0)
|
||||
description: Optional[str] = None
|
||||
|
||||
class TransactionResponse(BaseModel):
|
||||
id: int
|
||||
piggy_bank_id: int
|
||||
amount: float
|
||||
description: Optional[str]
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
Reference in New Issue
Block a user