diff --git a/engine/callcost.go b/engine/callcost.go index 857ba3750..9e6bf6244 100644 --- a/engine/callcost.go +++ b/engine/callcost.go @@ -133,7 +133,8 @@ func (cc *CallCost) ToDataCost() (*DataCost, error) { DataIndex: callDuration, MatchedSubject: ts.MatchedSubject, MatchedPrefix: ts.MatchedPrefix, - MatchedDestId: ts.MatchedDestId, + MatchedDestID: ts.MatchedDestID, + RatingPlanID: ts.RatingPlanID, } dc.DataSpans[i].Increments = make([]*DataIncrement, len(ts.Increments)) for j, incr := range ts.Increments { diff --git a/engine/calldesc.go b/engine/calldesc.go index d0b2507c6..16a9f1c0a 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -890,7 +890,7 @@ func (cd *CallDescriptor) GetLCR(stats StatsInterface) (*LCRCost, error) { // Supplier: supplier, // Error: err, //}) - Logger.Warning(fmt.Sprintf("LCR_WARNING: Ignoring supplier: %s, cannot calculate cost, error: %v", err)) + Logger.Warning(fmt.Sprintf("LCR_WARNING: Ignoring supplier: %s, cannot calculate cost, error: %v", supplier, err)) continue } else { supplCost := &LCRSupplierCost{ diff --git a/engine/calldesc_test.go b/engine/calldesc_test.go index 2c4f95ac1..4690af94a 100644 --- a/engine/calldesc_test.go +++ b/engine/calldesc_test.go @@ -133,7 +133,7 @@ func TestSplitSpansWeekend(t *testing.T) { &RatingInfo{ MatchedSubject: "*out:foehn:postpaid:foehn", MatchedPrefix: "0034678", - MatchedDestId: "SPN_MOB", + MatchedDestID: "SPN_MOB", ActivationTime: time.Date(2015, 4, 23, 0, 0, 0, 0, time.UTC), RateIntervals: []*RateInterval{ &RateInterval{ diff --git a/engine/datacost.go b/engine/datacost.go index 0207b06b5..c389a69eb 100644 --- a/engine/datacost.go +++ b/engine/datacost.go @@ -25,13 +25,13 @@ type DataCost struct { deductConnectFee bool } type DataSpan struct { - DataStart, DataEnd float64 - Cost float64 - ratingInfo *RatingInfo - RateInterval *RateInterval - DataIndex float64 // the data transfer so far till DataEnd - Increments []*DataIncrement - MatchedSubject, MatchedPrefix, MatchedDestId string + DataStart, DataEnd float64 + Cost float64 + ratingInfo *RatingInfo + RateInterval *RateInterval + DataIndex float64 // the data transfer so far till DataEnd + Increments []*DataIncrement + MatchedSubject, MatchedPrefix, MatchedDestID, RatingPlanID string } type DataIncrement struct { diff --git a/engine/ratingprofile.go b/engine/ratingprofile.go index c8be32613..3a3ef0cdc 100644 --- a/engine/ratingprofile.go +++ b/engine/ratingprofile.go @@ -82,8 +82,9 @@ func (rpas RatingPlanActivations) GetActiveForCall(cd *CallDescriptor) RatingPla type RatingInfo struct { MatchedSubject string + RatingPlanID string MatchedPrefix string - MatchedDestId string + MatchedDestID string ActivationTime time.Time RateIntervals RateIntervalList FallbackKeys []string @@ -159,15 +160,36 @@ func (rp *RatingProfile) GetRatingPlansForPrefix(cd *CallDescriptor) (err error) } // check if it's the first ri and add a blank one for the initial part not covered if index == 0 && cd.TimeStart.Before(rpa.ActivationTime) { - ris = append(ris, &RatingInfo{"", "", "", cd.TimeStart, nil, []string{cd.GetKey(FALLBACK_SUBJECT)}}) + ris = append(ris, &RatingInfo{ + MatchedSubject: "", + MatchedPrefix: "", + MatchedDestID: "", + ActivationTime: cd.TimeStart, + RateIntervals: nil, + FallbackKeys: []string{cd.GetKey(FALLBACK_SUBJECT)}}) } if len(prefix) > 0 { - ris = append(ris, &RatingInfo{rp.Id, prefix, destinationId, rpa.ActivationTime, rps, rpa.FallbackKeys}) + ris = append(ris, &RatingInfo{ + MatchedSubject: rp.Id, + RatingPlanID: rpl.Id, + MatchedPrefix: prefix, + MatchedDestID: destinationId, + ActivationTime: rpa.ActivationTime, + RateIntervals: rps, + FallbackKeys: rpa.FallbackKeys}) } else { // add for fallback information - ris = append(ris, &RatingInfo{"", "", "", rpa.ActivationTime, nil, rpa.FallbackKeys}) + ris = append(ris, &RatingInfo{ + MatchedSubject: "", + MatchedPrefix: "", + MatchedDestID: "", + ActivationTime: rpa.ActivationTime, + RateIntervals: nil, + FallbackKeys: rpa.FallbackKeys, + }) } } + if len(ris) > 0 { cd.addRatingInfos(ris) return diff --git a/engine/timespans.go b/engine/timespans.go index 1fe3e3835..10f1de9b3 100644 --- a/engine/timespans.go +++ b/engine/timespans.go @@ -31,13 +31,13 @@ import ( A unit in which a call will be split that has a specific price related interval attached to it. */ type TimeSpan struct { - TimeStart, TimeEnd time.Time - Cost float64 - ratingInfo *RatingInfo - RateInterval *RateInterval - DurationIndex time.Duration // the call duration so far till TimeEnd - Increments Increments - MatchedSubject, MatchedPrefix, MatchedDestId string + TimeStart, TimeEnd time.Time + Cost float64 + ratingInfo *RatingInfo + RateInterval *RateInterval + DurationIndex time.Duration // the call duration so far till TimeEnd + Increments Increments + MatchedSubject, MatchedPrefix, MatchedDestID, RatingPlanID string } type Increment struct { @@ -281,7 +281,8 @@ func (ts *TimeSpan) setRatingInfo(rp *RatingInfo) { ts.ratingInfo = rp ts.MatchedSubject = rp.MatchedSubject ts.MatchedPrefix = rp.MatchedPrefix - ts.MatchedDestId = rp.MatchedDestId + ts.MatchedDestID = rp.MatchedDestID + ts.RatingPlanID = rp.RatingPlanID } func (ts *TimeSpan) createIncrementsSlice() { diff --git a/engine/tpimporter_csv.go b/engine/tpimporter_csv.go index 8223c216f..80a6711be 100644 --- a/engine/tpimporter_csv.go +++ b/engine/tpimporter_csv.go @@ -64,7 +64,7 @@ func (self *TPCSVImporter) Run() error { continue } if err := fHandler(self, f.Name()); err != nil { - Logger.Err(fmt.Sprintf(" Importing file: %s, got error: %s", err.Error())) + Logger.Err(fmt.Sprintf(" Importing file: %s, got error: %s", f.Name(), err.Error())) } } return nil