Add budget-driven Restocking tab and Claude Code workflowNew features - #256
Open
tsharish wants to merge 2 commits into
Open
Add budget-driven Restocking tab and Claude Code workflowNew features#256tsharish wants to merge 2 commits into
tsharish wants to merge 2 commits into
Conversation
Adds a Restocking view that recommends what to reorder from the demand forecast for a given budget, and surfaces submitted orders in the Orders tab. Frontend: - New Restocking.vue: budget slider ($0-$10,000, $250 steps) driving a greedy-by-shortfall allocation with partial fills on the last affordable line. Full-coverage cost is computed from the loaded forecasts rather than hardcoded, so it tracks fixture changes. - Money math is rounded to cents at each step. Accumulated float subtraction otherwise left the remaining budget at 95.99999999999957 instead of 96.00, which silently dropped a $96.00 line item and left the budget unspent at exactly the full-coverage figure. - Restocking uses formatCurrencyWithDecimals(..., 2) for unit costs and line totals so they reconcile against quantity. The shared currency.js default of 0 decimals is unchanged, since Dashboard, Spending, Reports and Orders all depend on it. - Orders.vue gains a "Submitted Orders" card above All Orders showing lead time and expected delivery; loads independently of the FilterBar. - en/ja locales at parity (266 keys, no gaps). Backend: - demand_forecasts.json gains unit_cost and lead_time_days on all 9 records. PSU-501 reuses its real inventory cost ($18.99); the other 8 SKUs have no inventory row, so costs are set per part type. - POST /api/restock-orders re-validates the budget, SKUs and quantities server-side, so the client cannot overspend even if its arithmetic drifts. GET /api/restock-orders lists newest first. - Orders are stored in a process-scoped list and are lost on restart; this app has no database by design. Tests: 19 new backend tests (59 total, all passing), written relative to a baseline count since the order list accumulates within a session. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Responds to @claude mentions on issues and PR review comments, pinned to anthropics/claude-code-action@v1. This is step 3 of the manual setup only. The workflow does nothing until someone with repo admin also: 1. installs the Claude GitHub App (github.com/apps/claude) 2. adds an ANTHROPIC_API_KEY repository secret /install-github-app could not be used here: it needs an interactive terminal for the OAuth grant and the gh CLI, which is not installed. On this public repo the action only runs for commenters with write access, and GitHub withholds secrets from fork-PR runs. No credential is committed here, only the secrets.ANTHROPIC_API_KEY reference. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two independent changes, one commit each:
8b9a11a— Restocking tab. A new view that recommends what to reorder from the demand forecast for a given budget, plus a "Submitted Orders" section in the Orders tab showing delivery lead time.04ca729— Claude Code GitHub Actions workflow. Responds to@claudementions. Inert until two manual steps are done — see below.Restocking tab
Frontend
client/src/views/Restocking.vue: budget slider ($0–$10,000 in $250 steps) driving a greedy-by-shortfall allocation, with a partial fill on the last affordable line. Full-coverage cost is computed from the loaded forecasts rather than hardcoded, so it tracks fixture changes.Orders.vuegains a "Submitted Orders" card above All Orders, loading independently of the FilterBar.en/jalocales at parity (266 keys, no gaps).Backend
demand_forecasts.jsongainsunit_costandlead_time_dayson all 9 records.PSU-501reuses its real inventory cost ($18.99); the other 8 SKUs have no inventory row, so costs are set per part type.POST /api/restock-ordersre-validates budget, SKUs and quantities server-side, so the client cannot overspend even if its arithmetic drifts.GET /api/restock-orderslists newest first.Two bugs caught during review
95.99999999999957instead of96.00.VLV-506costs exactly $96.00, so it failed the affordability check, andMath.floor(95.99999999999957 / 96.0)then returned0— delivering 7 of 8 items with $96 unspent. Fixed by rounding to cents at each step. Deliberately not fixed with an epsilon (>= fullCost - 0.01), which would permit a one-cent overspend.formatCurrencyusesmaximumFractionDigits: 0, so unit costs rendered as $25 against a line total of $3,675 — 150 × $25 = $3,750, and nothing on screen reconciled. Restocking now uses the pre-existingformatCurrencyWithDecimals(..., 2). The sharedcurrency.jsis unchanged, since Dashboard, Spending, Reports and Orders all depend on its 0-decimal default.Testing
59 backend tests pass (40 pre-existing + 19 new in
tests/backend/test_restocking.py). New tests are written relative to a baseline count, since the order list accumulates within a session.Verified live end-to-end: at a $7,000 budget all 8 shortfall items are recommended, every line total equals quantity × unit cost exactly, summing to $6,832.48 with $167.52 remaining. A submitted order appeared in Orders with a 28-day lead time and the correct delivery date.
Known limitations
currency.jsrounds each converted value independently and yen has no subunit, so a unit price of ¥1,838 shows against a ¥198,450 line total (¥54 across 108 units, ~0.03%). Inherent to the shared util, which this PR leaves alone.The workflow file needs two manual steps
.github/workflows/claude.ymldoes nothing until someone with repo admin also:ANTHROPIC_API_KEYrepository secret./install-github-appcould not be used to automate this: it needs an interactive terminal for the OAuth grant, and theghCLI is not installed on the dev machine.Security notes for a public repo: no credential is committed — only the
secrets.ANTHROPIC_API_KEYreference. The action only runs for commenters with write access, and GitHub withholds secrets from fork-PR runs.client/.npmrcand theclient/package-lock.jsongitignore rule are untouched.Not included
docs/architecture.html(written earlier in the same session) is intentionally left out. It predates this feature — it says 14 endpoints when there are now 16, and doesn't mention the Restocking tab. It'll come in a separate PR once refreshed.🤖 Generated with Claude Code