5066

First Expired, First Out

Algorithm
Medium
Pro
fefo
item-tracking
lots
sorting

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" — Date
  • Quantity — Decimal, what is physically available on this entry; never changes
  • Blocked — 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:

  1. An entry is shippable when it is not Blocked and its "Expiration Date" is on or after ShipmentDate. 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.
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
  • 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.

$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