mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Compile the EventCost for sRun before storing it
This commit is contained in:
committed by
Dan Christian Bogos
parent
9152bb452c
commit
bba4ab873d
@@ -716,6 +716,12 @@ func testSSv1ItCDRsGetCdrs(t *testing.T) {
|
||||
if cdrs[0].Cost != 0.198 {
|
||||
t.Errorf("Unexpected cost for CDR: %f", cdrs[0].Cost)
|
||||
}
|
||||
if cdrs[0].CostDetails.Usage == nil || *cdrs[0].CostDetails.Usage != 10*time.Minute {
|
||||
t.Errorf("Unexpected usage from CostDetails for CDR: %+v", cdrs[0].CostDetails.Usage)
|
||||
}
|
||||
if cdrs[0].CostDetails.Cost == nil || *cdrs[0].CostDetails.Cost != 0.198 {
|
||||
t.Errorf("Unexpected cost from CostDetails for CDR: %+v", cdrs[0].CostDetails.Cost)
|
||||
}
|
||||
}
|
||||
args = &utils.RPCCDRsFilterWithOpts{RPCCDRsFilter: &utils.RPCCDRsFilter{RunIDs: []string{"SupplierCharges"},
|
||||
OriginIDs: []string{"TestSSv1It1"}}}
|
||||
@@ -727,6 +733,12 @@ func testSSv1ItCDRsGetCdrs(t *testing.T) {
|
||||
if cdrs[0].Cost != 0.102 {
|
||||
t.Errorf("Unexpected cost for CDR: %f", cdrs[0].Cost)
|
||||
}
|
||||
if cdrs[0].CostDetails.Usage == nil || *cdrs[0].CostDetails.Usage != 10*time.Minute {
|
||||
t.Errorf("Unexpected usage from CostDetails for CDR: %+v", cdrs[0].CostDetails.Usage)
|
||||
}
|
||||
if cdrs[0].CostDetails.Cost == nil || *cdrs[0].CostDetails.Cost != 0.102 {
|
||||
t.Errorf("Unexpected cost from CostDetails for CDR: %+v", cdrs[0].CostDetails.Cost)
|
||||
}
|
||||
}
|
||||
|
||||
args = &utils.RPCCDRsFilterWithOpts{RPCCDRsFilter: &utils.RPCCDRsFilter{RunIDs: []string{"CustomerCharges"},
|
||||
@@ -739,6 +751,12 @@ func testSSv1ItCDRsGetCdrs(t *testing.T) {
|
||||
if cdrs[0].Cost != 0.099 {
|
||||
t.Errorf("Unexpected cost for CDR: %f", cdrs[0].Cost)
|
||||
}
|
||||
if cdrs[0].CostDetails.Usage == nil || *cdrs[0].CostDetails.Usage != 5*time.Minute {
|
||||
t.Errorf("Unexpected usage from CostDetails for CDR: %+v", cdrs[0].CostDetails.Usage)
|
||||
}
|
||||
if cdrs[0].CostDetails.Cost == nil || *cdrs[0].CostDetails.Cost != 0.099 {
|
||||
t.Errorf("Unexpected cost from CostDetails for CDR: %+v", cdrs[0].CostDetails.Cost)
|
||||
}
|
||||
}
|
||||
args = &utils.RPCCDRsFilterWithOpts{RPCCDRsFilter: &utils.RPCCDRsFilter{RunIDs: []string{"SupplierCharges"},
|
||||
OriginIDs: []string{"TestSSv1It2"}}}
|
||||
@@ -750,6 +768,12 @@ func testSSv1ItCDRsGetCdrs(t *testing.T) {
|
||||
if cdrs[0].Cost != 0.051 {
|
||||
t.Errorf("Unexpected cost for CDR: %f", cdrs[0].Cost)
|
||||
}
|
||||
if cdrs[0].CostDetails.Usage == nil || *cdrs[0].CostDetails.Usage != 5*time.Minute {
|
||||
t.Errorf("Unexpected usage from CostDetails for CDR: %+v", cdrs[0].CostDetails.Usage)
|
||||
}
|
||||
if cdrs[0].CostDetails.Cost == nil || *cdrs[0].CostDetails.Cost != 0.051 {
|
||||
t.Errorf("Unexpected cost from CostDetails for CDR: %+v", cdrs[0].CostDetails.Cost)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1551,6 +1551,9 @@ func (sS *SessionS) endSession(s *Session, tUsage, lastUsage *time.Duration,
|
||||
utils.SessionS, s.CGRID, sRunIdx, err.Error()))
|
||||
}
|
||||
}
|
||||
// compute the event cost before saving the SessionCost
|
||||
// add here to be applied for messages also
|
||||
sr.EventCost.Compute()
|
||||
if sS.cgrCfg.SessionSCfg().StoreSCosts {
|
||||
if err := sS.storeSCost(s, sRunIdx); err != nil {
|
||||
utils.Logger.Warning(
|
||||
|
||||
Reference in New Issue
Block a user