...
The lookup into the Call Rate table is based on the following keys: From the Dialed Number: The NPA, NXX, Country Code (for International), Mexico Band (for Mexico). Also the Rating Group, Service Host, and Billing Group. For International calls, the country code must be extracted from the dialed digits. Unfortunately, the length of the country code can be 3, 2, or 1 digits. So we must try the lookup into the Call Rate table up to 3 times, using 3, 2, or 1 digit or until a match is found. If no match is found, then we try the look-up lookup with a blank Country Code. This lets the User create one International default rate record for all countries that don't have an individual Rate.
For Mexico calls, we try the lookup into the Call Rate table with the 1 digit Mexico Band. If a Call Rate record is not found with that Band, do the look-up lookup without the Band value. This is because when the Call Rate records are defined, you can create up to 8 different Mexico rates, one for each band, or you can create one rate for all of Mexico.
For all other Calls, the Rate record might include the dialed NPA-NXX, just the NPA, or neither. So we try the look-up with the NPA-NXX, then the NPA, then neither. For all of the lookups, the first attempts include the Rating Group, Service Host, and the Billing Group. These are read from the Service ID of the phone Phone making the call Call (or receiving the call Call for incoming calls). If the lookup fails, then they are tried again with a blank Rating Group, then a blank Billing Group, then again with a blank Service Host. After all this, a Call Rate record should have been found. If it has not, a Rating Error is assigned to the call with a Description of "No rate defined for this call type". If there was no error, the correct rate amounts (based on time of day of the call) in the Call Rate record are multiplied by the duration to get the Call Cost. Further the call duration can be rounded to a specified duration using the CALL_USAGE_RATING_DURATION_PRECISION and CALL_USAGE_RATING_DURATION_ROUND_METHOD configuration options.
...