def process_cdr(self, cdr_xml):
        cdr_dom = xml.parseString(cdr_xml)
        #handle only b-legs for billing
        origin = cdr_dom.getElementsByTagName("origination")
        if (origin):
            return

        billsec = getText(cdr_dom.getElementsByTagName("billsec")[0].childNodes)
        caller = getText(cdr_dom.getElementsByTagName("username")[0].childNodes)
        if (caller[0] == '+'):
            caller = caller[1:]

        #in b-leg cdrs, there are multiple destinations
        #the sip one (IMSI) and the dialed one (MSISDN)
        #we want the latter
        callees = cdr_dom.getElementsByTagName("destination_number")
        callee = ''
        for c in callees:
            c = getText(c.childNodes)
            #NOT THE IMSI
            if (c[0:4] != "IMSI"):
                callee = c
                break

        if (callee[0] == "+"):
            callee = callee[1:]

        if len(cdr_dom.getElementsByTagName("service_type")) > 0:
            service_type = getText(cdr_dom.getElementsByTagName("service_type")[0].childNodes)
            rate = vbts_credit.get_service_tariff(service_type)
            cost = vbts_credit.call_cost(billsec, service_type)
            print "%s: %s sec @ %s R/min, %d" % (caller, billsec, rate, cost)
            vbts_credit.deduct(cost, caller, "%d sec call to %s at %s" % (int(billsec), callee, service_type))
        else:
            print "No rate info for this call. (from: %s, billsec: %s)" % (caller, billsec)
 def bill(self, to, from_):
     syslog.syslog("VBTS " + to + " " + from_)
     try:
         tariff = vbts_credit.sms_cost(self.tariff_type)
         username = vbts_util.messenger.SR_dialdata_get("dial", ("exten", to))
         if (username and username != ""):
             vbts_credit.deduct(tariff, username, "Incoming SMS from %s to %s at %s" % (from_, to, self.tariff_type))
     except Exception as e:
         syslog.syslog("VBTS " + traceback.format_exc(e))
Пример #3
0
 def bill(self, to, from_):
     syslog.syslog("VBTS " + to + " " + from_)
     try:
         tariff = vbts_credit.sms_cost(self.tariff_type)
         username = vbts_util.messenger.SR_dialdata_get(
             "dial", ("exten", to))
         if (username and username != ""):
             vbts_credit.deduct(
                 tariff, username, "Incoming SMS from %s to %s at %s" %
                 (from_, to, self.tariff_type))
     except Exception as e:
         syslog.syslog("VBTS " + traceback.format_exc(e))
Пример #4
0
    def process_cdr(self, cdr_xml):
        cdr_dom = xml.parseString(cdr_xml)
        #handle only b-legs for billing
        origin = cdr_dom.getElementsByTagName("origination")
        if (origin):
            return

        billsec = getText(
            cdr_dom.getElementsByTagName("billsec")[0].childNodes)
        caller = getText(
            cdr_dom.getElementsByTagName("username")[0].childNodes)
        if (caller[0] == '+'):
            caller = caller[1:]

        #in b-leg cdrs, there are multiple destinations
        #the sip one (IMSI) and the dialed one (MSISDN)
        #we want the latter
        callees = cdr_dom.getElementsByTagName("destination_number")
        callee = ''
        for c in callees:
            c = getText(c.childNodes)
            #NOT THE IMSI
            if (c[0:4] != "IMSI"):
                callee = c
                break

        if (callee[0] == "+"):
            callee = callee[1:]

        if len(cdr_dom.getElementsByTagName("service_type")) > 0:
            service_type = getText(
                cdr_dom.getElementsByTagName("service_type")[0].childNodes)
            rate = vbts_credit.get_service_tariff(service_type)
            cost = vbts_credit.call_cost(billsec, service_type)
            print "%s: %s sec @ %s R/min, %d" % (caller, billsec, rate, cost)
            vbts_credit.deduct(
                cost, caller, "%d sec call to %s at %s" %
                (int(billsec), callee, service_type))
        else:
            print "No rate info for this call. (from: %s, billsec: %s)" % (
                caller, billsec)
 def process_smscdr(self, from_, service_type, dest):
     cost_in_credits = vbts_credit.sms_cost(service_type)
     vbts_credit.deduct(int(cost_in_credits), from_, "SMS sent to %s at %s" % (dest, service_type))
Пример #6
0
 def process_smscdr(self, from_, service_type, dest):
     cost_in_credits = vbts_credit.sms_cost(service_type)
     vbts_credit.deduct(int(cost_in_credits), from_,
                        "SMS sent to %s at %s" % (dest, service_type))