Calculating, Converting and Rounding Rater Charges ¶
These Steps use variables defined in the Raterto:
-
Calculate how much a call or SMS should be charged
-
Convert currencies
-
Round a call and calculate the charge for the resulting value
Rater variables must also be set in the Rater Configuration.
Calculating the Charge ¶
The following step calculates the charge by either:
-
Verifying that an amount consisting of the tariff for the call duration or number of SMS sent correlates to a value defined in the Rater.
-
Verifying that an amount corresponds to the result of a calculation.
Syntax
1 2 | the charge for <tariff Identifier>(<amount Number>) is <charge Any> |
Parameters
-
tariff - The tariff defined in the Rater
-
amount - One of call duration in seconds or the amount of SMS sent
-
charge - The total charge calculated for the call duration or amount of SMS sent
- This may be any expression that resolves to a number
- For example, a number, a calculation such as
(10+6)
, or a context object
Example
1 2 3 | Then the charge for CH_01(20) is 120 Then the charge for CH_02(20) is (120 - 60) Then the charge for CH_01(10) is (balance1 - balance2) |
- Deferred
Converting the Charge ¶
The following step converts a charge's value from one currency unit to another currency unit.
Syntax
1 2 | convert <value Any> as <name Identifier> from <currencyUnitFrom Identifier> to <currencyUnitTo Identifier> |
-
value - The charge's value
- This may be any expression that resolves to a number, therefore, a number, a calculation such as
(10+6)
, or a context object
- This may be any expression that resolves to a number, therefore, a number, a calculation such as
-
name - The variable that stores the conversion result
-
currencyUnitFrom - The monetary unit (such as Euro, Dollar) to convert from, as defined in the Rater configuration
-
currencyUnitTo - The monetary unit (such as Euro, Dollar) to convert to, as defined in the Rater configuration
Example
1 | And convert myCredit as specialCredit from Euro to Cent |
Calculating the Charge with Conversion ¶
The following step calculates the charge and converts it to another unit. For example, from Euro to Cent.
Syntax
1 2 | calculate the charge for <amount Number> of <tariff Identifier> converted from <currenctUnitFrom Identifier> to <currencyUnitTo Identifier> as <name Identifier> |
Parameters
-
amount - One of call duration in seconds or the number of SMS sent
-
tariff - The tariff defined in the Rater
-
currenctUnitFrom - The monetary unit (such as Euro, Dollar) to be converted from, as defined in the Rater configuration
-
currencyUnitTo - The unit to convert to, as defined in the Rater configuration
-
name - Stores the conversion result
Example
1 2 | And calculate the charge for 20 of CH_01 converted from Euro to Cent as callCostMOC |
Calculating the Rounded Call ¶
The following step returns a rounded value for the call duration and calculates the resulting charge.
Syntax
1 2 | calculate the rounded call duration for <amount Number> of <tariff Identifier> as <name Identifier> |
Parameters
-
amount - The call duration in seconds
-
tariff - The tariff defined in the Rater
-
name - The variable that stores the conversion result
Example
1 | And calculate the rounded call duration for 65 of CH_02 as roundedIncrement |
In the example above, if the billing increment was defined as 60:30
in the Rater, the call curation of 65
seconds returns 90
according to the charge used.