mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Updated RoundingDecimals
This commit is contained in:
committed by
Dan Christian Bogos
parent
2c9bfbbe7f
commit
e9bbe666df
@@ -567,7 +567,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "ToR",
|
||||
"Timezone": "",
|
||||
@@ -592,7 +592,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "OriginID",
|
||||
"Timezone": "",
|
||||
@@ -617,7 +617,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "RequestType",
|
||||
"Timezone": "",
|
||||
@@ -642,7 +642,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "Tenant",
|
||||
"Timezone": "",
|
||||
@@ -667,7 +667,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "Category",
|
||||
"Timezone": "",
|
||||
@@ -692,7 +692,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "Account",
|
||||
"Timezone": "",
|
||||
@@ -717,7 +717,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "Subject",
|
||||
"Timezone": "",
|
||||
@@ -742,7 +742,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "Destination",
|
||||
"Timezone": "",
|
||||
@@ -767,7 +767,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "SetupTime",
|
||||
"Timezone": "",
|
||||
@@ -792,7 +792,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "AnswerTime",
|
||||
"Timezone": "",
|
||||
@@ -817,7 +817,7 @@ func testCgrCfgV1ReloadConfigSection(t *testing.T) {
|
||||
"MaskLen": 0,
|
||||
"NewBranch": false,
|
||||
"Padding": "",
|
||||
"RoundingDecimals": 0,
|
||||
"RoundingDecimals": nil,
|
||||
"Strip": "",
|
||||
"Tag": "Usage",
|
||||
"Timezone": "",
|
||||
|
||||
@@ -566,7 +566,7 @@ func TestCgrCfgJSONDefaultsCdreProfiles(t *testing.T) {
|
||||
Path: "*exp.Cost",
|
||||
Type: "*variable",
|
||||
Value: NewRSRParsersMustCompile("~*req.Cost", true, utils.INFIELD_SEP),
|
||||
RoundingDecimals: 4,
|
||||
RoundingDecimals: utils.IntPointer(4),
|
||||
},
|
||||
}
|
||||
eCdreCfg := map[string]*CdreCfg{
|
||||
|
||||
@@ -82,7 +82,8 @@ func NewFCTemplateFromFCTemplateJsonCfg(jsnCfg *FcTemplateJsonCfg, separator str
|
||||
fcTmp.CostShiftDigits = *jsnCfg.Cost_shift_digits
|
||||
}
|
||||
if jsnCfg.Rounding_decimals != nil {
|
||||
fcTmp.RoundingDecimals = *jsnCfg.Rounding_decimals
|
||||
fcTmp.RoundingDecimals = new(int)
|
||||
*fcTmp.RoundingDecimals = *jsnCfg.Rounding_decimals
|
||||
}
|
||||
if jsnCfg.Mask_destinationd_id != nil {
|
||||
fcTmp.MaskDestID = *jsnCfg.Mask_destinationd_id
|
||||
@@ -110,7 +111,7 @@ type FCTemplate struct {
|
||||
BreakOnSuccess bool
|
||||
Layout string // time format
|
||||
CostShiftDigits int // Used for CDR
|
||||
RoundingDecimals int
|
||||
RoundingDecimals *int
|
||||
MaskDestID string
|
||||
MaskLen int
|
||||
}
|
||||
|
||||
@@ -313,10 +313,15 @@ func (cdr *CDR) combimedCdrFieldVal(cfgCdrFld *config.FCTemplate, groupCDRs []*C
|
||||
func (cdr *CDR) exportFieldValue(cfgCdrFld *config.FCTemplate, filterS *FilterS) (retVal string, err error) {
|
||||
for _, rsrFld := range cfgCdrFld.Value {
|
||||
var cdrVal string
|
||||
var roundDec int
|
||||
switch cfgCdrFld.Path {
|
||||
case utils.MetaExp + utils.NestingSep + utils.COST:
|
||||
cdrVal = cdr.FormatCost(cfgCdrFld.CostShiftDigits,
|
||||
cfgCdrFld.RoundingDecimals)
|
||||
if cfgCdrFld.RoundingDecimals == nil {
|
||||
roundDec = config.CgrConfig().GeneralCfg().RoundingDecimals
|
||||
} else {
|
||||
roundDec = *cfgCdrFld.RoundingDecimals
|
||||
}
|
||||
cdrVal = cdr.FormatCost(cfgCdrFld.CostShiftDigits, roundDec)
|
||||
case utils.MetaExp + utils.NestingSep + utils.SetupTime:
|
||||
if cfgCdrFld.Layout == "" {
|
||||
cfgCdrFld.Layout = time.RFC3339
|
||||
|
||||
@@ -185,7 +185,7 @@ func TestExportVoiceWithConvert(t *testing.T) {
|
||||
Path: "*exp.Cost",
|
||||
Type: "*composed",
|
||||
Value: config.NewRSRParsersMustCompile(utils.DynamicDataPrefix+utils.MetaReq+utils.NestingSep+"Cost", true, utils.INFIELD_SEP),
|
||||
RoundingDecimals: 5},
|
||||
RoundingDecimals: utils.IntPointer(5)},
|
||||
}
|
||||
cdrVoice := &CDR{
|
||||
CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()),
|
||||
@@ -324,7 +324,7 @@ func TestExportWithFilter(t *testing.T) {
|
||||
Path: "*exp.Cost",
|
||||
Type: "*composed",
|
||||
Value: config.NewRSRParsersMustCompile(utils.DynamicDataPrefix+utils.MetaReq+utils.NestingSep+"Cost", true, utils.INFIELD_SEP),
|
||||
RoundingDecimals: 5},
|
||||
RoundingDecimals: utils.IntPointer(5)},
|
||||
}
|
||||
cdrVoice := &CDR{
|
||||
CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()),
|
||||
@@ -462,7 +462,7 @@ func TestExportWithFilter2(t *testing.T) {
|
||||
Path: "*exp.Cost",
|
||||
Type: "*composed",
|
||||
Value: config.NewRSRParsersMustCompile(utils.DynamicDataPrefix+utils.MetaReq+utils.NestingSep+"Cost", true, utils.INFIELD_SEP),
|
||||
RoundingDecimals: 5},
|
||||
RoundingDecimals: utils.IntPointer(5)},
|
||||
}
|
||||
cdrVoice := &CDR{
|
||||
CGRID: utils.Sha1("dsafdsaf", time.Unix(1383813745, 0).UTC().String()),
|
||||
|
||||
Reference in New Issue
Block a user