Here's a toy rater.
Story and Requirements
We need a rater to process customer usage. The rater will allow us to issue bills to customers regularly, with bill value based on ongoing customer use, and the tariff available at the time of use. We need to reconcile input and output, to track costs, and to manage invalid records.
- The rater should allocate usage to the correct account..
- The rater should match usage to the applicable tariff, and calculate cost based on logged usage and tariff details. ..
- The rater will assist billing by totalling cost between dates, and indicating that those records have been billed...
- Where account information is missing, the rater should put the usage information into ‘suspense’..
- Where an account does not have an applicable tariff, the rater should put the account into suspense..
- No usage should be billed twice...
- The rater will keep statistics of records rated, records suspended, amount used, cost to be billed
Account 1, with a tariff of 12K / unit, uses 10 units a day in June and July. The June bill, for 30 days, is 360K. The July bill is 372K
We receive a record of 10 units with an invalid account ID – the use record is suspended.
Account 2 has a June tariff of 5K/unit, and a July tariff of 8K/unit. They use 100 units in June, and are billed 500K. They use 80 units in July, and are billed 640K.
Added all-new billing
Improved statistics, adding stats for value as well as count
- 001: anecdotal reports of conflicts between tariff dates and applicable dates for tariffs on accounts
- 002: anecdotal reports of records wrongly suspended or wrongly processed when they might be expected to be suspended.
Jasmine unit tests
Choose base data:
Currently using: –
Vary dates from 20220825 to 20221025
Edit generated records
Test has sent records for rating.
Number Value Processed Allocated Billed Suspended
These records have not been allocated to an account
Main Rater Log
Contains tariffSet and accountSet .
Configuration described as :
Current set of test data Accounts:
Current set of test Tariffs:
config – new name: , new description:
tarrifSet - new name:
accountSet - new Name: