Commission from Posted Documents
At month end the sales manager wants one number per salesperson: what their posted sales actually earned them. Quotes and open orders do not count — only documents that reached the posted ledgers — and a credit memo takes back exactly what its invoice once paid out. You will compute that number straight from the real posted document tables.
Requirements
Extend the standard "Salesperson/Purchaser" table with a Decimal field named "Commission Rate %" — the salesperson's commission rate in percent. The grading tests write this field directly (no Validate), so any triggers or value-limit properties you add are never exercised. The starter ships the extension object as "Salesperson Commission Rate"; the tests bind only to the field name, so match it character for character — mind the space before %.
Create a codeunit named "Salesperson Commission" with a public procedure:
procedure CalculateCommission(SalespersonCode: Code[20]; StartDate: Date; EndDate: Date): DecimalRules:
- The commission base is the sum of
Amount(the amount excluding VAT) over every posted sales invoice (table"Sales Invoice Header") whose"Salesperson Code"equalsSalespersonCodeand whose"Posting Date"lies betweenStartDateandEndDate— both boundaries inclusive — minus the same sum over posted sales credit memos (table"Sales Cr.Memo Header").
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
- 9 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