[ { "name": "a dairy ration for 100 cows over 30 days: the group cost is 467.5p x 3000 exactly, not 468p x 3000", "args": [ [ { "name": "grass silage", "freshKgPerHead": 40, "dryMatterBasisPoints": 3000, "pricePerTonne": { "minor": 4000, "currency": "GBP" } }, { "name": "maize silage", "freshKgPerHead": 15, "dryMatterBasisPoints": 3200, "pricePerTonne": { "minor": 4500, "currency": "GBP" } }, { "name": "dairy compound", "freshKgPerHead": 8, "dryMatterBasisPoints": 8800, "pricePerTonne": { "minor": 30000, "currency": "GBP" } } ], 100, 30, "GBP" ], "expect": { "lines": [ { "name": "grass silage", "freshKgPerHead": 40, "dryMatterKgPerHead": 12, "costPerHead": { "minor": 160, "currency": "GBP" } }, { "name": "maize silage", "freshKgPerHead": 15, "dryMatterKgPerHead": 4.8, "costPerHead": { "minor": 68, "currency": "GBP" } }, { "name": "dairy compound", "freshKgPerHead": 8, "dryMatterKgPerHead": 7.04, "costPerHead": { "minor": 240, "currency": "GBP" } } ], "freshKgPerHead": 63, "dryMatterKgPerHead": 23.84, "dryMatterBasisPoints": 3784, "costPerHeadPerDay": { "minor": 468, "currency": "GBP" }, "totalCost": { "minor": 1402500, "currency": "GBP" }, "costPerTonneDryMatter": { "minor": 19610, "currency": "GBP" } } }, { "name": "the same ration for one cow for one day", "args": [ [ { "name": "grass silage", "freshKgPerHead": 40, "dryMatterBasisPoints": 3000, "pricePerTonne": { "minor": 4000, "currency": "GBP" } }, { "name": "maize silage", "freshKgPerHead": 15, "dryMatterBasisPoints": 3200, "pricePerTonne": { "minor": 4500, "currency": "GBP" } }, { "name": "dairy compound", "freshKgPerHead": 8, "dryMatterBasisPoints": 8800, "pricePerTonne": { "minor": 30000, "currency": "GBP" } } ], 1, 1, "GBP" ], "expect": { "lines": [ { "name": "grass silage", "freshKgPerHead": 40, "dryMatterKgPerHead": 12, "costPerHead": { "minor": 160, "currency": "GBP" } }, { "name": "maize silage", "freshKgPerHead": 15, "dryMatterKgPerHead": 4.8, "costPerHead": { "minor": 68, "currency": "GBP" } }, { "name": "dairy compound", "freshKgPerHead": 8, "dryMatterKgPerHead": 7.04, "costPerHead": { "minor": 240, "currency": "GBP" } } ], "freshKgPerHead": 63, "dryMatterKgPerHead": 23.84, "dryMatterBasisPoints": 3784, "costPerHeadPerDay": { "minor": 468, "currency": "GBP" }, "totalCost": { "minor": 468, "currency": "GBP" }, "costPerTonneDryMatter": { "minor": 19610, "currency": "GBP" } } }, { "name": "hay alone: 10 kg at 85% DM and £120/t is £1.20 a day and £141.18 a tonne of DM", "args": [ [ { "name": "hay", "freshKgPerHead": 10, "dryMatterBasisPoints": 8500, "pricePerTonne": { "minor": 12000, "currency": "GBP" } } ], 1, 1, "GBP" ], "expect": { "lines": [ { "name": "hay", "freshKgPerHead": 10, "dryMatterKgPerHead": 8.5, "costPerHead": { "minor": 120, "currency": "GBP" } } ], "freshKgPerHead": 10, "dryMatterKgPerHead": 8.5, "dryMatterBasisPoints": 8500, "costPerHeadPerDay": { "minor": 120, "currency": "GBP" }, "totalCost": { "minor": 120, "currency": "GBP" }, "costPerTonneDryMatter": { "minor": 14118, "currency": "GBP" } } }, { "name": "a sheep flock on a small concentrate allowance, 0.45 kg at £280/t", "args": [ [ { "name": "ewe nuts", "freshKgPerHead": 0.45, "dryMatterBasisPoints": 8700, "pricePerTonne": { "minor": 28000, "currency": "GBP" } } ], 400, 42, "GBP" ], "expect": { "lines": [ { "name": "ewe nuts", "freshKgPerHead": 0.45, "dryMatterKgPerHead": 0.392, "costPerHead": { "minor": 13, "currency": "GBP" } } ], "freshKgPerHead": 0.45, "dryMatterKgPerHead": 0.392, "dryMatterBasisPoints": 8700, "costPerHeadPerDay": { "minor": 13, "currency": "GBP" }, "totalCost": { "minor": 211680, "currency": "GBP" }, "costPerTonneDryMatter": { "minor": 32184, "currency": "GBP" } } }, { "name": "fresh weights are taken to the gram", "args": [ [ { "name": "hay", "freshKgPerHead": 2.0004, "dryMatterBasisPoints": 8500, "pricePerTonne": { "minor": 12000, "currency": "GBP" } } ], 1, 1, "GBP" ], "expect": { "lines": [ { "name": "hay", "freshKgPerHead": 2, "dryMatterKgPerHead": 1.7, "costPerHead": { "minor": 24, "currency": "GBP" } } ], "freshKgPerHead": 2, "dryMatterKgPerHead": 1.7, "dryMatterBasisPoints": 8500, "costPerHeadPerDay": { "minor": 24, "currency": "GBP" }, "totalCost": { "minor": 24, "currency": "GBP" }, "costPerTonneDryMatter": { "minor": 14118, "currency": "GBP" } } }, { "name": "water: fresh weight but no dry matter and no cost", "args": [ [ { "name": "water", "freshKgPerHead": 60, "dryMatterBasisPoints": 0, "pricePerTonne": { "minor": 0, "currency": "GBP" } } ], 1, 1, "GBP" ], "expect": { "lines": [ { "name": "water", "freshKgPerHead": 60, "dryMatterKgPerHead": 0, "costPerHead": { "minor": 0, "currency": "GBP" } } ], "freshKgPerHead": 60, "dryMatterKgPerHead": 0, "dryMatterBasisPoints": 0, "costPerHeadPerDay": { "minor": 0, "currency": "GBP" }, "totalCost": { "minor": 0, "currency": "GBP" }, "costPerTonneDryMatter": null } }, { "name": "no feeds is zero, with no DM share or cost per tonne of DM", "args": [ [], 10, 7, "EUR" ], "expect": { "lines": [], "freshKgPerHead": 0, "dryMatterKgPerHead": 0, "dryMatterBasisPoints": null, "costPerHeadPerDay": { "minor": 0, "currency": "EUR" }, "totalCost": { "minor": 0, "currency": "EUR" }, "costPerTonneDryMatter": null } }, { "name": "a line under half a penny rounds to zero but still counts in the total", "args": [ [ { "name": "minerals", "freshKgPerHead": 0.1, "dryMatterBasisPoints": 9500, "pricePerTonne": { "minor": 4000, "currency": "GBP" } } ], 1000, 1, "GBP" ], "expect": { "lines": [ { "name": "minerals", "freshKgPerHead": 0.1, "dryMatterKgPerHead": 0.095, "costPerHead": { "minor": 0, "currency": "GBP" } } ], "freshKgPerHead": 0.1, "dryMatterKgPerHead": 0.095, "dryMatterBasisPoints": 9500, "costPerHeadPerDay": { "minor": 0, "currency": "GBP" }, "totalCost": { "minor": 400, "currency": "GBP" }, "costPerTonneDryMatter": { "minor": 4211, "currency": "GBP" } } }, { "name": "zero head is an error", "args": [ [ { "name": "grass silage", "freshKgPerHead": 40, "dryMatterBasisPoints": 3000, "pricePerTonne": { "minor": 4000, "currency": "GBP" } }, { "name": "maize silage", "freshKgPerHead": 15, "dryMatterBasisPoints": 3200, "pricePerTonne": { "minor": 4500, "currency": "GBP" } }, { "name": "dairy compound", "freshKgPerHead": 8, "dryMatterBasisPoints": 8800, "pricePerTonne": { "minor": 30000, "currency": "GBP" } } ], 0, 1, "GBP" ], "expectError": "head must be a whole number from 1 to 1000000" }, { "name": "a fractional day is an error", "args": [ [ { "name": "grass silage", "freshKgPerHead": 40, "dryMatterBasisPoints": 3000, "pricePerTonne": { "minor": 4000, "currency": "GBP" } }, { "name": "maize silage", "freshKgPerHead": 15, "dryMatterBasisPoints": 3200, "pricePerTonne": { "minor": 4500, "currency": "GBP" } }, { "name": "dairy compound", "freshKgPerHead": 8, "dryMatterBasisPoints": 8800, "pricePerTonne": { "minor": 30000, "currency": "GBP" } } ], 1, 1.5, "GBP" ], "expectError": "days must be a whole number from 1 to 3660" }, { "name": "DM over 100% is an error", "args": [ [ { "name": "hay", "freshKgPerHead": 10, "dryMatterBasisPoints": 10001, "pricePerTonne": { "minor": 12000, "currency": "GBP" } } ], 1, 1, "GBP" ], "expectError": "feed 1: dryMatterBasisPoints must be a whole number from 0 to 10000" }, { "name": "a DM percentage given as a fraction is an error", "args": [ [ { "name": "hay", "freshKgPerHead": 10, "dryMatterBasisPoints": 85.5, "pricePerTonne": { "minor": 12000, "currency": "GBP" } } ], 1, 1, "GBP" ], "expectError": "feed 1: dryMatterBasisPoints must be a whole number from 0 to 10000" }, { "name": "a negative fresh weight is an error", "args": [ [ { "name": "hay", "freshKgPerHead": -1, "dryMatterBasisPoints": 8500, "pricePerTonne": { "minor": 12000, "currency": "GBP" } } ], 1, 1, "GBP" ], "expectError": "feed 1: freshKgPerHead must be a finite number from 0 to 1000" }, { "name": "a negative price is an error", "args": [ [ { "name": "hay", "freshKgPerHead": 10, "dryMatterBasisPoints": 8500, "pricePerTonne": { "minor": -1, "currency": "GBP" } } ], 1, 1, "GBP" ], "expectError": "feed 1: pricePerTonne must be from 0 to 100000000 minor units" }, { "name": "a price in another currency is an error", "args": [ [ { "name": "hay", "freshKgPerHead": 10, "dryMatterBasisPoints": 8500, "pricePerTonne": { "minor": 12000, "currency": "GBP" } }, { "name": "straw", "freshKgPerHead": 2, "dryMatterBasisPoints": 8600, "pricePerTonne": { "minor": 9000, "currency": "EUR" } } ], 1, 1, "GBP" ], "expectError": "feed 2: currency mismatch: EUR and GBP" } ]