<div>Hi All,</div><div><br></div><div>My apologies, there was nothing to see here.</div><div><br></div><div>Skyler</div><div><br></div><div><div class="gmail_quote">On Mon, Feb 20, 2012 at 11:05 AM, Skyler <span dir="ltr"><<a href="mailto:skchopperguy@gmail.com" target="_blank">skchopperguy@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Daniel,<div><br></div><div> See, I knew my calculator was broken...where's my hammer!? ;o)</div><div>
<div><br></div><div>> That's because the DB, the CDR export and the SOAP / XML-RPC functions</div><div>> handle money in hundredths of your currency. So it's 0.48 ¢ in the DB<br>
> actually, which equates to 60 (interval length) * 4 (no. intervals) *<br>> 0.002 (rate in cent per second).</div></div><div><br>Ok, so I am definitely confused then. Let me just ask, if _you_ wanted to charge 0.002 cents per minute on a destination, how would _you_ enter this into a billing profile?</div>



<div><br></div><div>onpeak init rate: ?<br>onpeak init interval: ?<br>onpeak follow rate: ?<br>onpeak follow interval: ?</div><div><br></div><div> While we're here, my other goal is to obtain a total $ amount on all calls for each source_external_contract_id and give this to the accounting department. Below is what I had in mind for a query. My interpretation is "15215 did 107 calls at a cost of $46.50" but that is definitely wrong, so how would you do a select query to obtain the correct total $'s?</div>



<div><br></div><div><div>mysql> select source_external_contract_id, sum(customer_cost), count(*) from cdr group by source_external_contract_id;</div><div>+-----------------------------+--------------------+----------+</div>



<div>| source_external_contract_id | sum(customer_cost) | count(*) |</div><div>+-----------------------------+--------------------+----------+</div><div>|                             |               0.00 |        1 |</div>



<div>| 15215                       |              46.50 |      107 |</div><div>+-----------------------------+--------------------+----------+</div><div>2 rows in set (0.00 sec)</div></div><div><br></div><div><br></div><div>



TIA,</div><div>Skyler</div><div><div><div> <br><div class="gmail_quote">On Mon, Feb 20, 2012 at 10:19 AM, Daniel Tiefnig <span dir="ltr"><<a href="mailto:dtiefnig@sipwise.com" target="_blank">dtiefnig@sipwise.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 02/20/2012 06:42 PM, Skyler wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Stored Billing Fees:<br>
</blockquote><div>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
onpeak init rate: 0.002<br>
onpeak init interval: 60<br>
onpeak follow rate: 0.002<br>
onpeak follow interval: 60<br>
</blockquote>
<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
My goal with above settings is to charge $0.002 per minute[...]<br>
</blockquote>
<br>
Well this won't work out that way. As you can see in the admin web<br>
interface, you need to specify the "rate in cent per second". With the<br>
above settings, you'll charge 0.002 * 60 cent per minute. I know this is<br>
a bit confusing in the beginning.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Two things that strike me as wrong. First is call duration, in<br>
www_csc I see 03:45 and in accounting.cdr I see 224.010. My logic<br>
tells me that one of these is in minutes, the other is in seconds and<br>
also one of these should be correct, but my calculator says they<br>
don't add up together in any way ;).<br>
</blockquote>
<br></div>
Hmm, my biologically built-in calculator says it's correct. :o)<br>
<br>
224.010 seconds is 3 minutes (180 seconds) plus 44.010 seconds. As<br>
accounting for the customer is done per commenced second, this rounds up<br>
to 45 seconds. So it's 03:45 really.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Second, in www_csc I see the charge as $0.0048 but in the<br>
accounting.cdr I see customer_cost: 0.48. Also the corresponding<br>
cdrexport shows customer_cost: 0.48 as well.<br>
</blockquote>
<br></div>
That's because the DB, the CDR export and the SOAP / XML-RPC functions<br>
handle money in hundredths of your currency. So it's 0.48 ¢ in the DB<br>
actually, which equates to 60 (interval length) * 4 (no. intervals) *<br>
0.002 (rate in cent per second).<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In www_csc the display of 0.0048 indicates the db would be<br>
decimal(10,4), but in accounting.cdr is decimal(10,2). Shouldn't<br>
accounting.cdr be decimal(10,4) to match?<br>
</blockquote>
<br></div>
Same as above: As it's using ¢, it only stores 2 decimals for the value.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So I changed it to decimal(10,4) and that fixed the decimal trouble.<br>
</blockquote>
<br></div>
Hmm, which trouble, actually? :o)<br>
<br>
Let me know if you still see any wrong numbers.<br>
<br>
br,<br>
daniel<br>
<br>
______________________________<u></u>_________________<br>
Spce-user mailing list<br>
<a href="mailto:Spce-user@lists.sipwise.com" target="_blank">Spce-user@lists.sipwise.com</a><br>
<a href="http://lists.sipwise.com/listinfo/spce-user" target="_blank">http://lists.sipwise.com/<u></u>listinfo/spce-user</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>