callaccounting.ws forum

callaccounging.ws => Call Accounting Mate Q&A => Topic started by: sergey on September 07, 2005, 09:29:03 AM

Title: Concept of the tariff plan in Call Accounting Mate
Post by: sergey on September 07, 2005, 09:29:03 AM
The tariff plan in Call Accounting Mate is also numbering plan at the same time. It is most important part of the system data, because the software relies on the plan when parsing phone numbers to determine region for a call and also when rating the calls. Below we'll use tariff plan to denote this structure, keeping in mind that in CAM this actually means tariff and numbering plans at the same time.

Tariff plan in CAM is structured like a  tree, which means that every element of the tariff plan has a parent element (except the very first root element) and every element has zero or more child elements. Elements, which have no children are referred as leaves. Path in the tariff plan is a chain of elements in which every element is parent of the next element in the chain. Evey element in the path has prefix (phone code), which is either it's own, calculated from the element value, or inherited from the parent element or combined (parent prefix is appended in front of the current element's prefix and used as new prefix for the element). Current prefix on the path is prefix of the element, which CAM is currently processing. The current prefix is displayed in 3rd column of every expandable pane on the Settings/Operators/Rates page.

While parsing phone numbers and tariffing calls CAM navigates from root element of the tariff plan to leaves as deep as possible, searching for most appropriate path for a call. It uses various criteria described below to determine the path, which fits best for a given call. After such path is found CAM returns back to the root element using the found path and looks for rate elements. In case there is rate elements accessible from call path it uses them to rate call.

There are basically 3 operations which CAM does while navigating across the tariff plan:
- filtering
- assigning region
- calculating call cost
Different types of tariff plan elements perform different operations from the listed above and some of the elements even combine several operations. Different combinations of elements leads to different approaches in numbers parsing and calls tariffing allowing to achieve maximal flexibility using only limited set of basic operations.

Filtering allows plan elements to check if  a call matches certain condition(s). If it does the element allows CAM to navigate through it next to it's children, if the call failed to match element all element's children become inaccessible for the call and no more affect parsing of the call number and calculating it's rate.

Assigning region is simple operation. When call processing is starting and the call is at root element of the tariff plan it's region is empty. Later moving from element to element the call may be assigned  a region in case it has moved through the element, which has ability to assign regions. When assigning a region CAM uses call number to search for region by it's phone code. Longest possible match approach is used while assigning the region, i.e. if element assigns only country to the call CAM automatically extends this operation and tries to find state/province and city in the regions lookup table as well.

Calculating call cost is done every time when CAM meets rate element while navigating the tariff plan. It checks call duration, examines the rate element parameters and adds corresponding value to the current call cost. Initially cost of the call is zero.

To manage tariff plan 'Settings/Operators/Rates' page is used. On this page there is list of top level sections. Every section contains part of the tariff plan having it's own root element. In spite of this they are used as whole, i.e. all elements from all the sections form single tariff plan, which means that CAM searches all sections at the same time when looking for best path for a call. Sections are used for purpose of convenience allowing separate logical parts of the tariff plan from each other. For example, you may place plans for long distance calls and local calls in different sections or use different sections for different service providers. All default tariff plan templates shipped with CAM contain 2 sections: one for long distance calls and one for local calls.

Below is description of various tariff plan elements used in CAM

Access Code element.
This element has single value of phone number prefix. Value syntax is <prefix>*. Here <prefix> is  group of digits and * denotes that value is pattern matching all numbers starting with <prefix> This element combines 2 operations: filtering and assigning a region. It acts as follows:
- it accepts call which number start with <prefix>
- it removes <prefix> from the call number and uses rest of the number to search regions lookup table for a region which prefix match the call number with <prefix> removed
- in case such region is found the element assigns it to the call
- it changes current prefix in the tariff plan, making it's children to inherit it's own prefix defined by it's value
Example:
Access Code = 011* will accept call with number 0114419759344 and assign the call United Kingdom/Aberdeen, at the same time it will refuse a call with number 15574956234 and every other call, which number not starting with 011.

CO Line element.
This element contains list of one or more CO/Trunk lines. Value syntax is <line no>[,<line no>...]. Here <line no> is number of CO/Trunk line and [] denotes optional part of the list. This element is used for filtering only. It acts as follows:
- it accepts all calls, which CO/Trunk lines are found in list of lines stored in the element
- it refuses any other calls
Example:
CO Line = 010303 accepts all calls made using CO/Trunk line  010303.
CO Line = 234,349,283 accepts all calls made using either of  234,349 or 283 CO/Trunk lines.

Call Type element.
This element contains list of one or more call types. Value is defined with help of built-in property editor. To invoke the editor use [...] button of the element. This element is for filtering only. It acts as follows:
- it accepts all calls, which type lines is found in list of call types stored in the element
- it refuses any other calls
Example:
Call Type = Outgoing accepts all outgoing calls.
Call Type = Outgoing, Incoming, Internal[N] accepts all outgoing, incoming and internal (N type is either defined by the driver or PBX dependent) calls.

Check Region element (added in CAM 2.6.1.95.4).
This element has single value of region from regions lookup table. Value is defined with help of built-in property editor. To invoke the editor use [...] button of the element.  This element is used for filtering only. It acts as follows:
- it accepts only calls with region already assigned to them
- the region assigned to the call must match the element value
- it rejects any other calls
Example:
Check Region = United Kingdom will accept calls with United Kingdom region previously assigned to them (e.g. by Transparent Code element).


Expand region element.
This element has only one default value: 'From current prefix'. This element assigns a region to a call. This element uses current number prefix formed by it's parents to search regions lookup table. It acts as follows:
- it takes number prefix from it's parent and uses it to search regions lookup table
- in case region is found the element assigns it to the call
Example:
Parent element: Number/Prefix = 1*
Current element: Expand Region = From current prefix. In this case current prefix is 1 inherited from the parent Number/Prefix element. This prefix (1) will be used as region code, thus 120439439  will be assigned Canada/Manitoba and 16842394394 will be assigned Pacific/American Samoa.

Group element.
This element has value defining name of the group. This element has no function. It is used to group other elements of the tariff plan and assign them a name. For example, it can be used to define tariff zones, including several regions with single rate.

Number length element.
This element contains minimum and maximum restrictions for length of a call number. Value is defined with help of built-in property editor. To invoke the editor use [...] button of the element. This element is for filtering only. It acts as follows:
- it accepts all calls, which number length falls between minimum and maximum limits stored in the element
- it refuses any other calls
For optimization purposes and the plan reliability it is strongly recommended start every section of the tariff plan with the Number length element.
Example:
Number length = between 0 and 40 accepts almost all meaningful phone numbers.
Number length = between 1 and 8 accepts all calls, which number length is between 1 and 8 digits, e.g. local calls.

Number/Prefix element.
This element has single value of phone number prefix. Value syntax is <prefix>[ * ]. Here <prefix> is  group of digits and * denotes that value is pattern matching all numbers starting with <prefix>.  The * is optional, which is denoted by [ ]. In case * is omitted this element uses <prefix> for strict number matching. This element is used for filtering. It acts as follows:
- it accepts call which number start with <prefix> in case the <prefix> is followed by *
- it accepts call which number is equal to <prefix> in case the <prefix> is not followed by *
- it changes current prefix in the tariff plan, making it's children to inherit it's own prefix defined by it's value
Example:
Number/Prefix = 1* will accept call with number 15574956234, 1800239432 and any other call staring with 1.
Number/Prefix = 12343 will accept only calls, which numbers is exactly 12343.

Rate element.
This element has complex value defining the rate. Value is defined with help of built-in property editor. To invoke the editor use [...] button of the element.
Value consists of following fields:
  - Interval start (sec.)  - number of seconds since call start when the rate should be applied; time is zero based, i.e. call time starts at 0
  - Tariffing interval (sec.) - number of seconds in rate block
  - Tariff – amount per rate block
This element is used to rate calls. It acts as follows:
- rates elements are ordered by their Interval Start field
- all rates elements applied sequentially
- when calculating amount added by current rate element first number of blocks is calculated using following formula: (<end>-<start>)/<interval>, where <end> is either Interval Start field of the next rate element or call duration depending of whether the current element is last in rates sequence, <start > is Interval Start of the current element and <block> is Tariffing interval of the current element.
- the above number of blocks is multiplied by the amount in the Tariff field and added to the call cost

Region element (renamed to Region Code in CAM 2.6.1.95.4).
This element has single value of region from regions lookup table. Value is defined with help of built-in property editor. To invoke the editor use [...] button of the element.  This element combines 2 operations: filtering and assigning a region. It acts as follows:
- it accepts call which number starts with the prefix matching the element prefix; element prefix is defined as combination of the parent's prefix and the phone code of region stored in the element
- it assigns region stored in the element to the call passed the above check
- it changes current prefix in the tariff plan, making it's children to inherit it's own prefix defined by it's value
Example:
Region = United Kingdom will accept call with number 4419759344 and assign the call United Kingdom/Aberdeen, at the same time it will refuse a call with number 15574956234 and every other call, which number not starting with 44.

Time slot element.
This element contains restrictions for date/time of a call. Value is defined with help of built-in property editor. To invoke the editor use [...] button of the element. This element is for filtering only. It acts as follows:
- it accepts all calls, which date/time matches day of week, time slot start and time slot end
- it refuses any other calls
Please note that to allow time slots to act properly when filtering by holidays dates it is necessary to fill holidays lookup table (Settings/Holidays page).
Example:
Time slot =[00:00 - 24:00] Mon,Tue,Wed,Thu,Fri accepts all calls made any time on work days.

Transparent code element (renamed to Set Region in CAM 2.6.1.95.4).
This element has single value of region from regions lookup table. Value is defined with help of built-in property editor. To invoke the editor use [...] button of the element.  This element is used for  assigning a region. It acts as follows:
- in region stored in the element to every call passed through it
- it doesn't change current prefix in the tariff plan that's why it called transparent code
Example:
Transparent code = United Kingdom will accept call with number 19759344 and assign the call United Kingdom/Aberdeen, it's like implicit adding of 44 prefix to the above number.

Transparent prefix (added in CAM 2.6.1.95.4).
This element has single value of phone number prefix. Value syntax is <prefix>* . Here <prefix> is  group of digits and * denotes that value is pattern matching all numbers starting with <prefix>.  The * is mandatory. This element is used for temporarily adjusting the current prefix and assigning a region. It acts as follows:
- it accepts all calls
- it temporarily adds it's value to the call number (in front of it) and uses this new number to search for region in regions lookup table
- in case the region is found it assigns it to the call
- the element doesn't change the current prefix for it's children; that's why it's called 'transparent'
Example:
Good example is situation when it is allowed to dial +1 numbers without the leading 1. In this situation the 'Transparent prefix' element can be used to adjust the number temporarily and search for a region using the full number. The 'Set region' element can't be used in this case because several top level regions use +1 prefix (e.g. USA, Canada, Pacific etc).

User Ext element.
This element contains list of one or more extensions. Value syntax is <ext>[,<ext>...]. Here <ext> is extension and [] denotes optional part of the list. This element is used for filtering only. It acts as follows:
- it accepts all calls, which extension  is found in list of extensions stored in the element
- it refuses any other calls
Example:
User Ext  = 107 accepts all calls made from extension 107.
CO Line = 110,112,101 accepts all calls made from either of  110,112 or 101 extensions.