npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@zenuinebit/commission-calc

v0.1.0

Published

Sales commission: flat, tiered and quota plans, caps and thresholds, returns, team splits and period statements.

Readme

@zenuinebit/commission-calc

Sales commission: flat, tiered and quota plans, thresholds, caps and guaranteed minimums, returns, team splits, per-category plans and period statements per rep. Amounts are integers in minor units (see @zenuinebit/money); percentages are plain numbers (2.5 means 2.5%).

No plans or rates are built in: you define them. The numbers in the examples are made up.

import { commissionOn, calculatePeriod, tierProgress, settle, type Plan } from "@zenuinebit/commission-calc";

const plan: Plan = {
  rule: { type: "tiered", mode: "marginal", tiers: [{ upTo: 10_000_000, percent: 2 }, { upTo: 30_000_000, percent: 3 }, { percent: 5 }] },
  threshold: 1_000_000,          // nothing until 10,000.00 of sales (default: then everything earns; or thresholdMode: "excess")
  cap: 5_000_000,                // optional
  minimum: 0,                    // optional guaranteed floor
};

commissionOn(25_000_000, plan);
// { sales, calculated, slices: [{ from, to, percent, commission }], commission, belowThreshold, capped, minimumApplied, effectivePercent }

// A month's statement per rep. Returns are negative records and reduce net sales.
const { reps, totalCommission } = calculatePeriod(
  [
    { id: "s1", date: "2025-04-10", rep: "asha", amount: 12_000_000 },
    { id: "s2", date: "2025-04-12", rep: "asha", amount: 3_000_000, category: "services" },
    { id: "r1", date: "2025-04-20", rep: "asha", amount: -2_000_000 },
    { id: "s3", date: "2025-04-15", rep: "ravi", amount: 5_000_000, split: { ravi: 60, asha: 40 } },   // shared credit
  ],
  { default: plan, byCategory: { services: { rule: { type: "flat", percent: 10 } } } },
  { from: "2025-04-01", to: "2025-04-30" },
);
reps[0];   // { rep, sales, returns, net, commission, groups: [{ key, net, result }] }

tierProgress(4_000_000, plan.rule.tiers);   // current rate, and how far the next tier is
settle(paidSoFar, nowDue);                  // { payNow, clawback } after returns change the figures

Rules

  • flat: one percentage. tiered with mode: "marginal": each slice of sales earns its own tier's rate. With "retroactive": all sales earn the rate of the tier the total reaches. quota: one rate up to the quota, an accelerator above it.
  • Net sales (sales less returns) drive the tiers, so a return can drop a rep into a lower tier. Use settle to pay the difference or claw back.
  • Slices add up exactly to the calculated commission (largest-remainder rounding). The cap and minimum apply after: commission is what is payable, calculated is what the rule gave.
  • Zero or negative net sales earn nothing, apart from a guaranteed minimum.
  • Team split shares both sales and returns by weight, exactly. Categories with their own plan are totalled and paid separately; everything else goes under the default plan.

Not included: commission on collected (rather than invoiced) amounts, deferred or milestone payments, per-product margin rules, and payroll posting (pass the total to @zenuinebit/payroll-basics as an extra earning).