Functional Weave
Code in Rust

inventory.stock-turnover@1.0.0

README.md

1,617 bytes · view raw

# inventory.stock-turnover

Three measures of how quickly stock moves over a period, all at cost:

- **turns** (stock turnover ratio) = cost of sales / average stock, where
  average stock is (opening + closing) / 2. Six turns a year means the average
  holding is sold six times over.
- **daysInventoryOutstanding** = average stock / cost of sales x periodDays:
  how many days the average holding represents; periodDays / turns.
- **daysOfCover** = closing stock / cost of sales x periodDays: how many days
  the stock on hand now would last at this period's rate of use. This is the
  figure a warehouse plans with; it looks forward from the closing stock.

**Exact, then rounded once.** Each ratio is a single division of whole minor
units, rounded half-up with `math.round-div` to hundredths (turns) or tenths
(days), and only then turned into a float. So 0.005 turns is 0.01 in every
language, where `Math.round(x * 100) / 100` and Python's `round(x, 2)` disagree.
`averageStock` is rounded half-up to a minor unit for display; the ratios use
the exact sum, not the rounded average.

**No answer is null, not zero or infinity.** Turns is null when average stock is
zero; the two day counts are null when cost of sales is zero (stock that does
not move has no cover horizon).

Use cost values throughout: turnover on sales value against stock at cost
overstates it by the margin. Stock values and cost of sales may not be
negative, the three amounts must share a currency, and periodDays must be at
least 1.

Source: the standard definitions, e.g. CIMA Official Terminology (inventory
turnover, inventory days).