The billing is performed by several processes that run one after another.
Each operation is separate from any other operation and can be run out of order. However, some operations rely on DB output from prior operations, in order to perform actual work.
The operation flow is as follows: Receive -> Process -> Customer (guiding) → Rating → Pricing → Tax → Unify
Running the processor should be enough in case all the xDRs are rated correctly.
In case some product / customer change was done, or in cases of rebalancing, the calculators should be run as well.
The receiving operation is used to copy/download/move files into the BillRun workspace directory.
php -t <billrun_dir_path> <billrun_dir_path>/public/index.php --env <env> --receive --type <input_processor_name>
The processing operation is used to parse files that were received in the billrun workspace directory and insert their content into the DB. This also runs all calculators on xDRS found in the file.
In case of a file that can't be parsed, its CDRs will be discarded.
In case a matching customer / product cannot be found, the line will be stored in "queue" collection.
php -t <billrun_dir_path> <billrun_dir_path>/public/index.php --env <env> --process --type <input_processor_name>
The calculate customer operation is used to find the customer/subscriber that each of the CDRs that were processed into the DB belongs to.
php -t <billrun_dir_path> <billrun_dir_path>/public/index.php --env <env> --calculate --type customer
The calculate rate operation is used to find the correct product that each of the CDRs in the DB should be associated with based on the CDR usage information and the cdr associated customer information.
php -t <billrun_dir_path> <billrun_dir_path>/public/index.php --env <env> --calculate --type Rate_Usage
The calculate pricing operation is used to find the charge for each of the CDRs in the DB based on the rate that was associated with the CDRs and the associated customer offer.
php -t <billrun_dir_path> <billrun_dir_path>/public/index.php --env <env> --calculate --type customerPricing
The calculate Tax operation is used to find the correct tax (VAT is most cases) that each of the CDRs in the DB should be associated with based on the CDR usage information and the cdr associated customer information. The calculator adds also a final_charge field on the record.
php -t <billrun_dir_path> <billrun_dir_path>/public/index.php --env <env> --calculate --type tax
The “rebalance” calculator is used to reset CDRs of a given account in a given billing cycle.
The desired accounts must be first declared for rebalancing via the resetlines API.
After the rebalance operation, all the subscriber / product / prices data is removed from the line and the above calculators can be run from scratch.
Note:
By an example: Imagine a case where roaming calls were incorrectly assigned a local product which is included in the customer's plan (5000 minutes in a cycle). It is not sufficient to rebalance the roaming calls. All local calls of the customer have to be rebalanced as well!
php -t <billrun_dir_path> <billrun_dir_path>/public/index.php --env <ENV> --calculate --type rebalance