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