[ASTPPCOM-811] Issue with package minutes when using localization Created: 13/Oct/21  Updated: 03/Feb/23  Resolved: 03/Feb/23

Status: Closed
Project: ASTPP Community
Component/s: None
Affects Version/s: None
Fix Version/s: v5.0

Type: Bug Priority: High
Reporter: Fernando Dorna (Inactive) Assignee: Neetu Nogia
Resolution: Done Votes: 0
Labels: Suggestion
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Reproducibility: always
Category: Functional
Edition: Community

 Description   

Hello team!

the problem occurs when using package and localization.  For example.  I want to have a package of 1000 free minutes to Argentina Mobile.  the e.164 format for that destination is 549xxxxxxxxxx   (54 AR country code and 9 for mobiles).

This is the prefix we have either in origination and termination rates.  the customers does not dial in e.164 format of course, they dial like 1530571422 for a local Buenos Aires mobile and after passing the localization that number becomes 5491130571422 (e.164 format) and then, to the gateway...

Now the problem is when we want to use package.  As you now, the package uses the prefixes defined in the origination rate, in this case 549 form AR Mobile...

Seeing the debug in FS, you have the following:

 

2021-10-13 13:54:22.560093 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_PACKAGE_INFO] Query :SELECT *,P.id as package_id,P.product_id as product_id FROM packages_view as P inner join package_patterns as PKGPTR on P.product_id = PKGPTR.product_id WHERE (patterns = '^1530571422.' OR patterns = '^153057142.' OR patterns = '^15305714.' OR patterns = '^1530571.' OR patterns = '^153057.' OR patterns = '^15305.' OR patterns = '^1530.' OR patterns = '^153.' OR patterns = '^15.' OR patterns = '^1.' OR patterns ='--') AND accountid = 15 ORDER BY LENGTH(PKGPTR.patterns) DESC
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Package ID : 4
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Product ID : 2
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Package Type : 1 Call Direction : outbound [0:inbound,1:outbound,2:both]
2021-10-13 13:54:22.560093 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_COUNTER_INFO] Query :SELECT used_seconds FROM counters WHERE accountid = 15 AND package_id = 4 AND status=1 LIMIT 1
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Remaining minutes : 999
2021-10-13 13:54:22.560093 [NOTICE] switch_cpp.cpp:1365 [ASTPP] package_id : 4
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] =============== Account Information ===================
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] User id : 15
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Account code : 5270874382
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Balance : 746
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Type : 1 [0:prepaid,1:postpaid]
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] Ratecard id : 4
2021-10-13 13:54:22.560093 [INFO] switch_cpp.cpp:1365 [ASTPP] ========================================================
2021-10-13 13:54:22.560093 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_LOCALIZATION] Query :SELECT id,in_caller_id_originate,out_caller_id_originate,number_originate FROM localization WHERE id = 1 AND status=0 limit 1
2021-10-13 13:54:22.560093 [NOTICE] switch_cpp.cpp:1365 [ASTPP] [DONUMBERTRANSLATION] Before Localization CLI/DST : 1530571422
2021-10-13 13:54:22.560093 [NOTICE] switch_cpp.cpp:1365 [ASTPP] [DONUMBERTRANSLATION] After Localization CLI/DST : 5491130571422 

 

As you can see, package match occurs before localization and it does not find any coincidence.  The question is: Is there any way to do the package match after the localization [DONUMBERTRANSLATION]?

 

Thank you!!



 Comments   
Comment by Fernando Dorna (Inactive) [ 22/Oct/21 ]

I managed to achieve this by adding this portion of code in function function package_calculation located  at /usr/share/freeswitch/scripts/astpp/lib/astpp.functions.lua file:

original:

function package_calculation (destination_number,userinfo,call_direction)
      local package_act_id = userinfo['id']
      if(call_direction == 'inbound')then
                       Logger.debug("[GET_PACKAGE_INFO] call_direction :" .. call_direction)
                       if(didinfo and didinfo['accountid'] ~= '')then
                                           Logger.debug("[GET_PACKAGE_INFO] DID_ACCOUNTID :" .. didinfo['accountid'])
                                           package_act_id = didinfo['accountid']
                       end
      end
      local tmp = {}
      local remaining_sec
      local package_maxlength
      custom_destination = number_loop(destination_number,"patterns")
      local package_info_arr = {}
      local i = 1 fd .....( function continues...)......

 

introduced portion of code:

 

function package_calculation (destination_number,userinfo,call_direction)
      local package_act_id = userinfo['id']
      if(call_direction == 'inbound')then
                       Logger.debug("[GET_PACKAGE_INFO] call_direction :" .. call_direction)
                       if(didinfo and didinfo['accountid'] ~= '')then
                                           Logger.debug("[GET_PACKAGE_INFO] DID_ACCOUNTID :" .. didinfo['accountid'])
                                           package_act_id = didinfo['accountid']
                       end
      end
      local tmp = {}
      local remaining_sec
      local package_maxlength

       if (tonumber(userinfo['localization_id']) > 0) then
                     ar_localization = get_localization(userinfo['localization_id'],'O')
      end

      if (call_direction == 'outbound' and tonumber(userinfo['localization_id']) > 0 and ar_localization and ar_localization['number_originate'] ~= nil) then
                             ar_localization['number_originate'] = ar_localization['number_originate']:gsub(" ", "")
                             destination_number = do_number_translation(ar_localization['number_originate'],destination_number)
      end
      custom_destination = number_loop(destination_number,"patterns")
      local package_info_arr = {}
      local i = 1 fd .....( function continues...)......

 

       .................

 

Whit that add-on, you can make localization prior to package search.

 

Regards,

Fernando

Comment by Neetu Nogia [ 30/Jun/22 ]

Hello Fernando Dorna

Good day,

Can you please share with us the system configuration screenshot and Freeswitch call logs as well, so we can check accordingly?

Thank You

Generated at Sat Feb 10 07:20:28 CET 2024 using Jira 8.13.3#813003-sha1:22ebedbb75c99b147c66f14e031dd8a2d214753a.