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)...
On 1/23/2024 8:29 AM, [email protected] wrote:
On Tue, 2024-01-23 at 05:44 -0600, Marcin Groszek wrote:
$avp(dlg_lifetime) is a read/ write variable and you can change its
value before acc is written.
To round up the duration using minimum billing block and increments
you
need to save them first in to a dialog.
this is the logic I use (opensips 3.1)
if ($(DLG_lifetime{s.int}) >
$(dlg_val(minimum){s.int})) {
math_eval("$DLG_lifetime / $dlg_val(increment)", $avp(lifetime));
math_ceil("$avp(lifetime)", $avp(dlg_total_increment));
math_eval("$avp(dlg_total_increment) * $dlg_val(increment)",
$avp(dlg_lifetime));
math_ceil("$avp(dlg_lifetime)",$avp(dlg_lifetime));
}
else {
$avp(dlg_lifetime) =
$dlg_val(minimum);
}
Hi Marcin,
This only works for billing increments bigger than "1" I am
implementing per second billing and $DLG_lifetime is a rounded to the
nearest second, if a call duration is at 1001ms $DLG_Lifetime will
return 1 I need to round up I need to bill anything past 1000ms to 2
seconds.
Regards
Trevor Steyn
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
--
Best Regards:
Marcin Groszek
Business Phone Service
https://www.voipplus.net
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users