Stockroom Phase 5 Listings and Sales Plan

Part of the Simple Agility stack. Canonical copy: ~/source/stockroom/docs/superpowers/plans/2026-10-08-stockroom-phase-5-listings-and-sales.md (14 test-first tasks with complete code). This page mirrors the decisions for retrieval. It implements the phase 5 parts of StockroomChannelsAndSalesDesign, follows StockroomPhase4PhysicalTrackingPlan, and is followed by StockroomPhase6EbayConnectionAndAlertsPlan. Status: built and reviewed 2026-10-08, not yet deployed. Executed task by task (commits 7eb860b..bbd31c7), with a review per task and a final whole-phase review whose fix wave was verified. The backend and frontend gates pass. Operator acceptance is listed in docs/operations.md › Channels and sales.

Goal

Listings and sales, all of it working by hand:

No new module and no external calls. Phase 6 adds the eBay connection and Telegram alerts behind ports this phase already anticipates.

Key decisions

TopicDecision
StatusesItemStatus gains listed, to_ship, sold and at_fba. These are sales-owned: phases 1–4 never change them (SalesStatusGuard). sold and at_fba have left stock: placement, pick and count scans refuse them (409 ITEM_SOLD, naming when and where the item sold).
PostableAn item that is ready or listed, routed eBay or local, not a lot member and not dissolved. An FBA-routed item cannot be posted (FBA_EXCLUSIVE). One open post per channel.
CopyTitle and description come from the approved listing content; specifics are read from its ordered claims. Suggested prices come from the latest quote for the route.
SellingAny in-stock item that is not sales-owned, dissolved or a lot member can be sold, on any channel but buyback (buyback sales come from closing a buyback pick list). One active sale per item (ALREADY_SOLD). A lot sells as one item.
Sell scanA product code skips copies that already sold and wait to ship (unless every copy is one), then prefers copies with an active post.
Sale moneyThe price is exact. eBay fees are estimated with the existing net calculator. Postage is typed or estimated from the item's shipping weight. The predicted net is copied from the latest triage decision at sale time.
After the saleIn one transaction: the selling channel's post ends sold_here, every other open post becomes delist_pending, the item becomes to_ship or sold, its other pick lines are released, and a shipping sale joins the To-ship list.
CancelRestores the prior status (listed only if a post is active again), and pending posts go back to active.
To-ship listAt most one open list, created on demand with the packing location as its target. Finding or creating it, and its automatic close, are serialised by a transaction-scoped advisory lock rather than the list row's lock; callers take every item lock before their first To-ship call.
Close outcomesSent to Amazon moves picked items to at_fba; Sent to vendor records a buyback batch, split across the items by largest remainder. Each picked item is re-checked under its lock: one that sold meanwhile is skipped, and a posted item refuses Sent to Amazon (FBA_EXCLUSIVE).
Sales listAt most the newest 500 sales; the page says when the answer was cut, since its totals then cover those only.
LockingPost commands lock the item, then the post. Recording a sale locks the item, then a lot's members in UUID order. Cancel, postage and shipped lock the sale row first. A lock or lost-update abort answers 409 TRY_AGAIN.

Tasks

  1. Foundation: migrations V022–V025, entities, enums, settings
  2. Status ownership and left stock across phases 1–4
  3. To-ship lists and the packing location
  4. Posts: copy, links, postability, endpoints, To delist
  5. Sales: money, delist plan, record, cancel, postage, shipped, the Sell scan
  6. Close outcomes: Sent to Amazon, Sent to vendor, sale batches
  7. Sales list and the four queue tiles
  8. Frontend foundation
  9. The Post card and Ready to post
  10. Sell: Stock › Sell, Record sale, the sale card
  11. The To delist page
  12. Picks: packing location, To-ship lists, Shipped, close outcomes
  13. The Sales page
  14. Hand-over: operations, coverage, conformance, operator acceptance

Out of scope


Cluster Hub: Stockroom Hub (stockroom)