diff --git a/apier/v1/tprates.go b/apier/v1/tprates.go index 641eb5872..71f991cff 100644 --- a/apier/v1/tprates.go +++ b/apier/v1/tprates.go @@ -49,7 +49,7 @@ func (self *ApierV1) SetTPRate(attrs utils.TPRate, reply *string) error { } } rts[idx] = &engine.LoadRate{attrs.RateId, rtSlot.ConnectFee, rtSlot.Rate, itrvls[0], itrvls[1], itrvls[2], - rtSlot.RoundingMethod, rtSlot.RoundingDecimals, rtSlot.Weight} + rtSlot.RoundingMethod, rtSlot.RoundingDecimals} } if err := self.StorDb.SetTPRates(attrs.TPid, map[string][]*engine.LoadRate{attrs.RateId: rts}); err != nil { return fmt.Errorf("%s:%s", utils.ERR_SERVER_ERROR, err.Error()) diff --git a/engine/history_test.go b/engine/history_test.go index 274c25289..6f78e9393 100644 --- a/engine/history_test.go +++ b/engine/history_test.go @@ -30,6 +30,9 @@ func TestHistoryDestinations(t *testing.T) { {"Key":"GERMANY_O2","Object":{"Id":"GERMANY_O2","Prefixes":["41"]}} {"Key":"GERMANY_PREMIUM","Object":{"Id":"GERMANY_PREMIUM","Prefixes":["43"]}} {"Key":"NAT","Object":{"Id":"NAT","Prefixes":["0256","0257","0723"]}} +{"Key":"PSTN_70","Object":{"Id":"PSTN_70","Prefixes":["+4970"]}} +{"Key":"PSTN_71","Object":{"Id":"PSTN_71","Prefixes":["+4971"]}} +{"Key":"PSTN_72","Object":{"Id":"PSTN_72","Prefixes":["+4972"]}} {"Key":"RET","Object":{"Id":"RET","Prefixes":["0723","0724"]}} {"Key":"nat","Object":{"Id":"nat","Prefixes":["0257","0256","0723"]}}]` if scribe.DestBuf.String() != expected { diff --git a/engine/loader_csv.go b/engine/loader_csv.go index caf110b64..45a3032d9 100644 --- a/engine/loader_csv.go +++ b/engine/loader_csv.go @@ -221,10 +221,11 @@ func (csvr *CSVReader) LoadRates() (err error) { if fp != nil { defer fp.Close() } + for record, err := csvReader.Read(); err == nil; record, err = csvReader.Read() { tag := record[0] var r *LoadRate - r, err = NewLoadRate(record[0], record[1], record[2], record[3], record[4], record[5], record[6], record[7], record[8]) + r, err = NewLoadRate(record[0], record[1], record[2], record[3], record[4], record[5], record[6], record[7]) if err != nil { return err } @@ -331,15 +332,20 @@ func (csvr *CSVReader) LoadRatingProfiles() (err error) { } for _, drt := range drts { - plan := &RatingPlan{ActivationTime: at} + //log.Print("TAG: ", record[5]) for _, dr := range drt.destinationRates { + plan := &RatingPlan{ActivationTime: at} + //log.Printf("RI: %+v", drt.GetRateInterval(dr)) plan.AddRateInterval(drt.GetRateInterval(dr)) rp.AddRatingPlanIfNotPresent(dr.DestinationsTag, plan) } } if fallbacksubject != "" { - rp.FallbackKey = fmt.Sprintf("%s:%s:%s:%s", direction, tenant, tor, fallbacksubject) + for _, fbs := range strings.Split(fallbacksubject, ";") { + rp.FallbackKey += fmt.Sprintf("%s:%s:%s:%s", direction, tenant, tor, fbs) + ";" + } + rp.FallbackKey = strings.TrimRight(rp.FallbackKey, ";") } } return diff --git a/engine/loader_csv_test.go b/engine/loader_csv_test.go index 44a58045a..7862059ed 100644 --- a/engine/loader_csv_test.go +++ b/engine/loader_csv_test.go @@ -39,6 +39,9 @@ NAT,0257 NAT,0723 RET,0723 RET,0724 +PSTN_71,+4971 +PSTN_72,+4972 +PSTN_70,+4970 ` timings = ` WORKDAYS_00,*any,*any,*any,1;2;3;4;5,00:00:00 @@ -47,13 +50,16 @@ WEEKENDS,*any,*any,*any,6;7,00:00:00 ONE_TIME_RUN,2012,,,,*asap ` rates = ` -R1,0,0.2,60s,1s,0,*middle,2,10 -R2,0,0.1,60s,1s,0,*middle,2,10 -R3,0,0.05,60s,1s,0,*middle,2,10 -R4,1,1,1s,1s,0,*up,2,10 -R5,0,0.5,1s,1s,0,*down,2,10 -LANDLINE_OFFPEAK,0,1,1s,60s,0s,*up,4,10 -LANDLINE_OFFPEAK,0,1,1s,1s,60s,*up,4,10 +R1,0,0.2,60s,1s,0,*middle,2 +R2,0,0.1,60s,1s,0,*middle,2 +R3,0,0.05,60s,1s,0,*middle,2 +R4,1,1,1s,1s,0,*up,2 +R5,0,0.5,1s,1s,0,*down,2 +LANDLINE_OFFPEAK,0,1,1s,60s,0s,*up,4 +LANDLINE_OFFPEAK,0,1,1s,1s,60s,*up,4 +GBP_71,0.000000,5.55555,1s,1s,0s,*up,4 +GBP_72,0.000000,7.77777,1s,1s,0s,*up,4 +GBP_70,0.000000,1,1s,1s,0s,*up,4 ` destinationRates = ` RT_STANDARD,GERMANY,R1 @@ -65,6 +71,9 @@ RT_STD_WEEKEND,GERMANY_O2,R3 P1,NAT,R4 P2,NAT,R5 T1,NAT,LANDLINE_OFFPEAK +T2,GERMANY,GBP_72 +T2,GERMANY_O2,GBP_70 +T2,GERMANY_PREMIUM,GBP_71 ` destinationRateTimings = ` STANDARD,RT_STANDARD,WORKDAYS_00,10 @@ -76,6 +85,7 @@ EVENING,P1,WORKDAYS_00,10 EVENING,P2,WORKDAYS_18,10 EVENING,P2,WEEKENDS,10 TDRT,T1,WORKDAYS_00,10 +TDRT,T2,WORKDAYS_00,10 ` ratingProfiles = ` CUSTOMER_1,0,*out,rif:from:tm,2012-01-01T00:00:00Z,PREMIUM,danb @@ -89,7 +99,7 @@ vdf,0,*out,*any,2012-02-28T00:00:00Z,EVENING, vdf,0,*out,one,2012-02-28T00:00:00Z,STANDARD, vdf,0,*out,inf,2012-02-28T00:00:00Z,STANDARD,inf vdf,0,*out,fall,2012-02-28T00:00:00Z,PREMIUM,rif -test,0,*out,trp,2013-10-01T00:00:00Z,TDRT,rif +test,0,*out,trp,2013-10-01T00:00:00Z,TDRT,rif;danb ` actions = ` MINI,*topup_reset,*monetary,*out,10,*unlimited,,,10,,10 @@ -125,8 +135,8 @@ func init() { } func TestLoadDestinations(t *testing.T) { - if len(csvr.destinations) != 6 { - t.Error("Failed to load destinations: ", csvr.destinations) + if len(csvr.destinations) != 9 { + t.Error("Failed to load destinations: ", len(csvr.destinations)) } for _, d := range csvr.destinations { switch d.Id { @@ -154,6 +164,18 @@ func TestLoadDestinations(t *testing.T) { if !reflect.DeepEqual(d.Prefixes, []string{`43`}) { t.Error("Faild to load destinations", d) } + case "PSTN_71": + if !reflect.DeepEqual(d.Prefixes, []string{`+4971`}) { + t.Error("Faild to load destinations", d) + } + case "PSTN_72": + if !reflect.DeepEqual(d.Prefixes, []string{`+4972`}) { + t.Error("Faild to load destinations", d) + } + case "PSTN_70": + if !reflect.DeepEqual(d.Prefixes, []string{`+4970`}) { + t.Error("Faild to load destinations", d) + } default: t.Error("Unknown destination tag!") } @@ -211,7 +233,7 @@ func TestLoadTimimgs(t *testing.T) { } func TestLoadRates(t *testing.T) { - if len(csvr.rates) != 6 { + if len(csvr.rates) != 9 { t.Error("Failed to load rates: ", csvr.rates) } rate := csvr.rates["R1"][0] @@ -224,7 +246,6 @@ func TestLoadRates(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: utils.ROUNDING_MIDDLE, RoundingDecimals: 2, - Weight: 10, }) { t.Error("Error loading rate: ", csvr.rates["R1"][0]) } @@ -238,7 +259,6 @@ func TestLoadRates(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: utils.ROUNDING_MIDDLE, RoundingDecimals: 2, - Weight: 10, }) { t.Error("Error loading rate: ", csvr.rates) } @@ -252,7 +272,6 @@ func TestLoadRates(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: utils.ROUNDING_MIDDLE, RoundingDecimals: 2, - Weight: 10, }) { t.Error("Error loading rate: ", csvr.rates) } @@ -266,7 +285,6 @@ func TestLoadRates(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: utils.ROUNDING_UP, RoundingDecimals: 2, - Weight: 10, }) { t.Error("Error loading rate: ", csvr.rates) } @@ -280,7 +298,6 @@ func TestLoadRates(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: utils.ROUNDING_DOWN, RoundingDecimals: 2, - Weight: 10, }) { t.Error("Error loading rate: ", csvr.rates) } @@ -295,7 +312,6 @@ func TestLoadRates(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: utils.ROUNDING_UP, RoundingDecimals: 4, - Weight: 10, }) { t.Errorf("Error loading rate: %+v", rate) } @@ -309,14 +325,13 @@ func TestLoadRates(t *testing.T) { GroupIntervalStart: 60 * time.Second, RoundingMethod: utils.ROUNDING_UP, RoundingDecimals: 4, - Weight: 10, }) { t.Errorf("Error loading rate: %+v", rate) } } func TestLoadDestinationRates(t *testing.T) { - if len(csvr.destinationRates) != 6 { + if len(csvr.destinationRates) != 7 { t.Error("Failed to load destinationrates: ", csvr.destinationRates) } drs := csvr.destinationRates["RT_STANDARD"] @@ -394,6 +409,26 @@ func TestLoadDestinationRates(t *testing.T) { }) { t.Error("Error loading destination rate: ", drs) } + drs = csvr.destinationRates["T2"] + if !reflect.DeepEqual(drs, []*DestinationRate{ + &DestinationRate{ + Tag: "T2", + DestinationsTag: "GERMANY", + rates: csvr.rates["GBP_72"], + }, + &DestinationRate{ + Tag: "T2", + DestinationsTag: "GERMANY_O2", + rates: csvr.rates["GBP_70"], + }, + &DestinationRate{ + Tag: "T2", + DestinationsTag: "GERMANY_PREMIUM", + rates: csvr.rates["GBP_71"], + }, + }) { + t.Error("Error loading destination rate: ", drs) + } } func TestLoadDestinationRateTimings(t *testing.T) { @@ -417,7 +452,6 @@ func TestLoadDestinationRateTimings(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: "*middle", RoundingDecimals: 2, - Weight: 10, }, }, }, @@ -434,7 +468,6 @@ func TestLoadDestinationRateTimings(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: "*middle", RoundingDecimals: 2, - Weight: 10, }, }, }, @@ -451,7 +484,6 @@ func TestLoadDestinationRateTimings(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: "*middle", RoundingDecimals: 2, - Weight: 10, }, }, }, @@ -480,7 +512,6 @@ func TestLoadDestinationRateTimings(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: "*middle", RoundingDecimals: 2, - Weight: 10, }, }, }, @@ -497,7 +528,6 @@ func TestLoadDestinationRateTimings(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: "*middle", RoundingDecimals: 2, - Weight: 10, }, }, }, @@ -527,7 +557,6 @@ func TestLoadDestinationRateTimings(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: "*middle", RoundingDecimals: 2, - Weight: 10, }, }, }, @@ -544,7 +573,6 @@ func TestLoadDestinationRateTimings(t *testing.T) { GroupIntervalStart: 0, RoundingMethod: "*middle", RoundingDecimals: 2, - Weight: 10, }, }, }, @@ -570,6 +598,11 @@ func TestLoadDestinationRateTimings(t *testing.T) { Weight: 10, timing: csvr.timings["WORKDAYS_00"], }, + &DestinationRateTiming{ + destinationRates: csvr.destinationRates["T2"], + Weight: 10, + timing: csvr.timings["WORKDAYS_00"], + }, } if !reflect.DeepEqual(rplan, expected) { t.Errorf("Error loading destination rate timing: %+v", rplan[0]) @@ -583,7 +616,7 @@ func TestLoadRatingProfiles(t *testing.T) { rp := csvr.ratingProfiles["*out:test:0:trp"] expected := &RatingProfile{ Id: "*out:test:0:trp", - FallbackKey: "*out:test:0:rif", + FallbackKey: "*out:test:0:rif;*out:test:0:danb", DestinationMap: map[string][]*RatingPlan{ "NAT": []*RatingPlan{ &RatingPlan{ @@ -618,18 +651,169 @@ func TestLoadRatingProfiles(t *testing.T) { }, }, }, + "GERMANY": []*RatingPlan{ + &RatingPlan{ + ActivationTime: time.Date(2013, time.October, 1, 0, 0, 0, 0, time.UTC), + RateIntervals: []*RateInterval{ + &RateInterval{ + Years: Years{}, + Months: Months{}, + MonthDays: MonthDays{}, + WeekDays: WeekDays{1, 2, 3, 4, 5}, + StartTime: "00:00:00", + EndTime: "", + Weight: 10, + ConnectFee: 0, + Rates: RateGroups{ + &Rate{ + GroupIntervalStart: 0, + Value: 7.77777, + RateIncrement: time.Second, + RateUnit: time.Second, + }, + }, + RoundingMethod: utils.ROUNDING_UP, + RoundingDecimals: 4, + }, + }, + }, + }, + "GERMANY_O2": []*RatingPlan{ + &RatingPlan{ + ActivationTime: time.Date(2013, time.October, 1, 0, 0, 0, 0, time.UTC), + RateIntervals: []*RateInterval{ + &RateInterval{ + Years: Years{}, + Months: Months{}, + MonthDays: MonthDays{}, + WeekDays: WeekDays{1, 2, 3, 4, 5}, + StartTime: "00:00:00", + EndTime: "", + Weight: 10, + ConnectFee: 0, + Rates: RateGroups{ + &Rate{ + GroupIntervalStart: 0, + Value: 1, + RateIncrement: time.Second, + RateUnit: time.Second, + }, + }, + RoundingMethod: utils.ROUNDING_UP, + RoundingDecimals: 4, + }, + }, + }, + }, + "GERMANY_PREMIUM": []*RatingPlan{ + &RatingPlan{ + ActivationTime: time.Date(2013, time.October, 1, 0, 0, 0, 0, time.UTC), + RateIntervals: []*RateInterval{ + &RateInterval{ + Years: Years{}, + Months: Months{}, + MonthDays: MonthDays{}, + WeekDays: WeekDays{1, 2, 3, 4, 5}, + StartTime: "00:00:00", + EndTime: "", + Weight: 10, + ConnectFee: 0, + Rates: RateGroups{ + &Rate{ + GroupIntervalStart: 0, + Value: 5.55555, + RateIncrement: time.Second, + RateUnit: time.Second, + }, + }, + RoundingMethod: utils.ROUNDING_UP, + RoundingDecimals: 4, + }, + }, + }, + }, }, } if !reflect.DeepEqual(rp, expected) { - t.Errorf("Error loading rating profile: %+v") + t.Errorf("Error loading rating profile: %+v", rp.FallbackKey) + } + rp = csvr.ratingProfiles["*out:vdf:0:one"] + expected = &RatingProfile{ + DestinationMap: map[string][]*RatingPlan{ + "GERMANY": []*RatingPlan{ + &RatingPlan{ + ActivationTime: time.Date(2012, time.February, 28, 0, 0, 0, 0, time.UTC), + RateIntervals: []*RateInterval{ + &RateInterval{ + Years: Years{}, + Months: Months{}, + MonthDays: MonthDays{}, + WeekDays: WeekDays{1, 2, 3, 4, 5}, + StartTime: "00:00:00", + EndTime: "", + Weight: 10, + ConnectFee: 0, + Rates: RateGroups{ + &Rate{ + GroupIntervalStart: 0, + Value: 0.2, + RateIncrement: time.Second, + RateUnit: time.Minute, + }, + }, + RoundingMethod: utils.ROUNDING_MIDDLE, + RoundingDecimals: 2, + }, + &RateInterval{ + Years: Years{}, + Months: Months{}, + MonthDays: MonthDays{}, + WeekDays: WeekDays{1, 2, 3, 4, 5}, + StartTime: "18:00:00", + EndTime: "", + Weight: 10, + ConnectFee: 0, + Rates: RateGroups{ + &Rate{ + GroupIntervalStart: 0, + Value: 0.1, + RateIncrement: time.Second, + RateUnit: time.Minute, + }, + }, + RoundingMethod: utils.ROUNDING_MIDDLE, + RoundingDecimals: 2, + }, + &RateInterval{ + Years: Years{}, + Months: Months{}, + MonthDays: MonthDays{}, + WeekDays: WeekDays{6, 0}, + StartTime: "00:00:00", + EndTime: "", + Weight: 10, + ConnectFee: 0, + Rates: RateGroups{ + &Rate{ + GroupIntervalStart: 0, + Value: 0.1, + RateIncrement: time.Second, + RateUnit: time.Minute, + }, + }, + RoundingMethod: utils.ROUNDING_MIDDLE, + RoundingDecimals: 2, + }, + }, + }, + }, + }, + } + if !reflect.DeepEqual(rp.DestinationMap["GERMANY"], expected.DestinationMap["GERMANY"]) { + t.Errorf("Error loading rating profile: %+v", rp.DestinationMap["GERMANY"][0]) } } -/* -CUSTOMER_1,0,*out,rif:from:tm,2012-01-01T00:00:00Z,PREMIUM,danb -CUSTOMER_1,0,*out,rif:from:tm,2012-02-28T00:00:00Z,STANDARD,danb -*/ - func TestLoadActions(t *testing.T) { if len(csvr.actions) != 1 { t.Error("Failed to load actions: ", csvr.actions) diff --git a/engine/loader_helpers.go b/engine/loader_helpers.go index e9b96e517..ca956d125 100644 --- a/engine/loader_helpers.go +++ b/engine/loader_helpers.go @@ -53,10 +53,9 @@ type LoadRate struct { RateUnit, RateIncrement, GroupIntervalStart time.Duration RoundingMethod string RoundingDecimals int - Weight float64 } -func NewLoadRate(tag, connectFee, price, ratedUnits, rateIncrements, groupInterval, roundingMethod, roundingDecimals, weight string) (r *LoadRate, err error) { +func NewLoadRate(tag, connectFee, price, ratedUnits, rateIncrements, groupInterval, roundingMethod, roundingDecimals string) (r *LoadRate, err error) { cf, err := strconv.ParseFloat(connectFee, 64) if err != nil { log.Printf("Error parsing connect fee from: %v", connectFee) @@ -82,11 +81,6 @@ func NewLoadRate(tag, connectFee, price, ratedUnits, rateIncrements, groupInterv log.Printf("Error parsing rates increments from: %v", rateIncrements) return } - wght, err := strconv.ParseFloat(weight, 64) - if err != nil { - log.Printf("Error parsing weight from: %s", weight) - return - } rd, err := strconv.Atoi(roundingDecimals) if err != nil { log.Printf("Error parsing rounding decimals: %s", roundingDecimals) @@ -100,7 +94,6 @@ func NewLoadRate(tag, connectFee, price, ratedUnits, rateIncrements, groupInterv GroupIntervalStart: gi, RateUnit: ru, RateIncrement: ri, - Weight: wght, RoundingMethod: roundingMethod, RoundingDecimals: rd, } @@ -239,7 +232,7 @@ var FileValidators = map[string]*FileLineRegexValidator{ regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\*any\s*,\s*|(?:\d{1,4};?)+\s*,\s*|\s*,\s*){4}(?:\d{2}:\d{2}:\d{2}|\*asap){1}$`), "Tag([0-9A-Za-z_]),Years([0-9;]|*all|),Months([0-9;]|*all|),MonthDays([0-9;]|*all|),WeekDays([0-9;]|*all|),Time([0-9:]|*asap)"}, utils.RATES_CSV: &FileLineRegexValidator{utils.RATES_NRCOLS, - regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\d+\.?\d*,){2}(?:\d+s*,){3}(?:\*\w+,){1}(?:\d+\.?\d*,?){2}$`), + regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\d+\.?\d*,){2}(?:\d+s*,){3}(?:\*\w+,){1}x(?:\d+\.?\d*,?){1}$`), "Tag([0-9A-Za-z_]),ConnectFee([0-9.]),Rate([0-9.]),RateUnit([0-9.]),RateIncrementStart([0-9.])"}, utils.DESTINATION_RATES_CSV: &FileLineRegexValidator{utils.DESTINATION_RATES_NRCOLS, regexp.MustCompile(`(?:\w+\s*,?\s*){3}$`), diff --git a/engine/ratingplan.go b/engine/ratingplan.go index 0b6211630..e26762a15 100644 --- a/engine/ratingplan.go +++ b/engine/ratingplan.go @@ -40,21 +40,21 @@ type xCachedRatingPlans struct { /* Adds one ore more intervals to the internal interval list only if it is not allready in the list. */ -func (ap *RatingPlan) AddRateInterval(ris ...*RateInterval) { +func (rp *RatingPlan) AddRateInterval(ris ...*RateInterval) { for _, ri := range ris { found := false - for _, eri := range ap.RateIntervals { + for _, eri := range rp.RateIntervals { if ri.Equal(eri) { found = true break } } if !found { - ap.RateIntervals = append(ap.RateIntervals, ri) + rp.RateIntervals = append(rp.RateIntervals, ri) } } } -func (ap *RatingPlan) Equal(o *RatingPlan) bool { - return ap.ActivationTime == o.ActivationTime +func (rp *RatingPlan) Equal(o *RatingPlan) bool { + return rp.ActivationTime == o.ActivationTime } diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 3e30ecc71..a32fb4fb0 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -205,7 +205,7 @@ func (self *SQLStorage) SetTPRates(tpid string, rts map[string][]*LoadRate) erro } qry += fmt.Sprintf("('%s', '%s', %f, %f, %d, %d,%d,'%s', %d, %f)", tpid, rtId, rt.ConnectFee, rt.Price, rt.RateUnit, rt.RateIncrement, rt.GroupIntervalStart, - rt.RoundingMethod, rt.RoundingDecimals, rt.Weight) + rt.RoundingMethod, rt.RoundingDecimals) i++ } } @@ -234,7 +234,7 @@ func (self *SQLStorage) GetTPRate(tpid, rtId string) (*utils.TPRate, error) { return nil, err } rt.RateSlots = append(rt.RateSlots, utils.RateSlot{connectFee, rate, rateUnit.String(), rateIncrement.String(), - groupIntervalStart.String(), roundingMethod, roundingDecimals, weight}) + groupIntervalStart.String(), roundingMethod, roundingDecimals}) } if i == 0 { return nil, nil @@ -934,10 +934,10 @@ func (self *SQLStorage) GetTpRates(tpid, tag string) (map[string][]*LoadRate, er defer rows.Close() for rows.Next() { var tag, roundingMethod string - var connect_fee, rate, weight float64 + var connect_fee, rate float64 var rate_unit, rate_increment, group_interval_start time.Duration var roundingDecimals int - if err := rows.Scan(&tag, &connect_fee, &rate, &rate_unit, &rate_increment, &group_interval_start, &roundingMethod, &roundingDecimals, &weight); err != nil { + if err := rows.Scan(&tag, &connect_fee, &rate, &rate_unit, &rate_increment, &group_interval_start, &roundingMethod, &roundingDecimals); err != nil { return nil, err } r := &LoadRate{ @@ -949,7 +949,6 @@ func (self *SQLStorage) GetTpRates(tpid, tag string) (map[string][]*LoadRate, er GroupIntervalStart: group_interval_start, RoundingMethod: roundingMethod, RoundingDecimals: roundingDecimals, - Weight: weight, } // same tag only to create rate groups existingRates, exists := rts[tag] diff --git a/engine/tpimporter_csv.go b/engine/tpimporter_csv.go index 9d424ddee..f5acc337d 100644 --- a/engine/tpimporter_csv.go +++ b/engine/tpimporter_csv.go @@ -138,7 +138,7 @@ func (self *TPCSVImporter) importRates(fn string) error { } continue } - rt, err := NewLoadRate(record[0], record[1], record[2], record[3], record[4], record[5], record[6], record[7], record[8]) + rt, err := NewLoadRate(record[0], record[1], record[2], record[3], record[4], record[5], record[6], record[7]) if err != nil { return err } diff --git a/utils/apitpdata.go b/utils/apitpdata.go index ab22145f6..c9b616af6 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -34,7 +34,6 @@ type RateSlot struct { GroupIntervalStart string // Group position RoundingMethod string // Use this method to round the cost RoundingDecimals int // Round the cost number of decimals - Weight float64 // Rate's priority when dealing with grouped rates } type TPDestinationRate struct { diff --git a/utils/consts.go b/utils/consts.go index a84656d7b..12098d4ea 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -43,7 +43,7 @@ const ( ACCOUNT_ACTIONS_CSV = "AccountActions.csv" TIMINGS_NRCOLS = 6 DESTINATIONS_NRCOLS = 2 - RATES_NRCOLS = 9 + RATES_NRCOLS = 8 DESTINATION_RATES_NRCOLS = 3 DESTRATE_TIMINGS_NRCOLS = 4 RATE_PROFILES_NRCOLS = 7