nav-left cat-right
cat-right

Sales Commission By Customer

By default, sales commission is calculated on the basis of commission percentage specified in Salesperson Maintenance
window. Every now and then, we have the requirement of calculating the sales commission percentage based on the customer. There is third party product Ethotech Commission Planfor extensive commission requirements.

Like me if you just need a small piece of functionality – let’s say you just want to calculate the commission based on customer.
I have built a small GP Add-In for it. It allows you to save the commission percentage in user defined field1 (which is renamed as Comm Percent) in the customer card.
When user enters the sales transaction entry, the add- in automatically changes the commission percentage in the Sales Commission Entry Window. Therefore commission is calculated based on the commission percentage specified in the user defined field1 instead of percentage entered in salesperson maintenance window.
Also, I have applied validation in the user defined field to allow only valid percentage values up to two decimal places.

User Defined Field 1 in customer Maintenance for saving the commission percentage for the customer
Sales Commission Entry Window

User Defined Field 1 in customer Maintenance for saving the commission percentage for the customer
Customer Maintenance Window

For this I have written some .net code using the VS tools. The link for downloading the dll and solution of this add in available at end of the post.

The main code for overriding the commission is in SaveRecord_ValidateBeforeOriginal and SalespersonId_EnterAfterOriginalevent handlers

Commission percentage is updated just before just before saving the transaction.
void SaveRecord_ValidateBeforeOriginal(object sender, System.ComponentModel.CancelEventArgs e)
{
if (!customValue && !sopWindow.DisplayExistingRecord.Value)
{
updateCommission = true;
// open the sales commission window
sopWindow.CommissionsButton.RunValidate();
}
}

void SalespersonId_EnterAfterOriginal(object sender, EventArgs e)
{

if (sopComForm.SopCommissionEntry.CommScroll.SalespersonId.Value != “”)
{
if (!sopWindow.DisplayExistingRecord.Value && !customValue)
{
//get the commission rate from customer card
string commissionValue = GetCustomerCommissionRate(_customerNumber);
decimal intCommission;

if (decimal.TryParse(commissionValue, out intCommission))
{
Int16 value = Convert.ToInt16(ConvertNumber(commissionValue));
sopComForm.SopCommissionEntry.CommScroll.CommissionPercent.Value = value;
}
else
{
MessageBox.Show(“Enter the commission percentage in Customer card”);
}
}
//if opened window while saving record close it
if (updateCommission)
{

sopComForm.SopCommissionEntry.OkButton.RunValidate();
}
else
{
// if user updated the commison percentage, we don’t want to overruide it
customValue = true;
}
}
}

A couple of things to keep in mind –
If the user updates the sales commission while entering the transaction, we don’t want to change it. For this, I am using the customValue variable. If user changes the sales commission, custom value is set to true. In that case, we are updating sales commission while saving the record.

We don’t want to update the sales commission when an existing sales transaction is opened. For this I am using the DisplayExistingRecordfield in Sales transaction entry window.

Downloads:
Sales Commission dll.zip
Sales Commission Source Code.zip

One Response to “Sales Commission By Customer”

  1. [...] decided to go mainstream with her Dynamics GP Help blog.Check out her first couple of posts at – Sales Commission By CustomerAdding autocomplete to ANY fieldCheck it out, leave your feedback and your [...]

Leave a Reply