mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
fix for shared get max session
This commit is contained in:
@@ -158,10 +158,10 @@ func (ub *Account) debitBalanceAction(a *Action) error {
|
||||
func (ub *Account) getBalancesForPrefix(prefix string, balances BalanceChain, sharedGroup string) BalanceChain {
|
||||
var usefulBalances BalanceChain
|
||||
for _, b := range balances {
|
||||
if b.IsExpired() || (ub.AllowNegative == false && b.Value <= 0) {
|
||||
if b.IsExpired() || (ub.AllowNegative == false && b.SharedGroup == "" && b.Value <= 0) {
|
||||
continue
|
||||
}
|
||||
if sharedGroup != "" && b.SharedGroup != sharedGroup {
|
||||
if sharedGroup != "" && sharedGroup != "" && b.SharedGroup != sharedGroup {
|
||||
continue
|
||||
}
|
||||
if b.SharedGroup != "" {
|
||||
|
||||
@@ -56,7 +56,10 @@ func (b *Balance) Equal(o *Balance) bool {
|
||||
|
||||
// the default balance has no destinationid, Expirationdate or ratesubject
|
||||
func (b *Balance) IsDefault() bool {
|
||||
return (b.DestinationId == "" || b.DestinationId == utils.ANY) && b.RateSubject == "" && b.ExpirationDate.IsZero()
|
||||
return (b.DestinationId == "" || b.DestinationId == utils.ANY) &&
|
||||
b.RateSubject == "" &&
|
||||
b.ExpirationDate.IsZero() &&
|
||||
b.SharedGroup == ""
|
||||
}
|
||||
|
||||
func (b *Balance) IsExpired() bool {
|
||||
|
||||
@@ -340,6 +340,45 @@ func TestMaxSessionTimeWithAccountAlias(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaxSessionTimeWithAccountShared(t *testing.T) {
|
||||
ap, _ := accountingStorage.GetActionTimings("TOPUP_SHARED0_AT")
|
||||
for _, at := range ap {
|
||||
at.Execute()
|
||||
}
|
||||
ap, _ = accountingStorage.GetActionTimings("TOPUP_SHARED10_AT")
|
||||
for _, at := range ap {
|
||||
at.Execute()
|
||||
}
|
||||
|
||||
cd0 := &CallDescriptor{
|
||||
TimeStart: time.Date(2013, 10, 21, 18, 34, 0, 0, time.UTC),
|
||||
TimeEnd: time.Date(2013, 10, 21, 18, 35, 0, 0, time.UTC),
|
||||
Direction: "*out",
|
||||
TOR: "0",
|
||||
Tenant: "vdf",
|
||||
Subject: "rif",
|
||||
Account: "empty0",
|
||||
Destination: "0723",
|
||||
}
|
||||
|
||||
cd1 := &CallDescriptor{
|
||||
TimeStart: time.Date(2013, 10, 21, 18, 34, 0, 0, time.UTC),
|
||||
TimeEnd: time.Date(2013, 10, 21, 18, 35, 0, 0, time.UTC),
|
||||
Direction: "*out",
|
||||
TOR: "0",
|
||||
Tenant: "vdf",
|
||||
Subject: "rif",
|
||||
Account: "empty10",
|
||||
Destination: "0723",
|
||||
}
|
||||
|
||||
result0, err := cd0.GetMaxSessionDuration()
|
||||
result1, err := cd1.GetMaxSessionDuration()
|
||||
if result0 != result1 || err != nil {
|
||||
t.Errorf("Expected %v was %v, %v", result1, result0, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMaxSessionTimeWithAccountAccount(t *testing.T) {
|
||||
cd := &CallDescriptor{
|
||||
TimeStart: time.Date(2013, 10, 21, 18, 34, 0, 0, time.UTC),
|
||||
|
||||
@@ -132,12 +132,16 @@ MINI,*topup,*minutes,*out,100,*unlimited,NAT,test,10,,,10
|
||||
SHARED,*topup,*monetary,*out,100,*unlimited,,,10,SG1,,10
|
||||
TOPUP10_AC,*topup_reset,*monetary,*out,1,*unlimited,*any,,10,,,10
|
||||
TOPUP10_AC1,*topup_reset,*minutes,*out,40,*unlimited,DST_UK_Mobile_BIG5,discounted_minutes,10,,,10
|
||||
SE0,*topup_reset,*monetary,*out,0,*unlimited,,,10,SG2,,10
|
||||
SE10,*topup_reset,*monetary,*out,10,*unlimited,,,10,SG2,,10
|
||||
`
|
||||
actionTimings = `
|
||||
MORE_MINUTES,MINI,ONE_TIME_RUN,10
|
||||
MORE_MINUTES,SHARED,ONE_TIME_RUN,10
|
||||
TOPUP10_AT,TOPUP10_AC,ASAP,10
|
||||
TOPUP10_AT,TOPUP10_AC1,ASAP,10
|
||||
TOPUP_SHARED0_AT,SE0,ASAP,10
|
||||
TOPUP_SHARED10_AT,SE10,ASAP,10
|
||||
`
|
||||
actionTriggers = `
|
||||
STANDARD_TRIGGER,*minutes,*out,*min_counter,10,GERMANY_O2,SOME_1,10
|
||||
@@ -149,6 +153,8 @@ STANDARD_TRIGGERS,*monetary,*out,*max_counter,5,FS_USERS,LOG_WARNING,10
|
||||
accountActions = `
|
||||
vdf,minitsboy;a1;a2,*out,MORE_MINUTES,STANDARD_TRIGGER
|
||||
cgrates.directvoip.co.uk,12345,*out,TOPUP10_AT,STANDARD_TRIGGERS
|
||||
vdf,empty0,*out,TOPUP_SHARED0_AT,
|
||||
vdf,empty10,*out,TOPUP_SHARED10_AT,
|
||||
`
|
||||
)
|
||||
|
||||
@@ -592,7 +598,7 @@ func TestLoadRatingProfiles(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadActions(t *testing.T) {
|
||||
if len(csvr.actions) != 4 {
|
||||
if len(csvr.actions) != 6 {
|
||||
t.Error("Failed to load actions: ", csvr.actions)
|
||||
}
|
||||
as1 := csvr.actions["MINI"]
|
||||
@@ -701,7 +707,7 @@ func TestLoadSharedGroups(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadActionTimings(t *testing.T) {
|
||||
if len(csvr.actionsTimings) != 2 {
|
||||
if len(csvr.actionsTimings) != 4 {
|
||||
t.Error("Failed to load action timings: ", csvr.actionsTimings)
|
||||
}
|
||||
atm := csvr.actionsTimings["MORE_MINUTES"][0]
|
||||
@@ -763,7 +769,7 @@ func TestLoadActionTriggers(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoadAccountActions(t *testing.T) {
|
||||
if len(csvr.accountActions) != 2 {
|
||||
if len(csvr.accountActions) != 4 {
|
||||
t.Error("Failed to load account actions: ", csvr.accountActions)
|
||||
}
|
||||
aa := csvr.accountActions["*out:vdf:minitsboy"]
|
||||
|
||||
Reference in New Issue
Block a user