Functional Weave
Code in TypeScript

manufacturing.variance@1.0.0

README.md

2,242 bytes · view raw

# manufacturing.variance

The four basic standard-costing variances for a period, flexed to the output
actually produced:

    material price       = actual material cost - AQ x SP
    material usage       = (AQ - SQ) x SP        SQ = standard quantity per unit x actual output
    labour rate          = actual labour cost - AH x SR
    labour efficiency    = (AH - SH) x SR        SH = standard hours per unit x actual output

A variance is **adverse** when actual cost is higher than standard and
**favourable** when it is lower; `amount` is always the size and `effect` the
direction (`none` for exactly zero). The textbook case: a standard of 2 kg at
£3/kg and 3 hours at £10/h, 1,000 units made using 2,200 kg for £6,160 and
2,900 hours for £30,450, gives material price £440 F, usage £600 A, labour
rate £1,450 A, efficiency £1,000 F, and £610 A in total.

**The variances always add up.** Quantities and hours are exact fractions
(`Rational`: 1/3 kg, 1/4 hour), so the flexed costs (AQ x SP, SQ x SP, AH x SR,
SH x SR) are exact fractions of a minor unit. Each of those four is rounded
once by `mode`, and every variance is a difference of whole amounts, so price
plus usage is exactly actual material cost less standard material cost, and
the four together are exactly `actualCost - standardCost`. Rounding each
variance on its own would leave a penny or two unexplained.

**Price variance on usage.** The material price variance is computed on the
quantity used, not the quantity purchased; where stock is held at standard
cost and the price variance is taken on purchase, pass purchases in a separate
call with the purchase quantity as `actualQuantity`.

**Rules.** All money must be in the currency of `material.standardPrice`.
Prices, rates, quantities, hours and costs may not be negative; output is a
whole number, not negative. With zero output, all material and labour used is
usage and efficiency variance. Overhead variances are not included.

Source: CIMA Official Terminology (2005), "variance" entries for direct
material price, direct material usage, direct labour rate and direct labour
efficiency variances; the same definitions appear in ACCA Performance
Management (PM) study material on standard costing.