[ {"name": "a year: average 400.00 against 2400.00 cost of sales is 6 turns, 60.8 days, 45.6 days of cover", "args": [{"minor": 50000, "currency": "GBP"}, {"minor": 30000, "currency": "GBP"}, {"minor": 240000, "currency": "GBP"}, 365], "expect": {"averageStock": {"minor": 40000, "currency": "GBP"}, "turns": 6, "daysInventoryOutstanding": 60.8, "daysOfCover": 45.6}}, {"name": "awkward figures: 5.59 turns, 5.4 days, 7.0 days of cover over 30 days; the average 179.005 shows as 179.01", "args": [{"minor": 12345, "currency": "GBP"}, {"minor": 23456, "currency": "GBP"}, {"minor": 100000, "currency": "GBP"}, 30], "expect": {"averageStock": {"minor": 17901, "currency": "GBP"}, "turns": 5.59, "daysInventoryOutstanding": 5.4, "daysOfCover": 7.0}}, {"name": "an exact half of a hundredth, 0.005 turns, rounds half-up to 0.01", "args": [{"minor": 200, "currency": "GBP"}, {"minor": 200, "currency": "GBP"}, {"minor": 1, "currency": "GBP"}, 1], "expect": {"averageStock": {"minor": 200, "currency": "GBP"}, "turns": 0.01, "daysInventoryOutstanding": 200.0, "daysOfCover": 200.0}}, {"name": "a week: 0.7 turns and ten days' cover", "args": [{"minor": 1000, "currency": "GBP"}, {"minor": 1000, "currency": "GBP"}, {"minor": 700, "currency": "GBP"}, 7], "expect": {"averageStock": {"minor": 1000, "currency": "GBP"}, "turns": 0.7, "daysInventoryOutstanding": 10.0, "daysOfCover": 10.0}}, {"name": "stock ran out by the end: no cover left, though the average held some", "args": [{"minor": 10000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 20000, "currency": "GBP"}, 30], "expect": {"averageStock": {"minor": 5000, "currency": "GBP"}, "turns": 4, "daysInventoryOutstanding": 7.5, "daysOfCover": 0.0}}, {"name": "nothing sold: zero turns, and the day counts have no answer", "args": [{"minor": 10000, "currency": "GBP"}, {"minor": 10000, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, 30], "expect": {"averageStock": {"minor": 10000, "currency": "GBP"}, "turns": 0, "daysInventoryOutstanding": null, "daysOfCover": null}}, {"name": "no stock held but cost of sales (drop-shipped): turns has no answer", "args": [{"minor": 0, "currency": "GBP"}, {"minor": 0, "currency": "GBP"}, {"minor": 5000, "currency": "GBP"}, 30], "expect": {"averageStock": {"minor": 0, "currency": "GBP"}, "turns": null, "daysInventoryOutstanding": 0.0, "daysOfCover": 0.0}}, {"name": "nothing at all: every ratio is null", "args": [{"minor": 0, "currency": "EUR"}, {"minor": 0, "currency": "EUR"}, {"minor": 0, "currency": "EUR"}, 30], "expect": {"averageStock": {"minor": 0, "currency": "EUR"}, "turns": null, "daysInventoryOutstanding": null, "daysOfCover": null}}, {"name": "amounts in two currencies are an error", "args": [{"minor": 100, "currency": "GBP"}, {"minor": 100, "currency": "EUR"}, {"minor": 100, "currency": "GBP"}, 30], "expectError": "currency mismatch"}, {"name": "negative stock is an error", "args": [{"minor": -1, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, 30], "expectError": "openingStock must not be negative"}, {"name": "negative cost of sales is an error", "args": [{"minor": 100, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, {"minor": -100, "currency": "GBP"}, 30], "expectError": "costOfSales must not be negative"}, {"name": "a period of zero days is an error", "args": [{"minor": 100, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, 0], "expectError": "periodDays must be a whole number of days, at least 1"}, {"name": "a fractional period is an error", "args": [{"minor": 100, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, {"minor": 100, "currency": "GBP"}, 7.5], "expectError": "periodDays must be a whole number of days, at least 1"} ]