5060

Commission from Posted Documents

Algorithm
Easy
Pro
commission
posted-documents
sales
rounding

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): Decimal

Rules:

  1. The commission base is the sum of Amount (the amount excluding VAT) over every posted sales invoice (table "Sales Invoice Header") whose "Salesperson Code" equals SalespersonCode and whose "Posting Date" lies between StartDate and EndDate — both boundaries inclusive — minus the same sum over posted sales credit memos (table "Sales Cr.Memo Header").
The rest of the statement and 3 hints Unlock with Pro
ALBusiness Central 28.5
Pro
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
  • 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.

$10 / month
or $100 / year
Upgrade
This problem is part of Pro
Pro unlocks the full statement, tests, hints and solution. The code editor works on a computer.
Upgrade