diff --git a/data/conf/samples/tutmysql/cgrates.json b/data/conf/samples/tutmysql/cgrates.json index ff573c1b1..e131604b4 100644 --- a/data/conf/samples/tutmysql/cgrates.json +++ b/data/conf/samples/tutmysql/cgrates.json @@ -4,14 +4,18 @@ // Used for cgradmin // Starts rater, scheduler +"general": { + "log_level": 7, +}, + "listen": { - "rpc_json": ":2012", // RPC JSON listening address - "rpc_gob": ":2013", // RPC GOB listening address - "http": ":2080", // HTTP listening address + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", }, "rals": { - "enabled": true, // enable Rater service: + "enabled": true, "cdrstats_conns": [ {"address": "*internal"} ], @@ -27,11 +31,11 @@ }, "scheduler": { - "enabled": true, // start Scheduler service: + "enabled": true, }, "cdrs": { - "enabled": true, // start the CDR Server service: + "enabled": true, "cdrstats_conns": [ {"address": "*internal"} ], @@ -66,4 +70,23 @@ "enabled": true, // starts Aliases service: . }, +"cdre": { + "TestTutITExportCDR": { + "content_fields": [ // template of the exported content fields + {"tag": "CGRID", "type": "*composed", "value": "CGRID"}, + {"tag": "RunID", "type": "*composed", "value": "RunID"}, + {"tag":"OriginID", "type": "*composed", "value": "OriginID"}, + {"tag":"RequestType", "type": "*composed", "value": "RequestType"}, + {"tag":"Tenant", "type": "*composed", "value": "Tenant"}, + {"tag":"Category", "type": "*composed", "value": "Category"}, + {"tag":"Account", "type": "*composed", "value": "Account"}, + {"tag":"Destination", "type": "*composed", "value": "Destination"}, + {"tag":"AnswerTime", "type": "*composed", "value": "AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"}, + {"tag":"Usage", "type": "*composed", "value": "Usage"}, + {"tag":"Cost", "type": "*composed", "value": "Cost", "rounding_decimals": 4}, + {"tag":"MatchedDestinationID", "type": "*composed", "value": "~CostDetails:s/\"MatchedDestId\":.*_(\\w{4})/${1}/:s/\"MatchedDestId\":\"INTERNAL\"/ON010/"}, + ], + }, +}, + } diff --git a/engine/cdr.go b/engine/cdr.go index 80e4e0490..691e5b81a 100644 --- a/engine/cdr.go +++ b/engine/cdr.go @@ -709,13 +709,6 @@ func (cdr *CDR) exportFieldValue(cfgCdrFld *config.CfgCdrField) (string, error) for _, rsrFld := range cfgCdrFld.Value { var cdrVal string switch rsrFld.Id { - case utils.COST_DETAILS: // Special case when we need to further extract cost_details out of logDb - if cdr.CostDetails == nil { - cdrVal = "" - } else { - jsonVal, _ := json.Marshal(cdr.CostDetails) - cdrVal = string(jsonVal) - } case utils.COST: cdrVal = cdr.FormatCost(cfgCdrFld.CostShiftDigits, cfgCdrFld.RoundingDecimals) case utils.USAGE: diff --git a/general_tests/tutorial_it_test.go b/general_tests/tutorial_it_test.go index 7aa35fe0f..6c29b18c0 100644 --- a/general_tests/tutorial_it_test.go +++ b/general_tests/tutorial_it_test.go @@ -1379,13 +1379,13 @@ func TestTutITExportCDR(t *testing.T) { var replyExport utils.ExportedFileCdrs exportArgs := utils.AttrExportCdrsToFile{ExportDirectory: utils.StringPointer("/tmp"), ExportFileName: utils.StringPointer("TestTutITExportCDR.csv"), - RPCCDRsFilter: utils.RPCCDRsFilter{CGRIDs: []string{cdr.CGRID}}} + ExportTemplate: utils.StringPointer("TestTutITExportCDR"), + RPCCDRsFilter: utils.RPCCDRsFilter{CGRIDs: []string{cdr.CGRID}, NotRunIDs: []string{utils.MetaRaw}}} if err := tutLocalRpc.Call("ApierV2.ExportCdrsToFile", exportArgs, &replyExport); err != nil { t.Error(err) } - eExportContent := `f0a92222a7d21b4d9f72744aabe82daef52e20d8,*default,*voice,testexportcdr1,*rated,*out,cgrates.org,call,1001,1001,1003,2016-11-30T18:05:24+01:00,2016-11-30T18:06:04+01:00,98,1.3334 -f0a92222a7d21b4d9f72744aabe82daef52e20d8,*raw,*voice,testexportcdr1,*rated,*out,cgrates.org,call,1001,1001,1003,2016-11-30T18:05:24+01:00,2016-11-30T18:06:04+01:00,98,-1.0000 -f0a92222a7d21b4d9f72744aabe82daef52e20d8,derived_run1,*voice,testexportcdr1,*rated,*out,cgrates.org,call,1001,1002,1003,2016-11-30T18:05:24+01:00,2016-11-30T18:06:04+01:00,98,1.3334 + eExportContent := `f0a92222a7d21b4d9f72744aabe82daef52e20d8,*default,testexportcdr1,*rated,cgrates.org,call,1001,1003,2016-11-30T18:06:04+01:00,98,1.3334,RETA +f0a92222a7d21b4d9f72744aabe82daef52e20d8,derived_run1,testexportcdr1,*rated,cgrates.org,call,1001,1003,2016-11-30T18:06:04+01:00,98,1.3334,RETA ` if expContent, err := ioutil.ReadFile(path.Join(*exportArgs.ExportDirectory, *exportArgs.ExportFileName)); err != nil { t.Error(err)