If you're building anything that invoices customers, you eventually get asked: "How fast are we actually getting paid?"
The standard answer is accounts receivable (AR) turnover. It's a short formula, but a few input choices change the result, and they're easy to get wrong in code.
The formula
AR Turnover = Net Credit Sales / Average Accounts Receivable
Average AR = (Beginning AR + Ending AR) / 2
It tells you how many times in a period a business collects its average receivables balance. Higher means customers pay faster. Lower means cash is sitting in unpaid invoices.
A closely related metric is days sales outstanding (DSO), the average number of days it takes to collect:
DSO = Days in Period / AR Turnover
A worked example
A business reports, for the year:
- Net credit sales: $600,000
- Beginning AR: $50,000
- Ending AR: $70,000
- Average AR = (50,000 + 70,000) / 2 = $60,000
- AR turnover = 600,000 / 60,000 = 10.0
- DSO = 365 / 10 = 36.5 days
So the company collects its receivables about 10 times a year, and a typical invoice takes around 36 days to get paid.
Implementing it in JavaScript
Two things to get right: money should be handled in integer cents, and the denominator can be zero.
const toCents = (n) => Math.round(n * 100);
function arTurnover({
netCreditSales,
beginningAR,
endingAR,
daysInPeriod = 365,
}) {
const sales = toCents(netCreditSales);
const avgAR = (toCents(beginningAR) + toCents(endingAR)) / 2;
if (avgAR <= 0) {
throw new Error("Average accounts receivable must be greater than zero");
}
const turnover = sales / avgAR;
const dso = daysInPeriod / turnover;
return {
averageAR: avgAR / 100,
turnover: Number(turnover.toFixed(2)),
dso: Number(dso.toFixed(1)),
};
}
console.log(
arTurnover({ netCreditSales: 600000, beginningAR: 50000, endingAR: 70000 })
);
// { averageAR: 60000, turnover: 10, dso: 36.5 }
Gotchas worth handling
- Use credit sales, not total sales. Cash sales never create a receivable, so including them inflates the ratio. If you only have total sales, the result is an approximation, and your UI should say so.
-
Match the period to
daysInPeriod. A quarterly calculation should use 90 or 91 days, not 365, or DSO will be wrong by a factor of four. - Average, don't just use the ending balance. Seasonal businesses can have a very different year-end AR, which distorts the ratio.
-
Guard against zero. A new business with no receivables will divide by zero. Return a clear error or "not applicable" instead of
Infinity. - Compare within an industry. A "good" turnover varies a lot between sectors, so a single number only means something against a benchmark or your own trend.
Just need the number?
If you'd rather not write and maintain this yourself, here's a free calculator:
Direct link in case the embed doesn't render: Accounts Receivable Turnover Calculator
Takeaways
- AR turnover is net credit sales divided by average receivables, and DSO is days in the period divided by turnover.
- Most bugs come from the inputs: total vs. credit sales, mismatched periods, and zero denominators.
- Treat the result as a trend to watch, not an absolute grade.
If you've built receivables reporting into an invoicing or finance tool, I'd like to hear how you handled edge cases like partial payments or credit notes.
Top comments (0)