units.convert
Convert length, mass, area, volume, temperature and energy between units, exactly, as decimal text.
convertUnits in TypeScript
1.0.0
py rs ts
31 tests
units.parse-quantity
Parse "2.5 kg", "1,200 m" or "12 ft 6 in" into an exact decimal value and a canonical unit symbol, strictly.
parseQuantity in TypeScript
1.0.0
py rs ts
31 tests
money.currency-digits
How many decimal places a currency's minor unit has, from the ISO 4217 list.
currencyDigits in TypeScript
1.0.0
py rs ts
14 tests
agri.stocking-rate
Stocking rate: livestock units and LU per hectare from animal numbers, by a published LU coefficient table.
stockingRate in TypeScript
1.0.1
py rs ts
17 tests
retail.price-per-unit
Unit price for shelf-edge labels: price per kg, per 100 g, per litre, per 100 ml, per metre or per item.
unitPrice in TypeScript
1.0.1
py rs ts
27 tests
energy.price-cap
Ofgem energy price cap unit rate and daily standing charge for a fuel and payment method on a date (GB average).
priceCap in TypeScript
1.0.2
py rs ts
19 tests
time.round-to-increment
Round a duration in minutes to a billing increment such as 6 or 15 minutes, up, down or to nearest.
roundToIncrement in TypeScript
1.0.0
py rs ts
18 tests
money.parse
Parse "£1,234.50" or "1.234,50 €" into integer minor units, strictly: no guessing, no rounding.
parseMoney in TypeScript
1.0.0
py rs ts
37 tests
energy.gas-kwh
Convert gas meter units (cubic metres or hundreds of cubic feet) to kWh with the calorific value and 1.02264 correction.
gasKwh in TypeScript
1.0.0
py rs ts
16 tests
retail.sku-generate
Build a deterministic stock-keeping unit code from a prefix and product attributes.
generateSku in TypeScript
1.0.0
py rs ts
15 tests
subscriptions.ltv-cac
Customer lifetime value, LTV to CAC ratio and CAC payback months from ARPA, gross margin, churn and CAC.
ltvCac in TypeScript
1.0.0
py rs ts
14 tests
legal.time-billing Unreviewed
Fees from time entries: each rounded to 6-minute (or other) units and priced at the fee earner's hourly rate.
timeBilling in TypeScript
1.0.1
py rs ts
15 tests
logistics.sscc
Build an 18-digit SSCC pallet label number from extension digit, GS1 company prefix and serial, with its check digit.
buildSscc in TypeScript
1.1.0
py rs ts
16 tests
agri.growing-degree-days
Growing degree days (thermal time) from daily min/max temperatures, a base and an optional upper cap.
growingDegreeDays in TypeScript
1.0.0
py rs ts
18 tests
money.amount
A currency-tagged monetary amount held in integer minor units.
money in TypeScript
1.0.2
py rs ts
17 tests
inventory.eoq
Economic order quantity (Harris/Wilson): the order size that minimises ordering plus holding cost, in whole units.
economicOrderQuantity in TypeScript
1.0.0
py rs ts
20 tests
property.service-charge-apportion Unreviewed
Apportion a service charge across units by lease fraction, floor area or fixed percentage, exact to the penny.
apportionServiceCharge in TypeScript
1.0.1
py rs ts
19 tests
finance.compound-interest
Compound interest accrued period by period in minor units, the way a statement is built.
compoundInterest in TypeScript
1.0.0
py rs ts
18 tests
health.dose-weight-based Unreviewed
Weight-based dose (per kg) capped at a maximum single dose and rounded to a measurable volume, in exact micro-units.
weightBasedDose in TypeScript
1.0.1
py rs ts
20 tests
energy.meter-advance
Units consumed between two meter reads, counting the meter rolling over past all nines once.
meterAdvance in TypeScript
1.0.0
py rs ts
13 tests
agri.yield-per-hectare
Crop yield per hectare and per acre from harvested quantity and field area in any area unit, exactly, as decimal text.
yieldPerHectare in TypeScript
1.0.1
py rs ts
19 tests
manufacturing.batch-size
Economic batch quantity: the EOQ for a batch made at a finite production rate, in whole units.
economicBatchQuantity in TypeScript
1.0.0
py rs ts
20 tests
money.format
Render a monetary amount as text, using the currency's real minor-unit precision.
formatMoney in TypeScript
1.0.0
py rs ts
11 tests
1.0.0
py rs ts
9 tests
finance.credit-note.calculate
Credit note against an original invoice, by units or by amount, with VAT at the original tax point's rates.
calculateCreditNote in TypeScript
1.0.0
py rs ts
21 tests
manufacturing.bom-cost
Rolled-up standard cost of one unit of a product from its BOM, bought-in costs, and labour and overhead rates.
bomCost in TypeScript
1.0.0
py rs ts
15 tests
inventory.safety-stock
Safety stock in whole units, by service level and demand variability (z-score) or by max-minus-average.
safetyStock in TypeScript
1.0.0
py rs ts
22 tests
inventory.reorder-point
Reorder point: demand over the supplier lead time, rounded up to whole units, plus safety stock.
reorderPoint in TypeScript
1.0.0
py rs ts
13 tests
hospitality.recipe-scale
Scale a recipe to a new number of portions, tidying metric units (g to kg, mL to L) and rounding to kitchen precision.
scaleRecipe in TypeScript
1.0.1
py rs ts
26 tests
manufacturing.yield-scrap
Whole units to start for a required good output at a process yield, and the scrap that allows for.
inputForYield in TypeScript
1.0.0
py rs ts
15 tests
money.allocate
Split an amount across ratios without losing or inventing a single minor unit.
allocate in TypeScript
1.0.1
py rs ts
17 tests
invest.rebalance Unreviewed
Whole-unit buy and sell trades that bring a portfolio back to target weights, skipping trades below a minimum size.
rebalance in TypeScript
1.0.1
py rs ts
22 tests
invest.fee-drag Unreviewed
What an annual charge costs an investment over the years: value with and without the fee, year by year, in minor units.
feeDrag in TypeScript
1.0.1
py rs ts
20 tests
invest.dividend-yield Unreviewed
Trailing and forward dividend yield of a share or fund, in basis points, from the price and the dividends per unit.
dividendYield in TypeScript
1.0.1
py rs ts
19 tests
math.basis-points
Convert a rate between percent, basis points and a plain ratio exactly, as decimal text or integer basis points.
A group of 3: convertRate, toBasisPoints, fromBasisPoints
2.0.0
py rs ts
45 tests
energy.tariff-time-of-use
Cost half-hourly consumption against time-of-use rates: Economy 7 windows or Agile-style half-hourly prices.
timeOfUseCost in TypeScript
1.0.1
py rs ts
24 tests
manufacturing.oee
Overall equipment effectiveness (availability x performance x quality) in basis points, from times and counts.
overallEquipmentEffectiveness in TypeScript
1.0.0
py rs ts
18 tests
monitor.format-duration
A number of seconds as a short human duration for dashboards and alerts: "3h 12m", "2d 4h", "45s".
formatDuration in TypeScript
1.0.0
py rs ts
18 tests
energy.degree-days
Heating and cooling degree days from daily mean temperatures and a base temperature, exact to 0.1.
degreeDays in TypeScript
1.0.0
py rs ts
14 tests
money.split-even
Split an amount into n near-equal parts that add back up to exactly the whole.
splitEven in TypeScript
1.0.0
py rs ts
13 tests
subscriptions.usage-tiered
Price metered usage against tiers, graduated or volume, with an optional flat fee per tier.
priceUsage in TypeScript
1.0.0
py rs ts
25 tests
fleet.emissions
Vehicle greenhouse gas emissions (grams CO2e) from fuel used or distance, using UK government DESNZ conversion factors.
fleetEmissions in TypeScript
1.0.1
py rs ts
23 tests
fleet.vehicle-depreciation
A vehicle's current value from its cost, age and mileage, on retention curves the caller supplies, exactly.
vehicleDepreciation in TypeScript
1.0.0
py rs ts
20 tests
form.character-count
The GOV.UK character count message for a text box: characters or words left or over a limit, with a threshold.
characterCount in TypeScript
1.0.1
py rs ts
32 tests
manufacturing.takt-time
Takt time: available production time divided by customer demand, exact and in whole seconds.
taktTime in TypeScript
1.0.0
py rs ts
14 tests
inventory.stock-turnover
Stock turnover ratio, days inventory outstanding and days of cover for a period, computed exactly.
stockTurnover in TypeScript
1.0.0
py rs ts
13 tests
fleet.ev-charging-cost
Cost of an electric vehicle charge from the energy added, charger efficiency and power, and time-of-use tariff windows.
evChargingCost in TypeScript
1.0.0
py rs ts
24 tests
hospitality.recipe-cost
Cost a recipe and each portion from ingredient quantities, pack sizes and pack prices, allowing for trim and waste.
recipeCost in TypeScript
1.0.1
py rs ts
25 tests
math.exp
e to the power x from + - * / only, so TypeScript, Python and Rust return the same double for the same input.
exp in TypeScript
1.0.1
py rs ts
10 tests
money.convert
Convert an amount to another currency at a supplied exact rate, with an explicit rounding mode.
convertMoney in TypeScript
1.0.0
py rs ts
19 tests
agri.gross-margin
Enterprise gross margin (output less variable costs), in total and per hectare or per head, in exact money.
grossMargin in TypeScript
1.0.0
py rs ts
14 tests
energy.estimate-read
Estimate a meter read for a date from the average daily consumption between two earlier reads, with rollover.
estimateRead in TypeScript
1.0.0
py rs ts
17 tests
inventory.abc-classification
ABC classes by annual consumption value (Pareto), with configurable cut-offs such as 80/15/5 and deterministic ties.
abcClassification in TypeScript
1.0.0
py rs ts
17 tests
telecoms.call-rating
Rate a call from a rate deck: longest-prefix destination match, billing increments, connection fee and minimum charge.
rateCall in TypeScript
1.0.1
py rs ts
22 tests
charts.format
Axis and label text for charts: tick numbers, SI prefixes (1.2k, 3.4M), percentages, dates and money.
A group of 5: formatTick, formatSi, formatPercent, formatDate, formatMoneyTick
1.0.0
py rs ts
61 tests
energy.carbon-emissions
kgCO2e from kWh or litres of a fuel, using the UK government GHG conversion factors for the year.
carbonEmissions in TypeScript
1.0.1
py rs ts
17 tests
fleet.cost-per-mile
Whole-life cost per mile of a vehicle, in tenths of a penny, from depreciation, fuel, maintenance, insurance and tax.
costPerMile in TypeScript
1.0.0
py rs ts
13 tests
fleet.fuel-cost
Fuel cost of a trip from distance, fuel economy (UK or US mpg, or L/100km) and price per litre, exactly.
fuelCost in TypeScript
1.0.0
py rs ts
24 tests
inventory.valuation-weighted-average
Perpetual weighted average cost: stock value and cost of sales from a movement ledger, rounding once per issue.
weightedAverageValuation in TypeScript
1.0.0
py rs ts
17 tests
charity.donation-matching
Employer match on a donation: a ratio in basis points, limited by a per-donor cap and a programme budget.
donationMatch in TypeScript
1.0.0
py rs ts
17 tests
charity.fundraising-ratio
Cost to raise £1 and charitable spend ratio for a charity, in exact basis points.
fundraisingRatios in TypeScript
1.0.0
py rs ts
12 tests
energy.bill-calculate
Electricity or gas bill from two meter reads: energy, standing charge, Climate Change Levy and VAT.
calculateEnergyBill in TypeScript
1.0.0
py rs ts
15 tests
energy.climate-change-levy
Climate Change Levy on a business supply of electricity, gas, LPG or solid fuel, at the main rate in force on the date.
climateChangeLevy in TypeScript
1.0.2
py rs ts
20 tests
finance.markup-price
Selling price from a cost and a target margin or markup in basis points, with explicit rounding.
markupPrice in TypeScript
1.0.0
py rs ts
21 tests
inventory.expiry-fefo
First-expiry-first-out pick list for a quantity across batches, skipping expired and short-dated stock.
fefoPick in TypeScript
1.0.0
py rs ts
15 tests
manufacturing.bom-explode
Explode a multi-level bill of materials into exact total quantities per component, with scrap and cycle checks.
explodeBom in TypeScript
1.0.0
py rs ts
17 tests
math.atan
Arctangent in radians from + - * / only (fdlibm's method), so every language returns the same double.
atan in TypeScript
1.0.1
py rs ts
22 tests
math.ln
Natural logarithm from + - * / only, so TypeScript, Python and Rust return the same double for the same input.
ln in TypeScript
1.0.1
py rs ts
11 tests
telecoms.data-allowance
Mobile data allowance used and remaining, and the overage charge in whole blocks with an optional spend cap.
dataAllowance in TypeScript
1.0.0
py rs ts
18 tests
agri.milk-price
Milk price per litre and payment from a contract's base price, butterfat/protein adjustments and bonuses.
milkPrice in TypeScript
1.0.0
py rs ts
18 tests
inventory.valuation-fifo
FIFO stock valuation and cost of sales from a stock movement ledger, in exact money.
fifoValuation in TypeScript
1.0.0
py rs ts
18 tests
manufacturing.variance
Standard costing variances: material price and usage, labour rate and efficiency, favourable or adverse.
costVariances in TypeScript
1.0.0
py rs ts
15 tests
math.percent-change
Percentage change from one value to another, in basis points, with an explicit rounding mode.
percentChange in TypeScript
1.0.0
py rs ts
19 tests
retail.refund-calculate
Refund for returned items, sharing basket discounts back across the sale so every refund is exact to the penny.
calculateRefund in TypeScript
1.0.0
py rs ts
16 tests
stats.weighted-average
Weighted average of integers, computed exactly and rounded once to stated decimals with an explicit rounding mode.
weightedAverage in TypeScript
1.0.0
py rs ts
21 tests
text.number-to-words
Write a money amount in words for a cheque: "one thousand two hundred and thirty-four pounds and fifty-six pence".
amountInWords in TypeScript
1.0.0
py rs ts
16 tests
insurance.sum-insured-average Unreviewed
Average clause settlement for underinsurance: the loss times sum insured over value at risk, capped at the loss.
averageClauseSettlement in TypeScript
1.0.1
py rs ts
22 tests
lending.early-settlement Unreviewed
Early settlement figure and rebate on UK regulated consumer credit, per the Early Settlement Regulations 2004.
earlySettlement in TypeScript
1.0.1
py rs ts
18 tests
property.floor-area Unreviewed
Floor area from room lengths and widths, exactly, with the total in both square metres and square feet.
floorArea in TypeScript
1.0.2
py rs ts
20 tests
agri.spray-mix Unreviewed
Sprayer tank mix: tank fills, and product and water per full and part tank, for an area, water volume and dose.
sprayMix in TypeScript
1.0.1
py rs ts
14 tests
insurance.premium-proration Unreviewed
Return premium on mid-term cancellation, pro rata or on a short-period scale, with an optional minimum retained premium.
cancellationReturnPremium in TypeScript
1.0.1
py rs ts
26 tests
invest.time-weighted-return Unreviewed
Time-weighted return from valuations taken at each external cash flow, geometrically linked exactly.
timeWeightedReturn in TypeScript
1.0.1
py rs ts
22 tests
health.egfr Unreviewed
eGFR in mL/min/1.73 m² by the race-free CKD-EPI 2021 creatinine equation, from creatinine in µmol/L or mg/dL.
egfrCkdEpi2021 in TypeScript
1.0.1
py rs ts
25 tests
insurance.rating-factors Unreviewed
Premium from a base rate times factor-table lookups, loadings and discounts, within minimum and maximum premiums.
ratePremium in TypeScript
1.0.1
py rs ts
24 tests
invest.portfolio-weights Unreviewed
Each holding's share of a portfolio and its drift from a target weight, in basis points, from exact arithmetic.
portfolioWeights in TypeScript
1.0.1
py rs ts
19 tests
lending.loan-payment Unreviewed
Level repayment for a loan (annuity formula), computed exactly and rounded once, the way you choose.
loanPayment in TypeScript
1.0.1
py rs ts
23 tests
lending.daily-interest Unreviewed
Interest accrued day by day on a changing balance under a day-count convention, summed exactly and rounded once.
dailyInterest in TypeScript
1.0.1
py rs ts
21 tests
logistics.duty-estimate Unreviewed
Estimate import duty and import VAT on goods: customs value on a CIF basis, the caller's duty rate, VAT on top.
dutyEstimate in TypeScript
1.0.1
py rs ts
17 tests
property.rent-review Unreviewed
New rent after an index-linked (CPI/RPI) rent review, with an optional collar and cap and upward-only option.
rentReview in TypeScript
1.0.1
py rs ts
19 tests
agri.fertiliser-application
Fertiliser product rate (kg/ha and total) to meet N, P2O5 and K2O targets from its analysis, limiting nutrient first.
fertiliserApplication in TypeScript
1.0.0
py rs ts
16 tests
charts.stack
Stack several series for stacked bars and areas: on zero, normalised to 100%, or diverging around zero.
stack in TypeScript
1.0.0
py rs ts
14 tests
monitor.series-window
The samples of a time series from one moment up to (not including) another, checking they are in time order.
seriesWindow in TypeScript
1.0.0
py rs ts
12 tests
finance.invoice.calculate
Calculate a complete invoice: line nets, VAT per line, totals and a VAT summary grouped by rate.
calculateInvoice in TypeScript
1.0.1
py rs ts
15 tests
math.rational
Exact fraction arithmetic, always reduced, for rates and ratios that must not drift.
A group of 8: calculateRational, rational, addRational, subtractRational, multiplyRational, divideRational, compareRational, rationalToInteger
2.0.0
py rs ts
86 tests
banking.overdraft-interest
Overdraft interest for a statement period from daily balances, with an interest-free buffer.
overdraftInterest in TypeScript
1.0.0
py rs ts
15 tests
hospitality.gross-profit-menu
Menu gross profit (GP%) on the VAT-exclusive price, and the menu price that reaches a target GP.
A group of 2: menuGrossProfit, menuPriceForGp
1.0.0
py rs ts
20 tests
logistics.freight-rate
Freight charge from a carrier's dated weight-break tariff for a zone, with the fuel surcharge in force on the ship date.
freightRate in TypeScript
1.0.1
py rs ts
26 tests
retail.basket-total
Total a basket: line prices, promotions, a basket discount, VAT per line and delivery, into one checked total.
basketTotal in TypeScript
1.0.0
py rs ts
10 tests
retail.promotion-apply
Apply BOGOF, 3-for-2, percent off, amount off and multibuy deals to a basket, best for the customer, allocated to lines.
applyPromotions in TypeScript
1.0.0
py rs ts
23 tests
validation.uk-company-number
Check a Companies House company number's format and prefix (SC, NI, OC, LP...) and zero-pad it to eight characters.
validateUkCompanyNumber in TypeScript
2.0.1
py rs ts
18 tests