Rusty Shackleford wrote:
On Sat, June 18, 2005 2:34 pm, Darren Wiebe said:
Okay, I'll post both pieces of code. What I was seeing is that calls
where being billed more than I thought they should be. Lets use an
example with the following info:
Call Length: 147 Seconds
Increments: 6 Seconds
Connect Charge: 100
Included Seconds: 30
Cost per minute: 100
1. Present Code:
eval { my $adjtime = int(($answeredtime + $increment - 1) / $increment)
* $increment };
# adjtime = 152
This might be where your error is creeping in. $adjtime SHOULD equal 150.
Remember, the int() function removes the value to the right of the decimal
point - so int(($answerdtime + $increment -1) / $increment) = 25 and not
25.333333333~, as your example appears to show. This makes $adjtime
actually 150, not 152.
You are right, I missed the one bracket.
eval { $cost = int($adjcost * $adjtime / 60) };
# cost = 253
Corrected, this would be 250.
Viewed another way, using a 6 second increment, 147 seconds represents 25
such increments (actually 24.5, but we get all of the last increment, so
it's 25).
25 * 10 (the cost of one 6-second increment) = 250.
Yes, but we need to allow for 30,6 6,1 60,30 billing. I think the
easiest/best way to handle this is the connect charges as ASTCC
presently supports them.
$cost += $adjconn;
# Total Cost = 353
2. My Proposed Code:
$total_seconds = ($answeredtime - $numdata->{includedseconds})/$increment;
# Total_Seconds(This variable is not very well named) = 19.5
$bill_increments = ceil($total_seconds);
# We need to bill for 20 6 second increments.
$billseconds = $bill_increments * $increment;
# This translates to 120 seconds.
Which cheats us out of 27 seconds worth of revenue (actually 30 seconds,
since that 27 seconds represents five 6-second increments).
I don't think it does. The 30 seconds come out because that is the
amount included in the connect charge. The connect charge is added back
in here:
$cost = ($billseconds / 60) * $adjcost + $adjconn;
Darren Wiebe
_______________________________________________
Asterisk-Users mailing list
[email protected]
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
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users