Calculating a check digit

A common requirement for bill output is to include a check digit at the end of each scan line. The check digit is a single digit that is calculated based on the other digits in the scan line to help detect data entry errors.

To calculate a check digit, use the CheckDigit rule on the Hansen.Billing.Bill business object. This rule takes two parameters: the string of digits from which the check digit is calculated (called the builder string) and the algorithm used to calculate the check digit. The available algorithms are defined in the Checksum configuration in the Configuration Editor. (See the Configuration Editor documentation for more information on these algorithms.)

In most cases, the builder string must first be derived based on other keywords and rules. Each account's scan line in the output file typically includes data such as the account number, the bill amount, and the current amount due, so the builder string must be derived from the keywords for these various values. The steps to derive the builder string can include converting decimal values to strings, concatenating strings, and adding or removing characters so the string is the right length. A derived keyword for check digits can be used in an export template like any other keyword.