Skip to content

Calculate Incentive For Sales Team

You can calculate incentives for the sales team using a Client Script. To create one, search "Client Script List" in the search bar and click New.

It can be used in any Sales Transaction with a Sales Team table (on the More Info tab). Set the DocType (for example Sales Order) and use a script like this:

frappe.ui.form.on('Sales Order', {
    validate(frm) {
        // calculate incentives for each person on the deal
        let incentive_percent = 2;
        if (frm.doc.grand_total > 400) incentive_percent = 4;

        (frm.doc.sales_team || []).forEach(d => {
            // actual incentive
            d.incentives = flt(frm.doc.grand_total) * incentive_percent / 100;
        });
        frm.refresh_field('sales_team');
    }
});