Skip to main content

Sales Person Incentives in ERPNext (Custom Script Guide)

In ERPNext, Sales Incentives for the sales team can be calculated using custom scripts. This allows businesses to dynamically compute commission or rewards based on transaction values such as Sales Orders, Sales Invoices, or Delivery Notes.

SUMMARY
Sales incentives can be automatically calculated for each Sales Person in the Sales Team table using JavaScript custom scripts. The logic can vary based on business rules like order value, margin, or customer type.

1. Where It Can Be Used

This logic can be applied in any sales transaction that contains the Sales Team table, such as:

  • Sales Order
  • Sales Invoice
  • Delivery Note

2. How Incentive Calculation Works

The system loops through each Sales Person in the Sales Team table and calculates incentives based on conditions like Grand Total.

Example logic:

  • Default incentive = 2%
  • If Grand Total > 400, incentive becomes 4%

3. Custom Script Example

cur_frm.cscript.custom_validate = function(doc) {
    // calculate incentives for each person on the deal
    total_incentive = 0;

    $.each(wn.model.get("Sales Team", {parent:doc.name}), function(i, d) {

        // calculate incentive
        var incentive_percent = 2;
        if(doc.grand_total > 400) incentive_percent = 4;

        // actual incentive
        d.incentives = flt(doc.grand_total) * incentive_percent / 100;
        total_incentive += flt(d.incentives);
    });

    doc.total_incentive = total_incentive;
}

4. What This Script Does

The script:

  • Loops through each Sales Person in the Sales Team
  • Checks the total value of the transaction
  • Applies an incentive percentage dynamically
  • Calculates individual incentives
  • Stores total incentive in the document
NOTE
This is a client-side script (custom script) and is typically used for dynamic calculations before saving or submitting the transaction. Business rules can be customized as needed.

5. Key Takeaway

Sales incentives in ERPNext are fully customizable using scripting logic, allowing organizations to align commission structures with their exact sales strategy.

6. Related Topics

  • Sales Person Target Allocation
  • Sales Team in Transactions
  • Commission Calculation
Rating: 0 / 5 (0 votes)