RE: [Asterisk-Users] ASTCC gives me only the time, but no cost

2005-07-24 Thread Rusty Shackleford
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Darren Wiebe
 Sent: Saturday, July 23, 2005 3:09 PM
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: Re: [Asterisk-Users] ASTCC gives me only the time, 
 but no cost
 
 
 Thank you very, very much Rusty.  I reopened the bug report. 
 http://bugs.digium.com/view.php?id=4479  I made a very slight 
 change to 
 the method it uses to calculate costs but it should implement the 
 connect charge properly.  Initially I rewrote the cost 
 calculation code 
 but that was not necessary, it can be implemented by changing the 
 following lines
 my $adjtime = int(($answeredtime + $increment - 1) / $increment) * 
 $increment
 
 becomes
 
 $adjtime = int((($answeredtime - $numdata-{includedseconds}) + 
 $increment - 1) / $increment) * $increment

This can yield a negative number, where $answeredtime 
includedseconds, can it not?

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.4/57 - Release Date: 07/22/2005
 

___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] ASTCC gives me only the time, but no cost

2005-07-23 Thread Darren Wiebe

The problem is in the line beginning with eval.  It should read as follows.

   my $adjtime = eval { $adjtime = int((($answeredtime - 
$numdata-{includedseconds}) + $increment - 1) / $increment) * $increment;

   return $adjtime };

Darren Wiebe
[EMAIL PROTECTED]

Ronald Wiplinger wrote:

I try to track down an error that causes that Astcc just reports the 
time, but not the costs.



I could narrow the problem down into this sub routine:


sub calccost() {
my ($adjconn, $adjcost, $answeredtime, $increment) = @_;
eval { my $adjtime = int(($answeredtime + $increment - 1) / 
$increment) * $increment };

my $cost;
print STDERR Adjusted time is $adjtime, cost is $adjcost with 
$adjconn fee\n;

eval { $cost = int($adjcost * $adjtime / 60) };
$cost += $adjconn;
print STDERR Total cost is $cost\n;
return $cost;


I have added changes some lines

   } elsif ($res eq ANSWER) {
--my $increment = $carddata-{inc};
--xmy $cost = calccost($adjconn, $adjcost, 
$answeredtime, $increment);
--print STDERR  adjconn is $adjconn\n adjcost is 
$adjcost\n answeredtime is $answeredtime\n \

   inc is $carddata-{inc}\n increment is $increment;
   $carddata-{used} += $cost;
   print STDERR Total used is now $carddata-{used}\n;
   savecdr($cardno, $callerid, $phoneno, $trunk, 
$res, $answeredtime, $cost,$callstart);

   savedata($carddata);


The result is:
[Jul 23 12:20:29]   == Spawn extension (Line-optimize, 
901185228376786, 512) exited non-zero on 
'Local/[EMAIL PROTECTED],2'

res is ANSWER, answered time is 26
Adjusted time is , cost is 603 with 0 fee
Total cost is 0
adjconn is 0
adjcost is 603
answeredtime is 26
inc is 6
Total used is now 70

Why? What do I need to correct?


bye

Ronald Wiplinger
[Jul 23 12:20:29] -- AGI Script astcc.agi completed, returning 0






___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users



___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] ASTCC gives me only the time, but no cost

2005-07-23 Thread Ronald Wiplinger

Darren Wiebe wrote:

The problem is in the line beginning with eval.  It should read as 
follows.


   my $adjtime = eval { $adjtime = int((($answeredtime - 
$numdata-{includedseconds}) + $increment - 1) / $increment) * 
$increment;

   return $adjtime };


Thanks, I solved it by removing $adjtime = eval

Are  there other errors in the cvs  verion?


bye

Ronald Wiplinger

___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] ASTCC gives me only the time, but no cost

2005-07-23 Thread Darren Wiebe
The included seconds field is not taken into account when billing the 
connect charge.  IMHO this is a bug but I've not gotten enough feedback 
to put the patch through.  Therefore the patch has been closed. :-)


Darren Wiebe
[EMAIL PROTECTED]

Ronald Wiplinger wrote:


Darren Wiebe wrote:

The problem is in the line beginning with eval.  It should read as 
follows.


   my $adjtime = eval { $adjtime = int((($answeredtime - 
$numdata-{includedseconds}) + $increment - 1) / $increment) * 
$increment;

   return $adjtime };


Thanks, I solved it by removing $adjtime = eval

Are  there other errors in the cvs  verion?


bye

Ronald Wiplinger

___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users



___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


RE: [Asterisk-Users] ASTCC gives me only the time, but no cost

2005-07-23 Thread Rusty Shackleford

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Darren Wiebe
 Sent: Saturday, July 23, 2005 8:08 AM
 To: Asterisk Users Mailing List - Non-Commercial Discussion
 Subject: Re: [Asterisk-Users] ASTCC gives me only the time, 
 but no cost
 
 
 The included seconds field is not taken into account when billing the 
 connect charge.  IMHO this is a bug but I've not gotten 
 enough feedback 
 to put the patch through.  Therefore the patch has been closed. :-)

I spent an afternoon going through that code again, Darren. You were
right. If we assume that the intent was to use the includedseconds
column value as a way to allow for x/y billing intervals, and set
connectcost to the value that we want to charge for the call minimum
charge - x, the stock code charges that amount, but also starts the
meter running on the y value from the start of the call, resulting in
an over charge. The y value, by the way, is set in the brands table
and flows to the cards table when cards are created (breaking
normalization). For example, we have a route to McMurdo Station for
which we charge $.50 per minute, in six second increments with a 30
second minimum (30/6). If we set the connect charge column to $.25, the
included seconds to 30, and the cost to $.50, a 30 second call should
cost $.25. Instead, it's costing $.50, because ASTCC charged the connect
fee, plus the cost of 5 six second increments - $.25. It shouldn't start
charging those six second increments until AFTER the includedseconds
interval has passed. 

I've patched by scripts to correct this. It would be nice if the
correction were made to the distributed source, perhaps with some
documentation of how things are supposed to work.

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.4/57 - Release Date: 07/22/2005
 

___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [Asterisk-Users] ASTCC gives me only the time, but no cost

2005-07-23 Thread Darren Wiebe
Thank you very, very much Rusty.  I reopened the bug report. 
http://bugs.digium.com/view.php?id=4479  I made a very slight change to 
the method it uses to calculate costs but it should implement the 
connect charge properly.  Initially I rewrote the cost calculation code 
but that was not necessary, it can be implemented by changing the 
following lines
my $adjtime = int(($answeredtime + $increment - 1) / $increment) * 
$increment


becomes

$adjtime = int((($answeredtime - $numdata-{includedseconds}) + 
$increment - 1) / $increment) * $increment


Anybody that is interested, please feel free to comment on the bug 
report. Once that one goes in, another bug will probably get commited 
that allows you to calculate what ASTCC will charge for a call from the 
web interface.  That makes testing and confirming that you are setting 
it up right much easier.


Darren Wiebe
[EMAIL PROTECTED]


Rusty Shackleford wrote:


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Darren Wiebe

Sent: Saturday, July 23, 2005 8:08 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [Asterisk-Users] ASTCC gives me only the time, 
but no cost



The included seconds field is not taken into account when billing the 
connect charge.  IMHO this is a bug but I've not gotten 
enough feedback 
to put the patch through.  Therefore the patch has been closed. :-)
   



I spent an afternoon going through that code again, Darren. You were
right. If we assume that the intent was to use the includedseconds
column value as a way to allow for x/y billing intervals, and set
connectcost to the value that we want to charge for the call minimum
charge - x, the stock code charges that amount, but also starts the
meter running on the y value from the start of the call, resulting in
an over charge. The y value, by the way, is set in the brands table
and flows to the cards table when cards are created (breaking
normalization). For example, we have a route to McMurdo Station for
which we charge $.50 per minute, in six second increments with a 30
second minimum (30/6). If we set the connect charge column to $.25, the
included seconds to 30, and the cost to $.50, a 30 second call should
cost $.25. Instead, it's costing $.50, because ASTCC charged the connect
fee, plus the cost of 5 six second increments - $.25. It shouldn't start
charging those six second increments until AFTER the includedseconds
interval has passed. 


I've patched by scripts to correct this. It would be nice if the
correction were made to the distributed source, perhaps with some
documentation of how things are supposed to work.

 



___
Asterisk-Users mailing list
Asterisk-Users@lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users