Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Tue Apr 16, 2024 5:21 am
Hosted Voice Broadcast


All times are UTC




Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: call timeout on callback
PostPosted: Sun Jun 10, 2007 4:43 pm 
Offline

Joined: Mon Aug 21, 2006 11:03 pm
Posts: 34
Location: Livorno - Italy
Hi,
I'm testing callback on 1.3 and i notice what seems a bug.

The first leg is billed also if the called party is not answering and this is ok.
But when a2billing callback me, i dial the destination and for example i've 1.0 euro, a2billing doesn't consider in the timeout calculation (and so in the ivr telling me how much time i've) the rate used to the callback in act.
So, if a2billing is callingback me at 0.10/minutes, i've 1 credit, and i'm dialing a destination of 0.5/minutes rate. A2billing seems to calculate the timeout so:
1 credit / 0.5
instead of
1 credit / (0.10+0.5)

At the end of the call, anyway, a2billing consider the 1st leg and so happen that the credit go in negative.

Comments?

I'll start to check the code now because i think this could be an important bug :(

Regards,
Alessandro Marzini
DIGILAB


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 10, 2007 5:07 pm 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
Hello digilab,

I also think that this is a very important bug. I am using a2billing 1.2.3 and I am having the same problem. I was in the process of installing a2bliing 1.3 hoping that this bug would have been reported in the past and fixed in the new version. But you post tells me that the bug is still there.

So my only way around it is to look closely at the code and see what I can do. I will post a fix if I find any.


Top
 Profile  
 
 Post subject: callback wrong timeout
PostPosted: Mon Jun 11, 2007 8:48 am 
Offline

Joined: Mon Aug 21, 2006 11:03 pm
Posts: 34
Location: Livorno - Italy
asiby wrote:
Hello digilab,

I also think that this is a very important bug. I am using a2billing 1.2.3 and I am having the same problem. I was in the process of installing a2bliing 1.3 hoping that this bug would have been reported in the past and fixed in the new version. But you post tells me that the bug is still there.

So my only way around it is to look closely at the code and see what I can do. I will post a fix if I find any.


Hi,
in a2billing 1.3 the problem of the first leg billing is solved, even if the calling party doesn't digit any number.

But the main problem is that ivr tell to the calling party that he have much more time respect what he should have (due the callback in progres).

I'll try to investigate in the a2billing code.
I'll post here the patch.

Regards,
Alessandro Marzini
DIGILAB / YOUPHONE


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 11, 2007 2:06 pm 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
Yep digilab, you are right. We have made some test and the 1st leg billing works a little better. There is still a problem though. Let's say that the calling rate of one of your callback clients is 10¢/min, and let's assume that this client only has 5¢ left in his account. The callback daemon should not call him back, right? (not enough balance) Unfortunately, currently, it does call the customer back. So if the customer olds the line for 1 minute or less, you will end up with a negative balance of -5¢. I have track down this bug to the function ...

Code:
function rate_engine_calcultimeout (&$A2B, $credit, $K=0, $calling_party = ''){
      ...
      $this -> ratecard_obj[$K]['timeout']=0;
      /*
      Comment from Abdoulaye Siby
      This following "if" statement used to verify the minimum credit to call can be improved.
      This mininum credit should be calculated based on the destination, and the minimum billing block.
      */
      if ($credit < $A2B->agiconfig['min_credit_2call']) return "ERROR CT1";  //NO ENOUGH CREDIT TO CALL THIS NUMBER
      ...
}


... located in the file Class.RateEngine.php

As for the call duration of the call, it will have to might be fixed by take the 2 kinds of calculation : progressive rate :x and flat rate

I believe that the following code in the rate_engine_calcultimeout() function in Class.RateEngine.php is responsible for bug we are trying to fix.

Code:
// 2 KIND OF CALCULATION : PROGRESSIVE RATE & FLAT RATE
// IF FLAT RATE
if (empty($chargea) || $chargea==0 || empty($timechargea) || $timechargea==0 ){
         
   /*
   Comment from Abdoulaye Siby
   In all-callback or cid-callback mode, the number of minutes for
   the call should be calculated according to the rate of both legs of the call.
   */
   $num_min = $credit/$rateinitial;
   /*
   This should look like :
   $num_min = $credit/($rateinitial + $first_leg_rate);
   */


   if ($this -> debug_st) echo "num_min:$num_min ($credit/$rateinitial)\n";   
   $num_sec = intval($num_min * 60);
   if ($this -> debug_st) echo "num_sec:$num_sec \n";

   if ($billingblock > 0) {
      $mod_sec = $num_sec % $billingblock;    
      $num_sec=$num_sec-$mod_sec;
   }
         
   $TIMEOUT = $num_sec;

   // IF PROGRESSIVE RATE
}else{
   ...
}


I am trying to figure out a way to calculate $first_leg_rate without breaking the code. The main problem I am experiencing is that when you call either of the following functions, they will simply return 1 or 0 (true or false) for success or failure. They will, on the other hand, change the $RateEngine object accordingly. This makes it a bit difficult to reuse the same functions with other parameters without disturbing the smooth flow of a2billing.

Code:
function rate_engine_findrates (&$A2B, $phonenumber, $tariffgroupid) ...

function rate_engine_all_calcultimeout (&$A2B, $credit) ...


I am bit stuck. Any ideas?


Top
 Profile  
 
 Post subject: Call timeout on callback (POSSIBLY SOLVED)
PostPosted: Tue Jun 12, 2007 4:44 am 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
I have partly solved the problem.

To summarize, I have manage to get the rate for the 1st leg of the callback, then I have sent it to the AGI and variable. During the 2nd phase of the callback, the variables are brought back into a2billing.php and sent down the line until it reaches the place where the calculations are madeThe files that are affected are :

- a2billing.php
- Class.RateEngine.php
- Class.A2Billing.php

My A2Billing were to deeply customized. That makes it almost impossible to create a diff file that will not corrupt your installation.

Give me a day or 2, and I will release the instructions that you will we able to apply step by step.

This 1st fix target the cid-callback because it has a higher priority for us. Later on, I will make the same changes for the all-callback and web-callback as well.

Another thing, the fix doesn't affect the progressive billing scheme of a2billing, and it doesn't consider the connection or disconnection fees. Again, that's because we are not using those features. I will look into those later.

Here is what happen when I call:

- Account balance: 50¢
- Callback rate (calling number): 10¢/minute
- Destination (called number): 2¢/minute

After a successful callback, and dialing the destination, the system says that I have 4 minutes. Let's check that out!

time_to_call = credit / (callback_rate + destination_rate)

this becomes ...

time_to_call = 50 / 12 = 4.1667 minutes

Problem "almost" solved.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 9:10 am 
Offline

Joined: Fri Jun 01, 2007 5:12 am
Posts: 41
asiby, thank you!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 3:43 pm 
Offline
Moderator
User avatar

Joined: Tue Jun 06, 2006 12:14 pm
Posts: 685
Location: florida
Asiby, I've been talking about this issue since the last version, glad others now see the same issue. Can I make one small suggestion to your algorithm?

Since you are already in the 1st leg call and then you need to wait for the 2nd leg to actually answer - this should take within a minute. So I'd calculate it (assuming we like 1 minute billing) as:

balance - callback_rate / (callback-rate + destination-rate)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 4:18 pm 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
You are totally right krzykat,

This morning, we have noticed that all the ending balances were -0.02.

This was due to the duration of the 1st leg that is necessary before we can actually dial anything. The value itself was one of the 2 rates. Since this value has been obtained for a call where both rates were 2¢/min, it's hard to say. But as you have suggested, it's most likely the callback rate that have be applied for an extra minute. I will use your algorithm to fix that problem.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 9:48 pm 
Offline

Joined: Tue Mar 27, 2007 5:23 am
Posts: 93
Is it possible to do this then?

Have Web Callback to run under AGI-CONF11 and have the callback occur then when the client wants to dial out, force it to a trunk that connects to AGI-CONF12 which in return will use the customer's CallerID from the AGI-CONF11 for accounting. Therefore, the AGI-CONF11 will charge for Callback and AGI-CONF12 is a transparent caller which will handle the charging of the next leg of the call.

This way, you end up with 2 charges for the call.

Added after 5 minutes:

krzykat wrote:
Asiby, I've been talking about this issue since the last version, glad others now see the same issue. Can I make one small suggestion to your algorithm?

Since you are already in the 1st leg call and then you need to wait for the 2nd leg to actually answer - this should take within a minute. So I'd calculate it (assuming we like 1 minute billing) as:

balance - callback_rate / (callback-rate + destination-rate)


Or to be safe, try

(balance - callback_rate - min_credit_2call) / (callback-rate + destination-rate)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 6:14 pm 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
Just a little follow up. Thanks for your patience. We are getting there surely. I have finish analyze the code for the A2Billing v1.3 and I have found no issue when fixing the same bug. So the good news is that I will release to fixes. One for v1.2.3 and another one for v1.3.

As of now, the changes will affect 4 files instead of 3:


PostPosted: Mon Jun 11, 2007 11:44 pm Post subject: Call timeout on callback (POSSIBLY SOLVED)
I have partly solved the problem.

To summarize, I have manage to get the rate for the 1st leg of the callback, then I have sent it to the AGI and variable. During the 2nd phase of the callback, the variables are brought back into a2billing.php and sent down the line until it reaches the place where the calculations are madeThe files that are affected are :

- a2billing.php
- libs_a2billing/Class.RateEngine.php
- libs_a2billing/Class.A2Billing.php
- libs_a2billing/phpagi_2_14/phpagi.php

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 6:55 pm 
Offline
Moderator
User avatar

Joined: Tue Jun 06, 2006 12:14 pm
Posts: 685
Location: florida
You da man !!!!

Will patch be for all callback ? or just CID-callback or ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 7:16 pm 
Offline

Joined: Mon Aug 21, 2006 11:03 pm
Posts: 34
Location: Livorno - Italy
Hi!
Can you share your patch?
so we can study on and make some improvement and debugging together.

;)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 13, 2007 7:17 pm 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
It will be for ALL-CALLBACK and CID-CALLBACK.

But honestly, I have never even used the all-callback/web-callback before with a2billing. Some I am not sure about the result on the side. We (the community) will run some test and see what happen :D.

I am looking for the original code for A2Billing v1.2.3 (BrainCoral) on the SVN. But I can't seem to find it. So to create the diff files, I am probably going to have to rely on the zipped package that I have downloaded a while ago. For the version 1.3 (YellowJacket), the diff will be based on the trunk release on the SVN.

I am in the process of sharing it. My version of the files that are affected where to different from the originals. I should be able to share the patches tonight (Eastern Time).

They sure need a lot of improvement, specially with the progressive rate billing (I didn't even touch that part). But the base is there for you to have a lot of fun with it.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 9:01 am 
Offline
User avatar

Joined: Mon Apr 30, 2007 6:43 am
Posts: 1060
Location: Canada
Here is a patch that will modify 4 files as needed. Just copy the file in the /var/lib/asterisk/agi-bin/ directory, and execute the following command in the linux console (I think lol)

To download the patch:

Code:
# wget http://forum.asterisk2billing.org/download.php?id=31


To apply the patch

Code:
# patch <a2b-patch.txt


This patch also fixes the bug that makes a2billing ask for the card number during CID-CALLBACK even if the callerid is provided.

Correction: I have mentioned in my previous post that I have modified the ALL-CALLBACK too. Well, I have decided to revert the modifications since I have never used the ALL-CALLBACK and I am not sure if there is any problem with its timeout calculation.

Let me know if I did something wrong.


Attachments:
a2b-patch.txt [7.94 KiB]
Downloaded 588 times


Last edited by asiby on Sun Jun 17, 2007 12:32 pm, edited 1 time in total.
Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 15, 2007 11:24 am 
Offline

Joined: Mon Aug 21, 2006 11:03 pm
Posts: 34
Location: Livorno - Italy
Good man!
I'm just downloaded the patch and i'll test ;)

Regards,
Alessandro Marzini


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page 1, 2, 3  Next
Hosted Voice Broadcast


All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group