Prepaid Logic

From Kolmisoft Wiki

Jump to: navigation, search


[edit] Explanation

Prepaid Logic applies only to Prepaid users.

In /etc/asterisk/mor.conf value, frozen_time describes the maximum time for calls by prepaid users.

When a user makes a call, his balance is frozen by the amount which is necessary to make the maximum length of the call (frozen_time).

If the user talks for less time, his part of the balance is unfrozen and the correct amount is deducted.

If the user talks for a time which is equal to frozen_time, then his call ends automatically after the frozen_time minutes are up.

[edit] Example

/etc/asterisk/mor.conf frozen_time = 30

A call minute to Lithuania MOB costs 0.2 EUR/min.

A prepaid user has 8 EUR in his balance.

When the user makes his first call to Lithuania MOB:

  • MOR freezes his balance of 6 EUR (30 min * 0.2 EUR/min).
  • Now the user has 8 EUR in his balance with 6 EUR frozen (2 EUR left free).
  • The call limit for this call is 30 minutes.

When the user makes a second call to Lithuania MOB (the first call is in progress):

  • MOR freezes the remaining 2 EUR from the user's unfrozen balance.
  • Now the user has 8 EUR frozen balance and 0 left as unfrozen.
  • The call limit for this call is 10 min (2 EUR / 0.2 EUR/min).

When the user makes a third call to Lithuania MOB (the first and second calls are in progress):

  • The call is dropped because there is no free balance to cover the call.

When the user hangs up his first call, let's say after 12 minutes:

  • His balance is unfrozen by 6 EUR.
  • 2.4 EUR (12min * 0.2 EUR/min) is deducted from the user's balance, so now the user will have a total balance of 5.6 EUR (8 - 2.4), where 2 EUR is still frozen by the second call.
  • Now the user can make a fourth call while the second is still in progress, and the maximum length of the fourth call would be (5.6 - 2) / 0.2 = 18 minutes.

If the user hangs up his second call, say with a length of 9 minutes and there is no fourth call, we have this situation:

  • The balance is unfrozen by 2 EUR.
  • The call price is 9 * 0.2 = 1.8 EUR, so the user's balance will be 5.6 - 1.8 = 3.8 EUR, and none of this amount is frozen.

If the user talks for 10 minutes in the second call, this call is automatically ended by the system.

This logic prevents any loss to the system owner. It applies stricter rules, but this pays off in the long run.

[edit] Special case

When only one simultaneous call is allowed for the device and/or user (Call Limit = 1), then frozen_balance is not used.

Example #1: If User/Device is limited to only one call at a time, he can use all his remaining balance for the call (if the user is prepaid).

Example #2: Call will last till balance runs out.

NOTE: Two hours is the hardcoded call limit for all calls. Even if the balance allows longer calls than two hours, the call will still be limited to two hours.

If the user has Call Limit not 1, but his one device (D1) has Call Limit == 1 and another device (D2) Call Limit not 1 , then device D1 will be able to make 1 simm. call two hours in duration , and ONLY if the balance is sufficient to cover for frozen_time. Device D2 calls will be limited to frozen_time.

Calling Card calls are always limited to one call - that is, a calling card can make only one call (for whole available balance) at a time.

[edit] Questions

Q. What would happen if a user has a balance lower than the cost of a "maximum duration" call?
A. The user will be allowed to talk only for the time that is covered by his balance. Example: maximum duration = 2 hours. If a user has enough balance for one hour, his call will be limited to one hour. After one hour, his call will end (the system will terminate it) and you will not take any loss.

[edit] New Prepaid Logic (from MOR X5/M2)

Now User can make as many calls as he wants. His balance is checked every few seconds. When balance goes near zero - all calls are terminated.

[edit] See also

Personal tools


Try M2