Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Fri Mar 29, 2024 11:58 am
Hosted Voice Broadcast


All times are UTC




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Card in use not being reset to 0
PostPosted: Tue Jul 24, 2012 2:56 pm 
Offline

Joined: Thu Apr 21, 2011 5:22 pm
Posts: 106
Vulcan,

Thanks a million. Will implement these fixes and see if they help.

Thanks again


Top
 Profile  
 
 Post subject: Re: Card in use not being reset to 0
PostPosted: Fri Aug 10, 2012 6:04 pm 
Offline

Joined: Thu Apr 21, 2011 5:22 pm
Posts: 106
After all these fixes, issue is still there. in_use flag not being reset to 0. Noticed this only happens to customers that run out of credit i.e where the system hangs the call after rather than the customer pressing end or cancelling the call.


Top
 Profile  
 
 Post subject: Re: Card in use not being reset to 0
PostPosted: Sat Aug 11, 2012 10:05 am 
Offline

Joined: Mon Jan 08, 2007 6:56 pm
Posts: 345
Did you execute the patch or made changes manually? If you installed it manually, then you need to post the changes you made.


Top
 Profile  
 
 Post subject: Re: Card in use not being reset to 0
PostPosted: Sun Aug 12, 2012 7:47 pm 
Offline

Joined: Thu Apr 21, 2011 5:22 pm
Posts: 106
Dear Vulcan,

Here are the changes i made : Here is the scenario that this happens. I have replicated the issue several times and it happens every time.

1. Caller has a balance of $1. With a promotion ( Package offer ) of 5 free minutes.
2. Caller Dials a destination costing 0.15 per minute.
3. System announces " You have 11 minutes " ( this is 5 minutes from balance and 5 minutes from promotion which is correct).
4. Just at the beginning of the 11th minute system announces " You have 61 seconds left".
5. After 30 seconds, system announces you have 31 seconds left".
6. Exactly at 10th minute, call drops with message " You don't have enough credit" (prepaid-no-enough-credit-stop )

Now user cannot use account again because in_use value is not updated back to 0 and balance is -0.495 USD.

I have replicated this scenario 100 times and every time is thesame.


Code:
--- New Class.A2Billing.php
+++ OLD Class.A2Billing.php

@@ -766,14 +766,13 @@
   function enough_credit_to_call()
   {   
      if ($this->typepaid == 0) {

-                        if ($this->credit < $this->agiconfig['min_credit_2call'] || $this->credit <= 0 ) {   
+         if ($this->credit < $this->agiconfig['min_credit_2call'] || $this->credit < 0 ) {
            return false;
         } else {
            return true;
         }
      } else {
-         if ($this->credit <= 0) {   
+         if ($this->credit <= -$this->creditlimit) {
            $QUERY = "SELECT id_cc_package_offer FROM cc_tariffgroup WHERE id= ".$this->tariff ;
            $result = $this -> instance_table -> SQLExec ($this->DBHandle, $QUERY);
            if (!empty($result[0][0])) {
@@ -1164,7 +1163,7 @@
            if ($this->agiconfig['busy_timeout'] > 0)
               $res_busy = $agi->exec("Busy ".$this->agiconfig['busy_timeout']);
            $agi-> stream_file('prepaid-isbusy', '#');
-         } elseif ($dialstatus == "NOANSWER") {
+         } elseif ($this->dialstatus == "NOANSWER") {
            $answeredtime = 0;
            $agi-> stream_file('prepaid-noanswer', '#');
         } elseif ($dialstatus == "CANCEL") {

@@ -1319,8 +1318,7 @@
                     continue;
               } elseif ($dialstatus == "CANCEL") {
                  // Call cancelled, no need to follow-me
-                  $answeredtime = 0;
+                  return 1;
               } elseif ($dialstatus == "ANSWER") {
                  $this -> debug( DEBUG, $agi, __FILE__, __LINE__,
                              "[A2Billing] DID call friend: dialstatus : $dialstatus, answered time is ".$answeredtime." \n");
@@ -1461,8 +1459,7 @@
               }
                 }
             } else {

-                              if ($this->credit <= 0) {   
+            if ($this->credit <= -$this->creditlimit) {
               $time2call =0;
            } else {
               $credit_without_charge = $this->credit + abs($this->creditlimit) - abs($connection_charge);
@@ -1526,8 +1523,7 @@
                     // Dial(IAX2/[email protected]/s@default)
                     $myres = $this -> run_dial($agi, $dialstr);
                     $this -> debug( INFO, $agi, __FILE__, __LINE__, "DIAL $dialstr");
-                 } elseif ( $time2call > 0) {    // prevent 0 time to call on follow me
+                } else {
                     
                     $this -> debug( INFO, $agi, __FILE__, __LINE__, "TIME TO CALL : $time2call");
                     $this -> fct_say_time_2_call($agi,$time2call,$selling_rate);
@@ -1547,8 +1543,6 @@
                         $myres = $agi->exec("StopMixMonitor");
                         $this -> debug( INFO, $agi, __FILE__, __LINE__, "EXEC StopMixMonitor (".$this->uniqueid.")");
                     }
-                } else {
-                    continue;
                 }

                 $answeredtime    = $agi->get_variable("ANSWEREDTIME");
@@ -1571,14 +1565,14 @@
               $agi-> stream_file('prepaid-isbusy', '#');
               if (count($listdestination)>$callcount)
                  continue;
-                 } elseif ($dialstatus == "NOANSWER") {
+                } elseif ($this->dialstatus == "NOANSWER") {
               $answeredtime = 0;
               $agi-> stream_file('prepaid-callfollowme', '#');
               if (count($listdestination) > $callcount)
                  continue;
                 } elseif ($dialstatus == "CANCEL") {
               // Call cancelled, no need to follow-me
-               $answeredtime = 0;
+               return 1;
                 } elseif ($dialstatus == "ANSWER") {
               $this -> debug( DEBUG, $agi, __FILE__, __LINE__,
                           "[A2Billing] DID call friend: dialstatus : $dialstatus, answered time is ".$answeredtime." \n");







Top
 Profile  
 
 Post subject: Re: Card in use not being reset to 0
PostPosted: Mon Aug 13, 2012 2:02 pm 
Offline

Joined: Mon Jan 08, 2007 6:56 pm
Posts: 345
I think you have multiple copies of ClassA2billing.php.

Read this thread, and near the end you will find how to remedy this.

viewtopic.php?f=34&t=9243


Top
 Profile  
 
 Post subject: Re: Card in use not being reset to 0
PostPosted: Mon Aug 13, 2012 5:00 pm 
Offline

Joined: Thu Apr 21, 2011 5:22 pm
Posts: 106
Hi Vulcan,

I have checked and I do have just a single Class.A2billing.php.
I am using symbolic links to link to this file located at : /usr/local/src/a2billing/common/lib/Class.A2Billing.php


Top
 Profile  
 
 Post subject: Re: Card in use not being reset to 0
PostPosted: Tue Aug 14, 2012 4:11 pm 
Offline

Joined: Thu Apr 21, 2011 5:22 pm
Posts: 106
I have captured some logs to help troubleshoot this. See Below starting from when the system announces the amount of seconds left for the call.

Initial customer balance : $1
Package offer : 300 free seconds. ( 5 Minutes)
Rate of Dialed Destination : 0.45/min

As you can see, customer ended up with a credit of $ -2.15.
Card Inuse is never updated.




-- <SIP/####> Playing 'vm-youhave.slin' (language 'en')
-- <SIP/####> Playing 'digits/60.slin' (language 'en')
-- <SIP/####> Playing 'queue-seconds.slin' (language 'en')

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: Card in use not being reset to 0
PostPosted: Thu Aug 16, 2012 9:10 pm 
Offline

Joined: Mon Jan 08, 2007 6:56 pm
Posts: 345
Try setting the "number_try" to greater than 1 and "notenoughcredit_cardnumber" to yes in the confx and see what happens. This is a way to work-around the problem when prepaid balance goes into negative. In other words, when balance is less than mini_credit_2call at the end of a call.



One way to fix it in the case when balance happens to be less than mini_credit_2call due to any other errors during call, is to add these lines after line 427 of a2billing.php (v1.9.4)

Code:
               if ($A2B->set_inuse==1)
                  $A2B->callingcard_acct_start_inuse($agi,0);


All the other changes you made pertaining to the "inuse" issue are valid for other modes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Auto Dialer Software


All times are UTC


Who is online

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