Minor version bump (1.x.0) is appropriate because:
✅ New functionality added (soft delete system) ✅ Backward compatible (existing features unchanged) ✅ Significant enhancement (complete temporal tracking system) ✅ API additions (new endpoints, parameters) ✅ UI enhancements (new components, visual indicators)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date
|
||||
|
||||
# Brand schemas
|
||||
class BrandBase(BaseModel):
|
||||
@@ -70,7 +70,7 @@ class ProductBase(BaseModel):
|
||||
weight_unit: str = "g"
|
||||
|
||||
class ProductCreate(ProductBase):
|
||||
pass
|
||||
valid_from: Optional[date] = None # If not provided, will use current date
|
||||
|
||||
class ProductUpdate(BaseModel):
|
||||
name: Optional[str] = None
|
||||
@@ -79,6 +79,7 @@ class ProductUpdate(BaseModel):
|
||||
organic: Optional[bool] = None
|
||||
weight: Optional[float] = None
|
||||
weight_unit: Optional[str] = None
|
||||
valid_from: Optional[date] = None # If not provided, will use current date
|
||||
|
||||
class Product(ProductBase):
|
||||
id: int
|
||||
@@ -90,6 +91,54 @@ class Product(ProductBase):
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
# Historical Product schemas
|
||||
class ProductHistory(BaseModel):
|
||||
history_id: int
|
||||
id: int # Original product ID
|
||||
name: str
|
||||
category_id: int
|
||||
brand_id: Optional[int] = None
|
||||
organic: bool = False
|
||||
weight: Optional[float] = None
|
||||
weight_unit: str = "g"
|
||||
created_at: Optional[datetime] = None
|
||||
updated_at: Optional[datetime] = None
|
||||
valid_from: date
|
||||
valid_to: date
|
||||
deleted: bool
|
||||
operation: str # 'U' for Update, 'D' for Delete
|
||||
archived_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class ProductAtDate(BaseModel):
|
||||
id: int
|
||||
name: str
|
||||
category_id: int
|
||||
category: GroceryCategory
|
||||
brand_id: Optional[int] = None
|
||||
brand: Optional[Brand] = None
|
||||
organic: bool = False
|
||||
weight: Optional[float] = None
|
||||
weight_unit: str = "g"
|
||||
valid_from: date
|
||||
valid_to: date
|
||||
deleted: bool
|
||||
was_current: bool # True if from current table, False if from history
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
class ProductAtPurchase(BaseModel):
|
||||
product: ProductAtDate
|
||||
amount: float
|
||||
price: float
|
||||
discount: bool
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
# Shop schemas
|
||||
class ShopBase(BaseModel):
|
||||
name: str
|
||||
|
||||
Reference in New Issue
Block a user