<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>If you are not calculating the cost of the call in the script it
      self you may create external script to go over your acc table and
      use "ms_duration" to adjust "duration"</p>
    <p>or use <strong>$Ts</strong><strong>$Tsm  </strong>at the
      beginning of the call, save it to a dialog and compare it with
      same value at the end of the call, then round up and write to acc
      table and/or calculate cost of the call.</p>
    <p><br>
      <strong></strong></p>
    <div class="moz-cite-prefix">On 1/23/2024 9:01 AM, Marcin Groszek
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:67bce38d-58ea-1ab0-08c9-5ab02ca009f4@voipplus.net">use
      math_ceil
      <br>
      <br>
      1.4.5.  math_ceil(number, result_var)
      <br>
      <br>
      Truncates a number, always towards +infinity. This means that
      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>
      <br>
      <br>
      On 1/23/2024 8:29 AM, <a class="moz-txt-link-abbreviated" href="mailto:trevor@webon.co.za">trevor@webon.co.za</a> wrote:
      <br>
      <blockquote type="cite">On Tue, 2024-01-23 at 05:44 -0600, Marcin
        Groszek wrote:
        <br>
        <blockquote type="cite">$avp(dlg_lifetime) is a read/ write
          variable and you can change its
          <br>
          value before acc is written.
          <br>
          <br>
          To round up the duration using minimum billing block and
          increments
          <br>
          you
          <br>
          need to save them first in to a dialog.
          <br>
          <br>
          this is the logic I use (opensips 3.1)
          <br>
          <br>
                                                    if
          ($(DLG_lifetime{s.int}) >
          <br>
          $(dlg_val(minimum){s.int})) {
          <br>
          math_eval("$DLG_lifetime / $dlg_val(increment)",
          $avp(lifetime));
          <br>
          math_ceil("$avp(lifetime)", $avp(dlg_total_increment));
          <br>
          math_eval("$avp(dlg_total_increment) * $dlg_val(increment)",
          <br>
          $avp(dlg_lifetime));
          <br>
          math_ceil("$avp(dlg_lifetime)",$avp(dlg_lifetime));
          <br>
                                                    }
          <br>
                                                    else {
          <br>
                                                           
          $avp(dlg_lifetime) =
          <br>
          $dlg_val(minimum);
          <br>
                                                    }
          <br>
          <br>
          <br>
        </blockquote>
        Hi Marcin,
        <br>
        <br>
        This only works for billing increments bigger than "1" I am
        <br>
        implementing per second billing and $DLG_lifetime is a rounded
        to the
        <br>
        nearest second, if a call duration is at 1001ms $DLG_Lifetime
        will
        <br>
        return 1 I need to round up I need to bill anything past 1000ms
        to 2
        <br>
        seconds.
        <br>
        <br>
        Regards
        <br>
        Trevor Steyn
        <br>
        <br>
        <br>
        _______________________________________________
        <br>
        Users mailing list
        <br>
        <a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
        <br>
        <a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
        <br>
        <br>
      </blockquote>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Best Regards:
Marcin Groszek
Business Phone Service
<a class="moz-txt-link-freetext" href="https://www.voipplus.net">https://www.voipplus.net</a></pre>
  </body>
</html>