CDR fix for exporting CostDetails

This commit is contained in:
DanB
2016-12-01 13:21:02 +01:00
parent 82a7b3806c
commit de87d0f035
3 changed files with 33 additions and 17 deletions

View File

@@ -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: <true|false>
"enabled": true,
"cdrstats_conns": [
{"address": "*internal"}
],
@@ -27,11 +31,11 @@
},
"scheduler": {
"enabled": true, // start Scheduler service: <true|false>
"enabled": true,
},
"cdrs": {
"enabled": true, // start the CDR Server service: <true|false>
"enabled": true,
"cdrstats_conns": [
{"address": "*internal"}
],
@@ -66,4 +70,23 @@
"enabled": true, // starts Aliases service: <true|false>.
},
"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/"},
],
},
},
}

View File

@@ -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:

View File

@@ -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)