Ronald Wiplinger
2005-Jul-23  03:28 UTC
[Asterisk-Users] ASTCC gives me only the time, but no cost
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};
--x                    my $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/901185228376786@Line-optimize-3a9b,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
Darren Wiebe
2005-Jul-23  06:42 UTC
[Asterisk-Users] ASTCC gives me only the time, but no cost
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
darren@aleph-com.net
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};
> --x                    my $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/901185228376786@Line-optimize-3a9b,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
>
Ronald Wiplinger
2005-Jul-23  07:32 UTC
[Asterisk-Users] ASTCC gives me only the time, but no cost
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