mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
[SessionS] Compile the SRun.EventCost before store it and send it further
This commit is contained in:
committed by
Dan Christian Bogos
parent
19f30a418d
commit
249fd7eec3
@@ -692,6 +692,13 @@ 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.RPCCDRsFilterWithArgDispatcher{RPCCDRsFilter: &utils.RPCCDRsFilter{RunIDs: []string{"SupplierCharges"},
|
||||
OriginIDs: []string{"TestSSv1It1"}}}
|
||||
@@ -703,6 +710,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.RPCCDRsFilterWithArgDispatcher{RPCCDRsFilter: &utils.RPCCDRsFilter{RunIDs: []string{"CustomerCharges"},
|
||||
@@ -715,6 +728,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.RPCCDRsFilterWithArgDispatcher{RPCCDRsFilter: &utils.RPCCDRsFilter{RunIDs: []string{"SupplierCharges"},
|
||||
OriginIDs: []string{"TestSSv1It2"}}}
|
||||
@@ -726,6 +745,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ cgrates (0.10.3~dev) UNRELEASED; urgency=medium
|
||||
* [SessionS] Use rals_conns when sending refund rounding
|
||||
* [SupplierS] SupplierS require a connection to rals when give
|
||||
AccountIDs and RatingPlanIDs to calculate
|
||||
* [SessionS] Compile the SRun.EventCost before store it and send it further
|
||||
|
||||
-- DanB <danb@cgrates.org> Thu, 08 Oct 2020 16:23:58 +0300
|
||||
|
||||
|
||||
@@ -1501,8 +1501,10 @@ func (sS *SessionS) endSession(s *Session, tUsage, lastUsage *time.Duration,
|
||||
fmt.Sprintf("<%s> failed rounding session cost for <%s>, srIdx: <%d>, error: <%s>",
|
||||
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