Skip to content

fix(rest/python): synchronize simulated shipments with remaining quantities - #247

Open
arjun2075 wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
arjun2075:fix/python-shipping-remaining-quantities
Open

arjun2075 wants to merge 2 commits into
Universal-Commerce-Protocol:mainfrom
arjun2075:fix/python-shipping-remaining-quantities

Conversation

@arjun2075

Copy link
Copy Markdown

POST /testing/simulate-shipping/{id} appends a shipped fulfillment event whose per-line quantity is the quantity "fulfilled in this event" (2026-04-08 fulfillment_event.json), but leaves quantity.fulfilled = 0 and status = "processing" — the stored order contradicts its own event log, and the documented status derivation computes "processing" for an order the events say is shipped.

This change defines the simulation as "ship all remaining units": each call ships every not-yet-fulfilled unit, so the event's per-line quantities are exactly the fulfilled increments for that call. A call with nothing remaining appends no event and invents no quantities; it still normalizes zero-total lines to removed (the change is persisted, no shipment event is emitted). Zero-total lines are excluded from the event — the April schema requires each event quantity >= 1 — and recorded as removed.

Version-applicability note: no 2026-04-08 requirement governs counter/event consistency for this simulation path — this is a reference-implementation self-consistency fix, not spec enforcement. No schema, endpoint, or protocol-contract change.

Tests: five new cases (fresh order, prior partial fulfillment, repeated call, mixed removed/active lines, all-zero-total order) fail on the base and pass with the fix; full integration_test.py is green (43 passed).

@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Oct 2, 2026
@damaz91 damaz91 added status:under-review and removed status:needs-triage Signal that the PR is ready for human triage labels Oct 15, 2026

@damaz91 damaz91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @arjun2075! Great catch synchronizing the simulated shipping increments with the unfulfilled quantities and line-item status derivation, and thorough test coverage. (Pushed a quick EOF newline fix so the pre-commit linter passes.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants