feat(backend): order items keep the product and category they were sold under; reports use them
Platform v2 step 1.12 (APPS_PLATFORM D-18, CS-4). - order_items.product_name (NOT NULL), category_id, category_name (revision 0011, back-filled from the current catalogue). A before_flush hook in models/order.py fills them for every new item, whoever creates it; an item created with product_name set is left alone (importer). - Reports read the snapshots: order history, shift/printer/prep-zone breakdowns, cancellations, product and category performance (grouped by the category as sold, newest name in the period wins), and the printed product/category reports. Catalogue listings (unsold products in 'full' mode, meta endpoints, waste-only rows) keep live names on purpose. - Order detail and OrderItemOut expose product_name/category_id/category_name next to the live . Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -42,6 +42,9 @@ class OrderItemOut(BaseModel):
|
||||
order_id: int
|
||||
product_id: int
|
||||
product: Optional[ProductNameOut] = None
|
||||
product_name: Optional[str] = None # name when ordered (D-18); `product` is the live catalogue
|
||||
category_id: Optional[int] = None # category when ordered
|
||||
category_name: Optional[str] = None
|
||||
added_by: int
|
||||
quantity: float
|
||||
unit_type: str = "piece"
|
||||
|
||||
Reference in New Issue
Block a user