Customer vs Supplier pricing.

684 views
Skip to first unread message

Maxim Konin

unread,
Jan 22, 2021, 2:58:50 AM1/22/21
to CGRateS
Hi

I want to create a tariff plan with supplier and customer prices. There is a working example?

As far as I understand, I need to use the ChargerS module, but it's absolutely not clear to me in what form I should create a tariff plan

Thx

Alexandru Tripon

unread,
Jan 25, 2021, 9:19:23 AM1/25/21
to cgr...@googlegroups.com
Hi Maxim,

Here we have defined two Chargers, one for the customer and one for a supplier.
The charger for the supplier changes the category of the call, using attributes, to match the supplier rate(https://github.com/cgrates/cgrates/blob/master/data/tariffplans/tutorial2/RatingProfiles.csv#L9)

Thanks,
Trial97

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/27416874-e88a-4251-b7f7-dfbf4216e091n%40googlegroups.com.

Maxim Konin

unread,
Jan 25, 2021, 10:25:12 PM1/25/21
to CGRateS
This looks like what I need, Thank you

понедельник, 25 января 2021 г. в 21:19:23 UTC+7, alexandr...@itsyscom.com:

Maxim Konin

unread,
Feb 1, 2021, 5:46:02 AM2/1/21
to CGRateS
Hi Alex

I'm trying to follow your example but I get this error message
```
CGRateS <CGRAsterisk> [18440]: <AsteriskAgent> error: CHARGERS_ERROR:NOT_FOUND authorizing session for channelID: 1612176107.1069
CGRateS <CGRAsterisk> [18440]: <AsteriskAgent> failed disconnecting channel <1612176107.1069>, err: UNEXPECTED_REPLY_CODE: 404
```

Do you have any idea what could have gone wrong?

вторник, 26 января 2021 г. в 10:25:12 UTC+7, Maxim Konin:

Alexandru Tripon

unread,
Feb 1, 2021, 9:03:45 AM2/1/21
to cgr...@googlegroups.com
Hi Maxim,

Please make sure that you loaded the Chargers in the DataDB.
If they are correctly loaded in the DataDb please post them here and also post the ngrep between Asterisk and CGRateS.

Thanks,
Trial97

Maxim Konin

unread,
Feb 2, 2021, 4:10:32 AM2/2/21
to CGRateS
Hi



понедельник, 1 февраля 2021 г. в 21:03:45 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Feb 3, 2021, 4:39:42 AM2/3/21
to cgr...@googlegroups.com
Hi Maxim,

Please post the config you are using as I could not reproduce this only using the given data.
Can you also please attach the full ngrep with the ChargerSv1.ProcessEvent API call.

Thanks,
Trial97

Maxim Konin

unread,
Feb 3, 2021, 5:30:28 AM2/3/21
to CGRateS
Hi Alex


I use Postgres as a store db.

среда, 3 февраля 2021 г. в 16:39:42 UTC+7, alexandr...@itsyscom.com:

Maxim Konin

unread,
Feb 3, 2021, 5:31:37 AM2/3/21
to CGRateS
> Can you also please attach the full ngrep with the ChargerSv1.ProcessEvent API call.

It was the full ngrep

среда, 3 февраля 2021 г. в 17:30:28 UTC+7, Maxim Konin:

Alexandru Tripon

unread,
Feb 3, 2021, 8:43:06 AM2/3/21
to cgr...@googlegroups.com
Hi Maxim,

Please put the following connections: between Asterisk and SessionS, between SessionS and ChargerS, and between ChargerS and AttributeS on "*localhost" and recapture the ngrep.
The call from the previous ngrep is most probably between the sessions and attributes but the error from the Syslog is from ChargerS.

Thanks,
Trial97

Maxim Konin

unread,
Feb 3, 2021, 9:47:41 AM2/3/21
to CGRateS
Hi Alex

I've got logs

T 127.0.0.1:51462 -> 127.0.0.1:2012 [AP] #4

  {"method":"SessionSv1.AuthorizeEvent","params":[{"GetAttributes":true,"AuthorizeResources":true,"GetMaxUsage":true,"ForceDuration":false,"ProcessThresholds":true,"ProcessStats":tr

  ue,"GetRoutes":true,"RoutesMaxCost":"","RoutesIgnoreErrors":false,"AttributeIDs":null,"ThresholdIDs":null,"StatIDs":null,"Opts":{},"Tenant":"cgrates.org","ID":"b62a698","Time":"20

  21-02-03T14:42:20.916Z","Event":{"Account":"901","Destination":"7999","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612363340.1601","RequestType"

  :"*prepaid","SetupTime":"2021-02-03T14:42:20.910+0000","Source":"AsteriskAgent","cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","did":"7999",

  "direction":"out","my_disposition":"test"},"Limit":null,"Offset":null}],"id":0}.                                                                                                   

##

T 127.0.0.1:51462 -> 127.0.0.1:2012 [AP] #6

  {"method":"AttributeSv1.ProcessEvent","params":[{"AttributeIDs":null,"Context":"*sessions","ProcessRuns":null,"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"b62a698",

  "Time":"2021-02-03T14:42:20.916Z","Event":{"Account":"901","Destination":"7999","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612363340.1601","Re

  questType":"*prepaid","SetupTime":"2021-02-03T14:42:20.910+0000","Source":"AsteriskAgent","cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","di

  d":"7999","direction":"out","my_disposition":"test"}}],"id":1}.                                                                                                                    

##

T 127.0.0.1:2012 -> 127.0.0.1:51462 [AP] #8

  {"id":1,"result":null,"error":"NOT_FOUND"}.                                                                                                                                        

##

T 127.0.0.1:51462 -> 127.0.0.1:2012 [AP] #10

  {"method":"ChargerSv1.ProcessEvent","params":[{"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"b62a698","Time":"2021-02-03T14:42:20.916Z","Event":{"Account":"901","CGR

  ID":"5fe3066295bac24ff9141cce44831787e3b705d0","Destination":"7999","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612363340.1601","RequestType":"

  *prepaid","SetupTime":"2021-02-03T14:42:20.910+0000","Source":"AsteriskAgent","Usage":10800000000000,"cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid

  ":"901","did":"7999","direction":"out","my_disposition":"test"}}],"id":2}.                                                                                                         

#

T 127.0.0.1:2012 -> 127.0.0.1:51462 [AP] #11

  {"id":2,"result":null,"error":"NOT_FOUND"}.                                                                                                                                        

#

T 127.0.0.1:2012 -> 127.0.0.1:51462 [AP] #12

  {"id":0,"result":null,"error":"CHARGERS_ERROR:NOT_FOUND"}.    


среда, 3 февраля 2021 г. в 20:43:06 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Feb 5, 2021, 6:34:01 AM2/5/21
to cgr...@googlegroups.com
Hi Maxim,

Unfortunately, I could not reproduce this.
In the given config the dataDB section is missing, can we presume that you are using Redis as your dataDB?
In order for us to try to reproduce this better can you offer a fresh dataDB dump, only with the chargers and attributes?
And using this fresh DB try manually sending the ChargerSv1.ProcessEvent API call to CGRateS and post the output.
The Postgres(storDB) dump is not useful because the events are checked against the data from the dataDB.
Also please attach the version you are using.

Thanks,
Trial97

Maxim Konin

unread,
Feb 10, 2021, 10:03:03 AM2/10/21
to CGRateS
Hi. Sorry for the delay. 

> The Postgres(storDB) dump is not useful because the events are checked against the data from the dataDB.
I'm using loadTariffPlanFromStoreDB to load data from storedb to datadb

I've started from scratch. Now it looks like chargers work fine. ChargerSv1.ProcessEvent returns correct response

But I faced with issues connected with stats and thresholdes. Is it possible to disable these modules?

  {"method":"SessionSv1.AuthorizeEvent","params":[{"GetAttributes":true,"AuthorizeResources":true,"GetMaxUsage":true,"ForceDuration":false,"ProcessThresholds":true,"ProcessStats":tru

  e,"GetRoutes":true,"RoutesMaxCost":"","RoutesIgnoreErrors":false,"AttributeIDs":null,"ThresholdIDs":null,"StatIDs":null,"Opts":{},"Tenant":"cgrates.org","ID":"362ac79","Time":"2021

  -02-10T14:53:45.808Z","Event":{"Account":"901","Destination":"79134577371","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612968825.14952","Request

  Type":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","did":"79

  134577371","direction":"out","my_disposition":"test"},"Limit":null,"Offset":null}],"id":37}.                                                                                        

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #2

  {"method":"AttributeSv1.ProcessEvent","params":[{"AttributeIDs":null,"Context":"*sessions","ProcessRuns":null,"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"362ac79","

  Time":"2021-02-10T14:53:45.808Z","Event":{"Account":"901","Destination":"79134577371","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612968825.1495

  2","RequestType":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901

  ","did":"79134577371","direction":"out","my_disposition":"test"}}],"id":38}.                                                                                                        

##

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #4

  {"id":38,"result":{"MatchedProfiles":["ATTR_CRG_SUPPLIER"],"AlteredFields":["*req.Category"],"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"362ac79","Time":"2021-02-10

  T14:53:45.808Z","Event":{"Account":"901","Category":"reseller","Destination":"79134577371","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612968825

  .14952","RequestType":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid"

  :"901","did":"79134577371","direction":"out","my_disposition":"test"}},"error":null}.                                                                                               

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #5

  {"method":"AttributeSv1.ProcessEvent","params":[{"AttributeIDs":["ATTR_CRG_SUPPLIER"],"Context":"*chargers","ProcessRuns":null,"Opts":{"*subsys":"*chargers"},"Tenant":"cgrates.org"

  ,"ID":"362ac79","Time":"2021-02-10T14:53:45.808Z","Event":{"Account":"901","CGRID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","Category":"reseller","Destination":"79134577371","Eve

  ntName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612968825.14952","RequestType":"*prepaid","RunID":"reseller","SetupTime":"2021-02-10T14:53:45.800+0000",

  "Source":"AsteriskAgent","Usage":10800000000000,"cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disp

  osition":"test"}}],"id":39}.                                                                                                                                                        

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #6

  {"id":39,"result":null,"error":"NOT_FOUND"}.                                                                                                                                        

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #7

  {"method":"Responder.GetMaxSessionTime","params":[{"Category":"reseller","Tenant":"cgrates.org","Subject":"901","Account":"901","Destination":"79134577371","TimeStart":"2021-02-10T

  14:53:45.8Z","TimeEnd":"2021-02-10T17:53:45.8Z","LoopIndex":0,"DurationIndex":0,"FallbackSubject":"","RatingInfos":null,"Increments":null,"ToR":"","ExtraFields":{"EventName":"SMA_A

  UTHORIZATION","cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disposition":"test"},"MaxRate":0,"MaxR

  ateUnit":0,"MaxCostSoFar":0,"CgrID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","RunID":"reseller","ForceDuration":false,"PerformRounding":false,"DryRun":false,"DenyNegativeAccount"

  :false,"Opts":{"*subsys":"*sessions"}}],"id":40}.                                                                                                                                   

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #8

  {"id":40,"result":0,"error":null}.                                                                                                                                                  

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #9

  {"method":"Responder.GetMaxSessionTime","params":[{"Category":"reseller","Tenant":"cgrates.org","Subject":"901","Account":"901","Destination":"79134577371","TimeStart":"2021-02-10T

  14:53:45.8Z","TimeEnd":"2021-02-10T17:53:45.8Z","LoopIndex":0,"DurationIndex":0,"FallbackSubject":"","RatingInfos":null,"Increments":null,"ToR":"","ExtraFields":{"EventName":"SMA_A

  UTHORIZATION","cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disposition":"test"},"MaxRate":0,"MaxR

  ateUnit":0,"MaxCostSoFar":0,"CgrID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","RunID":"*default","ForceDuration":false,"PerformRounding":false,"DryRun":false,"DenyNegativeAccount"

  :false,"Opts":{"*subsys":"*sessions"}}],"id":41}.                                                                                                                                   

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #10

  {"id":41,"result":0,"error":null}.                                                                                                                                                  

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #11

  {"method":"ResourceSv1.AuthorizeResources","params":[{"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"362ac79","Time":"2021-02-10T14:53:45.808Z","Event":{"Account":"901

  ","CGRID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","Category":"reseller","Destination":"79134577371","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","OriginID"

  :"1612968825.14952","RequestType":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","Usage":10800000000000,"cgr_flags":"*accounts,*attributes,*resource

  s,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disposition":"test"},"UsageID":"1612968825.14952","UsageTTL":null,"Units":1}],"id":42}.         

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #12

  {"id":42,"result":"ResGroup1","error":null}.                                                                                                                                        

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #13

  {"method":"RouteSv1.GetRoutes","params":[{"IgnoreErrors":false,"MaxCost":"","Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"362ac79","Time":"2021-02-10T14:53:45.808Z","

  Event":{"Account":"901","CGRID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","Category":"reseller","Destination":"79134577371","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.l

  eadzvon.ru","OriginID":"1612968825.14952","RequestType":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","Usage":10800000000000,"cgr_flags":"*accounts

  ,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disposition":"test"},"Limit":null,"Offset":null}],"id":43}.               

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #14

  {"id":43,"result":{"ProfileID":"SIMPLE_ROUTE","Sorting":"*weight","Count":1,"SortedRoutes":[{"RouteID":"simple_route","RouteParameters":"","SortingData":{"Weight":20}}]},"error":nu

  ll}.                                                                                                                                                                                

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #15

  {"method":"ThresholdSv1.ProcessEvent","params":[{"ThresholdIDs":null,"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"362ac79","Time":"2021-02-10T14:53:45.808Z","Event":

  {"Account":"901","CGRID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","Category":"reseller","Destination":"79134577371","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon

  .ru","OriginID":"1612968825.14952","RequestType":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","Usage":10800000000000,"cgr_flags":"*accounts,*attri

  butes,*resources,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disposition":"test"}}],"id":44}.                                                 

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #16

  {"id":44,"result":null,"error":"NOT_FOUND"}.                                                                                                                                        

#

T 127.0.0.1:38604 -> 127.0.0.1:2012 [AP] #17

  {"method":"StatSv1.ProcessEvent","params":[{"StatIDs":null,"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"362ac79","Time":"2021-02-10T14:53:45.808Z","Event":{"Account"

  :"901","CGRID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","Category":"reseller","Destination":"79134577371","EventName":"SMA_AUTHORIZATION","OriginHost":"flypost.leadzvon.ru","Orig

  inID":"1612968825.14952","RequestType":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","Usage":10800000000000,"cgr_flags":"*accounts,*attributes,*res

  ources,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disposition":"test"}}],"id":45}.                                                           

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #18

  {"id":45,"result":null,"error":"NOT_FOUND"}.                                                                                                                                        

#

T 127.0.0.1:2012 -> 127.0.0.1:38604 [AP] #19

  {"id":37,"result":{"Attributes":{"MatchedProfiles":["ATTR_CRG_SUPPLIER"],"AlteredFields":["*req.Category"],"Opts":{"*subsys":"*sessions"},"Tenant":"cgrates.org","ID":"362ac79","Tim

  e":"2021-02-10T14:53:45.808Z","Event":{"Account":"901","CGRID":"3f3cf860c3a85ecbc889d43e44c0d59ec9e8b148","Category":"reseller","Destination":"79134577371","EventName":"SMA_AUTHORI

  ZATION","OriginHost":"flypost.leadzvon.ru","OriginID":"1612968825.14952","RequestType":"*prepaid","SetupTime":"2021-02-10T14:53:45.800+0000","Source":"AsteriskAgent","Usage":108000

  00000000,"cgr_flags":"*accounts,*attributes,*resources,*stats,*routes,*thresholds","cid":"901","did":"79134577371","direction":"out","my_disposition":"test"}},"ResourceAllocation":

  "ResGroup1","MaxUsage":0,"Routes":{"ProfileID":"SIMPLE_ROUTE","Sorting":"*weight","Count":1,"SortedRoutes":[{"RouteID":"simple_route","RouteParameters":"","SortingData":{"Weight":2

  0}}]},"ThresholdIDs":null,"StatQueueIDs":null},"error":null}. 


пятница, 5 февраля 2021 г. в 18:34:01 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Feb 10, 2021, 10:52:24 AM2/10/21
to cgr...@googlegroups.com
Hi Maxim,

Glad to hear that your issue was fixed.
In order to disable the Stats and Thresholds, you need to tweak the "cgr_flag"(https://github.com/cgrates/cgrates/blob/master/data/tutorials/asterisk_ari/asterisk/etc/asterisk/extensions.conf#L8) variable passed to the statis application.
It should not have the *thresholds and *stats flags similar to this:
"cgr_flags=*accounts,*attributes,*resources,*routes"

Thanks,
Trial97

Maxim Konin

unread,
Feb 11, 2021, 6:24:55 AM2/11/21
to CGRateS
Hi Alex

Thx for ur help.

Calls are working now and CDRs are being created. But "usage" is always 0, cost -1 and cost details is empty for each CDRs. The user's balance does not decrease either

среда, 10 февраля 2021 г. в 22:52:24 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Feb 12, 2021, 5:30:20 AM2/12/21
to cgr...@googlegroups.com
Hi Maxim,

What "cgr_flags" do you have?
In your ChargerS Profiles, I see that for one charger you set the request type to "*rated".
The Events with request type "*rated" will be considered already charged and will not be charged anymore.
What is the request type of the CDRs, are all "*rated" or are other request types for CDRs that have cost -1?

Thanks,
Trial97

Maxim Konin

unread,
Feb 12, 2021, 5:59:49 AM2/12/21
to CGRateS

Hi

"cgr_flags":"*accounts,*attributes,*resources,*routes"

> What is the request type of the CDRs, are all "*rated"

Yes. All CDRs have "*rated" request type, As soon as I change the request type to "*prepaid" it stops working. 

<AsteriskAgent> failed disconnecting channel <1613126957.1767>, err: UNEXPECTED_REPLY_CODE: 404

In fact. I wanna rate both since my goal is to calculate the difference between client and provider tariffs


пятница, 12 февраля 2021 г. в 17:30:20 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Feb 15, 2021, 6:41:31 AM2/15/21
to cgr...@googlegroups.com
Hi Maxim,

Not sure you understand the principle behind.
Please describe what you are trying to achieve.

Thanks,
Trial97

Maxim Konin

unread,
Feb 15, 2021, 7:15:27 AM2/15/21
to CGRateS
Hi Alex

I have 2 types of rating plans
1) Supplier rating plan, e.g.: $0.1 per second
2) I want to resell the traffic to our customers. So I have a "clients" rating plan. e.g.: $0.2

Suppose an account made a call and spoke for a minute. I want to see:
1) Account's balance has been decreased by 60 * $0.2 = $1.2
2) CDR/CDRs have been created with information about how much the call cost to the account and how much we should pay to the supplier (As I understand 2 cdr with different runId)

понедельник, 15 февраля 2021 г. в 18:41:31 UTC+7, alexandr...@itsyscom.com:

Srigo Kana

unread,
Feb 16, 2021, 5:32:59 AM2/16/21
to CGRateS
Hi,

There is a small error here:

For the reseller rating, it's calling ATTR_CRG_RESELLER1 for rewriting Catergory but ATTR_CRG_RESELLER1 not defined in Attributes.csv (It's called ATTR_CRG_SUPPLIER1 there). 

Srigo

Alexandru Tripon

unread,
Feb 16, 2021, 6:56:42 AM2/16/21
to cgr...@googlegroups.com
Hi Maxim,

Please put the request type for the supplier charger to `*rated` and make sure that you have a connection between the CDRServer and RALs(https://github.com/cgrates/cgrates/blob/master/config/config_defaults.go#L358) in order to calculate at the call end the cost for that CDR.
If you still get the Cost equal to -1 that means that you have errors and you need to post that CDR here in order to further investigate them.

Thanks,
Trial97

Maxim Konin

unread,
Feb 19, 2021, 11:11:13 PM2/19/21
to CGRateS
Hi Alex.

I've done that and now the price is set to 0. thx, But usage is still 0 too. Is it correct behavior?
But no matter, as soon as I set the request type as "*prepaid", Responder.GetMaxSessionTime returns 0s for any destinations. I guess something wrong with rate plans but I really cannot understand what. 

Srigo, Yeah, I saw and changed it, thx

вторник, 16 февраля 2021 г. в 18:56:42 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Feb 24, 2021, 9:34:01 AM2/24/21
to cgr...@googlegroups.com
Hi Maxim,

If the Usage is 0 that means that we receive the TerminateSession event from Asterisk with usage 0.
In order to see this can you put the communication between Asterisk agent and SessionS on *localhost and post the ngrep on port 2012.

Thanks,
Trial97

Maxim Konin

unread,
Mar 2, 2021, 6:33:52 AM3/2/21
to CGRateS
Hi Alex

usage is still 0

среда, 24 февраля 2021 г. в 21:34:01 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Mar 8, 2021, 5:07:10 AM3/8/21
to cgr...@googlegroups.com
Hi Maxim,

From the ngrep it can be seen that when the CDRs are generated for that call they already exist.
To see if the CDRs are generated correctly please make sure that the CDRs table is empty and retest.
Please post again the ngrep with the table empty and also post the generated CDRs.

Thanks,
Trial97

Maxim Konin

unread,
Mar 9, 2021, 6:49:29 AM3/9/21
to CGRateS
Hi.

I changed RequestType from prepaid to postpaid and it works now. CDRs are created with correct `usage`. But the "cost" fields are the same for both CDRs, even though I have different rates. I also noticed both CDR have the same `category` 

понедельник, 8 марта 2021 г. в 17:07:10 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Mar 10, 2021, 3:37:15 AM3/10/21
to cgr...@googlegroups.com
Hi Maxim,

I was wondering if you read my previous reply?
Can you please capture again the ngrep with the requestType *rated and empty CDRs table?
Also please post the CDRs generated by the captured call.

Thanks,
Trial97

Maxim Konin

unread,
Mar 11, 2021, 11:08:09 AM3/11/21
to CGRateS
Hi.

I noticed that the system behaves differently depending on the value of asterist_agent.session.conn
1) If it set as localhost the system creates 2 cdrs with usage & cost = 0
2) if it set as internal the system creates 2 cdrs with correct usage but with the same prices


CDRs for 2 case
3027 | 43d189eb0fa3399ea6f0607256ad2c2b080d4bf8 | reseller | flypost.leadzvon.ru | AsteriskAgent | 1615478034.13619 | *voice | *postpaid    | cgrates.org | reseller | 901     | 901 
    | 79XXXXXXXX | 2021-03-11 15:53:54.715+00 | 2021-03-11 15:54:06.525+00 | 6237000000 | {"cid": "901", "did": "79XXXXXXXX", "EventName": "SMA_SESSION_START", "cgr_flags": "*accou
nts,*attributes,*resources,*stats,*routes,*thresholds", "direction": "out", "cgr_routes": "supplier1", "my_disposition": "test"} | *cdrs       | 0.0700 | {"Cost": 0.07, "CGRID": "43d
189eb0fa3399ea6f0607256ad2c2b080d4bf8", "Rates": {"cc85276": [{"Value": 0.01, "RateUnit": 1000000000, "RateIncrement": 1000000000, "GroupIntervalStart": 0}]}, "RunID": "reseller", "U
sage": 7000000000, "Rating": {"983843d": {"MaxCost": 0, "RatesID": "cc85276", "TimingID": "7a89712", "ConnectFee": 0, "RoundingMethod": "*up", "MaxCostStrategy": "*disconnect", "Rati
ngFiltersID": "283c2ab", "RoundingDecimals": 4}}, "Charges": [{"RatingID": "983843d", "Increments": [{"Cost": 0.01, "Usage": 1000000000, "AccountingID": "274c5d0", "CompressFactor": 
7}], "CompressFactor": 1}], "Timings": {"7a89712": {"Years": [], "Months": [], "WeekDays": [], "MonthDays": [], "StartTime": "00:00:00"}}, "StartTime": "2021-03-11T15:54:06.525Z", "A
ccounting": {"274c5d0": {"Units": 0.01, "RatingID": "", "AccountID": "cgrates.org:901", "BalanceUUID": "3aee0c00-25ee-4476-825a-0de4eab3cf80", "ExtraChargeID": ""}}, "RatingFilters":
 {"283c2ab": {"Subject": "*out:cgrates.org:reseller:901", "RatingPlanID": "RP_RESELLER", "DestinationID": "*any", "DestinationPrefix": "*any"}}, "AccountSummary": {"ID": "901", "Tena
nt": "cgrates.org", "Disabled": false, "AllowNegative": false, "BalanceSummaries": [{"ID": "3aee0c00-25ee-4476-825a-0de4eab3cf80", "Type": "*monetary", "UUID": "3aee0c00-25ee-4476-82
5a-0de4eab3cf80", "Value": 99998.33, "Initial": 99998.4, "Disabled": false}]}}  |            | 2021-03-11 15:54:12.799797+00 | 2021-03-11 15:54:12.800066+00 | 
 3028 | 43d189eb0fa3399ea6f0607256ad2c2b080d4bf8 | *default | flypost.leadzvon.ru | AsteriskAgent | 1615478034.13619 | *voice | *postpaid    | cgrates.org | reseller | 901     | 901 
    | 79XXXXXXXX | 2021-03-11 15:53:54.715+00 | 2021-03-11 15:54:06.525+00 | 6237000000 | {"cid": "901", "did": "79XXXXXXXX", "EventName": "SMA_SESSION_START", "cgr_flags": "*accou
nts,*attributes,*resources,*stats,*routes,*thresholds", "direction": "out", "cgr_routes": "supplier1", "my_disposition": "test"} | *cdrs       | 0.0700 | {"Cost": 0.07, "CGRID": "43d
189eb0fa3399ea6f0607256ad2c2b080d4bf8", "Rates": {"06769ac": [{"Value": 0.01, "RateUnit": 1000000000, "RateIncrement": 1000000000, "GroupIntervalStart": 0}]}, "RunID": "*default", "U
sage": 7000000000, "Rating": {"27bfb74": {"MaxCost": 0, "RatesID": "06769ac", "TimingID": "8e6a2c8", "ConnectFee": 0, "RoundingMethod": "*up", "MaxCostStrategy": "*disconnect", "Rati
ngFiltersID": "7259ebd", "RoundingDecimals": 4}}, "Charges": [{"RatingID": "27bfb74", "Increments": [{"Cost": 0.01, "Usage": 1000000000, "AccountingID": "429e102", "CompressFactor": 
7}], "CompressFactor": 1}], "Timings": {"8e6a2c8": {"Years": [], "Months": [], "WeekDays": [], "MonthDays": [], "StartTime": "00:00:00"}}, "StartTime": "2021-03-11T15:54:06.525Z", "A
ccounting": {"429e102": {"Units": 0.01, "RatingID": "", "AccountID": "cgrates.org:901", "BalanceUUID": "3aee0c00-25ee-4476-825a-0de4eab3cf80", "ExtraChargeID": ""}}, "RatingFilters":
 {"7259ebd": {"Subject": "*out:cgrates.org:reseller:901", "RatingPlanID": "RP_RESELLER", "DestinationID": "*any", "DestinationPrefix": "*any"}}, "AccountSummary": {"ID": "901", "Tena
nt": "cgrates.org", "Disabled": false, "AllowNegative": false, "BalanceSummaries": [{"ID": "3aee0c00-25ee-4476-825a-0de4eab3cf80", "Type": "*monetary", "UUID": "3aee0c00-25ee-4476-82
5a-0de4eab3cf80", "Value": 99998.26, "Initial": 99998.33, "Disabled": false}]}} |            | 2021-03-11 15:54:12.821683+00 | 2021-03-11 15:54:12.821761+00 | 

среда, 10 марта 2021 г. в 15:37:15 UTC+7, alexandr...@itsyscom.com:

Alexandru Tripon

unread,
Mar 12, 2021, 4:11:33 AM3/12/21
to cgr...@googlegroups.com
Hi Maxim,

From the ngrep we can see that you change the RequestType for the event before the event is sent to chargers.
If you want to change the RequestType only for the CRG_RESELLER Charger please make sure that you defined the ATTR_CRG_SUPPLIER AttributeProfile with "*chargers" context as of now this is applied for "*sessions" context at the call start.

Thanks,
Trial97

Maxim Konin

unread,
Mar 15, 2021, 8:36:38 AM3/15/21
to CGRateS
Hi

It works fine. Thank you for ur help!

пятница, 12 марта 2021 г. в 16:11:33 UTC+7, alexandr...@itsyscom.com:
Reply all
Reply to author
Forward
0 new messages