Functional Weave
Code in Python

professional.utilisation@1.0.0

vectors.json

5,100 bytes · view raw

[
 {
  "name": "a typical quarter: 75% utilised, 90% billed, 95% collected, 85.5% overall",
  "args": [
   6000,
   8000,
   {
    "minor": 1000000,
    "currency": "GBP"
   },
   {
    "minor": 900000,
    "currency": "GBP"
   },
   {
    "minor": 855000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 7500,
   "billingRealisationBasisPoints": 9000,
   "collectionRealisationBasisPoints": 9500,
   "overallRealisationBasisPoints": 8550
  }
 },
 {
  "name": "a third rounds down to 3333 basis points",
  "args": [
   1,
   3,
   {
    "minor": 300,
    "currency": "GBP"
   },
   {
    "minor": 100,
    "currency": "GBP"
   },
   {
    "minor": 100,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 3333,
   "billingRealisationBasisPoints": 3333,
   "collectionRealisationBasisPoints": 10000,
   "overallRealisationBasisPoints": 3333
  }
 },
 {
  "name": "two thirds rounds up to 6667 basis points",
  "args": [
   2,
   3,
   {
    "minor": 3,
    "currency": "GBP"
   },
   {
    "minor": 2,
    "currency": "GBP"
   },
   {
    "minor": 2,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 6667,
   "billingRealisationBasisPoints": 6667,
   "collectionRealisationBasisPoints": 10000,
   "overallRealisationBasisPoints": 6667
  }
 },
 {
  "name": "exactly half a basis point rounds up, where truncating gives 0",
  "args": [
   1,
   20000,
   {
    "minor": 20000,
    "currency": "GBP"
   },
   {
    "minor": 1,
    "currency": "GBP"
   },
   {
    "minor": 1,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 1,
   "billingRealisationBasisPoints": 1,
   "collectionRealisationBasisPoints": 10000,
   "overallRealisationBasisPoints": 1
  }
 },
 {
  "name": "time beyond contracted hours and premium billing both exceed 100%",
  "args": [
   9000,
   8000,
   {
    "minor": 1000000,
    "currency": "GBP"
   },
   {
    "minor": 1100000,
    "currency": "GBP"
   },
   {
    "minor": 1100000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 11250,
   "billingRealisationBasisPoints": 11000,
   "collectionRealisationBasisPoints": 10000,
   "overallRealisationBasisPoints": 11000
  }
 },
 {
  "name": "no billable time is 0% utilisation",
  "args": [
   0,
   7500,
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 0,
   "billingRealisationBasisPoints": null,
   "collectionRealisationBasisPoints": null,
   "overallRealisationBasisPoints": null
  }
 },
 {
  "name": "nothing billed: collection realisation is null, not 0%",
  "args": [
   600,
   1000,
   {
    "minor": 50000,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 6000,
   "billingRealisationBasisPoints": 0,
   "collectionRealisationBasisPoints": null,
   "overallRealisationBasisPoints": 0
  }
 },
 {
  "name": "no standard value: billing and overall realisation are null",
  "args": [
   600,
   1000,
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 5000,
    "currency": "GBP"
   },
   {
    "minor": 5000,
    "currency": "GBP"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 6000,
   "billingRealisationBasisPoints": null,
   "collectionRealisationBasisPoints": 10000,
   "overallRealisationBasisPoints": null
  }
 },
 {
  "name": "in euros, part collected",
  "args": [
   4200,
   6000,
   {
    "minor": 250000,
    "currency": "EUR"
   },
   {
    "minor": 200000,
    "currency": "EUR"
   },
   {
    "minor": 150000,
    "currency": "EUR"
   }
  ],
  "expect": {
   "utilisationBasisPoints": 7000,
   "billingRealisationBasisPoints": 8000,
   "collectionRealisationBasisPoints": 7500,
   "overallRealisationBasisPoints": 6000
  }
 },
 {
  "name": "no available time is an error",
  "args": [
   0,
   0,
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   }
  ],
  "expectError": "availableMinutes must be greater than zero"
 },
 {
  "name": "negative billable time is an error",
  "args": [
   -60,
   1000,
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   },
   {
    "minor": 0,
    "currency": "GBP"
   }
  ],
  "expectError": "billableMinutes must be a non-negative integer"
 },
 {
  "name": "mixed currencies are an error",
  "args": [
   60,
   1000,
   {
    "minor": 100,
    "currency": "GBP"
   },
   {
    "minor": 100,
    "currency": "EUR"
   },
   {
    "minor": 100,
    "currency": "GBP"
   }
  ],
  "expectError": "currency mismatch"
 },
 {
  "name": "a negative collected amount is an error",
  "args": [
   60,
   1000,
   {
    "minor": 100,
    "currency": "GBP"
   },
   {
    "minor": 100,
    "currency": "GBP"
   },
   {
    "minor": -1,
    "currency": "GBP"
   }
  ],
  "expectError": "collectedValue must not be negative"
 }
]