Add purchase date picker and sells feature
- Purchase form now includes a date picker (defaults to today) - New Sell model, CRUD endpoints (/sells), and stats integration - AddSell and SellList components added to dashboard - Portfolio chart updated to reflect sells over time Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
from sqlalchemy.orm import Session
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
from datetime import datetime
|
||||
|
||||
from ..database import get_db
|
||||
@@ -14,6 +14,7 @@ router = APIRouter()
|
||||
class PurchaseCreate(BaseModel):
|
||||
amount_eur: float = Field(gt=0, le=10_000_000)
|
||||
price_eur: float = Field(gt=0, le=10_000_000)
|
||||
created_at: Optional[datetime] = None
|
||||
|
||||
|
||||
class PurchaseUpdate(BaseModel):
|
||||
@@ -54,6 +55,7 @@ def add_purchase(
|
||||
purchase = models.Purchase(
|
||||
amount_eur=purchase_in.amount_eur,
|
||||
price_eur=purchase_in.price_eur,
|
||||
created_at=purchase_in.created_at or datetime.utcnow(),
|
||||
user_id=current_user.id,
|
||||
)
|
||||
db.add(purchase)
|
||||
|
||||
Reference in New Issue
Block a user