Added FieldAsInterface for EventCost

This commit is contained in:
Trial97
2020-02-05 11:02:55 +02:00
committed by Dan Christian Bogos
parent 2f8b7dc53e
commit ff5f5f2d21
7 changed files with 532 additions and 121 deletions

View File

@@ -497,6 +497,29 @@ const (
Accounting = "Accounting"
Rating = "Rating"
Charges = "Charges"
CompressFactor = "CompressFactor"
Increments = "Increments"
Balance = "Balance"
BalanceSummaries = "BalanceSummaries"
Type = "Type"
YearsFieldName = "Years"
MonthsFieldName = "Months"
MonthDaysFieldName = "MonthDays"
WeekDaysFieldName = "WeekDays"
GroupIntervalStart = "GroupIntervalStart"
RateIncrement = "RateIncrement"
RateUnit = "RateUnit"
BalanceUUID = "BalanceUUID"
RatingID = "RatingID"
ExtraChargeID = "ExtraChargeID"
ConnectFee = "ConnectFee"
RoundingMethod = "RoundingMethod"
RoundingDecimals = "RoundingDecimals"
MaxCostStrategy = "MaxCostStrategy"
TimingID = "TimingID"
RatesID = "RatesID"
RatingFiltersID = "RatingFiltersID"
AccountingID = "AccountingID"
MetaSessionS = "*sessions"
MetaDefault = "*default"
Error = "Error"

View File

@@ -892,3 +892,23 @@ func CastRPCErr(err error) error {
func RandomInteger(min, max int) int {
return math_rand.Intn(max-min) + min
}
// GetPathIndex returns the path and index if index present
// path[index]=>path,index
// path=>path,nil
func GetPathIndex(spath string) (opath string, idx *int) {
idxStart := strings.Index(spath, IdxStart)
if idxStart == -1 || !strings.HasSuffix(spath, IdxEnd) {
return spath, nil
}
slctr := spath[idxStart+1 : len(spath)-1]
opath = spath[:idxStart]
// if strings.HasPrefix(slctr, DynamicDataPrefix) {
// return
// }
idxVal, err := strconv.Atoi(slctr)
if err != nil {
return spath, nil
}
return opath, &idxVal
}