mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Adding prepaid1centpsec rate sample files
This commit is contained in:
6
data/rates/prepaid1centpsec/AccountActions.csv
Normal file
6
data/rates/prepaid1centpsec/AccountActions.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
Tenant,Account,Direction,ActionTimingsTag,ActionTriggersTag
|
||||
0,1000,OUT,TOPUP_10,
|
||||
0,1001,OUT,TOPUP_10,
|
||||
0,1002,OUT,TOPUP_10,
|
||||
0,1003,OUT,TOPUP_10,
|
||||
0,1004,OUT,TOPUP_10,
|
||||
|
2
data/rates/prepaid1centpsec/ActionTimings.csv
Normal file
2
data/rates/prepaid1centpsec/ActionTimings.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
Tag,ActionsTag,TimingTag, Weight
|
||||
TOPUP_10,TOPUP_10,ONE_TIME_RUN,10
|
||||
|
1
data/rates/prepaid1centpsec/ActionTriggers.csv
Normal file
1
data/rates/prepaid1centpsec/ActionTriggers.csv
Normal file
@@ -0,0 +1 @@
|
||||
Tag,BalanceTag,Direction,ThresholdValue,DestinationTag,ActionsTag,Weight
|
||||
|
2
data/rates/prepaid1centpsec/Actions.csv
Normal file
2
data/rates/prepaid1centpsec/Actions.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
Tag,Action,BalanceTag,Direction,Units,DestinationTag,PriceType,PriceValue,MinutesWeight,Weight
|
||||
TOPUP_10,TOPUP_RESET,MONETARY,OUT,10,*all,,,,10
|
||||
|
2
data/rates/prepaid1centpsec/Destinations.csv
Normal file
2
data/rates/prepaid1centpsec/Destinations.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
Tag,Prefix
|
||||
FS_USERS,10
|
||||
|
10
data/rates/prepaid1centpsec/README.md
Normal file
10
data/rates/prepaid1centpsec/README.md
Normal file
@@ -0,0 +1,10 @@
|
||||
CGRateS - Prepaid1CentPSec
|
||||
===========================
|
||||
|
||||
Scenario:
|
||||
--------
|
||||
|
||||
* Creates 5 prepaid accounts
|
||||
* Loads prepaid accounts each with 10 units of credit
|
||||
* Defines rates of 1 cent per second for TOR 0, Tenant 0, independent of time of the call.
|
||||
|
||||
2
data/rates/prepaid1centpsec/RateTimings.csv
Normal file
2
data/rates/prepaid1centpsec/RateTimings.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
Tag,RatesTag,TimingProfile,Weight
|
||||
1CENTPERSEC,1CENTPERSEC,ALWAYS,10
|
||||
|
2
data/rates/prepaid1centpsec/Rates.csv
Normal file
2
data/rates/prepaid1centpsec/Rates.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
Tag,DestinationsTag,ConnectFee,Price,PricedUnits,RateIncrements
|
||||
1CENTPERSEC,FS_USERS,0,0.01,1,1
|
||||
|
2
data/rates/prepaid1centpsec/RatingProfiles.csv
Normal file
2
data/rates/prepaid1centpsec/RatingProfiles.csv
Normal file
@@ -0,0 +1,2 @@
|
||||
Tenant,TOR,Direction,Subject,RatesFallbackSubject,RatesTimingTag,ActivationTime
|
||||
0,0,OUT,*all,,1CENTPERSEC,2013-01-01T00:00:00Z
|
||||
|
3
data/rates/prepaid1centpsec/Timings.csv
Normal file
3
data/rates/prepaid1centpsec/Timings.csv
Normal file
@@ -0,0 +1,3 @@
|
||||
Tag,Years,Months,MonthDays,WeekDays,Time
|
||||
ALWAYS,*all,*all,*all,*all,00:00:00
|
||||
ONE_TIME_RUN,,,,,*asap
|
||||
|
@@ -19,12 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package rater
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
"time"
|
||||
"log"
|
||||
)
|
||||
|
||||
func ATestAccountLock(t *testing.T) {
|
||||
func ATestAccountLock(t *testing.T) {
|
||||
go AccLock.Guard("1", func() (float64, error) {
|
||||
log.Print("first 1")
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
@@ -40,30 +40,30 @@ type Action struct {
|
||||
|
||||
type actionTypeFunc func(*UserBalance, *Action) error
|
||||
|
||||
func getActionFunc(typ string)(actionTypeFunc, bool) {
|
||||
func getActionFunc(typ string) (actionTypeFunc, bool) {
|
||||
switch typ {
|
||||
case "LOG":
|
||||
return logAction, true
|
||||
case "RESET_TRIGGERS":
|
||||
return resetTriggersAction, true
|
||||
case "SET_POSTPAID":
|
||||
return setPostpaidAction, true
|
||||
case "RESET_POSTPAID":
|
||||
return resetPostpaidAction, true
|
||||
case "SET_PREPAID":
|
||||
return setPrepaidAction, true
|
||||
case "RESET_PREPAID":
|
||||
return resetPrepaidAction, true
|
||||
case "TOPUP_RESET":
|
||||
return topupResetAction, true
|
||||
case "TOPUP":
|
||||
return topupAction, true
|
||||
case "DEBIT":
|
||||
return debitAction, true
|
||||
case "RESET_COUNTER":
|
||||
return resetCounterAction, true
|
||||
case "RESET_COUNTERS":
|
||||
return resetCountersAction, true
|
||||
case "LOG":
|
||||
return logAction, true
|
||||
case "RESET_TRIGGERS":
|
||||
return resetTriggersAction, true
|
||||
case "SET_POSTPAID":
|
||||
return setPostpaidAction, true
|
||||
case "RESET_POSTPAID":
|
||||
return resetPostpaidAction, true
|
||||
case "SET_PREPAID":
|
||||
return setPrepaidAction, true
|
||||
case "RESET_PREPAID":
|
||||
return resetPrepaidAction, true
|
||||
case "TOPUP_RESET":
|
||||
return topupResetAction, true
|
||||
case "TOPUP":
|
||||
return topupAction, true
|
||||
case "DEBIT":
|
||||
return debitAction, true
|
||||
case "RESET_COUNTER":
|
||||
return resetCounterAction, true
|
||||
case "RESET_COUNTERS":
|
||||
return resetCountersAction, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
@@ -79,7 +79,7 @@ func resetTriggersAction(ub *UserBalance, a *Action) (err error) {
|
||||
}
|
||||
|
||||
func setPostpaidAction(ub *UserBalance, a *Action) (err error) {
|
||||
ub.Type = UB_TYPE_POSTPAID
|
||||
ub.Type = UB_TYPE_POSTPAID
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ func (at *ActionTiming) restore(input string) {
|
||||
at.Id = elements[0]
|
||||
at.Tag = elements[1]
|
||||
for _, ubi := range strings.Split(elements[2], ",") {
|
||||
if strings.TrimSpace(ubi) != ""{
|
||||
if strings.TrimSpace(ubi) != "" {
|
||||
at.UserBalanceIds = append(at.UserBalanceIds, ubi)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,10 +350,10 @@ func (cd *CallDescriptor) Debit() (cc *CallCost, err error) {
|
||||
Logger.Err(fmt.Sprintf("<Rater> Error getting cost for account key %v: %v", cd.GetUserBalanceKey(), err))
|
||||
return
|
||||
}
|
||||
if userBalance, err := cd.getUserBalance(); err == nil && userBalance != nil {
|
||||
if userBalance, err := cd.getUserBalance(); err != nil {
|
||||
Logger.Err(fmt.Sprintf("<Rater> Error retrieving user balance: %v", err))
|
||||
} else if userBalance == nil {
|
||||
Logger.Debug(fmt.Sprintf("<Rater> No user balance defined: %v",cd.GetUserBalanceKey()))
|
||||
Logger.Debug(fmt.Sprintf("<Rater> No user balance defined: %v", cd.GetUserBalanceKey()))
|
||||
} else {
|
||||
Logger.Debug(fmt.Sprintf("<Rater> Attempting to debit from %v, value: %v", cd.GetUserBalanceKey(), cc.Cost+cc.ConnectFee))
|
||||
defer storageGetter.SetUserBalance(userBalance)
|
||||
|
||||
@@ -207,14 +207,14 @@ func (sm *FSSessionManager) OnChannelHangupComplete(ev Event) {
|
||||
return
|
||||
}
|
||||
cd := rater.CallDescriptor{
|
||||
Direction: ev.GetDirection(),
|
||||
Tenant: ev.GetTenant(),
|
||||
TOR: ev.GetTOR(),
|
||||
Subject: ev.GetSubject(),
|
||||
Account: ev.GetAccount(),
|
||||
Destination: ev.GetDestination(),
|
||||
TimeStart: startTime,
|
||||
TimeEnd: endTime,
|
||||
Direction: ev.GetDirection(),
|
||||
Tenant: ev.GetTenant(),
|
||||
TOR: ev.GetTOR(),
|
||||
Subject: ev.GetSubject(),
|
||||
Account: ev.GetAccount(),
|
||||
Destination: ev.GetDestination(),
|
||||
TimeStart: startTime,
|
||||
TimeEnd: endTime,
|
||||
FallbackSubject: ev.GetFallbackSubj(),
|
||||
}
|
||||
cc := &rater.CallCost{}
|
||||
@@ -342,8 +342,8 @@ func (sm *FSSessionManager) Shutdown() (err error) {
|
||||
rater.Logger.Info("Shutting down all sessions...")
|
||||
cmdKillPrepaid := "hupall MANAGER_REQUEST cgr_reqtype prepaid"
|
||||
cmdKillPostpaid := "hupall MANAGER_REQUEST cgr_reqtype postpaid"
|
||||
for _,cmd := range[]string{cmdKillPrepaid, cmdKillPostpaid} {
|
||||
if err = fsock.FS.SendApiCmd(cmd); err!= nil {
|
||||
for _, cmd := range []string{cmdKillPrepaid, cmdKillPostpaid} {
|
||||
if err = fsock.FS.SendApiCmd(cmd); err != nil {
|
||||
rater.Logger.Err(fmt.Sprintf("Error on calls shutdown: %s", err))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ func NewSession(ev Event, sm SessionManager) (s *Session) {
|
||||
return
|
||||
}
|
||||
// Make sure cgr_type is enforced even if not set by FreeSWITCH
|
||||
if err := fsock.FS.SendApiCmd(fmt.Sprintf("uuid_setvar %s cgr_reqtype %s\n\n", ev.GetUUID(), ev.GetReqType())); err!=nil {
|
||||
if err := fsock.FS.SendApiCmd(fmt.Sprintf("uuid_setvar %s cgr_reqtype %s\n\n", ev.GetUUID(), ev.GetReqType())); err != nil {
|
||||
rater.Logger.Err(fmt.Sprintf("Error on attempting to overwrite cgr_type in chan variables: %v", err))
|
||||
}
|
||||
startTime, err := ev.GetStartTime(START_TIME)
|
||||
|
||||
@@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package sessionmanager
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/cgrates/cgrates/config"
|
||||
"testing"
|
||||
// "time"
|
||||
)
|
||||
|
||||
@@ -67,9 +67,9 @@ var (
|
||||
func TestSessionNilSession(t *testing.T) {
|
||||
cfgTestPath := "../config/test_data.txt"
|
||||
var errCfg error
|
||||
cfg,errCfg = config.NewCGRConfig(&cfgTestPath) // Needed here to avoid nil on cfg variable
|
||||
if errCfg!= nil {
|
||||
t.Errorf("Cannot get configuration %v",errCfg)
|
||||
cfg, errCfg = config.NewCGRConfig(&cfgTestPath) // Needed here to avoid nil on cfg variable
|
||||
if errCfg != nil {
|
||||
t.Errorf("Cannot get configuration %v", errCfg)
|
||||
}
|
||||
newEvent := new(FSEvent).New("")
|
||||
sm := &FSSessionManager{}
|
||||
|
||||
Reference in New Issue
Block a user