Assemble to Stock: Post the Kit and Report What It Consumed
The warehouse builds gift kits all day: two bottles and three glasses go into one box, and the box is what the webshop sells. Most mornings the team posts only part of an order — a component ran short, or the pallet is only half packed — and finance still wants a truthful line for every posting: how many kits actually went into stock, and what came out of the component bins to make them.
Your codeunit builds the assembly order from the item's assembly BOM, posts it, and then reads the answer back out of the inventory ledger — where the truth about a partial post lives, and where the order header cannot lie to you.
Requirements
Implement the codeunit "Assembly Kit Mgt." with exactly these four procedures — the grading tests bind to every name below character for character:
procedure PostAssemblyOrder(ParentItemNo: Code[20]; OrderQuantity: Decimal; QuantityToAssemble: Decimal; PostingDate: Date): Code[20]
procedure GetOutputQuantity(PostedAssemblyNo: Code[20]): Decimal
procedure GetOutputCost(PostedAssemblyNo: Code[20]): Decimal
procedure GetConsumption(PostedAssemblyNo: Code[20]; var ConsumedQuantity: Dictionary of [Code[20], Decimal]; var ConsumedCost: Dictionary of [Code[20], Decimal])Rules for PostAssemblyOrder:
- Create an assembly order for
OrderQuantityunits ofParentItemNowhose component lines come from that item's assembly BOM — one line per BOM component, each forOrderQuantity× the component's"Quantity per". - Post
QuantityToAssembleunits of it, onPostingDate.QuantityToAssembleis at least 1 and never more thanOrderQuantity. The whole flow must run silently: the grading tests declare no UI handlers, so anyConfirmorMessageyour code triggers fails the test as unhandled UI. Two of them lurk in the order header — validating any of its three dates ("Starting Date","Ending Date","Due Date") asks whether to move the other two along with it, and a component line that falls due before the work date makes the header show a warning message. Keep the header's dates onPostingDate; the component lines take their due date from the header's"Starting Date"the moment they are created, so the dates must be in place before the lines are.
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
- 14 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