Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Thu Mar 28, 2024 6:11 pm
Predictive Dialer


All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Problem with Balance in V1.2 (and V1.2.1)
PostPosted: Mon Jun 26, 2006 1:47 am 
Offline

Joined: Mon Jun 26, 2006 1:38 am
Posts: 2
I have been testing A2Billing 1.1.0 for about 1 month now and have not had a problem.

Yesterday I installed (in a different server) A2Billing version 1.2 and testing today, I realized that if my balance was $0.10 and made a call where sell rate = $0.10 and sell rate billing block = 60 seconds, and I hung up before the 60 seconds, I would expect my balance to equal $0, instead, it equals $ 1.49012e-09. Installed today A2Billing version 1.2.1 and still having the same problem.

When calling again with the balance of $1.49012e-09, the platform says that I have $1.49, however, when dialing the destination (which costs $0.10/min) it correctly says that I do not have enough funds to make this call. Is there a way to round $1.49012e-09 (or whatever the balance is) to 2 decimal points ($0.00)?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 9:52 pm 
Offline

Joined: Mon Jun 26, 2006 5:19 am
Posts: 14
Location: US
All:

Experiencing the same issue. Setup is as follows:

- Asterisk 1.2.9.1
- PHP 4.3.9 (cgi) (built: Nov 10 2005 14:00:12)
- A2billing 1.2.1

The Database for A2billing 1.2.1 is on a different machine. Eg:

Asterisk --> A2billing DB (MySql)

If there is only 10 cents @ 10 cents a minute setup for example, the result after hanging up before the full minute has ended is:

in cc_card credit=1.49012e-09

This result does not play correctly since the platform seems to interpret as an integer, hence it says: You have 1 dollar and 49 cents if we try to dial another call with the same pin number.

The strange issue is that when trying to modify the code, (just for testing), if we try to do an:

$QUERY = "UPDATE cc_card SET credit= ".round('credit',2)." WHERE username='".$A2B->username."'";

in "Class.RateEngine.php", we are unable to round the value for credit. It makes credit go to zero all the time regardless of how low or high credit is.

Does that seem to indicate an issue with PHP ? If we run the command in the DB by hand it works, it properly rounds the number.

Any help is greatly appreciated.

Thanks,

Alfredo Q-V


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 1:56 pm 
Offline

Joined: Mon Jun 19, 2006 4:36 pm
Posts: 6
lawwton wrote:
All:

Experiencing the same issue. Setup is as follows:

- Asterisk 1.2.9.1
- PHP 4.3.9 (cgi) (built: Nov 10 2005 14:00:12)
- A2billing 1.2.1

The Database for A2billing 1.2.1 is on a different machine. Eg:

Asterisk --> A2billing DB (MySql)

If there is only 10 cents @ 10 cents a minute setup for example, the result after hanging up before the full minute has ended is:

in cc_card credit=1.49012e-09

This result does not play correctly since the platform seems to interpret as an integer, hence it says: You have 1 dollar and 49 cents if we try to dial another call with the same pin number.

The strange issue is that when trying to modify the code, (just for testing), if we try to do an:

$QUERY = "UPDATE cc_card SET credit= ".round('credit',2)." WHERE username='".$A2B->username."'";

in "Class.RateEngine.php", we are unable to round the value for credit. It makes credit go to zero all the time regardless of how low or high credit is.

Does that seem to indicate an issue with PHP ? If we run the command in the DB by hand it works, it properly rounds the number.

Any help is greatly appreciated.

Thanks,

Alfredo Q-V


The original line of code is

$QUERY = "UPDATE cc_card SET credit= credit$signe".abs($cost)." $myclause_nodidcall, lastuse=now(), nbused=nbused+1 WHERE username='".$A2B->username."'";

credit is the field name of the table and you can't use the php round function on it directly. You could try doing the following

$QUERY = "UPDATE cc_card SET credit= credit$signe".round(abs($cost),2)." $myclause_nodidcall, lastuse=now(), nbused=nbused+1 WHERE username='".$A2B->username."'";

or

$QUERY = "UPDATE cc_card SET credit= credit$signe".abs(round($cost,2))." $myclause_nodidcall, lastuse=now(), nbused=nbused+1 WHERE username='".$A2B->username."'";

BTW you should try maybe replacing 2 with 3 or 4 decimal places just to be safe in case you have rates that have more than 2 decimal places.

Disclaimer: I'm not a php programmer so test it before actually using it in production. I haven't tested this changes but they look right.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 2:57 pm 
Offline

Joined: Sun Mar 12, 2006 2:49 pm
Posts: 954
Location: Barcelona
that sounds like a correct solution to me :)
anyone else can confirm the fix ?

Rgds, Areski


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 3:05 pm 
Offline

Joined: Mon Jun 26, 2006 5:19 am
Posts: 14
Location: US
We'll be testing it this afternoon and reply back with the results.

Thanks all for your help,

Alfredo Q-V


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 11:49 pm 
Offline

Joined: Mon Jun 26, 2006 1:38 am
Posts: 2
areski/athos1800,

Worked with Lawwton on this, we seem to have gotten to the same outcome:

------------
DID NOT WORK :-(
------------

$QUERY = "UPDATE cc_card SET credit= credit$signe".abs(round($cost,2))." $myclause_nodidcall, lastuse=now(), nbused=nbused+1 WHERE username='".$A2B->username."'";

------------
DID NOT WORK :-(
------------

$QUERY = "UPDATE cc_card SET credit= credit$signe".round(abs($cost),2)." $myclause_nodidcall, lastuse=now(), nbused=nbused+1 WHERE username='".$A2B->username."'";

----------------
OUR FIX FOR NOW:
----------------

We decided to setup the DB column credit to decimal(8,4). This although does a little bit of rounding seems to do the job well while also eliminating any small values that could be left behind from small balances.

Can't really think of a different way to do it, not even sure why it behaves this way. Is it a problem with php/sql, where we end up with a very small number instead of 0?

For example:

@ .10 cents a minute with a "SellRate Billing Block" = 60,
we would assume that the result of the original query would be zero if either called or calling party hangs up the
call before the minute is over.

$QUERY = "UPDATE cc_card SET credit= credit$signe".abs($cost)." $myclause_nodidcall, lastuse=now(), nbused=nbused+1 WHERE username='".$A2B->username."'";

However, the result seems to always be the same, a very small number # e^-9.

The same command directly in MySql seems to work just fine (considering we change the variables for actual values), even the round seems ok with a direct update.

What do you guys think?

DrioJ
Lawwton


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 02, 2006 8:44 pm 
Offline

Joined: Sun Mar 12, 2006 2:49 pm
Posts: 954
Location: Barcelona
I guess this happens only with mysql

you might try this to modify the DB
ALTER TABLE `cc_card` CHANGE `credit` `credit` DECIMAL( 15, 5 ) DEFAULT '0';

do a backup previously :D
Rgds, Areski


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 03, 2006 12:30 am 
Offline

Joined: Mon Jun 26, 2006 5:19 am
Posts: 14
Location: US
Areski:

Thanks for the help, really appreciate it. We've made the change.

Alfredo Q-V


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 
VoIP Billing solution


All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group