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:
@@ -357,6 +357,7 @@ def get_order(order_id: int, db: Session = Depends(get_db), user: User = Depends
|
||||
"order_id": i.order_id,
|
||||
"product_id": i.product_id,
|
||||
"product": {"id": i.product.id, "name": i.product.name} if i.product else None,
|
||||
"product_name": i.product_name, "category_id": i.category_id, "category_name": i.category_name,
|
||||
"added_by": i.added_by,
|
||||
"added_by_name": name_map.get(i.added_by),
|
||||
"quantity": i.quantity,
|
||||
|
||||
Reference in New Issue
Block a user