Repository navigation
Conversation
Receiving a Picnic order archived the plan but left the cart in place. Sync leaves unnamed cart rows alone, so the next order showed those lines again. A quantity of 0 also failed to stick when substitution moved it onto a replacement. Closing now removes every cart article. A direct zero stays on that product and clears a stand-in replacement that nothing else wants. Co-authored-by: Adrian Philipp <adri@users.noreply.github.com>
This branch has not been 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.
Root cause
Receiving a Picnic order (
start_shopping/ "Bestelling ontvangen") archived the plan rows, which is whyget_previous_ordersshowed the 19 Oct order closed. It never touched the Picnic cart.Two things then kept those 44 lines on the new order:
start_shoppingmovedPlannedRecipeandManualIngredientoff line"1"and, in picnic mode, stored no snapshot (order_item.product_idis numeric; Picnic selling-unit ids are strings).Order.Synctreats a product the plan does not mention (new_count == nil) as something the Picnic app added itself, and does not remove it. After close the plan on line"1"is empty, so the daily sync neither deletes the old rows nor has to re-add them — they just stay.picnic_linerenders that cart as the current order, withplanned_recipesempty because the recipes now live on the closed order.There is a second way the same lines get back into the cart: if Picnic itself empties the cart at checkout before Picape closes the order, a sync in that window still has the plan on line
"1"and pushes every line into the fresh cart. Closing then has to clear that refill too. It did not.Quantity 0
Substitution rewrites a wanted id onto the replacement and drops the original. A quantity of 0 was moved onto the replacement and added to whatever else had landed there (
0 + 1 = 1), and the original id left the wanted map. Sync then treated the missing id as "leave untouched", so the cart row stayed at its old quantity.Fix
start_shoppingremoves every article currently in the Picnic cart, using the existingremove_productdelta. The closed order still keeps its plan rows. The next sync sees an empty plan and an empty cart, so it pushes nothing back. A product added in the Picnic app after that is still left alone.start_shoppingnow triggersorder_changed, so an open app picks up the empty order.No checkout, payment, or delivery-slot call was added. The AH substitution path, AH product ids, and replacement mappings are unchanged. No migration.
If Picnic is unreachable at the moment of close, the plan is still archived and the clear is logged and skipped. Tapping "Bestelling ontvangen" again retries the clear.
Tests
mix check(format, credo --strict, compile --warnings-as-errors,mix test --warnings-as-errors, sobelow): 197 tests, 0 failures.New coverage in
test/picnic_mode_test.exs:GET /api/15/cartandremove_product. The AH basket is unchanged.Existing picnic and AH replacement tests still pass, including "a manual 0 on an unavailable product keeps the planned replacement".