Direct Commissions
Set Specific Sales Line Commission
Sales lines contain a hidden IDPCOS Manual Commission % field. If any value different from zero is specified, this will be the percentage used to generate commissions, regardless of any commission rates that might apply.
If needed, this field can be shown in the UI or filled in by code in order to specify a commission %, ignoring any existing commission rates.
Add New Filters
Description
If a customer wants to be able to set direct commission rates based on custom fields in their environment, iDynamics Commissions makes it easy to do so.
In order to add custom filters:
- Extend the "IDPCOS Direct Commission Rate" table, and add the filter fields requested by the customer.
- Subscribe to the OnAfterCheckDirectCommissionRateAppliesToSalesLine in codeunit "IDPCOS Direct Comm. Entry Mgt.". This event lets you say whether a commission rate applies (or not) to a sales line.
OnAfterCheckDirectCommissionRateAppliesToSalesLine
Let's expand the event that must be used to extend the available filters. You would subscribe to the event, with a code such as this one:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"IDPCOS Direct Comm. Entry Mgt.", 'OnAfterCheckDirectCommissionRateAppliesToSalesLine', '', true, true)]
local procedure OnAfterCheckDirectCommissionRateAppliesToSalesLine(
CommissionRate: Record "IDPCOS Direct Commission Rate";
var TempCommissSalesLine: Record "IDPCOS Commiss. Sales Line" temporary;
var TempCommissSalesHeader: Record "IDPCOS Commiss. Sales Header" temporary;
var Applies: Boolean)
begin
if not Applies then
exit;
// Check whether the custom condition applies or not and set Applies accordingly.
if Condition then
Applies := false;
end;
Setting the Applies variable to false, you can specify that an extra restriction set on the rate was not met and that it should not apply. Note that the rate might already have been discarded. That's why, in the example, the code directly exists if the value is already false.
Event parameters
To understand when the previous event is raised, and what the different parameters are, it's helpful to know that, in order to check whether a commission rate applies or not to a sales line, iDynamics Commissions does the following:
- It transforms the Sales Header (if we are previewing commissions), Sales Invoice Header or Sales Cr.Memo Header into a temporary IDPCOS Commiss. Sales Header.
- Fields “Source Doc. Type”, “No.”, and “Sales Header Document Type” (if it’s a Sales Header) will tell you the actual record from which this temporary record was created.
- Same thing with the Sales Line/Sales Invoice Line/Sales Cr.Memo Line. In this case, the app can create several temporary records depending on how many salespeople are assigned to the line (e.g. one for the main salesperson, one for the manager).
Once we have a temporary header and a temporary line for each combination of sales line/salesperson that might receive a commission, for each line:
- The app gets all commission rates that might apply, based on the customer/item/salesperson assigned to the line. These rates are looped by the app, to check whether either of the conditions that have to be checked by code (e.g. dimensions) apply or not.
- It is at this moment where the previous event is raised, with each one of the three mentioned records passed as parameters (temporary header, temporary line, commission rate).
Note that the IDPCOS Direct Comm. Entry Mgt. codeunit has many other events that might be useful for your customizations. In most of them, you will find the same temporary records as the OnAfterCheckDirectCommissionRateAppliesToSalesLine event.