First Expired, First Out
A warehouse full of perishable goods lives and dies by one rule: whatever expires first leaves first. Business Central calls it Pick According to FEFO, and behind the toggle sits a precise little allocation algorithm — an exact sort order, blocked-lot and expiration guards, and respect for lot quantities a clerk already promised by hand. You are going to build that core, without any of the warehouse machinery around it.
Requirements
The starter contains two tables — keep both exactly as shipped, the grading tests seed and read them:
"Lot Inventory Entry" — one row per lot quantity sitting on the shelf:
"Entry No."—Integer, the primary key"Lot No."—Code[20]"Expiration Date"—DateQuantity—Decimal, what is physically available on this entry; never changesBlocked—Boolean, a quality hold"Qty. to Ship"—Decimal, your output: how much of this entry the shipment takes
"Demand Lot Assignment" — lot quantities already pinned on the demand before your code runs:
"Line No."—Integer, the primary key"Lot No."—Code[20]Quantity—Decimal
Create a codeunit named "FEFO Allocator" with one public procedure:
procedure AllocateShipment(var LotInventoryEntry: Record "Lot Inventory Entry"; var DemandLotAssignment: Record "Demand Lot Assignment"; QtyToShip: Decimal; ShipmentDate: Date)Rules:
- An entry is shippable when it is not
Blockedand its"Expiration Date"is on or afterShipmentDate. This is strict expiration posting: a lot that expired before the shipment date never leaves the warehouse — but a lot expiring exactly on the shipment date still ships.
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
- 13 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