Chapter 11 — Last-Time Buy (retiring a part)¶
11.1 — What it is, and what it does¶
The Last-Time Buy screen decides how many units of a retiring part to buy, one last time, and commits that buy as incoming supply for the rest of the part's service life.
When a supplier ends a part — or your business decides to stop procuring it — you are left with one decision: how many to buy now so that service keeps running until the part's service end date. The Last-Time Buy screen (Workflows → Last-Time Buy) walks you through that decision end to end:
- You tell it a part is retiring — which part, until when you must keep servicing it, and by when the last buy has to be placed. The planning engines keep planning buys for the part until that last-buy date and stop after it — nothing re-orders the part silently once the window has closed. The series Supply tab shows the last-buy date as a vertical line on the projection chart, so the window is visible where the plan is.
- It proposes the size of the final buy — per location, from your own forecast: expected demand until the end of service, plus a safety margin for the service level you choose, minus the stock and open orders you already have.
- You adjust the proposal to your local knowledge — per-location quantities are editable, and the totals follow your edits.
- You approve it — the app records the decision and always commits the buy as firm incoming supply, split across the locations that can actually receive it (your buy lanes), in shares you can edit. The engines count those arrivals during the run-down.
- You watch the run-down — a weekly projection of stock against demand for every location, until the service end.
Everything lives in one screen with two panels — the Retirement register (one line per retiring part) and Obsolescence risk (the money stuck in stock when a part retires with inventory left) — plus a per-part window (Size LTB…) for sizing, approving and monitoring.
flowchart LR
A["INPUT — a part retires<br/>(item, service end, last buy date)"] --> B["STATUS — LTB announced<br/>new BUY planning stops"]
B -->|"size it, then Approve LTB"| C["STATUS — LTB placed 🔒<br/>decision recorded, supply committed"]
C -->|"retract (before the buy arrives)"| B
B -->|"delete the register line"| D["CANCELLED —<br/>BUY planning resumes"]
classDef io fill:#e7f6f0,stroke:#10b981,color:#1b4332
classDef proc fill:#eef2ff,stroke:#6366f1,color:#312e81
class A,D io
class B,C proc
The status is never something you choose — the screen derives it from what you do. Placing a retirement announces it. Approving the final buy places the decision. Retracting takes it back. That is the whole lifecycle.
11.2 — The retirement register¶
⚙ Process: Workflows → Last-Time Buy → the Retirement register panel.
Each line of the register is one retiring part:
| Column | What it tells you |
|---|---|
| Status | LTB announced (blue) while you are sizing; 🔒 LTB placed (green) once the final buy is decided. |
| Last buy | The date the buying window closes — your deadline for approving the final buy, and the default arrival date of its committed supply. |
| Service until | The service end date. Everything — the proposal, the run-down, the risk report — looks from the planning week to this date. |
| SL | The service level the proposal protects (a percentage, editable on the line). |
| Recommended LTB / $ | What the app thinks the final buy should be today — the network proposal at the line's service level, with its money value. A dash means it could not be computed; hover it for the exact reason (usually: run the forecast step first). |
| Successor | The part that takes over demand at the cutover, if one is set. |
| LTB qty / $ / By | The decided buy — quantity, value and who approved it, once you have approved. |
Working with the lines:
- Click anywhere non-editable on a line to open the per-part Size LTB window — the same thing as its Size LTB… button.
- Edit directly on the line — last-buy date, service end, service level and successor are editable in place (single-click the cell).
- Delete a line to cancel the retirement — buying resumes immediately. Deleting is offered only while the part is announced: once the buy is decided, the line is a record (below).
- When a line cannot make a recommendation, the register still loads — the dash carries the reason, and the Size LTB window shows the same reason in full.
11.3 — Sizing the final buy (the Size LTB window)¶
⚙ Process: any register line → Size LTB… (or click the line) → LTB calculator.
The calculator proposes, for every location with demand history, the quantity that covers demand from the planning week to the service end date:
recommended per location = forecast demand to service end + safety for the chosen service level − on-hand stock − open supply orders (never below zero)
| Table column | Meaning |
|---|---|
| Forecast demand | Your best-method forecast, summed over the remaining weeks of service. |
| Safety | The safety margin for the slider's service level — higher service level, more safety. |
| Gross | Forecast demand + safety. |
| On-hand / Open orders | The stock you already hold, and committed supply already on its way. |
| Your LTB qty | The proposal — editable. Your entries drive the total. |
Three things to know when sizing:
- The service-level slider is a live what-if. Drag it (or type a new service level on the register line) and the whole proposal recomputes at the new level.
- Your per-location quantities drive the final order. The Network total under the table is the sum of your entries, and the ≈ $ value next to it follows — edit a location and the size and the value of the final order move with it. The small gray pooled number is the risk-pooled alternative (spreading the safety stock across locations can make it lower than the per-location sum); it stays visible for comparison.
- The proposal needs your forecast to be fresh. The calculator reads the pipeline's forecast and fitted demand distributions; if they are missing it says so explicitly instead of guessing — run the forecast step and reopen.
If the part's shelf life is shorter than the service horizon, a warning suggests buying in several staggered batches instead of one (a single batch would expire before service ends).
11.4 — Approving: creating the committed supply¶
⚙ Process: Size LTB window → Approve Last-Time Buy → set the destination split → ✓ Approve LTB.
Approving does two things, always together:
- It records the decision — the line becomes
🔒 LTB placed: quantity, value, who, when, your note. The line is now a record: no more edits, no delete, until you retract it (below). The engines keep crediting its committed supply for the whole run-down. - It commits the buy as firm incoming supply — one committed supply line per destination, visible in Master Data → Supply Orders. This is not an option you switch on: there is no approve without the commitment, because the commitment is what the planners' engines, the run-down chart and the supply plan actually count.
Where the buy goes — only your buy lanes, as many as needed. The destinations are the locations with an active buy route for this exact part; nothing else is offered (no buy lane at all → the window says so, and you cannot approve until one exists). You select one or many — all of them start selected, because the final buy normally covers the whole network.
The split starts from history, and then it is yours. Every selected destination is seeded with its share of the total, weighted by how much that location has demanded of the part so far (its closed demand history). Each quantity is an editable input:
- edit a destination quantity → the total follows the sum of your parts;
- edit the total → the split re-seeds proportionally;
- locations with no demand history start at zero — type their share in manually.
flowchart LR
S["INPUT — your per-location<br/>demand quantities"] --> T["PROCESS — total + $ value<br/>(the sum of your entries)"]
D["INPUT — destinations<br/>(locations with buy routes)"] --> SP["PROCESS — split<br/>seeded by history, then your edits"]
T --> SP
SP --> CO["OUTPUT — one committed<br/>supply line per destination"]
CO --> R["PROCESS — engines credit the arrivals;<br/>run-down & burn-down show them"]
classDef io fill:#e7f6f0,stroke:#10b981,color:#1b4332
classDef proc fill:#eef2ff,stroke:#6366f1,color:#312e81
class S,D,CO io
class T,SP,R proc
Worked example — seal kit GS-220 (invented numbers)¶
A supplier ends GS-220, a seal kit your workshops fit during repairs. Unit cost 12. Your pipeline's planning week is mid-June 2026.
1 — Place the retirement. On the register: create the line for GS-220 with service until
2027-06-13 (52 weeks out), last buy date 2026-09-14, service level 95 %. The line
shows LTB announced — from this run on, no plan will propose a new buy for GS-220.
2 — Size it. The register's Recommended LTB reads about 1,002 units. Open Size LTB…:
| Location | Forecast demand | Safety | Gross | On-hand | Open orders | Your LTB qty |
|---|---|---|---|---|---|---|
| Amsterdam workshop | 600 | 118 | 718 | 40 | 20 | 658 |
| Rotterdam workshop | 340 | 66 | 406 | 10 | — | 396 |
| Network (sum / pooled) | 940 | — | — | 50 | 20 | 1,054 / 1,002 pooled |
The Qty (total) box opens at the pooled proposal (1,002 ≈ 12,024 $). You know Rotterdam's workshop will wind down earlier than its forecast says, so you set its quantity to 300 — the total follows: 658 + 300 = 958 ≈ 11,496 $.
3 — Choose the destinations and the split. GS-220 has active buy routes at two depots — Utrecht Central and Antwerp DC — and both start selected. Their demand history of the part is 4,800 vs 1,600, so the split seeds 75 % / 25 % of 958: 718.5 / 239.5. You prefer round numbers on orders: Utrecht 720, Antwerp 238 — the total stays 958.
4 — Approve. Arrival date defaults to the last buy date (2026-09-14), you add a note ("supplier end-of-life, covers service to 2027-06") and approve. The result:
- two committed supply lines are created — Utrecht Central: 720 units (≈ 8,640 $) and Antwerp DC: 238 units (≈ 2,856 $), both arriving 2026-09-14;
- the register line turns
🔒 LTB placedwith LTB qty 958, LTB $ 11,496, decided by you, with the note — and the decision log under the window records the split (720 / 238) alongside; - from the next planning run on, both arrivals are credited as incoming supply, and the run-down charts show stock jumping by 720 and 238 in the arrival week.
5 — The supplier moves the date. Two weeks later the supplier pushes the last buy to October.
The buy has not arrived yet, so you open the window and retract: the decision clears, both
committed lines are deleted, the line returns to LTB announced. You move the last-buy date to
2026-10-05, re-check the proposal (a fortnight of forecast later), re-approve — new committed
lines, new arrival date. Had any of the committed buy already been received, retract would
refuse: received stock is physical — it is corrected in Master Data → Supply Orders instead.
11.5 — Correcting or cancelling¶
| You want to… | Do this |
|---|---|
| Change the size, the split, the dates or the note after approving | Retract LTB (Size LTB window) while the buy is unreceived → edit → approve again. |
| Cancel the retirement entirely (keep buying the part) | Retract first if decided, then Delete the register line — buying resumes immediately. |
| Undo an approval after the buy has landed | Not from here — received stock is physical. Correct or remove the supply lines in Master Data → Supply Orders. |
| Fix a mistake on a line that is only announced | Edit the cells directly on the line, or delete the line and recreate it. |
The freeze on a placed line is deliberate: the line is the decision record, the engines' buy stop, and the anchor of the committed supply. Everything about it changes through retract → edit → re-approve, so the decision log keeps the full story.
11.6 — Running down to the end of service¶
⚙ Process: Size LTB window → Run-down; register → Obsolescence risk panel.
- The run-down projects, per location and per week: projected stock (initial + committed arrivals, then consumed by demand) against cumulative demand, with real actuals taking over as weeks pass. Badges flag the situation early: weeks of cover, stockout risk (the first week the projection goes below zero before service end) and excess at service end (more than a fifth of the initial stock projected to be left over). Charts zoom with the wheel or a drag-box; double-click resets the zoom (hovering shows the chart toolbar).
- Obsolescence risk lists every retiring part that still holds stock, with the on-hand, the expected remaining demand and the surplus — the money at risk if service ends with inventory left. Use it to challenge the buy while it is still cheap to move (a smaller approved quantity) or to plan scrapping/resale.
- The decision log (bottom of the window) records every event on the line — creation, edits, the approval with its full split, retractions — with who and when.
11.7 — The successor part (supersession)¶
If a successor part exists, set it on the register line (editable while announced). At the cutover — by default the last buy date — the + Supersession action in the Size LTB window creates the migration: from that date the successor's network takes over the demand, while everything before the cutover keeps being served by the retiring part. The line's stock rolls to successor flag decides whether the old part's leftover stock is counted for the successor's service or not.
11.8 — A planner's working routine¶
- The moment a part's end-of-life is known — create the register line (item, service end, last buy date, service level, successor if known). Buying stops in the next planning run; you will not be surprised by an auto-order for a dead part.
- Check the buy lanes exist. The destinations come from the part's active buy routes — if there is none, the approve step says so. Create the route before the buying window closes.
- Watch the proposal as forecasts refresh — the Recommended LTB column moves with the forecast. Drag the service-level slider when the business asks for a different protection.
- Apply local knowledge before approving — per-location quantities and the destination split are yours to edit; the totals follow.
- Approve inside the buying window — the committed supply arrives at the date you set (default: the last buy date). Approving takes a minute; the record freezes; the run-down starts showing the arrivals.
- Monitor weekly — run-down badges for stockout risk and excess; the risk panel for the money dimension. Excess before the last buy date → retract and approve a smaller quantity.
- At the cutover — create the supersession to the successor; the risk panel tells you what is left to scrap or roll over.
11.T — Step-by-step walkthrough¶
- Open Workflows → Last-Time Buy for a pipeline whose forecast step has run.
- Create a retirement for a low-risk item: pick the item, a service end a year out, a last buy
date a few months out, SL 95 %, and leave the successor empty. The line appears
LTB announcedand the Recommended LTB column shows a quantity (if it shows a dash, hover the dash — the tooltip names the missing input). - Click the line — the Size LTB window opens with the per-location proposal and the total.
- Edit one location's quantity: the Network total and the ≈ $ value follow; edit the total instead — the per-location proposal stays, the destination split re-seeds.
- In the approve box: all buy-lane destinations start selected with a history-seeded split. Change one split quantity — the total follows. Uncheck a destination — the split re-seeds across the remaining ones.
- ✓ Approve LTB — the line turns
🔒 LTB placedwith the decided quantity and value; the cells on the line are frozen; the Delete button is gone; the decision log holds the split. - Open Master Data → Supply Orders — one committed BUY line per destination, with your quantities and the arrival date.
- Back on the line: the Run-down shows the arrival week; then ↩ Retract LTB — the committed lines disappear and the line is editable again.
11.D — For developers¶
| Call | Purpose |
|---|---|
GET /api/retirement/list?pipeline_id= |
Register + live fields + per-row recommended LTB (batched; per-row recommendation_error when inputs are missing — forecast step not run, no demand history, past horizon, ClickHouse down). |
POST /api/retirement/register |
Upsert (pipeline_id, item_id). The conflict update only fires on an ltb_announced row — a re-POST over a placed decision is a 409. |
PATCH /api/retirement/register/{id} |
Edit mutable fields. Refused (409) while ltb_placed; status is never patchable (derived). |
DELETE /api/retirement/register/{id} |
Delete the record. Refused (409) while ltb_placed — retract first. |
POST /api/retirement/register/{id}/calculate |
Per-site proposal at a service-level override + buy_sites (active-BUY-route destinations with closed-demand history) + tranche hint. 422 when forecast/distributions are missing. |
POST /api/retirement/register/{id}/approve-ltb |
Records the decision and ALWAYS writes one committed row per destination: splits: [{site_id, qty}] — the planner's final quantities (model-validated: ≥ 1 destination, no duplicates, qty ≥ 0); destinations must have an active BUY route (400 otherwise); total = Σ parts; duplicate natural-key row → 409. |
POST /api/retirement/register/{id}/retract-ltb |
ltb_placed → ltb_announced; clears the decision; deletes the committed rows carrying attributes.source = 'retirement#{id}' while fully unreceived (received → 409). |
POST /api/retirement/register/{id}/supersession |
Creates the master.item_supersession edge (cutover = last buy date, else service until). |
GET /api/retirement/register/{id}/burn-down |
Weekly per-site projection with Monday-normalized firm arrivals. |
GET /api/retirement/register/{id}/events |
Decision log (part_retirement_event). |
GET /api/retirement/risk?pipeline_id= |
Obsolescence $-at-risk across the register. |
Engine coupling — supply_runner._load_retirement_cutoff_items cuts the item's BUY lanes
off once the pipeline's planning date is past its last_buy_date (user decision, Dec 2026 —
supersedes the Nov 2026 date-free rule): an ltb_announced row inside its window keeps buying, a
row with no last-buy date never buys again, and ltb_placed cuts BUY off for good (approving the
LTB committed the final buy as a firm order — engine buys would double-buy). MAKE/repair keep
serving the run-down; deleting the row is what resumes buying before the date. The series Supply
tab draws the item's last-buy date as a vertical line on the projection chart
(ltbChartMarks in frontend/src/utils/plotlyHelpers.js, fed by GET /api/retirement/list).
Committed rows live in {schema}.master_supply_orders_firm (order_type='BUY', release = the
real approval moment, arrival = the planner's date, attributes.source = 'retirement#{id}') and
are credited as scheduled receipts by the normal firm-order readers; the burn-down and the
register's recommended column read them the same way. Lifecycle statuses are exactly
ltb_announced / ltb_placed (migration files/DDL/migrations/simplify_ltb_lifecycle.sql,
mirrored at startup).
Key files
| File | Role |
|---|---|
files/api/retirement_router.py |
All endpoints; the shared proposal assembly (_assemble_ltb) used by both the calculator and the register's recommended column; destination validation (_ltb_buy_split_sites). |
files/utils/ltb_calculator.py |
Pure math: compute_site_ltb, compute_network_ltb (σ pooled as √Σσ² across sites). |
files/frontend/src/components/LtbTab.jsx |
Register, Size LTB window (editable demand quantities, editable destination split), burn-down, risk panel. |
files/supply_runner.py |
The BUY cutoff for retiring items. |