mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Add verify for timing for RateInterval
This commit is contained in:
committed by
Dan Christian Bogos
parent
f42153961e
commit
4bfb0c2845
@@ -551,7 +551,6 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) {
|
||||
if err != nil || cd.GetDuration() == 0 {
|
||||
return cc, err
|
||||
}
|
||||
|
||||
cost := 0.0
|
||||
for i, ts := range cc.Timespans {
|
||||
// only add connect fee if this is the first/only call cost request
|
||||
|
||||
@@ -173,11 +173,21 @@ func (rpf *RatingProfile) GetRatingPlansForPrefix(cd *CallDescriptor) (err error
|
||||
for _, p := range utils.SplitPrefix(cd.Destination, MIN_PREFIX_MATCH) {
|
||||
if destIDs, err := dm.DataDB().GetReverseDestination(p, false, utils.NonTransactional); err == nil {
|
||||
var bestWeight *float64
|
||||
var timeChecker bool
|
||||
for _, dID := range destIDs {
|
||||
if _, ok := rpl.DestinationRates[dID]; ok {
|
||||
ril := rpl.RateIntervalList(dID)
|
||||
//check if RateInverval is active for call descriptor time
|
||||
for _, ri := range ril {
|
||||
if !ri.Timing.IsActiveAt(cd.TimeStart) {
|
||||
continue
|
||||
} else {
|
||||
timeChecker = true
|
||||
break
|
||||
}
|
||||
}
|
||||
currentWeight := ril.GetWeight()
|
||||
if bestWeight == nil || currentWeight > *bestWeight {
|
||||
if timeChecker && (bestWeight == nil || currentWeight > *bestWeight) {
|
||||
bestWeight = utils.Float64Pointer(currentWeight)
|
||||
rps = ril
|
||||
prefix = p
|
||||
|
||||
@@ -72,10 +72,7 @@ func testTutLoadConfig(t *testing.T) {
|
||||
if tutCfg, err = config.NewCGRConfigFromPath(tutCfgPath); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
switch tutCfgDir {
|
||||
default:
|
||||
tutDelay = 2000
|
||||
}
|
||||
tutDelay = 2000
|
||||
}
|
||||
|
||||
func testTutResetDB(t *testing.T) {
|
||||
@@ -144,20 +141,18 @@ func testTutGetCost(t *testing.T) {
|
||||
AnswerTime: "2019-03-11T21:00:00Z",
|
||||
Usage: "45s",
|
||||
}
|
||||
/*
|
||||
// *any to 2001
|
||||
attrs = v1.AttrGetCost{
|
||||
Subject: "1002",
|
||||
Destination: "2001",
|
||||
AnswerTime: "*now",
|
||||
Usage: "45s",
|
||||
}
|
||||
if err := tutRpc.Call(utils.ApierV1GetCost, attrs, &rply); err != nil {
|
||||
t.Error("Unexpected nil error received: ", err.Error())
|
||||
} else if *rply.Cost != 1.2 { // FixMe: missing ConnectFee out of Cost
|
||||
t.Errorf("Unexpected cost received: %f", *rply.Cost)
|
||||
}
|
||||
*/
|
||||
// *any to 2001
|
||||
attrs = v1.AttrGetCost{
|
||||
Subject: "1002",
|
||||
Destination: "2001",
|
||||
AnswerTime: "*now",
|
||||
Usage: "45s",
|
||||
}
|
||||
if err := tutRpc.Call(utils.ApierV1GetCost, attrs, &rply); err != nil {
|
||||
t.Error("Unexpected nil error received: ", err.Error())
|
||||
} else if *rply.Cost != 1.4 {
|
||||
t.Errorf("Unexpected cost received: %f", *rply.Cost)
|
||||
}
|
||||
// *any to 2001 on NEW_YEAR
|
||||
attrs = v1.AttrGetCost{
|
||||
Subject: "1002",
|
||||
|
||||
Reference in New Issue
Block a user