[Spce-user] Problems with rate-o-mat?

Mario Contreras mario.contreras at innovasur.com
Wed Oct 17 06:00:08 EDT 2012


Hi all,

I have realized that since I upgraded to 2.6 rate-o-mat has been rating 
all calls incorrectly. I saw the problem because all calls' cost was the 
real cost plus all previous costs.

First at all, if I understand correctly the cash_balance and the 
cash_balance_interval they mustn't be negatives, right? Maybe I just 
worried, but I think here is a better solution.

 From line 531 of rate-o-mat:

if($pinfo->{use_free_time} && $balance{free_time_balance} > 0)
{
     if($balance{free_time_balance} != 0){
         if($balance{free_time_balance} - $$r_duration > 0){
             $balance{free_time_balance} -= $$r_duration;
             $$r_cost = 0;
             $$r_free_time += $$r_duration;
             $balance{free_time_balance_interval} += $$r_duration;
         } else {
             $$r_cost *= $balance{free_time_balance} / $$r_duration;
             $$r_free_time += $$r_duration - $balance{free_time_balance};
             $balance{free_time_balance_interval} += $$r_free_time;
             $balance{free_time_balance} = 0;
         }
     }
}

if($$r_cost)
{
     if($balance{cash_balance} == 0){
         $balance{cash_balance_interval} += $$r_cost;
     } else {
         if(($balance{cash_balance} - $$r_cost) > 0){
             $balance{cash_balance} -= $$r_cost;
         } else {
             $$r_cost = $$r_cost - $balance{cash_balance};
             $balance{cash_balance_interval} += $$r_cost;
             $balance{cash_balance} = 0;
         }
     }
}



I hope it can help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sipwise.com/mailman/private/spce-user_lists.sipwise.com/attachments/20121017/e9ae5647/attachment.html>


More information about the Spce-user mailing list