Hi All,
I noticed that when a call is less than initialblock it is still billed at the billingblock rate :
for example,
Initialblock = 60
billingblock = 120
call duration = 32
this call should be billed as Initialblock = 60 , but now with the curent code it is billed at 120 = 2 minutes.
The problem is in Class.RateEngine.php file in this section:
inside the function rate_engine_calculcost(....
Code:
// 2 KIND OF CALCULATION : PROGRESSIVE RATE & FLAT RATE
// IF FLAT RATE
if (empty($chargea) || $chargea==0 || empty($timechargea) || $timechargea==0 ){
if ($billingblock>0) { // <<------- This is where the error is
$mod_sec = $callduration % $billingblock;
if ($mod_sec>0) $callduration += ($billingblock - $mod_sec);
}
$cost -= ($callduration/60) * $rateinitial;
To fix it you only need to change this line
Code:
if ($billingblock>0) {
to
Code:
if (($callduration > $initblock) && ($billingblock > 0)) {
By adding this line you make sure that you do not add any increment to the calls that have durations less then or equal to initialblock.
same thing applies to
Code:
// CALCULATION BUYRATE COST
$buyratecallduration = $callduration;
$buyratecost =0;
if ($buyratecallduration<$buyrateinitblock) $buyratecallduration=$buyrateinitblock;
if ($buyrateincrement > 0) { // <---------------ERROR in here
$mod_sec = $buyratecallduration % $buyrateincrement;
if ($mod_sec>0) $buyratecallduration += ($buyrateincrement - $mod_sec);
}
$buyratecost -= ($buyratecallduration/60) * $buyrate;
to fix it
change this
Code:
if ($buyrateincrement > 0) {
to
Code:
if (($buyratecallduration>$buyrateinitblock) && ($buyrateincrement > 0) {
this
Thank you,
Added after 1 hours 51 minutes: Hi,
Today I have been looking at the code of ClassRateEngine.php and debugging.
I found that if you have this case:
min_duration_2bill = 10 ( or any other number > 0 )
( if there was a problem or the call is less then 10 seconds I don't want to bill the client)
BUT I want to know how much it is costing me, and when i generate a report in order to compare my
buycost with my provider's bill, I
want them to match.After fixing the bug, you will have a much more accurate Profit estimate
- assuming the rest of the code that I havn't checked yet is good
The curent code does not bill the client and sets the buycost to zero.
I prefer to keep my buycost as it is and not zero, this way I know how much it is costing me to keep that min_duration_2bill > 0
Look for this code
Code:
$buycost = 0;
if ($doibill==0 || $sessiontime < $A2B->agiconfig['min_duration_2bill']) $cost = 0;
else{
$cost = $this -> lastcost;
$buycost = abs($this -> lastbuycost);
}
and change the first line to
Code:
$buycost = abs($this -> lastbuycost);
thanks,