Tag

asterrc

using astercc and asterrc daemon to bill your asterisk

By | asterBilling | 2 Comments

asterrc is a billing script in asterCC package, together with astercc, asterrc could provide you the realtime billing feature to your asterisk system.

there’re some billing fields in table ‘curcdr’, they are

`credit` : credit by customer rate (rates in table ‘myrate’)
`callshopcredit`: credit by callshop (rates in table ‘callshoprate’)
`resellercredit`: credit by reseller (rates in table ‘resellerrate’)
`creditlimit`: if we have a creditlimit for this call, if it has once the ‘credit’ reach the number, the call would be hang up
`destination` : destination of the call, get from table ‘myrate’
`memo` : rate of the call, get from table ‘myrate’

asterrc daemon will maintain these fields during a live call, and we have same fields in table mycdr, so when a call is finished, we can also get the credit of the call.

Also, we have billing fields in table ‘clid’, ‘accountgroup’,’resellergroup’

`curcredit` current credit (works as a billing flag)
`credit_clid` total clid credit for the item
`credit_group` total group credit for the item
`credit_reseller` total reseller credit for the item

Here’s a example to show you how asterrc works

say we have defined a rate, we sell to reseller in 0.1 a minute, reseller sell to callshop in 0.2 a minute, and callshop sell 0.4 a minute to customer, when customer start a call, astercc will get the live CDR into table curcdr, and asterrc will put value 0.4, 0.2, 0.1 to fields ‘credit’, ‘callshopcredit’, ‘resellercredit’ when it’s the first minute, and then 0.8, 0.4, 0.2 when it’s the second minute …. when it’s 2 minutes and a half, customer hangup the call, then we get a record with billing message 1.2 in ‘credit’,  0.6 in ‘callshopcredit’, 0.3 in ‘resellercredit’, meantime fields in clid, accountgroup and resellergroup would be updated, credit_clid = credit_clid + 1.2, credit_group = credit_group + 0.6, credit_reseller = credit_reseller + 0.3.

field ‘curcredit’ is used to save credit for comparing with creditlimt, it is updated after a call is finished, if limit type is set and curcredit is greater or equal with the creditlimit, the call would be hangup, when clid/group/reseller charges, we set curcredit = curcredit – {fund charged} so that curcredit is less than creditlimit and calls can go out.
Say a reseller pay you 500 euro, and u set his limit type to prepaid, and creditlimit = 500, then it is curcredit = 0, limittype= prepaid, creditlimit = 500 in table resellergroup, then booths under this reseller start to call ,  curcredit will increase by resellerrate, when it reachs 500, all calls stoped, reseller comes to you and charge 2000 euro, here you have two options

1. set credit limit to 500+2000 = 2500, but not recommend, coz there’d no log for changing of creditlimit

2. charge 2000 to curcredit, then curcredit = 500-2000 = -1500,  and this operation would be logged in credithistory, so that you can check the charge history of each customer.

Hope this could help you under stand how asterbilling works.

scripts in asterCC

By | asterBilling, asterCRM | 3 Comments

The scripts folder in asterCC package, it provides you several scripts, so here is what are they:

  • astercc: the main daemon script in asterCC, it would run as a daemon when add “-d” parameter (astercc -d), astercc will connect to your asterisk via AMI, and catch all call events and put them into mysql database in realtime, so only astercc is running, all other functions would work.
  • asterrc: a billing daemon, it would load rates to memory and when there’re new calls it would analyze the CDR based callerid and destnation then put the rate into database in realtime. It support three level billing, reseller, group, and customer. You need asterrc running when you want to bill your asterisk.
  • astercclock: astercclock is used for billing as well, when there is no credit for customer/group/reseller/single call/callback it would cut the call, also if a callerid is blocked, the would also be hangup.
  • astercctools: astercctools will put some useful data to database, like sip status and queue status

so you need astercc and astercctools running when it’s a call center application, and need astercc, asterrc, astercclock when it’s a billing application. In scripts directory, it also provide you some tools to control daemons above

  • asterccd: start, stop or check astercc status(you can edit it to assign which daemon could be controled)
  • asterccdaemon: a watch dog shell, put it to your cron job list so it would start astercc daemons when they dies(if it start by asterccd,then which daemon could be checked by it is same as which daemon could be controled by asterccd)