NAS - Rating Calculation



Calculation Logic

Short Call Threshold

 
if (actual_duration < short_call_threshold)
Skip Rating and no charge


Duration

 
if (actual_duration < min_duration)
duration = min_duration)
else
duration = (round up to duration_increment)(actual_duration – min_duration) + min_duration


Charge

 
if (duration * rate <= min_charge)
charge = min_charge + ExtraCharge
else
charge = duration * rate + ExtraCharge


Long Call Charge

 
if (duration >= LongCallStart)
charge += LongCallExtra
if ((LongCallInc != 0) && (duration - LongCallStart > LongCallInc * N))
charge += LongCallExtra * N
{where N is amount of increments over the start time}


Disconnect Fee

 
if (duration >= LongDiscStart)
charge += LongDiscExtra

For Real Time Rating, Disconnect Fee is only applied upon disconnect, and not applied when checking accumulated charges against available balance at the beginning or during the middle of a call.

Tax

 
charge = charge + (charge * tax)

For Real Time Rating, Tax is only applied upon disconnect, and not applied when checking accumulated charges against available balance at the beginning or during the middle of a call.

Table Structures

Structure of Rate Plan Entry

Name type Descriptions
RatePlan varchar Name of the Rate Plan
Domain
varchar Domain of the Rate Plan
PlanDescription varchar Description for reference
Tax Grace Period
varchar Grace Period from 1st Use to not charge Tax
Long Call Grace Period
varchar Grace Period from 1st Use to not charge Long Call Fee
Disconnect Fee Grace Period varchar Grace Period from 1st Use to not charge Disconnect Fee
Short Call Threshold
integer
Calls below this duration in second incur no charge
Ceiling Duration Unit
yes or no
Ceiling to the next Unit Duration Greater or Equal to the Actual Duration
Next Rate Plan
varchar
Next Rate Plan to chain to


Structure of Rate Table Entry

Name type Descriptions
RateEntryID int
A system-wise unique ID for this Rate Entry
RatePlan varchar
Name of the Rate Plan that this entry belong to
Domain
varchar
Domain of the Rate Plan that this entry belong to
TermPrefix varchar Termination Prefix (cannot be “*”)
TermDomain varchar Termination Domain (“*” for all)
OrigPrefix
varchar Origination Prefix (“*” for all)
OrigDomain varchar Origination Domain (“*” for all)
LERG Class
varchar
LERG Class
0 - not classified
1 - Inter-State, Inter-LATA
2 - Inter-State, Intra-LATA
3 - Intra-State, Inter-LATA
4 - Intra-State, Intra-LATA
5 - Local
DayOfWeek varchar Day of Week Match pattern (0..6, Sunday==0, or “*” for all)
HourOfDay varchar Hour of Day Match pattern (A..X, or “*” for all)
Bucket ID
varcharMinute Bucket ID to apply
Tax ID
varcharTax ID to apply
Rate double Charge per second (dollar)
MaxDuration
int Maximum duration (second) that the call should be allowed to continue. "0" imply no limit.
MinDuration int
Minimum charged duration (second)
UnitDuration int
Charged duration increment (second)
ExtraCharge double Extra charge (dollar)
Tax double
Tax to apply to all charges
LongCallExtra double Long Call Extra Charge
LongCallStart int
Time threshold to apply Long Call Charge
LongCallInc int
Time increment for each additional Long Call Charge
LongDiscExtra double Disconnect Fee
LongDiscStart int
Time threshold to apply Disconnect Fee
ValidFrom datetime Start of effective date (yyyy-mm-dd hh:mm:ss)
ValidTo datetime
End of Effective date (yyyy-mm-dd hh:mm:ss)
EntryStatus varchar
“active” or “inactive”