Need Help Regarding Suppliers/Derived Charges/Charges

130 views
Skip to first unread message

mtayya...@gmail.com

unread,
Feb 8, 2019, 2:42:53 AM2/8/19
to CGRateS
Hi, I need help regarding Suppliers and Derived Charges
My first question is that what is difference between Charges and Derived Charges (I know derived charges are used for forking cdrs).
So I want to know how I can find how much we are paying to supplier for a call in cdrs or some other way.
In my supplier I may use multiple suppliers for same destination for failover. What is best solution to achieve this if call is made to X supplier and I want to fork CDR so I know what amount we have paid to that supplier X and what amount we have charged from customer (Which is already there in CDRs)
Thanks
Regards,
Tayyab Talha 

Dan Christian Bogos

unread,
Feb 8, 2019, 3:25:59 AM2/8/19
to cgr...@googlegroups.com
Hi Tayyab,

Please find answers inline ...

On Thu, 2019-02-07 at 23:42 -0800, mtayya...@gmail.com wrote:
> Hi, I need help regarding Suppliers and Derived Charges
> My first question is that what is difference between Charges and
> Derived Charges (I know derived charges are used for forking cdrs).
The Derived Chargers was deprecated by Chargers (and will be removed
from code in the following weeks). Basically Chargers are forking CDRs
and sessions based on your defined rules. There needs to be at least
one Charger profile in your system since otherwise you will have no
billing runs. This would be the main difference compared with old
DerivedChargers since the *default was done there by default.

> So I want to know how I can find how much we are paying to supplier
> for a call in cdrs or some other way.
For that you should configure at least 2 ChargerProfiles - one for
default rating and one for your supplier rating.

> In my supplier I may use multiple suppliers for same destination for
> failover. What is best solution to achieve this if call is made to X
> supplier and I want to fork CDR so I know what amount we have paid to
> that supplier X and what amount we have charged from customer (Which
> is already there in CDRs)
You need to identify the supplier information in your CDR and use that
as rating Subject or Category. From there you configure rating in
RatingProfiles as you would do for a standalone CDR.

Hope it helps.

DanB
> Thanks
> Regards,
> Tayyab Talha
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/b152ef79-9870-4e17-81a0-84f2a16dd9c2%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

mtayya...@gmail.com

unread,
Feb 8, 2019, 7:04:05 AM2/8/19
to CGRateS
Hi, Dan
Thanks for your reply  you are always very helpful.
So as per your advice I have enabled charger in my cgrates.json by adding following config
"cdrs": {
        "enabled": true,
        "sessions_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "stats_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "chargers_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "sessions_cost_retries": 5,
},


"sessions": {
        "enabled": true,
        "rals_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "cdrs_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "chargers_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "resources_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "suppliers_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "attributes_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "stats_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "thresholds_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],
        "debit_interval": "5s",
        "channel_sync_interval":"7s",
},
"chargers": {                                                           // Charger service
        "enabled": true,                                                // starts charger service: <true|false>.
        "attributes_conns": [
                {"address": "127.0.0.1:2012", "transport": "*json"},
        ],                                      // address where to reach the AttributeS <""|127.0.0.1:2013>
//      //"string_indexed_fields": [],                  // query indexes based on these fields for faster processing
//      "prefix_indexed_fields": [],                    // query indexes based on these fields for faster processing
},


Here are my Chargers

curl -X POST -H "Content-Type: application/json" -d '{"method":"ApierV1.GetChargerProfileIDs","params":["cgrates.org"]}' http://cgrates:2080/jsonrpc | python -m json.tool
{
    "error": null,
    "id": null,
    "result": [
        "Suppliers",
        "DEFAULT"
    ]
}


curl -X POST -H "Content-Type: application/json" -d '{"method":"ApierV1.GetChargerProfile","params":[{"tenant":"cgrates.org","ID":"Suppliers"}]}' http://cgrates:2080/jsonrpc | python -m json.tool

{
    "error": null,
    "id": null,
    "result": {
        "ActivationInterval": null,
        "AttributeIDs": [
            "*none"
        ],
        "FilterIDs": [],
        "ID": "Suppliers",
        "RunID": "supplier",
        "Tenant": "cgrates.org",
        "Weight": 0
    }
}

curl -X POST -H "Content-Type: application/json" -d '{"method":"ApierV1.GetChargerProfile","params":[{"tenant":"cgrates.org","ID":"DEFAULT"}]}' http://cgrates:2080/jsonrpc | python -m json.tool

{
    "error": null,
    "id": null,
    "result": {
        "ActivationInterval": null,
        "AttributeIDs": [
            "*none"
        ],
        "FilterIDs": [],
        "ID": "DEFAULT",
        "RunID": "*default",
        "Tenant": "cgrates.org",
        "Weight": 0
    }
}


But After setting this up Now I'm getting RATING_PLAN_NOT_FOUND. You can check in following logs. Anything I'm doing wrong

#
  {"method":"AttributeSv1.ProcessEvent","params":[{"AttributeIDs":null,"ProcessRuns":null,"Tenant":"cgrates.org","ID":"f668b9d","Context":"*sessions","Time":"2019-02-08T12:20:03.723Z","RouteID":null,"Event":{"Account":"1001","Destinat
  ion":"447380700001","EventName":"SMA_AUTHORIZATION","OriginHost":"billing","OriginID":"billing-1549628403.2082","RequestType":"*prepaid","SetupTime":"2019-02-08T12:20:03.720+0000","Source":"AsteriskAgent","Supplier":"supplier1","cgr
  _defaultaccount":"800106500000","cgr_subsystems":"*accounts*attributes*resources*stats*suppliers*thresholds*chargers"}}],"id":0}.
##
  {"id":0,"result":{"MatchedProfiles":["ATTR_TEST1"],"AlteredFields":["NEXMO","AQL1"],"CGREvent":{"Tenant":"cgrates.org","ID":"f668b9d","Context":"*sessions","Time":"2019-02-08T12:20:03.723Z","RouteID":null,"Event":{"AQL1":"10.1.1.12"
  ,"Account":"1001","Destination":"447380700001","EventName":"SMA_AUTHORIZATION","NEXMO":"10.1.1.13","OriginHost":"billing","OriginID":"billing-1549628403.2082","RequestType":"*prepaid","SetupTime":"2019-02-08T12:20:03.720+0000","Sour
  ce":"AsteriskAgent","Supplier":"supplier1","cgr_defaultaccount":"800106500000","cgr_subsystems":"*accounts*attributes*resources*stats*suppliers*thresholds*chargers"}}},"error":null}.
##
  {"method":"ChargerSv1.ProcessEvent","params":[{"Tenant":"cgrates.org","ID":"cd5812a","Context":null,"Time":null,"RouteID":null,"Event":{"AQL1":"10.1.1.12","Account":"1001","CGRID":"122f391bb0ec80887e3f9337cc2bc14c34feaca4","Destinat
  ion":"447380700001","EventName":"SMA_AUTHORIZATION","NEXMO":"10.1.1.13","OriginHost":"billing","OriginID":"billing-1549628403.2082","RequestType":"*prepaid","SetupTime":"2019-02-08T12:20:03.720+0000","Source":"AsteriskAgent","Suppli
  er":"supplier1","Usage":10800000000000,"cgr_defaultaccount":"800106500000","cgr_subsystems":"*accounts*attributes*resources*stats*suppliers*thresholds*chargers"}}],"id":0}.
##
  {"id":0,"result":[{"ChargerSProfile":"DEFAULT","AttributeSProfiles":null,"AlteredFields":null,"CGREvent":{"Tenant":"cgrates.org","ID":"cd5812a","Context":null,"Time":null,"RouteID":null,"Event":{"AQL1":"10.1.1.12","Account":"1001","
  CGRID":"122f391bb0ec80887e3f9337cc2bc14c34feaca4","Destination":"447380700001","EventName":"SMA_AUTHORIZATION","NEXMO":"10.1.1.13","OriginHost":"billing","OriginID":"billing-1549628403.2082","RequestType":"*prepaid","RunID":"*defaul
  t","SetupTime":"2019-02-08T12:20:03.720+0000","Source":"AsteriskAgent","Supplier":"supplier1","Usage":10800000000000,"cgr_defaultaccount":"800106500000","cgr_subsystems":"*accounts*attributes*resources*stats*suppliers*thresholds*cha
  rgers"}}},{"ChargerSProfile":"Suppliers","AttributeSProfiles":null,"AlteredFields":null,"CGREvent":{"Tenant":"cgrates.org","ID":"cd5812a","Context":null,"Time":null,"RouteID":null,"Event":{"AQL1":"10.1.1.12","Account":"1001","CGRID"
  :"122f391bb0ec80887e3f9337cc2bc14c34feaca4","Destination":"447380700001","EventName":"SMA_AUTHORIZATION","NEXMO":"10.1.1.13","OriginHost":"billing","OriginID":"billing-1549628403.2082","RequestType":"*prepaid","RunID":"supplier","Se
  tupTime":"2019-02-08T12:20:03.720+0000","Source":"AsteriskAgent","Supplier":"supplier1","Usage":10800000000000,"cgr_defaultaccount":"800106500000","cgr_subsystems":"*accounts*attributes*resources*stats*suppliers*thresholds*chargers"
  }}}],"error":null}.
##
  {"method":"Responder.GetMaxSessionTime","params":[{"Direction":"*out","Category":"","Tenant":"cgrates.org","Subject":"","Account":"1001","Destination":"447380700001","TimeStart":"2019-02-08T12:20:03.72Z","TimeEnd":"2019-02-08T15:20:
  03.72Z","LoopIndex":0,"DurationIndex":0,"FallbackSubject":"","RatingInfos":null,"Increments":null,"TOR":"","ExtraFields":{"AQL1":"10.1.1.12","EventName":"SMA_AUTHORIZATION","NEXMO":"10.1.1.13","Supplier":"supplier1","cgr_defaultacco
  unt":"800106500000","cgr_subsystems":"*accounts*attributes*resources*stats*suppliers*thresholds*chargers"},"MaxRate":0,"MaxRateUnit":0,"MaxCostSoFar":0,"CgrID":"122f391bb0ec80887e3f9337cc2bc14c34feaca4","RunID":"*default","ForceDura
  tion":false,"PerformRounding":false,"DryRun":false,"DenyNegativeAccount":false}],"id":0}.
##
  {"id":0,"result":null,"error":"RATING_PLAN_NOT_FOUND"}.


Another question is that in case of Chargers How I can get suppliers info from cdrs and use it for further charges as in following Chargers I only see arrtibutes and Filters. So I'm assuming that somehow we need to use filters and Attributes for that purpose. So I can get some example or some more info how I can use supplier information in filters to run charges for forking cdrs.  
Chargers
#Tenant,ID,FilterIDs,ActivationInterval,RunID,AttributeIDs,Weight
cgrates.org,DEFAULT,,,*default,*none,0
cgrates.org,Suppliers,,,supplier,*none,0

Dan Christian Bogos

unread,
Feb 8, 2019, 7:23:38 AM2/8/19
to cgr...@googlegroups.com
Hi Tayyab,

To solve RATING_PLAN_NOT_FOUND error, you should make cost simulation
working since most probably you have an error in your tariff plans.

DanB



mtayya...@gmail.com

unread,
Feb 8, 2019, 7:41:14 AM2/8/19
to CGRateS
Hi Dan,
Thannks for your reply
I have figure out that in that case Subject and Category was empty so I pass these from dialplan and now call is working fine. May be now it is not setting it by default now.
But I'm still confuse on how to apply filters on charges. Now it is charging the account for two time one for DEFAULT and other for Suppliers so how I can change the request type to *rated and also want to set supplier rating so I can calculate it charges for different suppliers
Regards,
Tayyab Talha

Dan Christian Bogos

unread,
Feb 8, 2019, 10:13:16 AM2/8/19
to cgr...@googlegroups.com
Tayyab,

You should "overwrite" the original category or subject in the second
run (supplier) via AttributeS (configure AttributeIDs).
In that scenario, ChargerS will use AttributeS to alter your second CDR
with the profile you configure inthere.

DanB
> --
> You received this message because you are subscribed to the Google
> Groups "CGRateS" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to cgrates+u...@googlegroups.com.
> To post to this group, send email to cgr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/cgrates/e1f0c0b8-8b4d-4b0f-baf2-871911bf4b70%40googlegroups.com

mtayya...@gmail.com

unread,
Feb 9, 2019, 2:53:44 AM2/9/19
to CGRateS
Hi Dan,
Thank you very much it working now the trick here to create attributes with context *charges and replace RequestType from  *prepared to *rated and Subject to RatingProfile of supplier then use these attribute in chargers.
Regards,
Tayyab Talha 
Reply all
Reply to author
Forward
0 new messages