mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 22:58:44 +05:00
Make the FCTmpl.RoundingDecimals field a pointer
The purpose of this is to check whether RoundingDecimals was set from the fields configuration. If it wasn't, we are going to be using the RoundingDecimals dictated by the general subsection.
This commit is contained in:
committed by
Dan Christian Bogos
parent
6a6fefd0cd
commit
a3a8c5a4a4
@@ -565,7 +565,7 @@ func TestCgrCfgJSONDefaultsCdreProfiles(t *testing.T) {
|
||||
Path: "*exp.Cost",
|
||||
Type: "*composed",
|
||||
Value: NewRSRParsersMustCompile("~*req.Cost", true, utils.INFIELD_SEP),
|
||||
RoundingDecimals: 4,
|
||||
RoundingDecimals: utils.IntPointer(4),
|
||||
},
|
||||
}
|
||||
for _, v := range eContentFlds {
|
||||
|
||||
@@ -86,7 +86,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
|
||||
@@ -114,7 +115,7 @@ type FCTemplate struct {
|
||||
BreakOnSuccess bool
|
||||
Layout string // time format
|
||||
CostShiftDigits int // Used for CDR
|
||||
RoundingDecimals int
|
||||
RoundingDecimals *int
|
||||
MaskDestID string
|
||||
MaskLen int
|
||||
pathItems utils.PathItems // Field identifier
|
||||
@@ -196,7 +197,8 @@ func (fc *FCTemplate) Clone() *FCTemplate {
|
||||
cln.BreakOnSuccess = fc.BreakOnSuccess
|
||||
cln.Layout = fc.Layout
|
||||
cln.CostShiftDigits = fc.CostShiftDigits
|
||||
cln.RoundingDecimals = fc.RoundingDecimals
|
||||
cln.RoundingDecimals = new(int)
|
||||
*cln.RoundingDecimals = *fc.RoundingDecimals
|
||||
cln.MaskDestID = fc.MaskDestID
|
||||
cln.MaskLen = fc.MaskLen
|
||||
return cln
|
||||
@@ -261,8 +263,8 @@ func (fc *FCTemplate) AsMapInterface(separator string) (mp map[string]interface{
|
||||
if fc.CostShiftDigits != 0 {
|
||||
mp[utils.CostShiftDigitsCfg] = fc.CostShiftDigits
|
||||
}
|
||||
if fc.RoundingDecimals != 0 {
|
||||
mp[utils.RoundingDecimalsCfg] = fc.RoundingDecimals
|
||||
if fc.RoundingDecimals != nil {
|
||||
mp[utils.RoundingDecimalsCfg] = *fc.RoundingDecimals
|
||||
}
|
||||
if fc.MaskDestID != utils.EmptyString {
|
||||
mp[utils.MaskDestIDCfg] = fc.MaskDestID
|
||||
|
||||
@@ -327,8 +327,12 @@ func (cdr *CDR) exportFieldValue(cfgCdrFld *config.FCTemplate, filterS *FilterS)
|
||||
var cdrVal string
|
||||
switch cfgCdrFld.Path {
|
||||
case utils.MetaExp + utils.NestingSep + utils.COST:
|
||||
roundingDecimals := config.CgrConfig().GeneralCfg().RoundingDecimals
|
||||
if cfgCdrFld.RoundingDecimals != nil {
|
||||
roundingDecimals = *cfgCdrFld.RoundingDecimals
|
||||
}
|
||||
cdrVal, err = cdr.FormatCost(rsrFld, cfgCdrFld.CostShiftDigits,
|
||||
cfgCdrFld.RoundingDecimals)
|
||||
roundingDecimals)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -187,7 +187,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()),
|
||||
@@ -326,7 +326,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()),
|
||||
@@ -464,7 +464,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