The Date Promising Engine
"When can we deliver?" is the one question every order taker must answer instantly, and Business Central answers it with base calendars, customized calendars per customer, and date walks across them. Your job is that machinery distilled to its core: one rule table, one precedence ladder, and a day-walker that runs in both directions.
Requirements
The starter contains a table "Delivery Calendar Rule" — keep it exactly as shipped, the grading tests seed it and pass it to your procedures:
"Entry No."—Integer, the primary key"Customer No."—Code[20]; blank means the rule belongs to the base calendar, otherwise to that customer's calendar"Rule Type"—Option"Day of Week"orDate"Day of Week"—Integer,1= Monday …7= Sunday (theDate2DWYconvention); only meaningful on"Day of Week"rules"Rule Date"—Date; only meaningful onDaterulesNonworking—Boolean;truecloses the day,falseopens it (an override that re-opens a day some broader rule closed)
Create a codeunit named "Date Promising Engine" with three public procedures:
procedure IsWorkingDay(var DeliveryCalendarRule: Record "Delivery Calendar Rule"; CustomerNo: Code[20]; TargetDate: Date): Boolean
procedure PromisedDeliveryDate(var DeliveryCalendarRule: Record "Delivery Calendar Rule"; CustomerNo: Code[20]; OrderDate: Date; WorkingDays: Integer): Date
procedure LatestOrderDate(var DeliveryCalendarRule: Record "Delivery Calendar Rule"; CustomerNo: Code[20]; RequiredDate: Date; WorkingDays: Integer): DateWhether a date is working — the precedence ladder
IsWorkingDay decides whether TargetDate is a working day for CustomerNo. Walk this ladder top to bottom and let the first matching rule decide — the day is nonworking exactly when that rule's Nonworking is true:
- a
Daterule of that customer for exactlyTargetDate - a
Daterule of the base calendar (blank"Customer No.") for exactlyTargetDate
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
- 23 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.
Already on Pro? Sign in