Repository navigation
feat(v3): every screen reads the stage and one money helper - #629
Open
privatejoel wants to merge 1 commit into
Open
privatejoel wants to merge 1 commit into
privatejoel wants to merge 1 commit into
Conversation
Every order screen now reads order.stage, which C-9 sends. One set of helpers in lib/helpers.ts gives the label and the value: - stageLabel(key) uses STAGE_LABELS from the server stage module. - stageKeyOf(o) and stageChip(o) read o.stage. If an endpoint sends no stage, they read the status. - awaitsAction(o) is true while the order has a next move. - orderValue(o, lines?) and fmtOrderValue(o, opts) give the value: the printed grand total, else the sum of the line totals, in the order currency. The per-screen status maps and money formatters are gone. Home, the SO list, the Kanban, the Register, the approvals drawer, Tally push, Tally reconcile, the gun viewer and the thread drawer use the helpers. Home "My queue" counts from the stage before it takes 8 rows. A verified or cancelled order leaves the queue. "Oldest" is the oldest order. The nav badges count from the stage. The SO list has one tab for each stage. The Kanban puts each order in a column by its stage. A Mode B order that is handed off, keyed or verified moves out of Approve. The SO workspace reads the stage from GET /api/orders/exceptions, else from orderStage() on the order it holds. The stepper reads the stage. The next-step bar shows at every stage. When an edit clears the approval, the bar sends the order to DRAFT and then for approval again. The server uses the same value. The line math moves to src/api/_lib/line-totals.js, and orderValue() is added to _lib/order-value.js. The approvals queue and the Register use it. Pending SOs give the open value as rate x balance quantity, not rate x ordered quantity. No migration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Stacked on #626. Merge #626 first.
Summary
This is C-10 of docs/SO_EXECUTION_COHESION.md (R-M1). Every order screen now reads
order.stage, which #626 sends. One label and one value come from one helper module.Helpers in
src/v3-app/lib/helpers.ts:stageLabel(key)usesSTAGE_LABELSfromsrc/api/_lib/order-stage.js. The client does not copy the labels.stageKeyOf(o)andstageChip(o)reado.stage. If an endpoint sends no stage, they read the status (Mode A, no handoff or ERP evidence).awaitsAction(o)is true while the order has a next move: not verified, not cancelled, not parked.orderValue(o, lines?)andfmtOrderValue(o, { compact, lines })give the printed grand total, else the sum of the line totals, in the order currency.orderValueis insrc/api/_lib/order-value.js, so the server uses the same code.What changes for a person:
stageOf()and its status map are gone. "approval" for APPROVED, "shipped" for RECONCILED, and the per-screen maps are gone too. Home, the SO list, the Kanban, the Register, Tally push, Tally reconcile, the gun viewer and the thread drawer show the same stage label. A status that the stage hides shows as a note, for example "Verifying, blocked" or "Approved, push failed".in_approvalstage.in_approval. Intake countsreceived,verifyingandreturned.awaitsAction.orderStage()on the order.nextStep()gets the stage.resubmit_for_approval(an edit after the approval) sends PATCH DRAFT, then PENDING_REVIEW. The other stage-only steps show their label on a disabled button.fmtMoneyin the Kanban and in Pending SOs, and the localmoneyin the workspace. A scanned PO with no grand total now has the same value on the list, Home, the Kanban, the approvals drawer and queue, the Register and the workspace. The workspace header now adds tax, the same as the line grid footer (it summed taxable only before).On the server, the line math moves from
src/v3-app/lib/line-totals.tstosrc/api/_lib/line-totals.js(the TS file now only re-exports it). The approvals queue (value_inr) and the Register (value) callorderValue().Shortcuts (each one has a
shortcut:comment):helpers.ts: a row with nostageis read from its status alone. Upgrade when every order endpoint sendsstage.home.tsx: the queue counts the newest 50 orders for the whole tenant. Upgrade when the C-14 worklist serves "waiting on me".order-value.js:orderGrandTotal(the win/loss rollups) still calculates its own value. Upgrade when the rollups must match the screens.Deploy notes
Tests
New tests:
src/v3-app/lib/helpers-stage-label.test.ts: labels, stage over status, the status fallback, notes,awaitsAction,orderValueand currency.src/v3-app/screens/home-mode-b-queue.test.tsx: a verified or cancelled Mode B order leaves the queue. 30 open orders count as 30, the table shows 8 rows, and "oldest" is 30 days.src/v3-app/lib/telemetry-badges.test.ts: the SO, Approvals and Intake badges count from the stage.src/v3-app/screens/so-workspace-stepper.test.tsx: a verified Mode B order completes the stepper. The server stage wins. A cleared approval stops at Approve. The resubmit sends DRAFT, then PENDING_REVIEW.src/v3-app/screens/order-value-list-workspace.test.tsx: a PO with no grand total shows 236 on the SO list and in the workspace.src/v3-app/screens/orders-stage-tabs.test.tsx: the SO list files each order under its stage tab.src/v3-app/api-pending-sales-orders-value.test.js: the real handler values a line at rate x balance.src/v3-app/screens/pipeline-kanban.test.tsx(new describe): columns come from the stage, and a dropped card that has a server stage moves at once.Updated assertions (intended label and format changes): the Register row labels, the Kanban card note and value (
₹ 120k), the workspace summary value (₹1,500.00), the RECONCILED workspace bar (it is now present, with actionnone), and thestageOfunit tests (removed withstageOf).Mutation check. I broke each rule, saw a test fail, and restored the rule:
stageKeyOfignoreso.stageawaitsActionignoresnext_action: nonein_approvalstatus === APPROVEDorderValuehas no line-sum fallbackGates:
npm run check: pass.npm run lint: 0 errors. The warnings were there before.npm run build: pass. I deleted the outputs.npm run verify: pass. I restoreddocs/RBAC_AUDIT.mdanddocs/WRITE_PATH_AUDIT.md. Their changes were drift from earlier work, not from this change.npm run eval:golden: pass.NODE_OPTIONS=--no-experimental-webstorage npx vitest run --maxWorkers=2: 636 files and 7432 tests pass.Not covered
orderGrandTotal) keep their own value calculation.value_inr, and it shows the value in INR.🤖 Generated with Claude Code