Skip to content

Add budget-constrained restocking with submitted order tracking - #235

Open
andercsantos wants to merge 3 commits into
beck-source:mainfrom
andercsantos:new_features
Open

Add budget-constrained restocking with submitted order tracking#235
andercsantos wants to merge 3 commits into
beck-source:mainfrom
andercsantos:new_features

Conversation

@andercsantos

Copy link
Copy Markdown

Summary

Adds a Restocking page that recommends which below-reorder-point items to replenish within an available budget, and surfaces submitted restock orders on the Orders page.

Changes

Frontend

  • New Restocking.vue view + useRestocking.js composable — budget slider ($5K–$250K), greedy allocation by priority, and an explicit "excluded, over budget" table so skipped items stay visible rather than being silently dropped
  • Submitted restock orders section on Orders, fetched in parallel with the filtered order list (restock orders take no filter params, so they stay visible across filter changes)
  • Route + nav tab wiring; getRestockOrders / createRestockOrder in api.js
  • en/ja locale strings

Backend

  • GET / POST /api/restock-orders. POST recomputes the basket total server-side, so the budget check can't be bypassed by a tampered request
  • Order ETA uses the longest lead time in the basket, since the order is only complete once its slowest line arrives
  • lead_time_days added to InventoryItem (defaults to 14 when absent), populated across inventory.json

Also fixed

  • Demand.vue rendered ++50.0% on the increasing-trend card — getChangePercent already returns a signed string and the template added a second +. Separate commit.

Testing

  • 56/56 backend tests pass, including 16 new in tests/backend/test_restocking.py covering budget enforcement, item validation, and lead-time math
  • All 7 pages verified in Chromium by clicking through each nav tab: zero console errors, zero failed requests
  • Demand fix confirmed in-browser: +50.0%, +20.0%, +18.8%, -30.0%

Note

The budget allocator is greedy by priority, so it can leave money unspent — a $50K budget allocates $49,472 while PSU-505 is excluded for being "over by $410". Reasonable for a demo, but worth flagging if backfilling cheaper items into the remainder is preferred.

🤖 Generated with Claude Code

andercsantos and others added 3 commits July 29, 2026 11:09
Adds a Restocking page that recommends which below-reorder-point items to
replenish within an available budget, and surfaces submitted restock orders
on the Orders page.

- Restocking view + useRestocking composable: budget slider ($5K-$250K),
  greedy allocation by priority, and an explicit "excluded, over budget"
  table so skipped items are visible rather than silently dropped
- GET/POST /api/restock-orders; POST recomputes the basket total
  server-side so the budget check cannot be bypassed by a tampered request
- Order ETA uses the longest lead time in the basket, since an order is
  only complete once its slowest line arrives
- lead_time_days added to InventoryItem (defaults to 14 when absent) and
  populated across inventory.json
- Submitted restock orders section on Orders, fetched in parallel with
  the filtered order list; restock orders take no filter params
- en/ja locale strings; 16 backend tests covering budget, validation,
  and lead-time math

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
getChangePercent already returns a signed string, so the literal "+" in the
template rendered "++50.0%". The stable and decreasing cards omit the literal
"+", which is why only the increasing card was affected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant