On Tue, 2024-01-23 at 09:25 -0600, Marcin Groszek wrote: > > 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" > > or use $Ts$Tsm 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. > > > > > On 1/23/2024 9:01 AM, Marcin Groszek wrote: > > > > use math_ceil > > > > 1.4.5. math_ceil(number, result_var) > > > > Truncates a number, always towards +infinity. This means that > > ceil(3.2) = 4.0 and ceil(-2.9) = -2.0 > > > > > > 1.10.3. $DLG_lifetime > > > > Returns the duration (in seconds)...
Hi Marcin, Using math_ceil on $DLG_lifetime wont work as it returns seconds not ms. As for your other suggestion I am doing something similar just not sure its the most efficient I am using get_accurate_time would $ts$Tsm be a better approach, at 200OK in onreply route if ($rs == 200) { get_accurate_time($var(now_s), $var(now_us)); $dlg_val(start_s) = $var(now_s); $dlg_val(start_us) = $var(now_us); } then on BYE if (is_method("BYE")) { get_accurate_time($var(end_s), $var(end_us)); ts_usec_delta($(dlg_val(start_s){s.int}), $(dlg_val(start_us){s.int}), $var(end_s), $var(end_us) , $var(billed_duration)); $var(end_us) , $acc_extra(billed_duration)\n"); math_eval("$var(billed_duration) / 1000000", $var(billed_duration)); math_ceil($var(billed_duration),$var(billed_duration)); $acc_extra(billed_duration) = $var(billed_duration); ## Rate the call math_eval("$acc_extra(c_price) / 60 * $acc_extra(billed_duration)", $var(c_cost)); math_eval("$acc_extra(v_price) / 60 * $acc_extra(billed_duration)", $var(v_cost)); $acc_extra(cost) = $var(c_cost); $acc_extra(v_cost) = $var(v_cost); } Thanks. _______________________________________________ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users