[ { "name": "September, good constituents, middle volume tier: 40.100 ppl on 750,000 litres is £300,750", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 750000, "butterfatBasisPoints": 420, "proteinBasisPoints": 340, "month": 9 } ], "expect": { "basePrice": 38000, "butterfatAdjustment": 500, "proteinAdjustment": 400, "volumeBonus": 200, "seasonalAdjustment": 1000, "pricePerLitre": 40100, "total": { "minor": 30075000, "currency": "GBP" } } }, { "name": "May spring flush with low constituents on the top volume tier", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 1200000, "butterfatBasisPoints": 385, "proteinBasisPoints": 322, "month": 5 } ], "expect": { "basePrice": 38000, "butterfatAdjustment": -375, "proteinAdjustment": -320, "volumeBonus": 400, "seasonalAdjustment": -1500, "pricePerLitre": 36205, "total": { "minor": 43446000, "currency": "GBP" } } }, { "name": "a pro-rata butterfat adjustment of 76.5 thousandths rounds up to 77", "args": [ { "currency": "GBP", "basePrice": 30000, "standardButterfatBasisPoints": 400, "butterfatValue": 255, "standardProteinBasisPoints": 330, "proteinValue": 0, "volumeBonuses": [], "seasonality": [] }, { "litres": 1000, "butterfatBasisPoints": 403, "proteinBasisPoints": 330, "month": 1 } ], "expect": { "basePrice": 30000, "butterfatAdjustment": 77, "proteinAdjustment": 0, "volumeBonus": 0, "seasonalAdjustment": 0, "pricePerLitre": 30077, "total": { "minor": 30077, "currency": "GBP" } } }, { "name": "below standard it rounds away from zero, to -77", "args": [ { "currency": "GBP", "basePrice": 30000, "standardButterfatBasisPoints": 400, "butterfatValue": 255, "standardProteinBasisPoints": 330, "proteinValue": 0, "volumeBonuses": [], "seasonality": [] }, { "litres": 1000, "butterfatBasisPoints": 397, "proteinBasisPoints": 330, "month": 1 } ], "expect": { "basePrice": 30000, "butterfatAdjustment": -77, "proteinAdjustment": 0, "volumeBonus": 0, "seasonalAdjustment": 0, "pricePerLitre": 29923, "total": { "minor": 29923, "currency": "GBP" } } }, { "name": "the payment is rounded once: 333 litres at 39.900 ppl is 13,286.7p", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 333, "butterfatBasisPoints": 420, "proteinBasisPoints": 340, "month": 9 } ], "expect": { "basePrice": 38000, "butterfatAdjustment": 500, "proteinAdjustment": 400, "volumeBonus": 0, "seasonalAdjustment": 1000, "pricePerLitre": 39900, "total": { "minor": 13287, "currency": "GBP" } } }, { "name": "the payment rounds half up: 5 litres at 30.100 ppl is 150.5p, paid as 151p", "args": [ { "currency": "GBP", "basePrice": 30100, "standardButterfatBasisPoints": 400, "butterfatValue": 0, "standardProteinBasisPoints": 330, "proteinValue": 0, "volumeBonuses": [], "seasonality": [] }, { "litres": 5, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 1 } ], "expect": { "basePrice": 30100, "butterfatAdjustment": 0, "proteinAdjustment": 0, "volumeBonus": 0, "seasonalAdjustment": 0, "pricePerLitre": 30100, "total": { "minor": 151, "currency": "GBP" } } }, { "name": "a volume tier starts at exactly its minimum", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 500000, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 1 } ], "expect": { "basePrice": 38000, "butterfatAdjustment": 0, "proteinAdjustment": 0, "volumeBonus": 200, "seasonalAdjustment": 0, "pricePerLitre": 38200, "total": { "minor": 19100000, "currency": "GBP" } } }, { "name": "one litre short of a tier gets nothing", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 499999, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 1 } ], "expect": { "basePrice": 38000, "butterfatAdjustment": 0, "proteinAdjustment": 0, "volumeBonus": 0, "seasonalAdjustment": 0, "pricePerLitre": 38000, "total": { "minor": 18999962, "currency": "GBP" } } }, { "name": "December uses the last seasonal value", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 100000, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 12 } ], "expect": { "basePrice": 38000, "butterfatAdjustment": 0, "proteinAdjustment": 0, "volumeBonus": 0, "seasonalAdjustment": 0, "pricePerLitre": 38000, "total": { "minor": 3800000, "currency": "GBP" } } }, { "name": "no milk is no payment", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 0, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 4 } ], "expect": { "basePrice": 38000, "butterfatAdjustment": 0, "proteinAdjustment": 0, "volumeBonus": 0, "seasonalAdjustment": -1000, "pricePerLitre": 37000, "total": { "minor": 0, "currency": "GBP" } } }, { "name": "a euro contract in cents", "args": [ { "currency": "EUR", "basePrice": 45000, "standardButterfatBasisPoints": 400, "butterfatValue": 300, "standardProteinBasisPoints": 330, "proteinValue": 500, "volumeBonuses": [], "seasonality": [] }, { "litres": 20000, "butterfatBasisPoints": 450, "proteinBasisPoints": 350, "month": 6 } ], "expect": { "basePrice": 45000, "butterfatAdjustment": 1500, "proteinAdjustment": 1000, "volumeBonus": 0, "seasonalAdjustment": 0, "pricePerLitre": 47500, "total": { "minor": 950000, "currency": "EUR" } } }, { "name": "a seasonality list that is not 12 long is an error", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] }, { "litres": 1000, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 1 } ], "expectError": "seasonality must have 12 monthly values or none" }, { "name": "month 13 is an error", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 1000, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 13 } ], "expectError": "month must be a whole number from 1 to 12" }, { "name": "volume tiers out of order are an error", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 1000000, "bonus": 400 }, { "minimumLitres": 500000, "bonus": 200 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 1000, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 1 } ], "expectError": "volumeBonuses must be in strictly ascending order of minimumLitres" }, { "name": "negative litres are an error", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": -1, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 1 } ], "expectError": "litres must be a whole number from 0 to 1000000000" }, { "name": "butterfat given as a percentage is an error", "args": [ { "currency": "GBP", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 1000, "butterfatBasisPoints": 4.12, "proteinBasisPoints": 330, "month": 1 } ], "expectError": "butterfatBasisPoints must be a whole number" }, { "name": "a price that goes negative is an error", "args": [ { "currency": "GBP", "basePrice": 1000, "standardButterfatBasisPoints": 400, "butterfatValue": 1000, "standardProteinBasisPoints": 330, "proteinValue": 0, "volumeBonuses": [], "seasonality": [] }, { "litres": 1000, "butterfatBasisPoints": 300, "proteinBasisPoints": 330, "month": 1 } ], "expectError": "price per litre must not be negative" }, { "name": "a bad currency code is an error", "args": [ { "currency": "gbp", "basePrice": 38000, "standardButterfatBasisPoints": 400, "butterfatValue": 250, "standardProteinBasisPoints": 330, "proteinValue": 400, "volumeBonuses": [ { "minimumLitres": 500000, "bonus": 200 }, { "minimumLitres": 1000000, "bonus": 400 } ], "seasonality": [ 0, 0, 0, -1000, -1500, -1000, 0, 500, 1000, 1000, 500, 0 ] }, { "litres": 1000, "butterfatBasisPoints": 400, "proteinBasisPoints": 330, "month": 1 } ], "expectError": "is not an uppercase ISO 4217 currency code" } ]