Back to Feed
article 3m read

Report said reorder, order screen said nothing needed

Two pages in my ordering system had their own idea of when to buy more. I moved the rule into one module, rewrote its order gate twice in under an hour, fixed a badge that could say order now next to a zero, and added a button that builds an editable draft from the same rule.

Article DepthPractice

Flow

Where each check sits in the shared rule

  1. 1Shelf position

    Target and stock in, one of five plain shelf words out, with the rule sentence attached.

  2. 2Demand veto

    A slow or stalled item with stock left gets zero. An empty one still goes through.

  3. 3Short or not

    Only critical and below target can order.

  4. 4Case rules

    Runs last, so rounding can never turn a zero into a partial case.

  5. 5Both pages

    The report and the order screen read the same answer.

Flow

What the draft button does

  1. 1Browser sends

    Only the supplier and the planning inputs. No amounts.

  2. 2Server checks

    The user may order from that supplier, within the stores they can see.

  3. 3Recompute

    The same shared rule works out every suggestion again.

  4. 4Clear and refill

    The session's draft for that supplier is emptied and filled again, so earlier edits go.

  5. 5Count the gaps

    Products the supplier doesn't carry are counted as skipped.

Ordering was needed for one product, according to the report. My order screen said the same product at the same store was fine. Both pages answer one question, and each had its own rule.

The report set a target from recent sales and only suggested an order when the sales label said the item was running out or running low. The order screen read a stored target and only counted a shortfall once stock fell well below it. It never looked at sales. So the same item could get an order on one page and a blank on the other.

The badge that could say "order now" next to a zero

The report's status badge went through four versions. The third one looked only at stock against target, but still used action words. So a slow seller well under target could show "order now" right beside an order of zero. The badge read the shelf, and the order column read the sales label.

The last version uses words that describe the shelf: critical, below target, at target, above target, and review when there's no target. Those can't claim an action the order column doesn't take. The page also says the badge is where stock sits and the order column is the action.

One rule, three tries

I moved the decision into one small module with no screen code in it. It does three things: says where stock sits, applies the supplier's case rules, and works out the suggested amount. Both pages call it now. The order screen had to start loading sales labels, and an item with no label counts as not moving.

The gate, the part that says "order or don't", went through three versions in under an hour:

  • Order only when sales say running low. That misses a slow seller with an empty shelf.
  • Order whenever stock is under target. That restocks things nobody buys.
  • Order when stock is under target, unless the item sells slowly and some stock is still there.

The third one stuck. One detail matters a lot: the case step rounds any small order up to part of a case. So the "should we order" checks have to run first. If they ran after, an item that needs nothing could still get a partial case.

From suggestions to a draft

Once both pages shared one rule, I added a button that builds a draft order for a supplier. The browser sends only the supplier and the planning inputs, never amounts. The server checks the user can order from that supplier, works the numbers out again with the same rule, then clears that draft and refills it. It counts and skips any products the supplier doesn't carry, but the page doesn't show that count. Nothing goes to the supplier. A person still edits it.

No tests, and edits get wiped on rebuild

There are no tests yet, and a rule that changed twice in an hour is the first place I'd add them. Rebuilding the draft also wipes any edits made to it earlier, so for now the button comes first and the hand edits come last.

Keep reading

Pick up a connected idea or branch into a nearby one.

5 paths forward