Invoice Two Shipments at Once
Your warehouse ships goods the moment they are ready, but finance wants one invoice per customer — not one invoice per truck. Business Central covers this with the Get Shipment Lines flow: orders are posted ship-only, and later the uninvoiced shipment lines are pulled together into a single sales invoice. Your job is to drive that flow from code.
Requirements
Create a codeunit named "Shipment Invoicer" with exactly this procedure:
procedure CreateInvoiceFromShipments(CustomerNo: Code[20]): Code[20]The procedure must:
- Create exactly one new sales invoice document — a
Sales Headerwith"Document Type"=Invoice— for the given customer. Leave"No."blank and insert the record with its insert trigger running, so the standard sales invoice number series assigns the number; then validate"Sell-to Customer No."with the given customer. - Pull every posted sales shipment line of that customer that still has a quantity left to invoice into that one invoice, using codeunit 64
"Sales-Get Shipment": hand it your invoice header viaSetSalesHeader, then pass the shipment lines toCreateInvLines.
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
- 7 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
Already on Pro? Sign in
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade