<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">A few people have mentioned this but I haven’t seen a response. Why do you have to do this conversion in the script? The call duration in ms is already included by default in every CDR. We are only talking
 about rounding here, why wouldn’t your rating application do that for you? That’s much less complex than adding an entirely new field just so OpenSIPS can do the rounding.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:black">Ben Newlin</span><span style="font-size:11.0pt"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Users <users-bounces@lists.opensips.org> on behalf of trevor@webon.co.za <trevor@webon.co.za><br>
<b>Date: </b>Tuesday, January 23, 2024 at 2:42 PM<br>
<b>To: </b>OpenSIPS users mailling list <users@lists.opensips.org><br>
<b>Subject: </b>Re: [OpenSIPS-Users] $DLG_lifetime but in ms<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt"> EXTERNAL EMAIL - Please use caution with links and attachments <br>
<br>
On Tue, 2024-01-23 at 09:25 -0600, Marcin Groszek wrote:<br>
>  <br>
> If you are not calculating the cost of the call in the script it self<br>
> you may create external script to go over your acc table and use<br>
> "ms_duration" to adjust "duration"<br>
>  <br>
> or use $Ts$Tsm  at the beginning of the call, save it to a dialog and<br>
> compare it with same value at the end of the call, then round up and<br>
> write to acc table and/or calculate cost of the call.<br>
>  <br>
> <br>
>  <br>
>  <br>
> On 1/23/2024 9:01 AM, Marcin Groszek wrote:<br>
>  <br>
>  <br>
> > use math_ceil <br>
> >  <br>
> >  1.4.5.  math_ceil(number, result_var) <br>
> >  <br>
> >  Truncates a number, always towards +infinity. This means that<br>
> > ceil(3.2) = 4.0 and ceil(-2.9) = -2.0 <br>
> >  <br>
> >  <br>
> >  1.10.3. $DLG_lifetime <br>
> >  <br>
> >  Returns the duration (in seconds)... <br>
<br>
Hi Marcin, <br>
<br>
Using math_ceil on $DLG_lifetime wont work as it returns seconds not<br>
ms.<br>
<br>
As for your other suggestion I am doing something similar just not sure<br>
its the most efficient I am using get_accurate_time would $ts$Tsm be a<br>
better approach,<br>
<br>
<br>
at 200OK in onreply route <br>
<br>
    if ($rs == 200) {<br>
        get_accurate_time($var(now_s), $var(now_us));<br>
        $dlg_val(start_s) = $var(now_s);<br>
        $dlg_val(start_us) = $var(now_us);<br>
    }<br>
<br>
then on BYE<br>
<br>
if (is_method("BYE")) {<br>
    get_accurate_time($var(end_s), $var(end_us));<br>
    ts_usec_delta($(dlg_val(start_s){s.int}),<br>
$(dlg_val(start_us){s.int}), $var(end_s),  $var(end_us) ,<br>
$var(billed_duration));<br>
   $var(end_us) , $acc_extra(billed_duration)\n");<br>
    math_eval("$var(billed_duration) / 1000000",<br>
$var(billed_duration));  <br>
    math_ceil($var(billed_duration),$var(billed_duration));<br>
    $acc_extra(billed_duration) = $var(billed_duration);<br>
<br>
## Rate the call<br>
<br>
    math_eval("$acc_extra(c_price) / 60 * $acc_extra(billed_duration)",<br>
$var(c_cost));<br>
    math_eval("$acc_extra(v_price) / 60 * $acc_extra(billed_duration)",<br>
$var(v_cost));<br>
    $acc_extra(cost) = $var(c_cost);<br>
    $acc_extra(v_cost) = $var(v_cost);<br>
}<br>
<br>
Thanks.<br>
<br>
_______________________________________________<br>
Users mailing list<br>
Users@lists.opensips.org<br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</body>
</html>