Mixed-Case Bundle Pricing
Marketing has launched a "mixed case" promotion: every unit sells at the same list price, but a bundle of different SKUs earns a discount that grows with the variety in the bundle. The checkout must charge the customer the cheapest total that any arrangement of their basket allows — and as every veteran of this pricing scheme knows, the obvious arrangement is not always the cheapest one.
Requirements
The starter ships a table named "Bundle Basket Line" — the in-memory basket your code prices. Keep its fields and key exactly as shipped; the grading tests seed it directly:
"SKU Code"—Code[20], the primary key: one line per distinct SKUQuantity—Integer, how many units of that SKU are in the basket
Complete the codeunit named "Bundle Pricing" with one public procedure:
procedure MinimalTotal(var BasketLine: Record "Bundle Basket Line"; UnitPrice: Decimal): DecimalRules:
- Every unit in the basket has the same list price,
UnitPrice. - A bundle is a group of 1 to 5 units whose SKUs are pairwise distinct — a bundle can never contain two units of the same SKU.
- A bundle's price is the sum of its units' list prices minus a discount that depends only on the bundle's size: 1 unit — no discount, 2 units — 5%, 3 units — 10%, 4 units — 20%, 5 units — 25%. So a bundle of
kunits costsk × UnitPrice × (100 − discount%) / 100.
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
- 12 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