[ASTPPCOM-443] Free Calls don't work without balance Created: 20/Jun/18  Updated: 09/Oct/19  Resolved: 13/Nov/18

Status: Done
Project: ASTPP Community
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Task
Reporter: leandronvoip Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hi,

I have some packages of free calls.
If the customer balance is 0, the free calls don't work.
If the customer balance is 0.10, and the cost for minute is 0.10, the call will drop after one minute.

The correct is free calls work with balance 0, if the minutes are consumed and customer don't have balance, drop the call, if the minutes are consumed and customer have balance, debit from balance the rest o call.



 Comments   
Comment by (Community) DN (Inactive) [ 27/Jun/18 ]

[~leandronvoip]

Account has 0 balance and having origination rate = 0.50 for prefix in rate group of that account
free package is applied to that rate group
This call will work.

Comment by leandronvoip [ 27/Jun/18 ]

But don't are working. If balance are 0, free calls don't complete.

Um abraço,
Leandro Campos
CEO
(11) 4118-6267
leandro.campos@nvoip.com.br (https://www.nvoip.com.br) (https://www.linkedin.com/in/leandro-campos/)
27 de junho de 2018 03:37, "Devang Nathwani" <notifications@github.com (notifications@github.com?to=%22Devang%20Nathwani%22%20<notifications@github.com>)> escreveu:
[~leandronvoip] (https://github.com/leandronvoip)

Account has 0 balance and having origination rate = 0.50 for prefix in rate group of that account
free package is applied to that rate group
This call will work.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (https://github.com/iNextrix/ASTPP/issues/443#issuecomment-400559313), or mute the thread (https://github.com/notifications/unsubscribe-auth/AmjraEz8cmrlDPWhY0jn2xRpMsSvUXkQks5uAyf6gaJpZM4UvMi6).

Comment by (Community) DN (Inactive) [ 02/Jul/18 ]

[~leandronvoip] Share the whole call fs_cli log with debug level and share the pastebin link please.

Comment by leandronvoip [ 05/Jul/18 ]

2018-07-04 20:08:49.528948 [DEBUG] sofia.c:7084 Channel sofia/default/[ACCOUNT]@[DOMAIN] entering state [received][100]
2018-07-04 20:08:49.528948 [DEBUG] sofia.c:7094 Remote SDP:
v=0
o=- 3739723729 3739723729 IN IP4 192.168.15.173
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4020 RTP/AVP 8 0 9 101
c=IN IP4 192.168.15.173
b=TIAS:64000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtcp:4021 IN IP4 192.168.15.173

2018-07-04 20:08:49.528948 [DEBUG] sofia.c:7480 (sofia/default/[ACCOUNT]@[DOMAIN]) State Change CS_NEW -> CS_INIT
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:584 (sofia/default/[ACCOUNT]@[DOMAIN]) Running State Change CS_INIT (Cur 1 Tot 66104)
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:627 (sofia/default/[ACCOUNT]@[DOMAIN]) State INIT
2018-07-04 20:08:49.528948 [DEBUG] mod_sofia.c:90 sofia/default/[ACCOUNT]@[DOMAIN] SOFIA INIT
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:40 sofia/default/[ACCOUNT]@[DOMAIN] Standard INIT
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:48 (sofia/default/[ACCOUNT]@[DOMAIN]) State Change CS_INIT -> CS_ROUTING
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:627 (sofia/default/[ACCOUNT]@[DOMAIN]) State INIT going to sleep
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:584 (sofia/default/[ACCOUNT]@[DOMAIN]) Running State Change CS_ROUTING (Cur 1 Tot 66104)
2018-07-04 20:08:49.528948 [DEBUG] switch_channel.c:2249 (sofia/default/[ACCOUNT]@[DOMAIN]) Callstate Change DOWN -> RINGING
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:643 (sofia/default/[ACCOUNT]@[DOMAIN]) State ROUTING
2018-07-04 20:08:49.528948 [DEBUG] mod_sofia.c:143 sofia/default/[ACCOUNT]@[DOMAIN] SOFIA ROUTING
2018-07-04 20:08:49.528948 [DEBUG] switch_core_state_machine.c:236 sofia/default/[ACCOUNT]@[DOMAIN] Standard ROUTING
2018-07-04 20:08:49.528948 [INFO] mod_dialplan_xml.c:637 Processing [ACCOUNT] <[ACCOUNT]>->553230835409 in context default
2018-07-04 20:08:49.538953 [DEBUG] freeswitch_lua.cpp:365 DBH handle 0x7fcbc043c870 Connected.
2018-07-04 20:08:49.538953 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [LOAD_CONF] Query :SELECT name,value FROM system WHERE group_title IN ('global','opensips','callingcard')
2018-07-04 20:08:49.548947 [INFO] switch_cpp.cpp:1365 [ASTPP] [Dialplan] Dialed number : 553230835409
2018-07-04 20:08:49.548947 [INFO] switch_cpp.cpp:1365 [ASTPP] [Dialplan] Caller Id name / number : 3235123700 / 3235123700
2018-07-04 20:08:49.548947 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [CHECK_DID] Query :SELECT A.id as id,B.id as accountid,B.number as account_code,B.did_cid_translation as did_cid_translation,A.number as did_number,A.connectcost,A.includedseconds,A.cost,A.inc,A.extensions,A.maxchannels,A.call_type,A.city,A.province,A.init_inc,A.leg_timeout FROM dids AS A,accounts AS B WHERE A.status=0 AND B.status=0 AND B.deleted=0 AND B.id=A.accountid AND A.number ="553230835409" LIMIT 1
2018-07-04 20:08:49.548947 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [CHECK_LOCAL_CALL] Query :SELECT sip_devices.username as username,accounts.number as accountcode,sip_devices.accountid as accountid,accounts.did_cid_translation as did_cid_translation FROM sip_devices as sip_devices,accounts as accounts WHERE accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND sip_devices.username="553230835409" limit 1
2018-07-04 20:08:49.548947 [INFO] switch_cpp.cpp:1365 [ASTPP] [Dialplan] Call direction : outbound
2018-07-04 20:08:49.548947 [NOTICE] switch_cpp.cpp:1365 [ASTPP] [Accountcode : [ACCOUNT]]
2018-07-04 20:08:49.548947 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [DOAUTHORIZATION] Query :SELECT * FROM accounts WHERE (number = "[ACCOUNT]" OR id="[ACCOUNT]") AND status=0 AND deleted=0 AND (expiry >= '2018-07-04 23:08:49' OR expiry = '0000-00-00 00:00:00') limit 1
2018-07-04 20:08:49.559411 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [CHECK_BLOCKED_PREFIX] Query :SELECT * FROM block_patterns WHERE (blocked_patterns ='^553230835409.' OR blocked_patterns ='^55323083540.' OR blocked_patterns ='^5532308354.' OR blocked_patterns ='^553230835.' OR blocked_patterns ='^55323083.' OR blocked_patterns ='^5532308.' OR blocked_patterns ='^553230.' OR blocked_patterns ='^55323.' OR blocked_patterns ='^5532.' OR blocked_patterns ='^553.' OR blocked_patterns ='^55.' OR blocked_patterns ='^5.' OR blocked_patterns ='--') AND accountid = 11 limit 1
2018-07-04 20:08:49.559411 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_PACKAGE_INFO] Query :SELECT * FROM packages as P inner join package_patterns as PKGPTR on P.id = PKGPTR.package_id WHERE (patterns ='^553230835409.' OR patterns ='^55323083540.' OR patterns ='^5532308354.' OR patterns ='^553230835.' OR patterns ='^55323083.' OR patterns ='^5532308.' OR patterns ='^553230.' OR patterns ='^55323.' OR patterns ='^5532.' OR patterns ='^553.' OR patterns ='^55.' OR patterns ='^5.' OR patterns ='--') AND status = 0 AND pricelist_id = 13 ORDER BY LENGTH(PKGPTR.patterns) DESC LIMIT 1
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] Pack Type : 0 Call Direction : outbound [0:outbound,1:inbound,2:both]
2018-07-04 20:08:49.559411 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_COUNTER_INFO] Query :SELECT seconds FROM counters WHERE accountid = 11 AND package_id = 6 AND status=1 LIMIT 1
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] Remaining Sec : 12000
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] =============== Account Information ===================
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] User id : 11
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] Account code : [ACCOUNT]
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] Balance : 0.0002
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] Type : 0 [0:prepaid,1:postpaid]
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] Ratecard id : 13
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] ========================================================
2018-07-04 20:08:49.559411 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_PRICELIST_INFO] Query :select * from pricelists WHERE id = 13 AND status = 0
2018-07-04 20:08:49.559411 [DEBUG] switch_cpp.cpp:1365 [ASTPP] [GET_RATES] Query :SELECT _ FROM routes WHERE (pattern ='^553230835409.' OR pattern ='^55323083540.' OR pattern ='^5532308354.' OR pattern ='^553230835.' OR pattern ='^55323083.' OR pattern ='^5532308.' OR pattern ='^553230.' OR pattern ='^55323.' OR pattern ='^5532.' OR pattern ='^553.' OR pattern ='^55._' OR pattern ='^5.*' OR pattern ='--') AND status = 0 AND pricelist_id = 13 ORDER BY LENGTH(pattern) DESC,cost DESC LIMIT 1
2018-07-04 20:08:49.559411 [INFO] switch_cpp.cpp:1365 [ASTPP] [FIND_MAXLENGTH] Your balance is not sufficent to dial 553230835409 !!!
2018-07-04 20:08:49.559411 [DEBUG] switch_cpp.cpp:1365 [ASTPP] Generated XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="dialplan" description="ASTPP Dialplan">
<context name="default">
<extension name="553230835409">
<condition field="destination_number" expression="553230835409">
<action application="log" data="WARNING Accountcode [ACCOUNT] doesn't have sufficiant fund!!"/>
<action application="playback" data="/usr/local/freeswitch/sounds/en/us/callie/astpp-not-enough-credit.wav"/>
<action application="set" data="original_caller_id_name=3235123700"/>
<action application="set" data="original_caller_id_number=3235123700"/>
<action application="set" data="error_cdr=1"/>
<action application="set" data="callstart=2018-07-04 23:08:49"/>
<action application="set" data="account_id=11"/>
<action application="set" data="call_direction=outbound"/>
<action application="set" data="sip_ignore_remote_cause=true"/>
<action application="set" data="call_processed=internal"/>
<action application="set" data="effective_destination_number=553230835409"/>
<action application="set" data="last_bridge_hangup_cause=NO_SUFFICIENT_FUND"/>
<action application="hangup" data="NO_SUFFICIENT_FUND"/>
</condition>
</extension>
</context>
</section>
</document>
2018-07-04 20:08:49.559411 [DEBUG] freeswitch_lua.cpp:382 DBH handle 0x7fcbc043c870 released.
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] parsing [default->553230835409] continue=false
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Regex (PASS) [553230835409] destination_number(553230835409) =~ /553230835409/ break=on-false
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action log(WARNING Accountcode [ACCOUNT] doesn't have sufficiant fund!!)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action playback(/usr/local/freeswitch/sounds/en/us/callie/astpp-not-enough-credit.wav)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(original_caller_id_name=3235123700)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(original_caller_id_number=3235123700)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(error_cdr=1)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(callstart=2018-07-04 23:08:49)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(account_id=11)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(call_direction=outbound)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(sip_ignore_remote_cause=true)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(call_processed=internal)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(effective_destination_number=553230835409)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action set(last_bridge_hangup_cause=NO_SUFFICIENT_FUND)
Dialplan: sofia/default/[ACCOUNT]@[DOMAIN] Action hangup(NO_SUFFICIENT_FUND)
2018-07-04 20:08:49.559411 [DEBUG] switch_core_state_machine.c:286 (sofia/default/[ACCOUNT]@[DOMAIN]) State Change CS_ROUTING -> CS_EXECUTE
2018-07-04 20:08:49.559411 [DEBUG] switch_core_state_machine.c:643 (sofia/default/[ACCOUNT]@[DOMAIN]) State ROUTING going to sleep
2018-07-04 20:08:49.559411 [DEBUG] switch_core_state_machine.c:584 (sofia/default/[ACCOUNT]@[DOMAIN]) Running State Change CS_EXECUTE (Cur 1 Tot 66104)
2018-07-04 20:08:49.559411 [DEBUG] switch_core_state_machine.c:650 (sofia/default/[ACCOUNT]@[DOMAIN]) State EXECUTE
2018-07-04 20:08:49.559411 [DEBUG] mod_sofia.c:198 sofia/default/[ACCOUNT]@[DOMAIN] SOFIA EXECUTE
2018-07-04 20:08:49.559411 [DEBUG] switch_core_state_machine.c:328 sofia/default/[ACCOUNT]@[DOMAIN] Standard EXECUTE
EXECUTE sofia/default/[ACCOUNT]@[DOMAIN] log(WARNING Accountcode [ACCOUNT] doesn't have sufficiant fund!!)
2018-07-04 20:08:49.559411 [WARNING] mod_dptools.c:1742 Accountcode [ACCOUNT] doesn't have sufficiant fund!!

Comment by leandronvoip [ 05/Jul/18 ]

If I put credit suficient to make the call, on CDR shows free call and don`t debit on balance. But are working only If I has balance.

Comment by Samir Doshi [ 12/Jul/18 ]

I just tried same thing in my local system and call worked without balance.

My call log : https://pastebin.freeswitch.org/view/6d31ea1d

Make sure you are running latest version of 3.6.

Comment by leandronvoip [ 12/Jul/18 ]

Check this line of your pastebin:

2018-07-12 12:53:46.069113 [NOTICE] switch_cpp.cpp:1376 [ASTPP] Allocating static balance for package calls, Balance : 100, Credit limit : 200

You have Balance: 100

Put prepaid account and balance: 0 and try make a free call.

Comment by Samir Doshi [ 16/Jul/18 ]

2018-07-12 12:53:46.069113 [INFO] switch_cpp.cpp:1376 [ASTPP] Remaining Sec : 50000
2018-07-12 12:53:46.069113 [NOTICE] switch_cpp.cpp:1376 [ASTPP] Actual Balance : 0
2018-07-12 12:53:46.069113 [NOTICE] switch_cpp.cpp:1376 [ASTPP] Allocating static balance for package calls, Balance : 100, Credit limit : 200

Check account balance is 0 and then system is allocating static balance as this is package call.

Comment by leandronvoip [ 01/Aug/18 ]

Hi.

I test with a new account and works fine. Old accounts don't are working. Is possible the remaining seconds free don't are reset?

Comment by leandronvoip [ 02/Aug/18 ]

Hi.

I found the error.

If I use the translation number on account profile, the call don't complete. If I remove ,works fine.

You can try?

Comment by leandronvoip [ 02/Aug/18 ]

Another problem: Only new accounts are making free calls. Old accounts don't make free calls if don't have balance. Something are change in lasts commits on accounts?

Comment by leandronvoip [ 02/Aug/18 ]

Another issue detected: If account has some balance, the call don't complete. Example: Put 0.01 (less a minimum call) and test.

Comment by leandronvoip [ 19/Sep/18 ]

Your test my last comment? New accounts with 0 balance the free call works, but if you add 0.01 of balance, the call don’t work.

Comment by leandronvoip [ 13/Nov/18 ]

Hi. I am testing here and found new errors:

This cenario:

I have 120 seconds of free calls.

I make a call and now i have only 3 seconds.
All calls start and drop, without count any seconds. I stay with only 3 seconds for calls.

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