mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
DestinationRates accepting * any as destination id, adding sample data plan to prepaid1centpsec sample tariff plan
This commit is contained in:
@@ -1274,7 +1274,7 @@ func TestResetDataAfterLoadFromFolder(t *testing.T) {
|
||||
t.Error("Calling ApierV1.ReloadCache got reply: ", reply)
|
||||
}
|
||||
var rcvStats *utils.CacheStats
|
||||
expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 1, RatingProfiles: 1, Actions: 2, DerivedChargers: 2}
|
||||
expectedStats := &utils.CacheStats{Destinations: 4, RatingPlans: 2, RatingProfiles: 2, Actions: 3, DerivedChargers: 2}
|
||||
var args utils.AttrCacheStats
|
||||
if err := rater.Call("ApierV1.GetCacheStats", args, &rcvStats); err != nil {
|
||||
t.Error("Got error on ApierV1.GetCacheStats: ", err.Error())
|
||||
|
||||
@@ -34,7 +34,7 @@ type AttrGetDataCosts struct {
|
||||
}
|
||||
|
||||
func (apier *ApierV1) GetDataCosts(attrs AttrGetDataCosts, reply *engine.DataCost) error {
|
||||
usageAsDuration := time.Duration(attrs.Usage)
|
||||
usageAsDuration := time.Duration(attrs.Usage) * time.Second // Convert to seconds to match the loaded rates
|
||||
cd := engine.CallDescriptor{
|
||||
Direction: attrs.Direction,
|
||||
Category: attrs.Category,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#ActionsTag,Action,BalanceType,Direction,Units,ExpiryTime,DestinationTag,RatingSubject,BalanceWeight,SharedGroup,ExtraParameters,Weight
|
||||
PREPAID_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,10,,,10
|
||||
BONUS_1,*topup,*monetary,*out,1,*unlimited,*any,,10,,,10
|
||||
LOG_BALANCE,*log,,,,,,,,,,10
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#Tag,DestinationsTag,RatesTag,RoundingMethod,RoundingDecimals
|
||||
DR_RETAIL,GERMANY,RT_1CENT,*up,2
|
||||
DR_RETAIL,GERMANY_MOBILE,RT_1CENT,*up,2
|
||||
DR_DATA_1,*any,RT_DATA_2c,*up,2
|
||||
|
@@ -1,2 +1,3 @@
|
||||
#Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart
|
||||
RT_1CENT,0,1,1s,1s,0s
|
||||
RT_DATA_2c,0,0.002,10,10,0
|
||||
|
@@ -1,2 +1,3 @@
|
||||
#Tag,DestinationRatesTag,TimingTag,Weight
|
||||
RP_RETAIL,DR_RETAIL,ALWAYS,10
|
||||
RP_DATA1,DR_DATA_1,ALWAYS,10
|
||||
|
||||
|
@@ -1,2 +1,3 @@
|
||||
#Direction,Tenant,Category,Subject,ActivationTime,RatingPlanId,RatesFallbackSubject
|
||||
*out,cgrates.org,call,*any,2012-01-01T00:00:00Z,RP_RETAIL,
|
||||
*out,cgrates.org,data,*any,2012-01-01T00:00:00Z,RP_DATA1,
|
||||
|
||||
|
@@ -425,14 +425,15 @@ func (csvr *CSVReader) LoadDestinationRates() (err error) {
|
||||
log.Printf("Error parsing rounding decimals: %s", record[4])
|
||||
return err
|
||||
}
|
||||
destinationExists := false
|
||||
for _, d := range csvr.destinations {
|
||||
if d.Id == record[1] {
|
||||
destinationExists = true
|
||||
break
|
||||
destinationExists := record[1] == utils.ANY
|
||||
if !destinationExists {
|
||||
for _, d := range csvr.destinations {
|
||||
if d.Id == record[1] {
|
||||
destinationExists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !destinationExists && csvr.dataStorage != nil {
|
||||
if destinationExists, err = csvr.dataStorage.HasData(DESTINATION_PREFIX, record[1]); err != nil {
|
||||
return err
|
||||
|
||||
@@ -288,11 +288,13 @@ func (dbr *DbReader) LoadDestinationRates() (err error) {
|
||||
return fmt.Errorf("Could not find rate for tag %v", dr.RateId)
|
||||
}
|
||||
dr.Rate = rate
|
||||
destinationExists := false
|
||||
for _, d := range dbr.destinations {
|
||||
if d.Id == dr.DestinationId {
|
||||
destinationExists = true
|
||||
break
|
||||
destinationExists := dr.DestinationId == utils.ANY
|
||||
if !destinationExists {
|
||||
for _, d := range dbr.destinations {
|
||||
if d.Id == dr.DestinationId {
|
||||
destinationExists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !destinationExists {
|
||||
@@ -408,7 +410,9 @@ func (dbr *DbReader) LoadRatingPlanByTag(tag string) (bool, error) {
|
||||
// Logger.Debug(fmt.Sprintf("Rate: %v", rt))
|
||||
drate.Rate = rt[drate.RateId]
|
||||
ratingPlan.AddRateInterval(drate.DestinationId, GetRateInterval(rp, drate))
|
||||
|
||||
if drate.DestinationId == utils.ANY {
|
||||
continue // no need of loading the destinations in this case
|
||||
}
|
||||
dms, err := dbr.storDb.GetTpDestinations(dbr.tpid, drate.DestinationId)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -181,11 +181,11 @@ 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;]|*any|<empty>),Months([0-9;]|*any|<empty>),MonthDays([0-9;]|*any|<empty>),WeekDays([0-9;]|*any|<empty>),Time([0-9:]|*asap)"},
|
||||
utils.RATES_CSV: &FileLineRegexValidator{utils.RATES_NRCOLS,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\d+\.?\d*,){2}(?:\d+s*,?){3}$`),
|
||||
"Tag([0-9A-Za-z_]),ConnectFee([0-9.]),Rate([0-9.]),RateUnit([0-9.]),RateIncrementStart([0-9.])"},
|
||||
regexp.MustCompile(`(?:\w+\s*),(?:\d+\.*\d*s*),(?:\d+\.*\d*s*),(?:\d+\.*\d*(ns|us|µs|ms|s|m|h)*\s*),(?:\d+\.*\d*(ns|us|µs|ms|s|m|h)*\s*),(?:\d+\.*\d*(ns|us|µs|ms|s|m|h)*\s*)$`),
|
||||
"Tag([0-9A-Za-z_]),ConnectFee([0-9.]),Rate([0-9.]),RateUnit([0-9.]ns|us|µs|ms|s|m|h),RateIncrementStart([0-9.]ns|us|µs|ms|s|m|h),GroupIntervalStart([0-9.]ns|us|µs|ms|s|m|h)"},
|
||||
utils.DESTINATION_RATES_CSV: &FileLineRegexValidator{utils.DESTINATION_RATES_NRCOLS,
|
||||
regexp.MustCompile(`^(?:\w+\s*),(?:\w+\s*),(?:\w+\s*),(?:\*\w+,){1}(?:\d+){1}$`),
|
||||
"Tag([0-9A-Za-z_]),DestinationsTag([0-9A-Za-z_]),RateTag([0-9A-Za-z_])"},
|
||||
regexp.MustCompile(`^(?:\w+\s*),(?:\w+\s*|\*any),(?:\w+\s*),(?:\*up|\*down|\*middle),(?:\d+)$`),
|
||||
"Tag([0-9A-Za-z_]),DestinationsTag([0-9A-Za-z_]|*any),RatesTag([0-9A-Za-z_]),RoundingMethod(*up|*middle|*down),RoundingDecimals([0-9.])"},
|
||||
utils.RATING_PLANS_CSV: &FileLineRegexValidator{utils.DESTRATE_TIMINGS_NRCOLS,
|
||||
regexp.MustCompile(`(?:\w+\s*,\s*){3}(?:\d+.?\d*){1}$`),
|
||||
"Tag([0-9A-Za-z_]),DestinationRatesTag([0-9A-Za-z_]),TimingProfile([0-9A-Za-z_]),Weight([0-9.])"},
|
||||
|
||||
@@ -42,11 +42,13 @@ GERMANY_MOBILE,+4915
|
||||
var ratesSample = `#Tag,DestinationRatesTag,TimingTag,Weight
|
||||
RT_1CENT,0,1,1s,1s,0s
|
||||
DUMMY,INVALID;DATA
|
||||
RT_DATA_2c,0,0.002,10,10,0
|
||||
`
|
||||
|
||||
var destRatesSample = `#Tag,DestinationsTag,RatesTag
|
||||
DR_RETAIL,GERMANY,RT_1CENT,*up,0
|
||||
DUMMY,INVALID;DATA
|
||||
DR_DATA_1,*any,RT_DATA_2c,*up,2
|
||||
`
|
||||
var ratingPlansSample = `#Tag,DestinationRatesTag,TimingTag,Weight
|
||||
RP_RETAIL,DR_RETAIL,ALWAYS,10
|
||||
@@ -168,7 +170,7 @@ func TestRatesValidator(t *testing.T) {
|
||||
if valid {
|
||||
t.Error("Validation passed for invalid line", string(ln))
|
||||
}
|
||||
case 2:
|
||||
case 2, 4:
|
||||
if !valid {
|
||||
t.Error("Validation did not pass for valid line", string(ln))
|
||||
}
|
||||
@@ -192,7 +194,7 @@ func TestDestRatesValidator(t *testing.T) {
|
||||
if valid {
|
||||
t.Error("Validation passed for invalid line", string(ln))
|
||||
}
|
||||
case 2:
|
||||
case 2, 4:
|
||||
if !valid {
|
||||
t.Error("Validation did not pass for valid line", string(ln))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user