rename RateSubject to RatingSubject

This commit is contained in:
Radu Ioan Fericean
2014-04-06 12:53:48 +03:00
parent 564efade3d
commit 7313e64362
12 changed files with 75 additions and 75 deletions

View File

@@ -126,7 +126,7 @@ func (self *ApierV1) AddBalance(attr *AttrAddBalance, reply *string) error {
Balance: &engine.Balance{
Value: attr.Value,
ExpirationDate: attr.ExpirationDate,
RateSubject: attr.RatingSubject,
RatingSubject: attr.RatingSubject,
DestinationId: attr.DestinationId,
Weight: attr.Weight,
},
@@ -300,7 +300,7 @@ func (self *ApierV1) SetActions(attrs AttrSetActions, reply *string) error {
Value: apiAct.Units,
Weight: apiAct.BalanceWeight,
DestinationId: apiAct.DestinationId,
RateSubject: apiAct.RatingSubject,
RatingSubject: apiAct.RatingSubject,
},
}
storeActions[idx] = a

View File

@@ -115,8 +115,8 @@ func TestGetSecondsForPrefix(t *testing.T) {
}
func TestGetSpecialPricedSeconds(t *testing.T) {
b1 := &Balance{Value: 10, Weight: 10, DestinationId: "NAT", RateSubject: "minu"}
b2 := &Balance{Value: 100, Weight: 20, DestinationId: "RET", RateSubject: "minu"}
b1 := &Balance{Value: 10, Weight: 10, DestinationId: "NAT", RatingSubject: "minu"}
b2 := &Balance{Value: 100, Weight: 20, DestinationId: "RET", RatingSubject: "minu"}
ub1 := &Account{
Id: "OUT:CUSTOMER_1:rif",
@@ -158,7 +158,7 @@ func TestAccountStorageStore(t *testing.T) {
}
func TestDebitCreditZeroSecond(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1s"}
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1s"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -187,7 +187,7 @@ func TestDebitCreditZeroSecond(t *testing.T) {
}
func TestDebitCreditZeroMinute(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1m"}
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1m"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -220,8 +220,8 @@ func TestDebitCreditZeroMinute(t *testing.T) {
}
}
func TestDebitCreditZeroMixedMinute(t *testing.T) {
b1 := &Balance{Uuid: "testm", Value: 70, Weight: 5, DestinationId: "NAT", RateSubject: "*zero1m"}
b2 := &Balance{Uuid: "tests", Value: 10, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1s"}
b1 := &Balance{Uuid: "testm", Value: 70, Weight: 5, DestinationId: "NAT", RatingSubject: "*zero1m"}
b2 := &Balance{Uuid: "tests", Value: 10, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1s"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -255,7 +255,7 @@ func TestDebitCreditZeroMixedMinute(t *testing.T) {
}
func TestDebitCreditNoCredit(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1m"}
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1m"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -295,7 +295,7 @@ func TestDebitCreditNoCredit(t *testing.T) {
}
func TestDebitCreditHasCredit(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1m"}
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1m"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -337,7 +337,7 @@ func TestDebitCreditHasCredit(t *testing.T) {
}
func TestDebitCreditSplitMinutesMoney(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1s"}
b1 := &Balance{Uuid: "testb", Value: 10, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1s"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -374,7 +374,7 @@ func TestDebitCreditSplitMinutesMoney(t *testing.T) {
}
func TestDebitCreditMoreTimespans(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 150, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1m"}
b1 := &Balance{Uuid: "testb", Value: 150, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1m"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -411,8 +411,8 @@ func TestDebitCreditMoreTimespans(t *testing.T) {
}
func TestDebitCreditMoreTimespansMixed(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1m"}
b2 := &Balance{Uuid: "testa", Value: 150, Weight: 5, DestinationId: "NAT", RateSubject: "*zero1s"}
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1m"}
b2 := &Balance{Uuid: "testa", Value: 150, Weight: 5, DestinationId: "NAT", RatingSubject: "*zero1s"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -450,7 +450,7 @@ func TestDebitCreditMoreTimespansMixed(t *testing.T) {
}
func TestDebitCreditNoConectFeeCredit(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RateSubject: "*zero1m"}
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RatingSubject: "*zero1m"}
cc := &CallCost{
Direction: OUTBOUND,
Destination: "0723045326",
@@ -527,7 +527,7 @@ func TestDebitCreditMoneyOnly(t *testing.T) {
}
func TestDebitCreditSubjectMinutes(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 250, Weight: 10, DestinationId: "NAT", RateSubject: "minu"}
b1 := &Balance{Uuid: "testb", Value: 250, Weight: 10, DestinationId: "NAT", RatingSubject: "minu"}
cc := &CallCost{
Tenant: "vdf",
TOR: "0",
@@ -586,7 +586,7 @@ func TestDebitCreditSubjectMoney(t *testing.T) {
deductConnectFee: true,
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 75, DestinationId: "NAT", RateSubject: "minu"}},
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 75, DestinationId: "NAT", RatingSubject: "minu"}},
}}
err := rifsBalance.debitCreditBalance(cc, false)
if err != nil {
@@ -606,7 +606,7 @@ func TestDebitCreditSubjectMoney(t *testing.T) {
}
func TestDebitCreditSubjectMixed(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 40, Weight: 10, DestinationId: "NAT", RateSubject: "minu"}
b1 := &Balance{Uuid: "testb", Value: 40, Weight: 10, DestinationId: "NAT", RatingSubject: "minu"}
cc := &CallCost{
Tenant: "vdf",
TOR: "0",
@@ -624,7 +624,7 @@ func TestDebitCreditSubjectMixed(t *testing.T) {
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 150, RateSubject: "minu"}},
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 150, RatingSubject: "minu"}},
}}
err := rifsBalance.debitCreditBalance(cc, false)
if err != nil {
@@ -649,7 +649,7 @@ func TestDebitCreditSubjectMixed(t *testing.T) {
}
func TestDebitCreditSubjectMixedMoreTS(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RateSubject: "minu"}
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RatingSubject: "minu"}
cc := &CallCost{
Tenant: "vdf",
TOR: "0",
@@ -673,7 +673,7 @@ func TestDebitCreditSubjectMixedMoreTS(t *testing.T) {
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 50, RateSubject: "minu"}},
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 50, RatingSubject: "minu"}},
}}
err := rifsBalance.debitCreditBalance(cc, false)
if err == nil {
@@ -700,7 +700,7 @@ func TestDebitCreditSubjectMixedMoreTS(t *testing.T) {
}
func TestDebitCreditSubjectMixedPartPay(t *testing.T) {
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RateSubject: "minu"}
b1 := &Balance{Uuid: "testb", Value: 70, Weight: 10, DestinationId: "NAT", RatingSubject: "minu"}
cc := &CallCost{
Tenant: "vdf",
TOR: "0",
@@ -724,7 +724,7 @@ func TestDebitCreditSubjectMixedPartPay(t *testing.T) {
}
rifsBalance := &Account{Id: "other", BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{b1},
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 75, RateSubject: "minu"}},
CREDIT + OUTBOUND: BalanceChain{&Balance{Uuid: "moneya", Value: 75, RatingSubject: "minu"}},
}}
err := rifsBalance.debitCreditBalance(cc, false)
if err == nil {

View File

@@ -48,22 +48,22 @@ type Action struct {
}
const (
LOG = "*log"
RESET_TRIGGERS = "*reset_triggers"
ALLOW_NEGATIVE = "*allow_negative"
DENY_NEGATIVE = "*deny_negative"
RESET_ACCOUNT = "*reset_account"
TOPUP_RESET = "*topup_reset"
TOPUP = "*topup"
DEBIT = "*debit"
RESET_COUNTER = "*reset_counter"
RESET_COUNTERS = "*reset_counters"
ENABLE_ACCOUNT = "*enable_account"
DISABLE_ACCOUNT = "*disable_account"
CALL_URL = "*call_url"
CALL_URL_ASYNC = "*call_url_async"
MAIL_ASYNC = "*mail_async"
UNLIMITED = "*unlimited"
LOG = "*log"
RESET_TRIGGERS = "*reset_triggers"
ALLOW_NEGATIVE = "*allow_negative"
DENY_NEGATIVE = "*deny_negative"
RESET_ACCOUNT = "*reset_account"
TOPUP_RESET = "*topup_reset"
TOPUP = "*topup"
DEBIT = "*debit"
RESET_COUNTER = "*reset_counter"
RESET_COUNTERS = "*reset_counters"
ENABLE_ACCOUNT = "*enable_account"
DISABLE_ACCOUNT = "*disable_account"
CALL_URL = "*call_url"
CALL_URL_ASYNC = "*call_url_async"
MAIL_ASYNC = "*mail_async"
UNLIMITED = "*unlimited"
)
type actionTypeFunc func(*Account, *Action) error

View File

@@ -21,8 +21,8 @@ package engine
import (
"encoding/json"
"fmt"
"sort"
"github.com/cgrates/cgrates/utils"
"sort"
)
type ActionTrigger struct {

View File

@@ -33,7 +33,7 @@ type Balance struct {
ExpirationDate time.Time
Weight float64
DestinationId string
RateSubject string
RatingSubject string
SharedGroup string
precision int
account *Account // used to store ub reference for shared balances
@@ -50,14 +50,14 @@ func (b *Balance) Equal(o *Balance) bool {
return b.ExpirationDate.Equal(o.ExpirationDate) &&
b.Weight == o.Weight &&
b.DestinationId == o.DestinationId &&
b.RateSubject == o.RateSubject &&
b.RatingSubject == o.RatingSubject &&
b.SharedGroup == o.SharedGroup
}
// the default balance has no destinationid, Expirationdate or ratesubject
func (b *Balance) IsDefault() bool {
return (b.DestinationId == "" || b.DestinationId == utils.ANY) &&
b.RateSubject == "" &&
b.RatingSubject == "" &&
b.ExpirationDate.IsZero() &&
b.SharedGroup == ""
}
@@ -81,7 +81,7 @@ func (b *Balance) Clone() *Balance {
DestinationId: b.DestinationId,
ExpirationDate: b.ExpirationDate,
Weight: b.Weight,
RateSubject: b.RateSubject,
RatingSubject: b.RatingSubject,
}
}
@@ -125,8 +125,8 @@ func (b *Balance) GetMinutesForCredit(origCD *CallDescriptor, initialCredit floa
}
func (b *Balance) GetCost(cd *CallDescriptor) (*CallCost, error) {
if b.RateSubject != "" {
cd.Subject = b.RateSubject
if b.RatingSubject != "" {
cd.Subject = b.RatingSubject
cd.Account = cd.Subject
cd.RatingInfos = nil
return cd.GetCost()
@@ -162,7 +162,7 @@ func (b *Balance) DebitMinutes(cc *CallCost, count bool, ub *Account, moneyBalan
if increment.paid {
continue
}
if duration, err := utils.ParseZeroRatingSubject(b.RateSubject); err == nil {
if duration, err := utils.ParseZeroRatingSubject(b.RatingSubject); err == nil {
seconds := duration.Seconds()
amount := seconds
if seconds == 1 {
@@ -215,7 +215,7 @@ func (b *Balance) DebitMinutes(cc *CallCost, count bool, ub *Account, moneyBalan
}
// get the new rate
cd := cc.CreateCallDescriptor()
cd.Subject = b.RateSubject
cd.Subject = b.RatingSubject
cd.TimeStart = ts.GetTimeStartForIncrement(incrementIndex)
cd.TimeEnd = cc.Timespans[len(cc.Timespans)-1].TimeEnd
cd.CallDuration = cc.Timespans[len(cc.Timespans)-1].CallDuration
@@ -310,7 +310,7 @@ func (b *Balance) DebitMoney(cc *CallCost, count bool, ub *Account) error {
continue
}
// check standard subject tags
if b.RateSubject == "" {
if b.RatingSubject == "" {
amount := increment.Cost
if b.Value >= amount {
b.SubstractAmount(amount)
@@ -324,7 +324,7 @@ func (b *Balance) DebitMoney(cc *CallCost, count bool, ub *Account) error {
} else {
// get the new rate
cd := cc.CreateCallDescriptor()
cd.Subject = b.RateSubject
cd.Subject = b.RatingSubject
cd.TimeStart = ts.GetTimeStartForIncrement(incrementIndex)
cd.TimeEnd = cc.Timespans[len(cc.Timespans)-1].TimeEnd
cd.CallDuration = cc.Timespans[len(cc.Timespans)-1].CallDuration

View File

@@ -79,16 +79,16 @@ func TestBalanceSortWeightLess(t *testing.T) {
}
func TestBalanceEqual(t *testing.T) {
mb1 := &Balance{Weight: 1, precision: 1, RateSubject: "1", DestinationId: ""}
mb2 := &Balance{Weight: 1, precision: 1, RateSubject: "1", DestinationId: ""}
mb3 := &Balance{Weight: 1, precision: 1, RateSubject: "2", DestinationId: ""}
mb1 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationId: ""}
mb2 := &Balance{Weight: 1, precision: 1, RatingSubject: "1", DestinationId: ""}
mb3 := &Balance{Weight: 1, precision: 1, RatingSubject: "2", DestinationId: ""}
if !mb1.Equal(mb2) || mb2.Equal(mb3) {
t.Error("Equal failure!", mb1 == mb2, mb3)
}
}
func TestBalanceClone(t *testing.T) {
mb1 := &Balance{Value: 1, Weight: 2, RateSubject: "test", DestinationId: "5"}
mb1 := &Balance{Value: 1, Weight: 2, RatingSubject: "test", DestinationId: "5"}
mb2 := mb1.Clone()
if mb1 == mb2 || !reflect.DeepEqual(mb1, mb2) {
t.Errorf("Cloning failure: \n%v\n%v", mb1, mb2)

View File

@@ -58,7 +58,7 @@ func populateDB() {
Id: "*out:vdf:broker",
BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{
&Balance{Value: 20, DestinationId: "NAT", Weight: 10, RateSubject: "rif"},
&Balance{Value: 20, DestinationId: "NAT", Weight: 10, RatingSubject: "rif"},
&Balance{Value: 100, DestinationId: "RET", Weight: 20},
}},
}
@@ -67,7 +67,7 @@ func populateDB() {
Id: "*out:vdf:minitsboy",
BalanceMap: map[string]BalanceChain{
MINUTES + OUTBOUND: BalanceChain{
&Balance{Value: 20, DestinationId: "NAT", Weight: 10, RateSubject: "rif"},
&Balance{Value: 20, DestinationId: "NAT", Weight: 10, RatingSubject: "rif"},
&Balance{Value: 100, DestinationId: "RET", Weight: 20},
},
CREDIT + OUTBOUND: BalanceChain{

View File

@@ -516,16 +516,16 @@ func (csvr *CSVReader) LoadSharedGroups() (err error) {
sg, found := csvr.sharedGroups[tag]
if found {
sg.AccountParameters[record[1]] = &SharingParameters{
Strategy: record[2],
RateSubject: record[3],
Strategy: record[2],
RatingSubject: record[3],
}
} else {
sg = &SharedGroup{
Id: tag,
AccountParameters: map[string]*SharingParameters{
record[1]: &SharingParameters{
Strategy: record[2],
RateSubject: record[3],
Strategy: record[2],
RatingSubject: record[3],
},
},
}
@@ -582,7 +582,7 @@ func (csvr *CSVReader) LoadActions() (err error) {
Value: units,
Weight: balanceWeight,
DestinationId: record[6],
RateSubject: record[7],
RatingSubject: record[7],
SharedGroup: record[9],
},
}

View File

@@ -633,7 +633,7 @@ func TestLoadActions(t *testing.T) {
Uuid: as1[1].Balance.Uuid,
Value: 100,
Weight: 10,
RateSubject: "test",
RatingSubject: "test",
DestinationId: "NAT",
},
},
@@ -673,8 +673,8 @@ func TestLoadSharedGroups(t *testing.T) {
Id: "SG1",
AccountParameters: map[string]*SharingParameters{
"*any": &SharingParameters{
Strategy: "*lowest",
RateSubject: "",
Strategy: "*lowest",
RatingSubject: "",
},
},
}
@@ -686,8 +686,8 @@ func TestLoadSharedGroups(t *testing.T) {
Id: "SG2",
AccountParameters: map[string]*SharingParameters{
"*any": &SharingParameters{
Strategy: "*lowest",
RateSubject: "one",
Strategy: "*lowest",
RatingSubject: "one",
},
},
}

View File

@@ -461,7 +461,7 @@ func (dbr *DbReader) LoadActions() (err error) {
Uuid: utils.GenUUID(),
Value: tpact.Units,
Weight: tpact.BalanceWeight,
RateSubject: tpact.RatingSubject,
RatingSubject: tpact.RatingSubject,
DestinationId: tpact.DestinationId,
},
}
@@ -700,7 +700,7 @@ func (dbr *DbReader) LoadAccountActionsFiltered(qriedAA *utils.TPAccountActions)
Uuid: utils.GenUUID(),
Value: tpact.Units,
Weight: tpact.BalanceWeight,
RateSubject: tpact.RatingSubject,
RatingSubject: tpact.RatingSubject,
DestinationId: tpact.DestinationId,
},
}

View File

@@ -45,8 +45,8 @@ type SharedGroup struct {
}
type SharingParameters struct {
Strategy string
RateSubject string
Strategy string
RatingSubject string
}
func (sg *SharedGroup) GetMembersExceptUser(ubId string) []string {

View File

@@ -294,7 +294,7 @@ func (self *SQLStorage) SetTPSharedGroups(tpid string, sgs map[string]*SharedGro
buffer.WriteRune(',')
}
buffer.WriteString(fmt.Sprintf("('%s','%s','%s','%s','%s')",
tpid, sgId, account, params.Strategy, params.RateSubject))
tpid, sgId, account, params.Strategy, params.RatingSubject))
i++
}
}
@@ -1055,16 +1055,16 @@ func (self *SQLStorage) GetTpSharedGroups(tpid, tag string) (map[string]*SharedG
sg, found := sgs[tag]
if found {
sg.AccountParameters[account] = &SharingParameters{
Strategy: strategy,
RateSubject: rateSubject,
Strategy: strategy,
RatingSubject: rateSubject,
}
} else {
sg = &SharedGroup{
Id: tag,
AccountParameters: map[string]*SharingParameters{
account: &SharingParameters{
Strategy: strategy,
RateSubject: rateSubject,
Strategy: strategy,
RatingSubject: rateSubject,
},
},
}