An order that changed under you is not saved over - #821
Merged
Merged
Conversation
A handset sends the WHOLE order when it saves, and the till keeps only what arrives. That is not a mistake: it is how a cancelled dish gets cancelled. It is also how a floor with several handsets loses food. Waiter A adds a biryani at 19:00. Waiter B saves at 19:01 from a screen opened at 18:58, so B's list has no biryani in it, and the till removes one the kitchen has already cooked. The bill goes out short. Nobody is told: not A, not B, not the kitchen, and not the shop, which has now given away a plate of biryani and has nothing that says so. So a caller may say which version of the order it was looking at, and a save written against an older one is refused with `order_changed` and the moment it actually changed. The client reloads and decides again, because only a person knows whether that biryani was meant to go. SILENCE STILL MEANS YES. A caller that sends no seen_at is served exactly as before. Handsets already in shops are older than this code, and refusing their saves would turn a bug that loses a dish into one that takes no orders. An unreadable timestamp is not a conflict either: that is a caller this check cannot help, and blocking it helps nobody. An order nobody has ever updated is judged by when it was created, so a first edit is guarded too rather than waved through. Six tests against a real mongod. Three of them fail without the guard; the other three are there to catch the guard overreaching, and pass either way.
The refusal went back as 404, which says the order is not there. It is there, the caller is welcome, and the request is simply out of date. 409 also gives the client something better to key on than the spelling of a message, so the handset's handling stays correct when somebody rewords it later.
sridharkalaibala
force-pushed
the
fix/an-order-changed-under-you
branch
from
September 16, 2026 10:03
961324d to
4a81253
Compare
Contributor
|
Merged to Try it at https://develop.posnic.io, or run it yourself: git fetch origin develop && git checkout develop
npm install && npm --prefix api install
npm run dev # then http://localhost:3000When you have tested it, say what you did and what happened, and set Reporting that something is broken is as useful as fixing it. It is |
This was referenced Sep 16, 2026
Merged
sridharkalaibala
added a commit
to Posnic/captain
that referenced
this pull request
Sep 16, 2026
* Somebody else got there first, and the waiter is told so A save sends the WHOLE order and the till keeps only what arrives, which is how a cancelled dish gets cancelled. On a floor with several handsets it is also how food goes missing: another waiter adds a biryani while this screen is open, this screen saves a list that never had it, and the till removes a dish the kitchen has already cooked. The bill goes out short and nobody is told. So both saves now say which version of the order they were looking at - the order's own timestamp, handed back exactly as it arrived, nothing guessed - and the till refuses one written against an older version. Posnic/POS#821 is that half. Being refused is not an error message. The waiter did nothing wrong and lost nothing, because what they typed was never sent. They are told that somebody else changed the order, the sheet closes rather than sitting there looking ready for a second tap at the same refusal, and the order is fetched again so the screen tells the truth. What happens next is theirs: only a person knows whether the dish somebody else added was meant to go. An order nobody has ever edited falls back to when it was opened, so a first edit is guarded too - which is the case a busy table hits most. An ordinary failure still reads as a failure. A server that is down is a different problem, and a waiter must not be told somebody edited the order when nobody did. The new sentence is not in the Tamil pack yet: that file is being rewritten in the coverage PR and adding a line here would collide with it. It follows once that lands. * And the waiter reads it in their own language The sentence shown when somebody else has changed the order was left in English because the pack was being rewritten in another branch at the time and a line here would have collided with it. That branch has landed, so the loose end closes rather than waiting to be noticed by a waiter who reads Tamil and meets one English sentence at the worst moment.
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.
A handset sends the whole order when it saves, and the till keeps only what arrives:
That is not a mistake. It is how a cancelled dish gets cancelled.
It is also how a floor with several handsets loses food:
The bill goes out short and nobody is told: not A, not B, not the kitchen, and not the shop, which has just given away a plate of biryani with nothing recording that it did.
The guard
A caller may say which version of the order it was looking at (
seen_at). A save written against an older one is refused withorder_changedand the moment the order actually changed, so the client can reload, show what happened, and let a person decide again. Only a person knows whether that biryani was meant to go.What it deliberately does not do
seen_atis served exactly as before. Handsets already in shops are older than this code, and refusing their saves would turn a bug that loses one dish into one that takes no orders at all.Tests
Against a real mongod, because the question is what the database ends up holding.
Three fail without the guard. The other three exist to catch the guard overreaching and pass either way - in particular, leaving a dish out must still cancel it, which is the behaviour this sits in front of.
The captain side, which sends
seen_atand shows the waiter what changed, follows in Posnic/captain.