Functional Weave
Code in Rust

inventory.cycle-count-schedule@1.0.0

README.md

1,935 bytes · view raw

# inventory.cycle-count-schedule

Cycle counting replaces the annual stocktake with small counts every working
day, counting valuable (class A) items more often than cheap ones. This builds
the calendar: given each item's class and how many times a class is counted in
the period, it says which items to count on each working day.

**Working days** are Monday to Friday from `startDate` to `endDate` inclusive,
less the `holidays` (pass `dates.bank-holidays` for the UK). The schedule lists
every working day, including days with nothing to count, so a count team can
see its load.

**Spreading.** For a class counted `f` times over `N` working days, the days
are cut into `f` consecutive windows as evenly as whole days allow (window `k`
starts on day `floor(k x N / f)`), so the counts of one item are roughly `N / f`
days apart. Within each window the class's items, in SKU order, are spread
evenly: item `j` of `m` goes on day `floor(j x length / m)` of the window. Each
class is spread on its own, so the daily load is the sum of even spreads. The
rule is plain integer arithmetic, so a schedule can be checked by hand and is
the same in every language.

A class counted 0 times is never scheduled. A class counted more often than
there are working days is an error (it would need two counts of one item on one
day); so are an item whose class has no frequency, a duplicate SKU, a negative
frequency, a period that ends before it starts, and malformed dates. Items on a
day are listed by class, then SKU, by character code (keep them ASCII for the
same order everywhere).

Typical frequencies: A monthly (12 a year), B quarterly (4), C yearly (1). The
schedule does not carry counts across periods: a yearly schedule is built once
for the year.

Source: the practice of ABC-based cycle counting, e.g. APICS Dictionary ("cycle
counting") and Silver, Pyke and Thomas, *Inventory and Production Management in
Supply Chains*, 4th ed.