fix for bad timespan

This commit is contained in:
Radu Ioan Fericean
2013-10-08 15:27:04 +03:00
parent 48ccb6e930
commit 56b4a3f0a4
3 changed files with 5 additions and 1 deletions

View File

@@ -236,6 +236,7 @@ func (cd *CallDescriptor) splitInTimeSpans(firstSpan *TimeSpan) (timespans []*Ti
if newTs != nil {
newTs.ratingPlan = rp
timespans = append(timespans, newTs)
break
}
}
}

View File

@@ -144,7 +144,7 @@ func (ts *TimeSpan) SplitByRateInterval(i *RateInterval) (nts *TimeSpan) {
i.Rates.Sort()
for _, rate := range i.Rates {
Logger.Debug(fmt.Sprintf("Rate: %+v", rate))
if ts.GetGroupStart() < rate.GroupIntervalStart && ts.GetGroupEnd() >= rate.GroupIntervalStart {
if ts.GetGroupStart() < rate.GroupIntervalStart && ts.GetGroupEnd() > rate.GroupIntervalStart {
Logger.Debug(fmt.Sprintf("Splitting"))
ts.SetRateInterval(i)
splitTime := ts.TimeStart.Add(rate.GroupIntervalStart - ts.GetGroupStart())

View File

@@ -188,6 +188,7 @@ func (ub *UserBalance) debitCreditBalance(cc *CallCost, count bool) error {
}
paid := false
for _, b := range usefulMinuteBalances {
// check standard subject tags
if b.RateSubject == ZEROSECOND || b.RateSubject == "" {
amount := increment.Duration.Seconds()
@@ -201,6 +202,7 @@ func (ub *UserBalance) debitCreditBalance(cc *CallCost, count bool) error {
}
break
}
continue
}
if b.RateSubject == ZEROMINUTE {
amount := time.Minute.Seconds()
@@ -256,6 +258,7 @@ func (ub *UserBalance) debitCreditBalance(cc *CallCost, count bool) error {
}
break
}
continue
}
// get the new rate
cd := cc.CreateCallDescriptor()