Updated *ec dp for ees

This commit is contained in:
porosnicuadrian
2022-02-23 18:15:12 +02:00
committed by Dan Christian Bogos
parent fa83e28b1d
commit c0c3b87b83
4 changed files with 8 additions and 8 deletions

View File

@@ -114,8 +114,8 @@
{"tag": "AnswerTime", "path": "*exp.AnswerTime", "type": "*variable", "value": "~*req.AnswerTime", "layout": "2006-01-02T15:04:05Z07:00"},
{"tag": "Usage", "path": "*exp.Usage", "type": "*variable", "value": "~*req.Usage"},
{"tag": "Cost", "path": "*exp.Cost", "type": "*variable", "value": "~*req.Cost{*round:4}"},
{"tag": "RatingPlan", "path": "*exp.RatingPlan", "type": "*variable", "value": "~*ec.EventCost.Charges[0].Rating.RatingFilter.RatingPlanID"},
{"tag": "RatingPlanSubject", "path": "*exp.RatingPlanSubject", "type": "*variable", "value": "~*ec.EventCost.Charges[0].Rating.RatingFilter.Subject"},
{"tag": "RatingPlan", "path": "*exp.RatingPlan", "type": "*variable", "value": "~*ec.CostDetails.Charges[0].Rating.RatingFilter.RatingPlanID"},
{"tag": "RatingPlanSubject", "path": "*exp.RatingPlanSubject", "type": "*variable", "value": "~*ec.CostDetails.Charges[0].Rating.RatingFilter.Subject"},
{"tag": "NumberOfEvents", "path": "*trl.NumberOfEvents", "type": "*variable", "value": "~*dc.NumberOfEvents"},
{"tag": "TotalDuration", "path": "*trl.TotalDuration", "type": "*variable", "value": "~*dc.TotalDuration"},

View File

@@ -270,7 +270,7 @@ func exportEventWithExporter(exp EventExporter, ev *utils.CGREvent, oneTime bool
utils.MetaDC: exp.GetMetrics(),
utils.MetaOpts: utils.MapStorage(ev.APIOpts),
utils.MetaCfg: cfg.GetDataProvider(),
utils.MetaEC: utils.MapStorage{utils.EventCost: ev.Event[utils.EventCost]},
utils.MetaEC: utils.MapStorage{utils.CostDetails: ev.Event[utils.CostDetails]},
}, utils.FirstNonEmpty(ev.Tenant, cfg.GeneralCfg().DefaultTenant),
filterS,
map[string]*utils.OrderedNavigableMap{utils.MetaExp: expNM}).SetFields(exp.Cfg().ContentFields())

View File

@@ -376,7 +376,7 @@ func testCsvExportComposedEvent(t *testing.T) {
utils.Cost: 1.016374,
"ExtraFields": map[string]string{"extra1": "val_extra1",
"extra2": "val_extra2", "extra3": "val_extra3"},
"EventCost": cd,
utils.CostDetails: cd,
},
},
}
@@ -405,7 +405,7 @@ func testCsvExportComposedEvent(t *testing.T) {
utils.Cost: 0.155462,
"ExtraFields": map[string]string{"extra1": "val_extra1",
"extra2": "val_extra2", "extra3": "val_extra3"},
"EventCost": cd,
utils.CostDetails: cd,
},
},
}

View File

@@ -50,8 +50,8 @@ func (cgr *CGREventWithEeIDs) UnmarshalJSON(data []byte) error {
return err
}
cgr.CGREvent = cgrEv
// check if we have EventCost and modify it's type (by default it was map[string]interface{} by unrmarshaling, now it will be EventCost)
if ecEv, has := cgrEv.Event[utils.EventCost]; has {
// check if we have CostDetails and modify it's type (by default it was map[string]interface{} by unrmarshaling, now it will be EventCost)
if ecEv, has := cgrEv.Event[utils.CostDetails]; has {
ec := new(EventCost)
bts, err := json.Marshal(ecEv)
if err != nil {
@@ -60,7 +60,7 @@ func (cgr *CGREventWithEeIDs) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(bts, &ec); err != nil {
return err
}
cgr.Event[utils.EventCost] = ec
cgr.Event[utils.CostDetails] = ec
}
return nil
}