Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Fri Apr 19, 2024 10:06 am
Voice Broadcast System


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Promotion Package causes account to go negative
PostPosted: Wed Aug 15, 2012 9:23 pm 
Offline

Joined: Thu Apr 21, 2011 5:22 pm
Posts: 106
I have discovered that up till now, my customers have actually been charged for the 300 free seconds in package offer. Very dangerous bug in the Class.RateEngine.php

Around line 814, cost of call is calculated :

Code:
$cost -= ($callduration/60) * $rateinitial;   


So if a customer has $1 balance with a 300 free seconds package offer and dials a destination costing 0.14USD/min ( 60 seconds billing increment), his $callduration calculated by Class.RateEngine.php will be 420 seconds ( 7 minutes ).

So his $cost will be - 3.15 USD. Now when his balance is updated at the end of the call, he will end up with a balance of -2.15USD.

This is wrong.

We need to subtract the 300 free seconds from $callduration before calculating the cost of the call. So i added the following if statement to do that.

Code:
   if ($this -> freetimetocall_used <= $callduration)
             {
                 $callduration = $callduration - $this->freetimetocall_used;
        }
    $cost -= ($callduration/60) * $rateinitial;


Below are logs i captured showing the above scenario :

a2billing.php,1: file:Class.RateEngine.php - line:1274 - uniqueid:1344958630.134 - DIAL SIP/###/##########|60|HL(420000:60000:00000)
a2billing.php,1: file:Class.RateEngine.php - line:1157 - uniqueid:1344958630.134 - [TRUNK STATUS UPDATE : UPDATE cc_trunk SET inuse=inuse-1 WHERE id_trunk='8']
a2billing.php,1: file:Class.RateEngine.php - line:1422 - uniqueid:1344958630.134 - -> dialstatus : ANSWER, answered time is 420
a2billing.php,1:
a2billing.php,1: file:Class.RateEngine.php - line:1426 - uniqueid:1344958630.134 - [USEDRATECARD=0]
a2billing.php,1: file:Class.RateEngine.php - line:959 - uniqueid:1344958630.134 - :[sessiontime:420 - id_cc_package_offer:2 - package2apply:Array]
a2billing.php,1:
a2billing.php,1:
a2billing.php,1: file:Class.RateEngine.php - line:736 - uniqueid:1344958630.134 - [CC_RATE_ENGINE_CALCULCOST: K=0 - CALLDURATION:420 - freetimetocall_used=300 - freetimetocall_left=300]
a2billing.php,1: file:Class.RateEngine.php - line:814 - uniqueid:1344958630.134 - [TEMP - CC_RATE_ENGINE_CALCULCOST: 1. COST: -3.15]:[ (420/60) * 0.45 ]
a2billing.php,1: file:Class.RateEngine.php - line:899 - uniqueid:1344958630.134 - [CC_RATE_ENGINE_CALCULCOST: K=0 - BUYCOST:-0.63 - SELLING COST:-3.15]
a2billing.php,1: file:Class.RateEngine.php - line:1000 - uniqueid:1344958630.134 - :[ID_CARD_PACKAGE_OFFER CREATED : 1259]:['620', '2', '300']

a2billing.php,1:
a2billing.php,1:
a2billing.php,1:
a2billing.php,1:
a2billing.php,1: file:Class.RateEngine.php - line:1042 - uniqueid:1344958630.134 - [CC_RATE_ENGINE_UPDATESYSTEM: usedratecard K=0 - (sessiontime=420 :: dialstatus=ANSWER :: buycost=0.63 :: cost=-3.15 : signe_cc_call=+: signe=-)]
a2billing.php,1: file:Class.RateEngine.php - line:1107 - uniqueid:1344958630.134 - [CC_asterisk_stop : SQL: DONE : result=1]
a2billing.php,1: file:Class.RateEngine.php - line:1108 - uniqueid:1344958630.134 - [CC_asterisk_stop : SQL: INSERT INTO cc_call (uniqueid, sessionid, card_id, nasipaddress, starttime, sessiontime, real_sessiontime, calledstation, terminatecauseid, stoptime, sessionbill, id_tariffgroup, id_tariffplan, id_ratecard, id_trunk, src, sipiax, buycost, id_card_package_offer, dnid, destination) VALUES ('1344958630.134', 'SIP/didforsale_Config1B-00000086', '620', '', SUBDATE(CURRENT_TIMESTAMP, INTERVAL 420 SECOND) , '420', '420', '##########', 1, now() , '+3.15', '1', '44', '1448122', '8', '##########', '0', '0.63', '1259', '##########', '#####')]
a2billing.php,1: file:Class.RateEngine.php - line:1132 - uniqueid:1344958630.134 - [CC_asterisk_stop 1.2: SQL: UPDATE cc_card SET credit= credit-3.15 , lastuse=now(), firstusedate=now(), nbused=nbused+1 WHERE username='7635008738']
a2billing.php,1: file:Class.RateEngine.php - line:1137 - uniqueid:1344958630.134 - UPDATE cc_trunk SET secondusedreal = secondusedreal + 420 WHERE id_trunk='8'
a2billing.php,1: file:Class.RateEngine.php - line:1141 - uniqueid:1344958630.134 - UPDATE cc_tariffplan SET secondusedreal = secondusedreal + 420 WHERE id='44'
a2billing.php,1: file:a2billing.php - line:588 - uniqueid:1344958630.134 - [a2billing account stop]
a2billing.php,1: file:a2billing.php - line:193 - uniqueid:1344958630.134 - [CHANNEL STATUS : 6 = Line is up]
a2billing.php,1: [CREDIT : -2.15][CREDIT MIN_CREDIT_2CALL : 0]
a2billing.php,1: file:a2billing.php - line:396 - uniqueid:2344958630.134 - TARIFF ID -> 1
-- Playing 'prepaid-no-enough-credit-stop' (escape_digits=#) (sample_offset 0)
a2billing.php,1: file:a2billing.php - line:403 - uniqueid:2344958630.134 - [STOP STREAM FILE prepaid-no-enough-credit-stop]
a2billing.php,1: file:a2billing.php - line:427 - uniqueid:2344958630.134 - [SET MAIL REMINDER - NOT ENOUGH CREDIT]
-- <SIP/######>AGI Script a2billing.php completed, returning 4
== Spawn extension (call-a2billing, #######, 3) exited non-zero on 'SIP/#####


Top
 Profile  
 
 Post subject: Re: Promotion Package causes account to go negative
PostPosted: Thu Aug 16, 2012 9:29 am 
Offline

Joined: Fri Jun 23, 2006 3:56 pm
Posts: 4065
Hi

Thank you for your efforts on this.

Can you raise an issue at https://github.com/Star2Billing/a2billing/issues

Yours

Joe


Top
 Profile  
 
 Post subject: Re: Promotion Package causes account to go negative
PostPosted: Tue Dec 11, 2012 8:54 pm 
Offline

Joined: Mon Apr 14, 2008 8:37 pm
Posts: 356
Location: Canada
Has this been sorted out as of version 1.9.4?


Top
 Profile  
 
 Post subject: Re: Promotion Package causes account to go negative
PostPosted: Sun Dec 30, 2012 5:46 pm 
Offline

Joined: Thu Apr 21, 2011 5:22 pm
Posts: 106
Unfortunately this patch was never applied to the newest a2b version. I upgraded and problem returned. I had to manually fix it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 
Hosted Voice Broadcast


All times are UTC


Who is online

Users browsing this forum: No registered users and 17 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