Repository navigation
fix(orders): no 24 h approval expiry in Mode B - #627
Open
privatejoel wants to merge 1 commit into
Open
privatejoel wants to merge 1 commit into
privatejoel wants to merge 1 commit into
Conversation
C-11 (A-PR19, decision C-D8). In Mode B, an approval does not expire. Mode A keeps the 24 h expiry. - Approve in Mode B stores approval_expires_at = null. Approve in Mode A stores now + 24 h. - approvalExpiryBlocks treats a Mode B approval as not expired. This includes old rows with a stored 24 h expiry. - The server sets the TTL. The client ttlHours is ignored. Before, ttlHours 1e6 gave an approval that did not expire, and "x" gave a 500. - In Mode A, an approval with no stored expiry (given in Mode B) expires 24 h after approved_at. - The handler reads the mode with isModeB. A missing setting, a read error or a thrown read is Mode A, so the 24 h expiry stays. - A line edit still clears the approval in both modes. A new test pins it. 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.
Summary
C-11 (A-PR19, decision C-D8). In Mode B, an approval does not expire. Mode A keeps the 24 h expiry.
In Mode B the order stays at APPROVED while a clerk keys the ERP. After 24 h, the expiry refused the later status moves of the order. The owner accepted the default of C-D8: in Mode B there is no 24 h expiry, and a line edit still clears the approval.
What changes:
approval_expires_at = null. In Mode A it stores now + 24 h.approvalExpiryBlocks, the only reader ofapproval_expires_at) treats a Mode B approval as not expired. This includes old rows that have a stored 24 h expiry.body.approval.ttlHoursis ignored. Before this change,ttlHours: 1e6gave a Mode A approval that did not expire, andttlHours: "x"gave a 500. No screen sends it.approved_at + 24 hwhen no expiry is stored. Thus a Mode B approval does not escape the 24 h rule after the tenant goes to Mode A.isModeBreader (_lib/so-processing-mode.js, filterstenant_id). If the setting is missing, or the read returns an error, or the read throws, the mode is A. Thus the 24 h expiry stays (the stricter rule).The handler reads the mode only for a PATCH that sets
status. A line edit does not read it.Deploy notes
Tests
New file:
src/v3-app/api-orders-approval-ttl.modeB.test.js. It runs the real PATCH handler on an in-memory database.ttlHoursis ignored:1e6and"x"in Mode A give 24 h (and no 500).1in Mode B gives no expiry.Changed:
src/v3-app/api-order-status-actions.test.js. Its describe label said "Mode B", but its tests run with no mode row (Mode A). The label now says what the tests do. The assertions did not change.Mutation check. I broke each rule, ran the new test file, saw tests fail, and restored the code:
approvalExpiryBlocksttlHours1)ttlHoursagain1e6and"x"in Mode A).catch(() => true))isModeBreads an unknown mode as Bapproved_atfallback in Mode ANot covered
approvalJSON keeps the keys the client sent,ttlHoursincluded. The server does not read it.requireApprovedOrderdo not read the expiry (before and after this change). This PR does not add an expiry to them.🤖 Generated with Claude Code