Add Other Purchases to budget page
- New other_purchases table (date, total, notes) - /api/other CRUD endpoints - Budget stats now include other costs in cost/egg and cost/dozen math - Budget page: new Log Other Purchases form, stat cards for other costs, combined Purchase History table showing feed and other entries together Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,28 @@ class FeedPurchaseOut(BaseModel):
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# ── Other Purchases ───────────────────────────────────────────────────────────
|
||||
|
||||
class OtherPurchaseCreate(BaseModel):
|
||||
date: date
|
||||
total: Decimal = Field(gt=0, decimal_places=2)
|
||||
notes: Optional[str] = None
|
||||
|
||||
class OtherPurchaseUpdate(BaseModel):
|
||||
date: Optional[date] = None
|
||||
total: Optional[Decimal] = Field(default=None, gt=0, decimal_places=2)
|
||||
notes: Optional[str] = None
|
||||
|
||||
class OtherPurchaseOut(BaseModel):
|
||||
id: int
|
||||
date: date
|
||||
total: Decimal
|
||||
notes: Optional[str]
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# ── Stats ─────────────────────────────────────────────────────────────────────
|
||||
|
||||
class MonthlySummary(BaseModel):
|
||||
@@ -85,6 +107,7 @@ class MonthlySummary(BaseModel):
|
||||
flock_at_month_end: Optional[int]
|
||||
avg_eggs_per_hen_per_day: Optional[float]
|
||||
feed_cost: Optional[Decimal]
|
||||
other_cost: Optional[Decimal]
|
||||
cost_per_egg: Optional[Decimal]
|
||||
cost_per_dozen: Optional[Decimal]
|
||||
|
||||
@@ -99,11 +122,13 @@ class DashboardStats(BaseModel):
|
||||
days_tracked: int
|
||||
|
||||
class BudgetStats(BaseModel):
|
||||
total_feed_cost: Optional[Decimal]
|
||||
total_feed_cost_30d: Optional[Decimal]
|
||||
total_eggs_alltime: int
|
||||
total_eggs_30d: int
|
||||
cost_per_egg: Optional[Decimal]
|
||||
cost_per_dozen: Optional[Decimal]
|
||||
cost_per_egg_30d: Optional[Decimal]
|
||||
cost_per_dozen_30d: Optional[Decimal]
|
||||
total_feed_cost: Optional[Decimal]
|
||||
total_feed_cost_30d: Optional[Decimal]
|
||||
total_other_cost: Optional[Decimal]
|
||||
total_other_cost_30d: Optional[Decimal]
|
||||
total_eggs_alltime: int
|
||||
total_eggs_30d: int
|
||||
cost_per_egg: Optional[Decimal]
|
||||
cost_per_dozen: Optional[Decimal]
|
||||
cost_per_egg_30d: Optional[Decimal]
|
||||
cost_per_dozen_30d: Optional[Decimal]
|
||||
|
||||
Reference in New Issue
Block a user