|
Dear all,
I have just realized that the "Cost" in the CDR reports are incorrectly calculated when "lower level:" matching codes exist with a lower price. For example - if you have a price for the code "+1" of USD 0.01 and a price for the code "+1234" of USD 0.20 and a call terminating to +1234567890123 ASTPP wrongfully calculates the cost with the USD 0.01 rate. Below is the query used to determine the termination rate - as one can see - the data is sorted by TR.COST ASC - I suppose if it were DESC all should work as it is supposed to. I am fresh to the community so I don't have a patch for the problem - can someone please have a look and fix this? Thanks!
2017-11-30 20:07:03.041860 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_CARRIER_RATES] Query :SELECT TK.id as trunk_id,TK.codec,GW.name as path,GW.dialplan_variable,TK.provider_id,TK.cid_translation,TR.init_inc,TK.status,TK.dialed_modify,TK.maxchannels,TK.leg_timeout,TR.pattern,TR.id as outbound_route_id,TR.connectcost,TR.comment,TR.includedseconds,TR.cost,TR.inc,TR.prepend,TR.strip,(select name from gateways where status=0 AND id = TK.failover_gateway_id) as path1,(select name from gateways where status=0 AND id = TK.failover_gateway_id1) as path2 FROM outbound_routes as TR,trunks as TK,gateways as GW WHERE GW.status=0 AND GW.id= TK.gateway_id AND TK.status=0 AND TK.id= TR.trunk_id AND (pattern ='1234567890123.' OR pattern ='+123456789012.' OR pattern ='+12345678901.' OR pattern ='+1234567890.' OR pattern ='+12345678.' OR pattern ='+1234567.' OR pattern ='+123456.' OR pattern ='+12345.' OR pattern ='+1234.' OR pattern ='+123.' OR pattern ='+12.' OR pattern ='+1.' OR pattern ='^.*' OR pattern ='--') AND TR.status = 0 AND TR.trunk_id=1 ORDER by TR.cost ASC,TR.precedence ASC, TK.precedence
|