diff --git a/apier/v1/apier.go b/apier/v1/apier.go index 0a5f118d3..14232bcd1 100644 --- a/apier/v1/apier.go +++ b/apier/v1/apier.go @@ -452,20 +452,20 @@ type V1TPActions struct { } type V1TPAction struct { - Identifier string // Identifier mapped in the code - BalanceId string // Balance identification string (account scope) - BalanceUuid string // Balance identification string (global scope) - BalanceType string // Type of balance the action will operate on - Directions string // Balance direction - Units float64 // Number of units to add/deduct - ExpiryTime string // Time when the units will expire - Filter string // The condition on balances that is checked before the action - TimingTags string // Timing when balance is active - DestinationIds string // Destination profile id - RatingSubject string // Reference a rate subject defined in RatingProfiles - Categories string // category filter for balances - SharedGroups string // Reference to a shared group - BalanceWeight string // Balance weight + Identifier string // Identifier mapped in the code + BalanceId string // Balance identification string (account scope) + BalanceUuid string // Balance identification string (global scope) + BalanceType string // Type of balance the action will operate on + Directions string // Balance direction + Units float64 // Number of units to add/deduct + ExpiryTime string // Time when the units will expire + Filter string // The condition on balances that is checked before the action + TimingTags string // Timing when balance is active + DestinationIds string // Destination profile id + RatingSubject string // Reference a rate subject defined in RatingProfiles + Categories string // category filter for balances + SharedGroups string // Reference to a shared group + BalanceWeight *float64 // Balance weight ExtraParameters string BalanceBlocker string BalanceDisabled string @@ -494,15 +494,6 @@ func (self *ApierV1) SetActions(attrs V1AttrSetActions, reply *string) error { } storeActions := make(engine.Actions, len(attrs.Actions)) for idx, apiAct := range attrs.Actions { - var weight *float64 - if apiAct.BalanceWeight != "" { - if x, err := strconv.ParseFloat(apiAct.BalanceWeight, 64); err == nil { - weight = &x - } else { - return err - } - } - a := &engine.Action{ Id: attrs.ActionsId, ActionType: apiAct.Identifier, @@ -515,7 +506,7 @@ func (self *ApierV1) SetActions(attrs V1AttrSetActions, reply *string) error { ID: utils.StringPointer(apiAct.BalanceId), Type: utils.StringPointer(apiAct.BalanceType), Value: &utils.ValueFormula{Static: apiAct.Units}, - Weight: weight, + Weight: apiAct.BalanceWeight, Directions: utils.StringMapPointer(utils.ParseStringMap(apiAct.Directions)), DestinationIDs: utils.StringMapPointer(utils.ParseStringMap(apiAct.DestinationIds)), RatingSubject: utils.StringPointer(apiAct.RatingSubject), diff --git a/utils/rsrfield_test.go b/utils/rsrfield_test.go index 938f2e2b9..3932e72a7 100644 --- a/utils/rsrfield_test.go +++ b/utils/rsrfield_test.go @@ -232,11 +232,11 @@ func TestRSRCostDetails(t *testing.T) { t.Errorf("Expecting: Canada, received: %s", parsedVal) } fieldsStr2 := `{"Direction":"*out","Category":"call","Tenant":"sip.test.cgrates.org","Subject":"dan","Account":"dan","Destination":"+4986517174963","TOR":"*voice","Cost":0,"Timespans":[{"TimeStart":"2015-05-13T15:03:34+02:00","TimeEnd":"2015-05-13T15:03:38+02:00","Cost":0,"RateInterval":{"Timing":{"Years":[],"Months":[],"MonthDays":[],"WeekDays":[],"StartTime":"00:00:00","EndTime":""},"Rating":{"ConnectFee":0,"RoundingMethod":"*middle","RoundingDecimals":4,"MaxCost":0,"MaxCostStrategy":"","Rates":[{"GroupIntervalStart":0,"Value":0,"RateIncrement":1000000000,"RateUnit":60000000000}]},"Weight":10},"DurationIndex":4000000000,"Increments":[{"Duration":1000000000,"Cost":0,"BalanceInfo":{"Unit":null,"Monetary":null,"AccountID":""},"CompressFactor":4}],"RoundIncrement":null,"MatchedSubject":"*out:sip.test.cgrates.org:call:*any","MatchedPrefix":"+31800","MatchedDestId":"CST_49800_DE080","RatingPlanId":"ISC_V","CompressFactor":1}],"RatedUsage":4}` - rsrField, err = NewRSRField(`~CostDetails:s/"MatchedDestId":.*_(\w{5})_/${1}/:s/"MatchedDestId":"INTERNAL"/ON010/`) + rsrField, err = NewRSRField(`~CostDetails:s/"MatchedDestId":.*_(\w{5})/${1}/:s/"MatchedDestId":"INTERNAL"/ON010/`) if err != nil { t.Error(err) } - eMatch := "49800" + eMatch := "DE080" if parsedVal := rsrField.ParseValue(fieldsStr2); parsedVal != eMatch { t.Errorf("Expecting: <%s>, received: <%s>", eMatch, parsedVal) }