Calculate commission
calculate_commissionUse this when the user wants to calculate sales commission for one rep: a flat rate, a tiered commission ("5% up to 50k then 8% above"), quota attainment with accelerators or decelerators, a cap, a draw against commission, split deals ("split commission 60/40"), SPIFFs, clawbacks for refunded or cancelled deals, gross-margin commission, or OTE/target variable pay. Give either a sales_total or the deals. Returns the commission per deal with the tier applied, the tier breakdown, marginal and retroactive results when the plan does not say which, the draw recovery, the amount payable now, and a PDF commission statement plus an Excel file. Does not compute taxes or take-home pay. Do not use for a whole team or an uploaded deals file (use generate_commission_statements) or for commission-free trading.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| plan | Yes | The commission plan terms: rate or tiers, quota, cap, draw, clawback rules, e.g. {"tiers":[{"up_to":50000,"rate":5},{"up_to":null,"rate":8}]}. | |
| deals | No | The rep's deals for the period, e.g. [{"deal":"Acme","amount":24000,"close_date":"2026-09-14"},{"deal":"Globex","amount":18000,"split_percent":60}]. | |
| currency | No | ISO currency code, default USD, e.g. CAD or EUR. | |
| rep_name | No | Rep name for the statement, e.g. "Maria Lopez". | |
| period_end | No | Last day of the period, e.g. 2026-09-30. | |
| sales_total | No | Total credited sales for the period when there are no individual deals, e.g. 72000. | |
| company_name | No | Company name printed on the statement, e.g. "Acme Corp". | |
| period_label | No | Label printed on statements, e.g. "September 2026" or "Q3 2026". | |
| period_start | No | First day of the commission period, e.g. 2026-09-01. Deals closed outside the period are not counted. | |
| prior_balance | No | Unrecovered draw or clawback balance owed from earlier periods, e.g. 1500. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rep | Yes | ||
| mode | Yes | ||
| notes | Yes | ||
| period | Yes | ||
| currency | Yes | ||
| downloads | Yes |