From a8feb82fa2dab1331c8da2c3e754ad501a01ac0e Mon Sep 17 00:00:00 2001 From: Stephen Masters Date: Mon, 20 Jul 2026 10:45:03 +0100 Subject: [PATCH 1/2] Add Restocking tab with budget-driven order recommendations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a new /restocking route with a $1K–$100K budget slider that recommends items to restock based on increasing demand forecasts. A greedy algorithm selects items by demand gap until the budget is exhausted. Placing an order submits it to POST /api/orders with a fixed 14-day lead time, and the submitted order appears in a new "Submitted Restocking Orders" section in the Orders tab. Co-Authored-By: Claude Sonnet 4.6 --- client/src/App.vue | 3 + client/src/api.js | 10 ++ client/src/main.js | 4 +- client/src/views/Orders.vue | 64 +++++++- client/src/views/Restocking.vue | 282 ++++++++++++++++++++++++++++++++ server/data/inventory.json | 36 ++++ server/main.py | 59 +++++++ 7 files changed, 455 insertions(+), 3 deletions(-) create mode 100644 client/src/views/Restocking.vue diff --git a/client/src/App.vue b/client/src/App.vue index c2da05a5c..2c6081c38 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -25,6 +25,9 @@ Reports + + Restocking +
-

{{ t('orders.allOrders') }} ({{ orders.length }})

+

{{ t('orders.allOrders') }} ({{ customerOrders.length }})

@@ -45,7 +45,7 @@ - +
{{ order.order_number }} {{ translateCustomerName(order.customer) }} @@ -74,6 +74,52 @@
+ + @@ -96,6 +142,14 @@ export default { const error = ref(null) const orders = ref([]) + const submittedOrders = computed(() => + orders.value.filter(o => o.status === 'Submitted') + ) + + const customerOrders = computed(() => + orders.value.filter(o => o.status !== 'Submitted') + ) + // Use shared filters const { selectedPeriod, @@ -160,6 +214,8 @@ export default { loading, error, orders, + submittedOrders, + customerOrders, getOrdersByStatus, getOrderStatusClass, formatDate, @@ -276,4 +332,8 @@ export default { font-size: 0.813rem; color: #64748b; } + +.submitted-orders-card { + margin-top: 1.5rem; +} diff --git a/client/src/views/Restocking.vue b/client/src/views/Restocking.vue new file mode 100644 index 000000000..772962d7e --- /dev/null +++ b/client/src/views/Restocking.vue @@ -0,0 +1,282 @@ + + + + + diff --git a/server/data/inventory.json b/server/data/inventory.json index 486fda819..ef7b518f5 100644 --- a/server/data/inventory.json +++ b/server/data/inventory.json @@ -382,5 +382,41 @@ "unit_cost": 185.50, "location": "Warehouse C-11", "last_updated": "2025-09-21T15:20:00" + }, + { + "id": "33", + "sku": "WDG-001", + "name": "Industrial Widget Type A", + "category": "Widgets", + "warehouse": "San Francisco", + "quantity_on_hand": 300, + "reorder_point": 250, + "unit_cost": 45.00, + "location": "Warehouse A-20", + "last_updated": "2025-09-30T10:30:00" + }, + { + "id": "34", + "sku": "FLT-405", + "name": "Oil Filter Cartridge", + "category": "Filters", + "warehouse": "San Francisco", + "quantity_on_hand": 200, + "reorder_point": 150, + "unit_cost": 8.50, + "location": "Warehouse B-10", + "last_updated": "2025-09-30T10:30:00" + }, + { + "id": "35", + "sku": "GSK-203", + "name": "High-Temperature Gasket", + "category": "Seals", + "warehouse": "San Francisco", + "quantity_on_hand": 100, + "reorder_point": 80, + "unit_cost": 22.75, + "location": "Warehouse C-05", + "last_updated": "2025-09-30T10:30:00" } ] \ No newline at end of file diff --git a/server/main.py b/server/main.py index a0c2d8c5a..5f80b007b 100644 --- a/server/main.py +++ b/server/main.py @@ -2,6 +2,7 @@ from fastapi.middleware.cors import CORSMiddleware from typing import List, Optional from pydantic import BaseModel +from datetime import datetime, timedelta from mock_data import inventory_items, orders, demand_forecasts, backlog_items, spending_summary, monthly_spending, category_spending, recent_transactions, purchase_orders app = FastAPI(title="Factory Inventory Management System") @@ -120,6 +121,15 @@ class CreatePurchaseOrderRequest(BaseModel): expected_delivery_date: str notes: Optional[str] = None +class RestockingOrderItem(BaseModel): + sku: str + name: str + quantity: int + unit_price: float + +class CreateRestockingOrderRequest(BaseModel): + items: List[RestockingOrderItem] + # API endpoints @app.get("/") def root(): @@ -161,6 +171,55 @@ def get_order(order_id: str): raise HTTPException(status_code=404, detail="Order not found") return order +@app.post("/api/orders", response_model=Order, status_code=201) +def create_restocking_order(request: CreateRestockingOrderRequest): + """Create a restocking order from demand-driven recommendations""" + next_id = str(len(orders) + 1) + next_num = str(len(orders) + 1).zfill(4) + order_number = f"RST-{datetime.now().year}-{next_num}" + today = datetime.now() + new_order = { + "id": next_id, + "order_number": order_number, + "customer": "Internal Restocking", + "items": [i.dict() for i in request.items], + "status": "Submitted", + "order_date": today.strftime("%Y-%m-%dT%H:%M:%S"), + "expected_delivery": (today + timedelta(days=14)).strftime("%Y-%m-%dT%H:%M:%S"), + "total_value": round(sum(i.quantity * i.unit_price for i in request.items), 2), + "actual_delivery": None, + "warehouse": None, + "category": None + } + orders.append(new_order) + return new_order + +@app.get("/api/restocking/recommendations") +def get_restocking_recommendations(): + """Return increasing-trend demand forecasts joined with inventory unit_cost, sorted by demand gap""" + inventory_by_sku = {item["sku"]: item for item in inventory_items} + result = [] + for forecast in demand_forecasts: + if forecast["trend"] != "increasing": + continue + gap = forecast["forecasted_demand"] - forecast["current_demand"] + if gap <= 0: + continue + inv = inventory_by_sku.get(forecast["item_sku"]) + unit_cost = inv["unit_cost"] if inv else None + result.append({ + "sku": forecast["item_sku"], + "name": forecast["item_name"], + "current_demand": forecast["current_demand"], + "forecasted_demand": forecast["forecasted_demand"], + "demand_gap": gap, + "unit_cost": unit_cost, + "item_cost": round(gap * unit_cost, 2) if unit_cost is not None else None, + "period": forecast["period"] + }) + result.sort(key=lambda x: x["demand_gap"], reverse=True) + return result + @app.get("/api/demand", response_model=List[DemandForecast]) def get_demand_forecasts(): """Get demand forecasts""" From 1d1cb12bd63ddcb2c395b3aff3d12e85fa80480c Mon Sep 17 00:00:00 2001 From: Stephen Masters Date: Mon, 20 Jul 2026 11:29:27 +0100 Subject: [PATCH 2/2] Redesign UI with sidebar nav and fix dropdown positioning - Replace top nav bar with fixed 240px dark sidebar (slate-900) with indigo accent - Add collapsible sidebar with floating toggle button (always visible when collapsed) - Fix ProfileMenu and LanguageSwitcher dropdowns to open upward and rightward when anchored to sidebar footer (avoids viewport clipping) - Add responsive collapse at <1024px viewport width Co-Authored-By: Claude Sonnet 4.6 --- client/src/App.vue | 354 +++++++++++++++------ client/src/components/LanguageSwitcher.vue | 4 +- client/src/components/ProfileMenu.vue | 4 +- 3 files changed, 267 insertions(+), 95 deletions(-) diff --git a/client/src/App.vue b/client/src/App.vue index 2c6081c38..e17257618 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -1,45 +1,81 @@