Prepaid Logic
Explanation
It is applied to Prepaid users only.
In /etc/asterisk/mor.conf value frozen_time describes the maximum time for the call of prepaid users.
When user makes call, his balance is frozen by the amount which is necessary to make maximum length of the call (frozen_time).
If user talks less time - his part of the balance is unfrozen and correct amount is deducted.
If user talks time which is equal to frozen_time, then his call end automatically after frozen_time minutes.
Example
/etc/asterisk/mor.conf frozen_time = 3
Call minute to Lithuania MOB costs 0.2 EUR/min
Prepaid user in his balance has 8 EUR.
When user makes first call to Lithuania MOB:
- MOR freezes his balance worth of 6 EUR (30 min * 0.2 EUR/min)
- Now user has 8 EUR in his balance where 6 EUR are frozen (2 EUR left free).
- Call limit for this call is 30 minutes
When user makes second call to Lithuania MOB (first call is in progress):
- MOR freezes remaining 2 EUR of user not-frozen balance
- Now user has 8 EUR frozen balance and 0 left as unfrozen
- Call limit for this call is 10 min (2 EUR / 0.2 EUR/min)
When user makes third call to Lithuania MOB (first and second calls are in progress):
- Call is dropped because no free balance to cover the call
When user hangups first call, lets say after 12 minutes:
- His balance is unfrozen by 6 EUR
- His balance is deducted for 2.4 EUR (12min * 0.2 EUR/min), so now user will have total balance 5.6 EUR (8 - 2.4) where 2 EUR is still frozen by second call.
- Now user can make 4th call why 2nd is still in progress, and the length of the 4th call would be (5.6 - 2) / 0.2 = 18 minutes
When user hangups second call which length is say 9 minutes (and there were no 4th call) then we have such situation:
- Balance is unfrozen by 2 EUR
- Call price is 9 * 0.2 = 1.8 EUR, so users balance will be 5.6 - 1.8 = 3.8 EUR. And non of this amount is frozen.
If user talks 10min in second call - this call is ended by system automatically.
Such logic does not allow any loss to the system owner. It applies more strict rules but this payoffs in a long run.
Special case
(Active from app_mor.so 0.7.2)
When only 1 simultaneous call is allowed for device and/or user (Call Limit = 1) then frozen_balance is not used.
E.g. Call will last till balance will run out.
NOTE: 2 hours is hardcoded call limit for all calls. If balance allows longer calls then 2 hours - call will be limited to 2 hours.
If 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 with duration 2h, and ONLY if it is enough balance to cover for frozen_time - device D2 calls will be limited to frozen_time.
Calling Card calls are always limited to 1 call. E.g. at same time calling card can make only 1 call (for whole available balance).
Questions
Q. What would happen if an user has balance lower than the cost of a "maximum duration" call?
A. User will be allowed to talk only such amount which is covered by his balance. Example: Maximum duration = 2h. User has enough balance for 1h. So his call will be limited to 1h. After 1h his call will end (system will terminate it) and you will not take any loss.