diff --git a/apis/accounts_it_test.go b/apis/accounts_it_test.go index c41452ce6..6bce88f84 100644 --- a/apis/accounts_it_test.go +++ b/apis/accounts_it_test.go @@ -1564,9 +1564,8 @@ func testAccActionSetRmvBalance(t *testing.T) { if err := accSRPC.Call(context.Background(), utils.AccountSv1ActionSetBalance, args2, &reply3); err != nil { t.Error(err) - } - if !reflect.DeepEqual(reply3, `OK`) { - t.Errorf("Expected %+v \n, received %+v", utils.ToJSON(`OK`), utils.ToJSON(reply3)) + } else if reply3 != utils.OK { + t.Errorf("Expected %+v \n, received %+v", utils.OK, utils.OK) } expectedAcc := utils.Account{ @@ -1575,13 +1574,9 @@ func testAccActionSetRmvBalance(t *testing.T) { Opts: map[string]interface{}{}, Balances: map[string]*utils.Balance{ "AbstractBalance3": { - ID: "AbstractBalance3", - FilterIDs: nil, - Weights: nil, - Type: "*concrete", - Units: utils.NewDecimal(10, 0), - UnitFactors: nil, - Opts: nil, + ID: "AbstractBalance3", + Type: "*concrete", + Units: utils.NewDecimal(10, 0), CostIncrements: []*utils.CostIncrement{ { FilterIDs: []string{"*string:~*req.ToR:*voice"}, @@ -1600,7 +1595,6 @@ func testAccActionSetRmvBalance(t *testing.T) { }, }, }, - "VoiceBalance": { ID: "VoiceBalance", FilterIDs: []string{"*string:~*req.Account:1001"}, diff --git a/apis/ees.go b/apis/ees.go index 55e1aac39..efd563860 100644 --- a/apis/ees.go +++ b/apis/ees.go @@ -33,6 +33,7 @@ type EeSv1 struct { ping } +// ProcessEvent triggers exports on EEs side func (cS *EeSv1) ProcessEvent(ctx *context.Context, cgrEv *utils.CGREventWithEeIDs, rply *map[string]map[string]interface{}) error { return cS.ees.V1ProcessEvent(ctx, cgrEv, rply) } diff --git a/engine/filters_test.go b/engine/filters_test.go index 2785b770d..5b111b79e 100644 --- a/engine/filters_test.go +++ b/engine/filters_test.go @@ -30,6 +30,82 @@ import ( "github.com/cgrates/cgrates/utils" ) +func TestRatesCostFiltering(t *testing.T) { + cfg := config.NewDefaultCGRConfig() + data := NewInternalDB(nil, nil, cfg.DataDbCfg().Items) + dmFilterPass := NewDataManager(data, config.CgrConfig().CacheCfg(), nil) + filterS := FilterS{ + cfg: cfg, + dm: dmFilterPass, + } + cgrEv := &utils.CGREventWithEeIDs{ + CGREvent: &utils.CGREvent{ + Tenant: "cgrates.org", + ID: "TestEv1", + Event: map[string]interface{}{ + "Account": "1001", + "Destination": "1002", + "OriginID": "TestEv1", + "RequestType": "*prepaid", + "Subject": "1001", + "ToR": "*voice", + "Usage": 60000000000, + }, + APIOpts: map[string]interface{}{ + utils.MetaRateSCost: map[string]interface{}{ + utils.Cost: 0.4, + "CostIntervals": []map[string]interface{}{ + { + "CompressFactor": 1, + "Increments": []map[string]interface{}{ + { + "CompressFactor": 2, + "RateID": "Rate1", + "RateIntervalIndex": 0, + "Usage": 60000000000, + }, + }, + }, + }, + "ID": "RT_RETAIL1", + "Rates": map[string]interface{}{ + "Rate1": map[string]interface{}{ + "Increment": 30000000000, + "IntervalStart": 0, + "RecurrentFee": 0.4, + "Unit": 60000000000, + }, + }, + }, + utils.OptsRateS: true, + utils.OptsCDRsExport: true, + utils.OptsAccountS: false, + }, + }, + } + cgrDP := cgrEv.AsDataProvider() + if pass, err := filterS.Pass(context.Background(), "cgrates.org", []string{"*gt:~*opts.*rateSCost.Cost:0"}, cgrDP); err != nil { + t.Error(err) + } else if !pass { + t.Errorf("Expected to pass") + } + if pass, err := filterS.Pass(context.Background(), "cgrates.org", []string{"*gt:~*opts.*rateSCost.Cost:0.5"}, cgrDP); err != nil { + t.Error(err) + } else if pass { + t.Errorf("Expected to fail") + } + if pass, err := filterS.Pass(context.Background(), "cgrates.org", []string{"*string:~*opts.*rateSCost.CostIntervals[0].Increments[0].RateID:Rate1"}, cgrDP); err != nil { + t.Error(err) + } else if !pass { + t.Errorf("Expected to pass") + } + if pass, err := filterS.Pass(context.Background(), "cgrates.org", []string{"*eq:~*opts.*rateSCost.Rates[Rate1].RecurrentFee:0.4"}, cgrDP); err != nil { + t.Error(err) + } else if !pass { + t.Errorf("Expected to pass") + } +} + func TestFilterPassGreaterThan(t *testing.T) { rf, err := NewFilterRule(utils.MetaLessThan, "~ASR", []string{"40"}) if err != nil {