AgriTech / models /expense.py
Tahasaif3's picture
code pushed'
a7f2c72
from typing import Optional
from pydantic import BaseModel, Field
class EntryMeta(BaseModel):
voiceText: Optional[str] = None
asrConfidence: Optional[float] = Field(default=None, ge=0, le=1)
lang: Optional[str] = None
class EntryCreate(BaseModel):
entryType: str # "expense" or "income"
category: str
amount: float
date: Optional[str] = None # ISO string from client; falls back to server time
currency: str = Field(default="PKR", min_length=1)
paymentMethod: str = Field(default="cash")
notes: Optional[str] = None
recordedBy: str # <-- changed to free string (user id, username, etc.)
deviceId: Optional[str] = None
meta: Optional[EntryMeta] = None
class EntryResponse(BaseModel):
id: str
type: str = Field(default="entry")
entryType: str
category: str
amount: float
currency: str
paymentMethod: str
notes: Optional[str]
createdAt: str
recordedBy: str # <-- free string allowed here too
deviceId: Optional[str]
syncStatus: str = Field(default="local")
meta: Optional[EntryMeta]