Hello All.

I am using FS with nibblebill and mod_lcr.

But i do not understand why nibblebill deduc balance two times; my log :

2015-05-21 19:56:08.846179 [DEBUG] mod_nibblebill.c:546 31 seconds passed since last bill time of 2015-05-21 19:55:37
2015-05-21 19:56:08.846179 [DEBUG] mod_nibblebill.c:563 Billing $16.800001 to 2 (Call: c457b3c6-6bc8-445e-9697-2ffc327c6722 / 0.000000 so far)
2015-05-21 19:56:08.846179 [DEBUG] mod_nibblebill.c:393 Doing update query
[UPDATE auth_user SET saldo=saldo-16.800001 WHERE id='2']
2015-05-21 19:56:08.866181 [DEBUG] mod_nibblebill.c:428 Retrieved current balance for account 2 (balance = 83.199999)
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:60 sofia/external/992797744 Standard HANGUP, cause: NORMAL_CLEARING
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:737 (sofia/external/992797744) State HANGUP going to sleep
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:504 (sofia/external/992797744) State Change CS_HANGUP -> CS_REPORTING
2015-05-21 19:56:08.866181 [DEBUG] switch_core_session.c:1388 Send signal sofia/external/992797744 [BREAK]
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:472 (sofia/external/992797744) Running State Change CS_REPORTING
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:823 (sofia/external/992797744) State REPORTING
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:104 sofia/external/992797744 Standard REPORTING, cause: NORMAL_CLEARING
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:823 (sofia/external/992797744) State REPORTING going to sleep
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:498 (sofia/external/992797744) State Change CS_REPORTING -> CS_DESTROY
2015-05-21 19:56:08.866181 [DEBUG] switch_core_session.c:1388 Send signal sofia/external/992797744 [BREAK]
2015-05-21 19:56:08.866181 [DEBUG] switch_core_session.c:1615 Session 8547 (sofia/external/992797744) Locked, Waiting on external entities
2015-05-21 19:56:08.866181 [NOTICE] switch_core_session.c:1633 Session 8547 (sofia/external/992797744) Ended
2015-05-21 19:56:08.866181 [NOTICE] switch_core_session.c:1637 Close Channel sofia/external/992797744 [CS_DESTROY]
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:626 (sofia/external/992797744) Running State Change CS_DESTROY
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:636 (sofia/external/992797744) State DESTROY
2015-05-21 19:56:08.866181 [DEBUG] mod_sofia.c:323 sofia/external/992797744 SOFIA DESTROY
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:111 sofia/external/992797744 Standard DESTROY
2015-05-21 19:56:08.866181 [DEBUG] switch_core_state_machine.c:636 (sofia/external/992797744) State DESTROY going to sleep
2015-05-21 19:56:08.886193 [DEBUG] mod_nibblebill.c:420 Doing lookup query
[SELECT saldo AS nibble_balance FROM auth_user WHERE id='2']
2015-05-21 19:56:08.886193 [DEBUG] mod_nibblebill.c:428 Retrieved current balance for account 2 (balance = 66.399998)
2015-05-21 19:56:08.886193 [DEBUG] switch_core_state_machine.c:60 sofia/internal/448908901@ssw.opendata.cl Standard HANGUP, cause: NORMAL_CLEARING
2015-05-21 19:56:08.886193 [DEBUG] switch_core_state_machine.c:737 (sofia/internal/448908901@ssw.opendata.cl) State HANGUP going to sleep
2015-05-21 19:56:08.886193 [DEBUG] switch_core_state_machine.c:504 (sofia/internal/448908901@ssw.opendata.cl) State Change CS_HANGUP -> CS_REPORTING
2015-05-21 19:56:08.886193 [DEBUG] switch_core_session.c:1388 Send signal sofia/internal/448908901@ssw.opendata.cl [BREAK]
2015-05-21 19:56:08.886193 [DEBUG] switch_core_state_machine.c:472 (sofia/internal/448908901@ssw.opendata.cl) Running State Change CS_REPORTING
2015-05-21 19:56:08.886193 [DEBUG] switch_core_state_machine.c:823 (sofia/internal/448908901@ssw.opendata.cl) State REPORTING
2015-05-21 19:56:08.886193 [DEBUG] switch_scheduler.c:144 Deleting task 8550 switch_core_session_sched_heartbeat (52f0e5f6-c97e-41c1-9a39-a4d12ec0683f)
2015-05-21 19:56:09.086191 [DEBUG] switch_core_state_machine.c:104 sofia/internal/448908901@ssw.opendata.cl Standard REPORTING, cause: NORMAL_CLEARING
2015-05-21 19:56:09.086191 [DEBUG] switch_core_state_machine.c:823 (sofia/internal/448908901@ssw.opendata.cl) State REPORTING going to sleep
2015-05-21 19:56:09.086191 [DEBUG] switch_core_state_machine.c:498 (sofia/internal/448908901@ssw.opendata.cl) State Change CS_REPORTING -> CS_DESTROY
2015-05-21 19:56:09.086191 [DEBUG] switch_core_session.c:1388 Send signal sofia/internal/448908901@ssw.opendata.cl [BREAK]
2015-05-21 19:56:09.086191 [DEBUG] switch_core_session.c:1615 Session 8546 (sofia/internal/448908901@ssw.opendata.cl) Locked, Waiting on external entities
2015-05-21 19:56:09.086191 [NOTICE] switch_core_session.c:1633 Session 8546 (sofia/internal/448908901@ssw.opendata.cl) Ended
2015-05-21 19:56:09.086191 [NOTICE] switch_core_session.c:1637 Close Channel sofia/internal/448908901@ssw.opendata.cl [CS_DESTROY]
2015-05-21 19:56:09.086191 [DEBUG] switch_core_state_machine.c:626 (sofia/internal/448908901@ssw.opendata.cl) Running State Change CS_DESTROY
2015-05-21 19:56:09.086191 [DEBUG] switch_core_state_machine.c:636 (sofia/internal/448908901@ssw.opendata.cl) State DESTROY
2015-05-21 19:56:09.086191 [DEBUG] mod_sofia.c:323 sofia/internal/448908901@ssw.opendata.cl SOFIA DESTROY
2015-05-21 19:56:09.086191 [DEBUG] switch_core_state_machine.c:111 sofia/internal/448908901@ssw.opendata.cl Standard DESTROY
2015-05-21 19:56:09.086191 [DEBUG] switch_core_state_machine.c:636 (sofia/internal/448908901@ssw.opendata.cl) State DESTROY going to sleep
2015-05-21 19:56:09.386178 [DEBUG] switch_scheduler.c:144 Deleting task 8549 switch_ivr_schedule_hangup (c457b3c6-6bc8-445e-9697-2ffc327c6722)


As you can see the first time say:

[UPDATE auth_user SET saldo=saldo-16.800001 WHERE id='2']
2015-05-21 19:56:08.866181 [DEBUG] mod_nibblebill.c:428 Retrieved current balance for account 2 (balance = 83.199999)

The new balance is 83.199999 it's fine

and then

2015-05-21 19:56:08.886193 [DEBUG] mod_nibblebill.c:420 Doing lookup query
[SELECT saldo AS nibble_balance FROM auth_user WHERE id='2']
2015-05-21 19:56:08.886193 [DEBUG] mod_nibblebill.c:428 Retrieved current balance for account 2 (balance = 66.399998)

But again retrieved balance and now balance is 66.399998 it's wrong!!


My dialplan:

    <extension name="Todo">
      <condition expression="^([2-9]\d{8})$" field="destination_number">
        <action application="export" data="dialed_extension=$1"/>
        <action application="set" data="hangup_after_bridge=true"/>
        <action application="set" data="continue_on_fail=true"/>
        <action application="sched_hangup" data="+1800 alloted_timeout"/>
        <action application="limit" data="hash fraud_protection calls_max_intl ${calls_max_intl} !NORMAL_TEMPORARY_FAILURE"/>
        <action application="lcr" data="$1 pg_prefix2"/>
        <action application="set" data="nibble_rate=${lcr_rate_1}"/>
        <action application="set" data="nibble_account=${accountcode}"/>
        <action application="set" data="lowbal_amt=${lowbal_amt}"/>
        <action application="set" data="nobal_amt=${nobal_amt}"/>
        <!--<action application="nibblebill" data="heartbeat 10"/>-->
        <action application="set" data="bypass_media=true"/>
        <action application="bridge" data="${lcr_auto_route}"/>

Anyone give some idea or what i am doing wrong.

Regards