From 402a1fbc68dd092aa3f2182b82190b8aaf882f1d Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Fri, 25 Apr 2014 21:50:34 +0300 Subject: [PATCH] Call descriptot Type is now Tor --- engine/account.go | 6 +++--- engine/account_test.go | 40 ++++++++++++++++++++-------------------- engine/balances.go | 8 ++++---- engine/callcost.go | 12 ++++++------ engine/callcost_test.go | 6 +++--- engine/calldesc.go | 26 +++++++++++++------------- engine/calldesc_test.go | 10 +++++----- engine/datacost.go | 8 ++++---- engine/timespans.go | 2 +- 9 files changed, 59 insertions(+), 59 deletions(-) diff --git a/engine/account.go b/engine/account.go index 6833f249d..feb500efb 100644 --- a/engine/account.go +++ b/engine/account.go @@ -62,7 +62,7 @@ type Account struct { 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.Type+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 { @@ -80,7 +80,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.Type+cd.Direction, ub) + sgb := sharedGroup.GetBalances(cd.Destination, cd.Tor+cd.Direction, ub) sgb = sharedGroup.SortBalancesByStrategy(mb, sgb) extendedMinuteBalances = append(extendedMinuteBalances, sgb...) } @@ -203,7 +203,7 @@ func (account *Account) getAlldBalancesForPrefix(destination, balanceType string } func (ub *Account) debitCreditBalance(cc *CallCost, count bool) (err error) { - usefulUnitBalances := ub.getAlldBalancesForPrefix(cc.Destination, cc.Type+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 { diff --git a/engine/account_test.go b/engine/account_test.go index 205fd0b75..6ac5d42cd 100644 --- a/engine/account_test.go +++ b/engine/account_test.go @@ -105,7 +105,7 @@ func TestGetSecondsForPrefix(t *testing.T) { DurationIndex: 10 * time.Second, Direction: OUTBOUND, Destination: "0723", - Type: 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", - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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}}}}, }, }, - Type: 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) { }, }, }, - Type: 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) { }, }, }, - Type: DATA, + Tor: DATA, } rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{ DATA + OUTBOUND: BalanceChain{&Balance{Uuid: "testm", Value: 0, Weight: 5, DestinationId: "NAT"}}, diff --git a/engine/balances.go b/engine/balances.go index 7d6a50c0a..b2b53c71b 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -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.Type} + inc.UnitInfo = &UnitInfo{cc.Destination, amount, cc.Tor} inc.Cost = 0 inc.paid = true if count { - ub.countUnits(&Action{BalanceType: cc.Type, 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.Type} + 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.Type, 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}}) } diff --git a/engine/callcost.go b/engine/callcost.go index 53ed08003..ac8843b64 100644 --- a/engine/callcost.go +++ b/engine/callcost.go @@ -25,10 +25,10 @@ import ( // The output structure that will be returned with the call cost information. type CallCost struct { - Direction, Category, Tenant, Subject, Account, Destination, Type string - Cost float64 - Timespans TimeSpans - deductConnectFee bool + Direction, Category, Tenant, Subject, Account, Destination, Tor string + Cost float64 + Timespans TimeSpans + deductConnectFee bool } // Pretty printing for call cost @@ -117,7 +117,7 @@ func (cc *CallCost) IsPaid() bool { } func (cc *CallCost) ToDataCost() (*DataCost, error) { - if cc.Type == 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, - Type: cc.Type, + Tor: cc.Tor, Cost: cc.Cost, deductConnectFee: cc.deductConnectFee, } diff --git a/engine/callcost_test.go b/engine/callcost_test.go index cc3ea4c8b..2cda0c4f6 100644 --- a/engine/callcost_test.go +++ b/engine/callcost_test.go @@ -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), - Type: 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), - Type: 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","Type":"*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)) } diff --git a/engine/calldesc.go b/engine/calldesc.go index e8b64d1f5..f8ced5fe2 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -116,7 +116,7 @@ type CallDescriptor struct { FallbackSubject string // the subject to check for destination if not found on primary subject RatingInfos RatingInfos Increments Increments - Type string + Tor string account *Account } @@ -306,7 +306,7 @@ func (cd *CallDescriptor) splitInTimeSpans() (timespans []*TimeSpan) { } firstSpan.ratingInfo = cd.RatingInfos[0] - if cd.Type == MINUTES { + if cd.Tor == MINUTES { // split on rating plans afterStart, afterEnd := false, false //optimization for multiple activation periods for _, rp := range cd.RatingInfos { @@ -400,8 +400,8 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) { if cd.DurationIndex < cd.TimeEnd.Sub(cd.TimeStart) { cd.DurationIndex = cd.TimeEnd.Sub(cd.TimeStart) } - if cd.Type == "" { - cd.Type = MINUTES + if cd.Tor == "" { + cd.Tor = MINUTES } err := cd.LoadRatingPlans() if err != nil { @@ -432,7 +432,7 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) { Cost: cost, Timespans: timespans, deductConnectFee: cd.LoopIndex == 0, - Type: cd.Type, + Tor: cd.Tor, } //Logger.Info(fmt.Sprintf(" Get Cost: %s => %v", cd.GetKey(), cc)) cc.Timespans.Compress() @@ -448,8 +448,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.Type == "" { - origCD.Type = MINUTES + if origCD.Tor == "" { + origCD.Tor = MINUTES } cd := origCD.Clone() //Logger.Debug(fmt.Sprintf("MAX SESSION cd: %+v", cd)) @@ -514,7 +514,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.Type); 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 @@ -564,7 +564,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.Type); 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 @@ -585,7 +585,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.Type); 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 { @@ -618,7 +618,7 @@ func (cd *CallDescriptor) RefundIncrements() (left float64, err error) { defer accountingStorage.SetAccount(account) } } - account.refundIncrement(increment, cd.Direction, cd.Type, true) + account.refundIncrement(increment, cd.Direction, cd.Tor, true) } return 0.0, err } @@ -641,7 +641,7 @@ func (cd *CallDescriptor) CreateCallCost() *CallCost { Subject: cd.Subject, Account: cd.Account, Destination: cd.Destination, - Type: cd.Type, + Tor: cd.Tor, } } @@ -661,6 +661,6 @@ func (cd *CallDescriptor) Clone() *CallDescriptor { FallbackSubject: cd.FallbackSubject, //RatingInfos: cd.RatingInfos, //Increments: cd.Increments, - Type: cd.Type, + Tor: cd.Tor, } } diff --git a/engine/calldesc_test.go b/engine/calldesc_test.go index 192e7e4dd..c7bb2307b 100644 --- a/engine/calldesc_test.go +++ b/engine/calldesc_test.go @@ -451,7 +451,7 @@ func TestMaxSessionTimeNoCredit(t *testing.T) { Tenant: "vdf", Subject: "broker", Destination: "0723", - Type: 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), - Type: 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), - Type: 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), - Type: 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), - Type: DATA, + Tor: DATA, } cc, err := cd.GetCost() if err != nil || cc.Cost != 65 { diff --git a/engine/datacost.go b/engine/datacost.go index d74ab5d2d..d584cab5d 100644 --- a/engine/datacost.go +++ b/engine/datacost.go @@ -19,10 +19,10 @@ package engine // type used for showing sane data cost type DataCost struct { - Direction, Category, Tenant, Subject, Account, Destination, Type string - Cost float64 - DataSpans []*DataSpan - deductConnectFee bool + Direction, Category, Tenant, Subject, Account, Destination, Tor string + Cost float64 + DataSpans []*DataSpan + deductConnectFee bool } type DataSpan struct { DataStart, DataEnd float64 diff --git a/engine/timespans.go b/engine/timespans.go index 6d2c48809..2420a2ce8 100644 --- a/engine/timespans.go +++ b/engine/timespans.go @@ -54,7 +54,7 @@ type Increment struct { type UnitInfo struct { DestinationId string Quantity float64 - Type string + Tor string //Price float64 }