cd Tor to TOR

This commit is contained in:
Radu Ioan Fericean
2014-04-26 01:50:08 +03:00
parent 9d0f252aad
commit 255fb4ea0e
13 changed files with 61 additions and 61 deletions

View File

@@ -61,7 +61,7 @@ type Account struct {
// User's available minutes for the specified destination
func (ub *Account) getCreditForPrefix(cd *CallDescriptor) (duration time.Duration, credit float64, balances BalanceChain) {
creditBalances := ub.getBalancesForPrefix(cd.Destination, ub.BalanceMap[CREDIT+cd.Direction], "")
unitBalances := ub.getBalancesForPrefix(cd.Destination, ub.BalanceMap[cd.Tor+cd.Direction], "")
unitBalances := ub.getBalancesForPrefix(cd.Destination, ub.BalanceMap[cd.TOR+cd.Direction], "")
// gather all balances from shared groups
var extendedCreditBalances BalanceChain
for _, cb := range creditBalances {
@@ -79,7 +79,7 @@ func (ub *Account) getCreditForPrefix(cd *CallDescriptor) (duration time.Duratio
for _, mb := range unitBalances {
if mb.SharedGroup != "" {
if sharedGroup, _ := accountingStorage.GetSharedGroup(mb.SharedGroup, false); sharedGroup != nil {
sgb := sharedGroup.GetBalances(cd.Destination, cd.Tor+cd.Direction, ub)
sgb := sharedGroup.GetBalances(cd.Destination, cd.TOR+cd.Direction, ub)
sgb = sharedGroup.SortBalancesByStrategy(mb, sgb)
extendedMinuteBalances = append(extendedMinuteBalances, sgb...)
}
@@ -202,7 +202,7 @@ func (account *Account) getAlldBalancesForPrefix(destination, balanceType string
}
func (ub *Account) debitCreditBalance(cc *CallCost, count bool) (err error) {
usefulUnitBalances := ub.getAlldBalancesForPrefix(cc.Destination, cc.Tor+cc.Direction)
usefulUnitBalances := ub.getAlldBalancesForPrefix(cc.Destination, cc.TOR+cc.Direction)
usefulMoneyBalances := ub.getAlldBalancesForPrefix(cc.Destination, CREDIT+cc.Direction)
// debit minutes
for _, balance := range usefulUnitBalances {

View File

@@ -105,7 +105,7 @@ func TestGetSecondsForPrefix(t *testing.T) {
DurationIndex: 10 * time.Second,
Direction: OUTBOUND,
Destination: "0723",
Tor: MINUTES,
TOR: MINUTES,
}
seconds, credit, bucketList := ub1.getCreditForPrefix(cd)
expected := 110 * time.Second
@@ -134,7 +134,7 @@ func TestGetSpecialPricedSeconds(t *testing.T) {
LoopIndex: 0,
Direction: OUTBOUND,
Destination: "0723",
Tor: MINUTES,
TOR: MINUTES,
}
seconds, credit, bucketList := ub1.getCreditForPrefix(cd)
expected := 20 * time.Second
@@ -172,7 +172,7 @@ func TestDebitCreditZeroSecond(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{MINUTES + OUTBOUND: BalanceChain{b1}, CREDIT + OUTBOUND: BalanceChain{&Balance{Value: 21}}}}
err := rifsBalance.debitCreditBalance(cc, false)
@@ -202,7 +202,7 @@ func TestDebitCreditZeroMinute(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
@@ -238,7 +238,7 @@ func TestDebitCreditZeroMixedMinute(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1, b2},
@@ -278,7 +278,7 @@ func TestDebitCreditNoCredit(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
@@ -319,7 +319,7 @@ func TestDebitCreditHasCredit(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 1, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
@@ -357,7 +357,7 @@ func TestDebitCreditSplitMinutesMoney(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 1, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
@@ -400,7 +400,7 @@ func TestDebitCreditMoreTimespans(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
@@ -439,7 +439,7 @@ func TestDebitCreditMoreTimespansMixed(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1, b2},
@@ -478,7 +478,7 @@ func TestDebitCreditNoConectFeeCredit(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 1, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
@@ -512,7 +512,7 @@ func TestDebitCreditMoneyOnly(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 1, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "money", Value: 50}},
@@ -553,7 +553,7 @@ func TestDebitCreditSubjectMinutes(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
deductConnectFee: true,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
@@ -596,7 +596,7 @@ func TestDebitCreditSubjectMoney(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
deductConnectFee: true,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
@@ -634,7 +634,7 @@ func TestDebitCreditSubjectMixed(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
deductConnectFee: true,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
@@ -684,7 +684,7 @@ func TestDebitCreditSubjectMixedMoreTS(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 1, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
deductConnectFee: true,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
@@ -736,7 +736,7 @@ func TestDebitCreditSubjectMixedPartPay(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 1, RateIncrement: 10 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: MINUTES,
TOR: MINUTES,
deductConnectFee: true,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
@@ -1043,7 +1043,7 @@ func TestDebitSMS(t *testing.T) {
RateInterval: &RateInterval{Rating: &RIRate{Rates: RateGroups{&Rate{GroupIntervalStart: 0, Value: 100, RateIncrement: 1 * time.Second, RateUnit: time.Second}}}},
},
},
Tor: SMS,
TOR: SMS,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
SMS + OUTBOUND: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationId: "NAT"}},
@@ -1083,7 +1083,7 @@ func TestDebitDataUnits(t *testing.T) {
},
},
},
Tor: DATA,
TOR: DATA,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
DATA + OUTBOUND: BalanceChain{&Balance{Uuid: "testm", Value: 100, Weight: 5, DestinationId: "NAT"}},
@@ -1122,7 +1122,7 @@ func TestDebitDataMoney(t *testing.T) {
},
},
},
Tor: DATA,
TOR: DATA,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
DATA + OUTBOUND: BalanceChain{&Balance{Uuid: "testm", Value: 0, Weight: 5, DestinationId: "NAT"}},

View File

@@ -204,11 +204,11 @@ func (b *Balance) DebitUnits(cc *CallCost, count bool, ub *Account, moneyBalance
b.SubstractAmount(amount)
inc.BalanceInfo.UnitBalanceUuid = b.Uuid
inc.BalanceInfo.AccountId = ub.Id
inc.UnitInfo = &UnitInfo{cc.Destination, amount, cc.Tor}
inc.UnitInfo = &UnitInfo{cc.Destination, amount, cc.TOR}
inc.Cost = 0
inc.paid = true
if count {
ub.countUnits(&Action{BalanceType: cc.Tor, Direction: cc.Direction, Balance: &Balance{Value: amount, DestinationId: cc.Destination}})
ub.countUnits(&Action{BalanceType: cc.TOR, Direction: cc.Direction, Balance: &Balance{Value: amount, DestinationId: cc.Destination}})
}
}
continue
@@ -244,7 +244,7 @@ func (b *Balance) DebitUnits(cc *CallCost, count bool, ub *Account, moneyBalance
b.SubstractAmount(seconds)
nInc.BalanceInfo.UnitBalanceUuid = b.Uuid
nInc.BalanceInfo.AccountId = ub.Id
nInc.UnitInfo = &UnitInfo{newCC.Destination, seconds, cc.Tor}
nInc.UnitInfo = &UnitInfo{newCC.Destination, seconds, cc.TOR}
if cost != 0 {
nInc.BalanceInfo.MoneyBalanceUuid = moneyBal.Uuid
moneyBal.Value -= cost
@@ -252,7 +252,7 @@ func (b *Balance) DebitUnits(cc *CallCost, count bool, ub *Account, moneyBalance
}
nInc.paid = true
if count {
ub.countUnits(&Action{BalanceType: newCC.Tor, Direction: newCC.Direction, Balance: &Balance{Value: seconds, DestinationId: newCC.Destination}})
ub.countUnits(&Action{BalanceType: newCC.TOR, Direction: newCC.Direction, Balance: &Balance{Value: seconds, DestinationId: newCC.Destination}})
if cost != 0 {
ub.countUnits(&Action{BalanceType: CREDIT, Direction: newCC.Direction, Balance: &Balance{Value: cost, DestinationId: newCC.Destination}})
}

View File

@@ -25,7 +25,7 @@ import (
// The output structure that will be returned with the call cost information.
type CallCost struct {
Direction, Category, Tenant, Subject, Account, Destination, Tor string
Direction, Category, Tenant, Subject, Account, Destination, TOR string
Cost float64
Timespans TimeSpans
deductConnectFee bool
@@ -117,7 +117,7 @@ func (cc *CallCost) IsPaid() bool {
}
func (cc *CallCost) ToDataCost() (*DataCost, error) {
if cc.Tor == MINUTES {
if cc.TOR == MINUTES {
return nil, errors.New("Not a data call!")
}
dc := &DataCost{
@@ -127,7 +127,7 @@ func (cc *CallCost) ToDataCost() (*DataCost, error) {
Subject: cc.Subject,
Account: cc.Account,
Destination: cc.Destination,
Tor: cc.Tor,
TOR: cc.TOR,
Cost: cc.Cost,
deductConnectFee: cc.deductConnectFee,
}

View File

@@ -174,7 +174,7 @@ func TestCallCostToDataCostError(t *testing.T) {
Destination: utils.ANY,
TimeStart: time.Date(2014, 3, 4, 6, 0, 0, 0, time.UTC),
TimeEnd: time.Date(2014, 3, 4, 6, 1, 5, 0, time.UTC),
Tor: MINUTES,
TOR: MINUTES,
}
cc, _ := cd.GetCost()
_, err := cc.ToDataCost()
@@ -192,7 +192,7 @@ func TestCallCostToDataCost(t *testing.T) {
Destination: utils.ANY,
TimeStart: time.Date(2014, 3, 4, 6, 0, 0, 0, time.UTC),
TimeEnd: time.Date(2014, 3, 4, 6, 1, 5, 0, time.UTC),
Tor: DATA,
TOR: DATA,
}
cc, _ := cd.GetCost()
dc, err := cc.ToDataCost()
@@ -200,7 +200,7 @@ func TestCallCostToDataCost(t *testing.T) {
t.Error("Error convertiong to data cost: ", err)
}
js, _ := json.Marshal(dc)
expected := `{"Direction":"*out","Category":"data","Tenant":"cgrates.org","Subject":"rif","Account":"","Destination":"*any","Tor":"*data","Cost":65,"DataSpans":[{"DataStart":0,"DataEnd":60,"Cost":60,"RateInterval":{"Timing":{"Years":[],"Months":[],"MonthDays":[],"WeekDays":[],"StartTime":"00:00:00","EndTime":""},"Rating":{"ConnectFee":0,"Rates":[{"GroupIntervalStart":0,"Value":1,"RateIncrement":60000000000,"RateUnit":1000000000},{"GroupIntervalStart":60000000000,"Value":1,"RateIncrement":1000000000,"RateUnit":1000000000}],"RoundingMethod":"*up","RoundingDecimals":4},"Weight":10},"DataIndex":60,"Increments":[],"MatchedSubject":"","MatchedPrefix":"","MatchedDestId":""},{"DataStart":60,"DataEnd":65,"Cost":5,"RateInterval":{"Timing":{"Years":[],"Months":[],"MonthDays":[],"WeekDays":[],"StartTime":"00:00:00","EndTime":""},"Rating":{"ConnectFee":0,"Rates":[{"GroupIntervalStart":0,"Value":1,"RateIncrement":60000000000,"RateUnit":1000000000},{"GroupIntervalStart":60000000000,"Value":1,"RateIncrement":1000000000,"RateUnit":1000000000}],"RoundingMethod":"*up","RoundingDecimals":4},"Weight":10},"DataIndex":65,"Increments":[],"MatchedSubject":"*out:cgrates.org:data:rif","MatchedPrefix":"*any","MatchedDestId":"*any"}]}`
expected := `{"Direction":"*out","Category":"data","Tenant":"cgrates.org","Subject":"rif","Account":"","Destination":"*any","TOR":"*data","Cost":65,"DataSpans":[{"DataStart":0,"DataEnd":60,"Cost":60,"RateInterval":{"Timing":{"Years":[],"Months":[],"MonthDays":[],"WeekDays":[],"StartTime":"00:00:00","EndTime":""},"Rating":{"ConnectFee":0,"Rates":[{"GroupIntervalStart":0,"Value":1,"RateIncrement":60000000000,"RateUnit":1000000000},{"GroupIntervalStart":60000000000,"Value":1,"RateIncrement":1000000000,"RateUnit":1000000000}],"RoundingMethod":"*up","RoundingDecimals":4},"Weight":10},"DataIndex":60,"Increments":[],"MatchedSubject":"","MatchedPrefix":"","MatchedDestId":""},{"DataStart":60,"DataEnd":65,"Cost":5,"RateInterval":{"Timing":{"Years":[],"Months":[],"MonthDays":[],"WeekDays":[],"StartTime":"00:00:00","EndTime":""},"Rating":{"ConnectFee":0,"Rates":[{"GroupIntervalStart":0,"Value":1,"RateIncrement":60000000000,"RateUnit":1000000000},{"GroupIntervalStart":60000000000,"Value":1,"RateIncrement":1000000000,"RateUnit":1000000000}],"RoundingMethod":"*up","RoundingDecimals":4},"Weight":10},"DataIndex":65,"Increments":[],"MatchedSubject":"*out:cgrates.org:data:rif","MatchedPrefix":"*any","MatchedDestId":"*any"}]}`
if string(js) != expected {
t.Error("Error coverting to data cost: ", string(js))
}

View File

@@ -117,7 +117,7 @@ type CallDescriptor struct {
FallbackSubject string // the subject to check for destination if not found on primary subject
RatingInfos RatingInfos
Increments Increments
Tor string
TOR string
account *Account
}
@@ -317,7 +317,7 @@ func (cd *CallDescriptor) splitInTimeSpans() (timespans []*TimeSpan) {
}
firstSpan.ratingInfo = cd.RatingInfos[0]
if cd.Tor == MINUTES {
if cd.TOR == MINUTES {
// split on rating plans
afterStart, afterEnd := false, false //optimization for multiple activation periods
for _, rp := range cd.RatingInfos {
@@ -411,8 +411,8 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) {
if cd.DurationIndex < cd.TimeEnd.Sub(cd.TimeStart) {
cd.DurationIndex = cd.TimeEnd.Sub(cd.TimeStart)
}
if cd.Tor == "" {
cd.Tor = MINUTES
if cd.TOR == "" {
cd.TOR = MINUTES
}
err := cd.LoadRatingPlans()
if err != nil {
@@ -432,7 +432,7 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) {
}
// global rounding
cost = utils.Round(cost, roundingDecimals, roundingMethod)
//startIndex := len(fmt.Sprintf("%s:%s:%s:", cd.Direction, cd.Tenant, cd.TOR))
//startIndex := len(fmt.Sprintf("%s:%s:%s:", cd.Direction, cd.Tenant, cd.Category))
cc := &CallCost{
Direction: cd.Direction,
Category: cd.Category,
@@ -443,7 +443,7 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) {
Cost: cost,
Timespans: timespans,
deductConnectFee: cd.LoopIndex == 0,
Tor: cd.Tor,
TOR: cd.TOR,
}
//Logger.Info(fmt.Sprintf("<Rater> Get Cost: %s => %v", cd.GetKey(), cc))
cc.Timespans.Compress()
@@ -459,8 +459,8 @@ func (origCD *CallDescriptor) getMaxSessionDuration(account *Account) (time.Dura
if origCD.DurationIndex < origCD.TimeEnd.Sub(origCD.TimeStart) {
origCD.DurationIndex = origCD.TimeEnd.Sub(origCD.TimeStart)
}
if origCD.Tor == "" {
origCD.Tor = MINUTES
if origCD.TOR == "" {
origCD.TOR = MINUTES
}
cd := origCD.Clone()
//Logger.Debug(fmt.Sprintf("MAX SESSION cd: %+v", cd))
@@ -525,7 +525,7 @@ func (cd *CallDescriptor) GetMaxSessionDuration() (duration time.Duration, err e
Logger.Err(fmt.Sprintf("Could not get user balance for %s: %s.", cd.GetAccountKey(), err.Error()))
return 0, err
} else {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd.Destination, cd.Direction, cd.Tor); err == nil {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd.Destination, cd.Direction, cd.TOR); err == nil {
AccLock.GuardMany(memberIds, func() (float64, error) {
duration, err = cd.getMaxSessionDuration(account)
return 0, err
@@ -575,7 +575,7 @@ func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
Logger.Err(fmt.Sprintf("Could not get user balance for %s: %s.", cd.GetAccountKey(), err.Error()))
return nil, err
} else {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd.Destination, cd.Direction, cd.Tor); err == nil {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd.Destination, cd.Direction, cd.TOR); err == nil {
AccLock.GuardMany(memberIds, func() (float64, error) {
cc, err = cd.debit(account)
return 0, err
@@ -596,7 +596,7 @@ func (cd *CallDescriptor) MaxDebit() (cc *CallCost, err error) {
Logger.Err(fmt.Sprintf("Could not get user balance for %s: %s.", cd.GetAccountKey(), err.Error()))
return nil, err
} else {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd.Destination, cd.Direction, cd.Tor); err == nil {
if memberIds, err := account.GetUniqueSharedGroupMembers(cd.Destination, cd.Direction, cd.TOR); err == nil {
AccLock.GuardMany(memberIds, func() (float64, error) {
remainingDuration, err := cd.getMaxSessionDuration(account)
if err != nil || remainingDuration == 0 {
@@ -629,7 +629,7 @@ func (cd *CallDescriptor) RefundIncrements() (left float64, err error) {
defer accountingStorage.SetAccount(account)
}
}
account.refundIncrement(increment, cd.Direction, cd.Tor, true)
account.refundIncrement(increment, cd.Direction, cd.TOR, true)
}
return 0.0, err
}
@@ -652,7 +652,7 @@ func (cd *CallDescriptor) CreateCallCost() *CallCost {
Subject: cd.Subject,
Account: cd.Account,
Destination: cd.Destination,
Tor: cd.Tor,
TOR: cd.TOR,
}
}
@@ -672,7 +672,7 @@ func (cd *CallDescriptor) Clone() *CallDescriptor {
FallbackSubject: cd.FallbackSubject,
//RatingInfos: cd.RatingInfos,
//Increments: cd.Increments,
Tor: cd.Tor,
TOR: cd.TOR,
}
}

View File

@@ -451,7 +451,7 @@ func TestMaxSessionTimeNoCredit(t *testing.T) {
Tenant: "vdf",
Subject: "broker",
Destination: "0723",
Tor: MINUTES,
TOR: MINUTES,
}
result, err := cd.GetMaxSessionDuration()
if result != time.Minute || err != nil {
@@ -472,7 +472,7 @@ func TestMaxSessionModifiesCallDesc(t *testing.T) {
Account: "minu",
Destination: "0723",
DurationIndex: t2.Sub(t1),
Tor: MINUTES,
TOR: MINUTES,
}
initial := cd.Clone()
cd.GetMaxSessionDuration()
@@ -701,7 +701,7 @@ func TestCDGetCostANY(t *testing.T) {
Destination: utils.ANY,
TimeStart: time.Date(2014, 3, 4, 6, 0, 0, 0, time.UTC),
TimeEnd: time.Date(2014, 3, 4, 6, 0, 1, 0, time.UTC),
Tor: DATA,
TOR: DATA,
}
cc, err := cd1.GetCost()
if err != nil || cc.Cost != 60 {
@@ -718,7 +718,7 @@ func TestCDSplitInDataSlots(t *testing.T) {
Destination: utils.ANY,
TimeStart: time.Date(2014, 3, 4, 6, 0, 0, 0, time.UTC),
TimeEnd: time.Date(2014, 3, 4, 6, 1, 5, 0, time.UTC),
Tor: DATA,
TOR: DATA,
DurationIndex: 65 * time.Second,
}
cd.LoadRatingPlans()
@@ -738,7 +738,7 @@ func TestCDDataGetCost(t *testing.T) {
Destination: utils.ANY,
TimeStart: time.Date(2014, 3, 4, 6, 0, 0, 0, time.UTC),
TimeEnd: time.Date(2014, 3, 4, 6, 1, 5, 0, time.UTC),
Tor: DATA,
TOR: DATA,
}
cc, err := cd.GetCost()
if err != nil || cc.Cost != 65 {

View File

@@ -19,7 +19,7 @@ package engine
// type used for showing sane data cost
type DataCost struct {
Direction, Category, Tenant, Subject, Account, Destination, Tor string
Direction, Category, Tenant, Subject, Account, Destination, TOR string
Cost float64
DataSpans []*DataSpan
deductConnectFee bool

View File

@@ -27,8 +27,8 @@ import (
func HandleGetDerivedChargers(acntStorage AccountingStorage, cfg *config.CGRConfig, attrs utils.AttrDerivedChargers) (utils.DerivedChargers, error) {
var dcs utils.DerivedChargers
var err error
strictKey := utils.DerivedChargersKey(attrs.Tenant, attrs.Tor, attrs.Direction, attrs.Account, attrs.Subject)
anySubjKey := utils.DerivedChargersKey(attrs.Tenant, attrs.Tor, attrs.Direction, attrs.Account, utils.ANY)
strictKey := utils.DerivedChargersKey(attrs.Tenant, attrs.Category, attrs.Direction, attrs.Account, attrs.Subject)
anySubjKey := utils.DerivedChargersKey(attrs.Tenant, attrs.Category, attrs.Direction, attrs.Account, utils.ANY)
for _, dcKey := range []string{strictKey, anySubjKey} {
if dcsDb, err := acntStorage.GetDerivedChargers(dcKey, false); err != nil && err.Error() != utils.ERR_NOT_FOUND {
return nil, err

View File

@@ -37,7 +37,7 @@ func init() {
// Accounting db has no DerivedChargers nor configured defaults
func TestHandleGetEmptyDC(t *testing.T) {
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Tor: "call", Direction: "*out", Account: "test2", Subject: "test2"}
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "test2", Subject: "test2"}
if dcs, err := HandleGetDerivedChargers(acntDb, cfgDcT, attrs); err != nil {
t.Error("Unexpected error", err.Error())
} else if !reflect.DeepEqual(dcs, cfgDcT.DerivedChargers) {
@@ -50,7 +50,7 @@ func TestHandleGetConfiguredDC(t *testing.T) {
cfgedDC := utils.DerivedChargers{&utils.DerivedCharger{RunId: "responder1", ReqTypeField: "test", DirectionField: "test", TenantField: "test",
CategoryField: "test", AccountField: "test", SubjectField: "test", DestinationField: "test", SetupTimeField: "test", AnswerTimeField: "test", DurationField: "test"}}
cfgDcT.DerivedChargers = cfgedDC
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Tor: "call", Direction: "*out", Account: "test3", Subject: "test3"}
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "test3", Subject: "test3"}
if dcs, err := HandleGetDerivedChargers(acntDb, cfgDcT, attrs); err != nil {
t.Error("Unexpected error", err.Error())
} else if !reflect.DeepEqual(dcs, cfgedDC) {
@@ -74,7 +74,7 @@ func TestHandleGetStoredDC(t *testing.T) {
expCharger1 := append(charger1, &utils.DerivedCharger{RunId: "responder1", ReqTypeField: "test", DirectionField: "test", TenantField: "test",
CategoryField: "test", AccountField: "test", SubjectField: "test", DestinationField: "test", SetupTimeField: "test", AnswerTimeField: "test", DurationField: "test"})
acntDb.CacheAccounting(nil, nil, nil, nil)
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Tor: "call", Direction: "*out", Account: "rif", Subject: "rif"}
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "rif", Subject: "rif"}
if dcs, err := HandleGetDerivedChargers(acntDb, cfgDcT, attrs); err != nil {
t.Error("Unexpected error", err.Error())
} else if !reflect.DeepEqual(dcs, expCharger1) {

View File

@@ -34,7 +34,7 @@ func TestResponderGetDerivedChargers(t *testing.T) {
cfg.DerivedChargers = cfgedDC
config.SetCgrConfig(cfg)
r := Responder{}
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Tor: "call", Direction: "*out", Account: "dan", Subject: "dan"}
attrs := utils.AttrDerivedChargers{Tenant: "cgrates.org", Category: "call", Direction: "*out", Account: "dan", Subject: "dan"}
var dcs utils.DerivedChargers
if err := r.GetDerivedChargers(attrs, &dcs); err != nil {
t.Error("Unexpected error", err.Error())

View File

@@ -54,7 +54,7 @@ type Increment struct {
type UnitInfo struct {
DestinationId string
Quantity float64
Tor string
TOR string
//Price float64
}

View File

@@ -381,5 +381,5 @@ type AttrGetDestination struct {
}
type AttrDerivedChargers struct {
Tenant, Tor, Direction, Account, Subject string
Tenant, Category, Direction, Account, Subject string
}