Errors That Fix Themselves
Every promo season the reward-voucher desk drowns in tickets: the redemption batch stops with "something went wrong", the operator guesses at the cause, retries, gives up and calls support. A modern Business Central error does better — it says what happened in one line, explains the remedy, carries the repair parameters in a machine-readable payload, and offers a button that performs the repair on the spot. You will build a redemption routine whose every error can fix itself.
What you get
The starter ships two tables. Keep both exactly as given and include them in your submission — the grading tests seed and read them by name.
- Table
"Reward Voucher": primary key"Voucher Code"(Code[20]), plusAmount(Decimal),"On Hold"(Boolean) andRedeemed(Boolean). - Table
"Voucher Setup": primary key"Primary Key"(Code[10]), plus"Max Voucher Amount"(Decimal). The setup is the single record whose primary key is empty — the tests always seed it before calling your code.
Requirements
Implement the codeunit named "Voucher Redemption" with one public procedure:
procedure Redeem(VoucherCode: Code[20])And the codeunit named "Voucher Repair" with two public procedures:
procedure ReleaseHold(FailureInfo: ErrorInfo)
procedure RaiseVoucherLimit(FailureInfo: ErrorInfo)Rules for Redeem (the tests only call it for a voucher that exists, is not yet redeemed, and with the setup record in place):
- A voucher is redeemable when
"On Hold"is false and itsAmountdoes not exceed"Max Voucher Amount"— an amount exactly at the limit still redeems; only strictly greater is a problem. Redeeming setsRedeemedto true and saves the voucher. - Problems are checked in this order: the hold first, then the limit. Each problem raises an error built to the exact anatomy in the table below.
- Both errors must be collectible: when
Redeemruns under an error-collecting caller, a raised problem must not stop the check sequence — a voucher that is on hold AND over the limit reports both problems, hold first, in that one run.
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