5089

Below the Reorder Point

Algorithm
Hard
Pro
supply-planning
reorder-point
time-buckets
order-modifiers

Below the Reorder Point

Every night, Business Central's planning engine walks one item's future — scheduled receipts, scheduled demand — and decides when to shout "order more!". You are rebuilding that watchdog for a single item: time-bucketed reorder-point checks, policy-sized suggestions, order modifiers, emergency safety-stock refills, and the overflow rule that asks you to shrink a purchase instead of placing another one.

Pick object IDs in the 50100–50199 range, and reference other objects by name, never by ID.

The shipped tables

The starter contains two tables — keep both exactly as shipped, the grading tests seed the first and read the second:

"Planning Timeline Event" — the item's known future, one row per scheduled event:

  • "Entry No." — Integer, the primary key; insertion order is arbitrary and carries no meaning
  • "Event Date" — Date, the day the event hits the stock
  • "Event Type" — Option Supply (a scheduled receipt, e.g. an open purchase order) or Demand (a scheduled consumption)
  • Quantity — Decimal, always positive; the event type carries the direction

"Planning Suggestion" — your output, one row per suggestion, numbered 1, 2, 3, … in the order you create them:

  • "Line No." — Integer, the primary key
  • "Action Message" — Option New (order new supply) or "Change Qty." (change an existing supply event's quantity)
  • "Due Date" — Date; for New lines the day the new supply must arrive, for "Change Qty." lines the "Event Date" of the supply event being changed
  • Quantity — Decimal; for New lines the quantity to order, for "Change Qty." lines the supply event's new quantity after the reduction — not the size of the reduction
  • "Reference Entry No." — Integer; for "Change Qty." lines the "Entry No." of the supply event being changed, 0 for New lines

The planner

Create a codeunit named "Reorder Point Planner" with one public procedure:

procedure CalculatePlan(var Item: Record Item; var TimelineEvent: Record "Planning Timeline Event"; InitialInventory: Decimal; StartingDate: Date; EndingDate: Date; var Suggestion: Record "Planning Suggestion")

The tests pass a standard Item record (never inserted — a pure parameter carrier) with these fields filled: "Reordering Policy" (always "Fixed Reorder Qty." or "Maximum Qty."), "Reorder Point", "Reorder Quantity", "Maximum Inventory", "Safety Stock Quantity", "Minimum Order Quantity", "Maximum Order Quantity", "Order Multiple", and "Time Bucket". A planning parameter of 0 (or a blank "Time Bucket") means "not used".

The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
Pro problem

Solve it with Pro

You’re reading the opening of the statement. Pro unlocks the whole problem:

  • The full statement
  • Starter code in the browser editor
  • 28 grading tests, run on Business Central 28.5
  • 3 hints
  • The reference solution

Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade