5061

Available to Promise

Algorithm
Medium
Pro
atp
supply-demand
planning
dates

Available to Promise

"Can I promise 25 pieces for the 10th?" — Business Central answers with its Order Promising machinery, which projects supply and demand into the future and refuses any date a later commitment would undermine. Your job is that machinery distilled to its core: one timeline table, one availability rule, and the roll-forward to the dates an order taker actually quotes.

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

Requirements

The starter contains a table "ATP Timeline Entry" — keep it exactly as shipped, the grading tests seed it and pass it to your procedures:

  • "Entry No." — Integer, the primary key; insertion order is arbitrary and carries no meaning — never assume it matches date order
  • "Entry Date" — Date, the day the event hits the stock
  • "Entry Type" — Option Supply (a receipt adding stock) or Demand (a commitment consuming it)
  • Quantity — Decimal, always positive; the entry type carries the direction

Create a codeunit named "ATP Engine" with three public procedures:

procedure ProjectedAvailability(var ATPTimelineEntry: Record "ATP Timeline Entry"; AsOfDate: Date): Decimal
procedure EarliestAvailabilityDate(var ATPTimelineEntry: Record "ATP Timeline Entry"; QuantityRequested: Decimal): Date
procedure CalcPlannedDates(var ATPTimelineEntry: Record "ATP Timeline Entry"; QuantityRequested: Decimal; HandlingTime: DateFormula; ShippingTime: DateFormula; var PlannedShipmentDate: Date; var PlannedDeliveryDate: Date): Boolean

Projected availability

ProjectedAvailability returns the stock position on AsOfDate: all Supply quantities dated on or before AsOfDate minus all Demand quantities dated on or before AsOfDate. Events dated exactly AsOfDate count, later ones never do; with no events on or before the date the result is 0. A negative result is legal — an overcommitted timeline is valid input.

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
  • 16 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