mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Fixing default import files, SQL correction in tp_actions tables
This commit is contained in:
@@ -121,12 +121,12 @@ CREATE TABLE `tp_actions` (
|
||||
`expiry_time` varchar(24) NOT NULL,
|
||||
`destination_tag` varchar(64) NOT NULL,
|
||||
`rate_subject` varchar(64) NOT NULL,
|
||||
`minutes_weight` DECIMAL(5,2) NOT NULL,
|
||||
`balance_weight` DECIMAL(5,2) NOT NULL,
|
||||
`extra_parameters` varchar(256) NOT NULL,
|
||||
`weight` DECIMAL(5,2) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tpid` (`tpid`),
|
||||
UNIQUE KEY `unique_action` (`tpid`,`tag`,`action`,`balance_type`,`direction`,`expiry_time`,`destination_tag`,`rate_type`,`minutes_weight`,`weight`)
|
||||
UNIQUE KEY `unique_action` (`tpid`,`tag`,`action`,`balance_type`,`direction`,`expiry_time`,`destination_tag`,`balance_weight`,`weight`)
|
||||
);
|
||||
|
||||
--
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#ActionsTag,Action,BalanceType,Direction,Units,ExpirationDate,DestinationTag,RateType,RateValue,MinutesWeight,Weight
|
||||
PREPAID_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,,,10
|
||||
#ActionsTag,Action,BalanceType,Direction,Units,ExpiryTime,DestinationTag,RateSubject,BalanceWeight,ExtraParameters,Weight
|
||||
PREPAID_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,10,,10
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#Tenant,Account,Direction,ActionTimingsTag,ActionTriggersTag
|
||||
cgrates.org,1001,*out,AT_FS10,STANDARD_TRIGGERS
|
||||
cgrates.org,1002,*out,AT_FS10,STANDARD_TRIGGERS
|
||||
cgrates.org,1003,*out,AT_FS10,STANDARD_TRIGGERS
|
||||
cgrates.org,1004,*out,AT_FS10,STANDARD_TRIGGERS
|
||||
cgrates.org,1005,*out,AT_FS10,STANDARD_TRIGGERS
|
||||
cgrates.org,1001,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1002,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1003,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1004,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
cgrates.org,1005,*out,PREPAID_10,STANDARD_TRIGGERS
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#Tag,ActionsTag,TimingTag,Weight
|
||||
AT_FS10,TOPUP_10,ASAP,10
|
||||
PREPAID_10,PREPAID_10,ASAP,10
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#ActionsTag,Action,BalanceType,Direction,Units,ExpirationDate,DestinationTag,RateType,RateValue,MinutesWeight,Weight
|
||||
TOPUP_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,,,10
|
||||
#ActionsTag,Action,BalanceType,Direction,Units,ExpiryTime,DestinationTag,RateSubject,BalanceWeight,ExtraParameters,Weight
|
||||
PREPAID_10,*topup_reset,*monetary,*out,10,*unlimited,*any,,10,,10
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#Tag,DestinationRatesTag,TimingTag,Weight
|
||||
DRT_1CENTPERSEC,DR_1CENTPERSEC,ALWAYS,10
|
||||
RETAIL1,DR_FREESWITCH_USERS,ALWAYS,10
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#Tag,DestinationsTag,RatesTag
|
||||
DR_1CENTPERSEC,GERMANY,1CENTPERSEC
|
||||
DR_FREESWITCH_USERS,FS_USERS,RT_FS_USERS
|
||||
|
||||
|
@@ -1,2 +1,6 @@
|
||||
#Tag,Prefix
|
||||
GERMANY,+49
|
||||
GERMANY_MOBILE,+4915
|
||||
GERMANY_MOBILE,+4916
|
||||
GERMANY_MOBILE,+4917
|
||||
FS_USERS,10
|
||||
|
||||
|
@@ -1,20 +1,14 @@
|
||||
CGRateS - Prepaid1CentPSec
|
||||
===========================
|
||||
CGRateS - FSGermanyPrep1
|
||||
==========================
|
||||
|
||||
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.
|
||||
---------
|
||||
|
||||
* Create the necessary timings (always, asap).
|
||||
* Configure FS_USERS destination profile.
|
||||
* Calls to FreeSWITCH users will be charged at 1 cent every second, time independent and middle rounded. Costs will be displayed using 4 decimals.
|
||||
* Configure 1 destination: FS_USERS.
|
||||
* Calls to FreeSWITCH users will be free and time independent.
|
||||
* This rating profile will be valid for any rating subject.
|
||||
|
||||
* Create 5 prepaid accounts (equivalent of 5 FreeSWITCH default test users - 1001, 1002, 1003, 1004, 1005).
|
||||
* Add to each of the accounts a monetary balance of 10 units.
|
||||
* For each balance created, attach 3 triggers to control the balance: log on balance=2, log on balance=20, log on 15 mins talked towards FS_USERS destination.
|
||||
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#Tag,ConnectFee,Rate,RateUnit,RateIncrement,GroupIntervalStart,RoundingMethod,RoundingDecimals,Weight
|
||||
1CENTPERSEC,0,0.01,1s,1s,0s,*middle,4,10
|
||||
RT_FS_USERS,0,0,60s,60s,0s,*up,0,10
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#Tenant,TOR,Direction,Subject,ActivationTime,DestinationRateTimingTag,RatesFallbackSubject
|
||||
cgrates.org,call,*out,*any,2012-01-01T00:00:00Z,DRT_1CENTPERSEC,
|
||||
cgrates.org,call,*out,*any,2012-01-01T00:00:00Z,RETAIL1,
|
||||
|
||||
|
@@ -532,14 +532,14 @@ func (self *SQLStorage) SetTPActions(tpid string, acts map[string][]*Action) err
|
||||
if len(acts) == 0 {
|
||||
return nil //Nothing to set
|
||||
}
|
||||
qry := fmt.Sprintf("INSERT INTO %s (tpid,tag,action,balance_type,direction,units,expiry_time,destination_tag,rate_type,rate, minutes_weight,weight) VALUES ", utils.TBL_TP_ACTIONS)
|
||||
qry := fmt.Sprintf("INSERT INTO %s (tpid,tag,action,balance_type,direction,units,expiry_time,destination_tag,rate_subject,balance_weight,extra_parameters,weight) VALUES ", utils.TBL_TP_ACTIONS)
|
||||
i := 0
|
||||
for actId, actRows := range acts {
|
||||
for _, act := range actRows {
|
||||
if i != 0 { //Consecutive values after the first will be prefixed with "," as separator
|
||||
qry += ","
|
||||
}
|
||||
qry += fmt.Sprintf("('%s','%s','%s','%s','%s',%f,'%s','%s',%f,'%s',%f)",
|
||||
qry += fmt.Sprintf("('%s','%s','%s','%s','%s',%f,'%s','%s','%s',%f,'%s',%f)",
|
||||
tpid, actId, act.ActionType, act.BalanceId, act.Direction, act.Balance.Value, act.ExpirationString,
|
||||
act.Balance.DestinationId, act.Balance.RateSubject, act.Balance.Weight, act.ExtraParameters, act.Weight)
|
||||
i++
|
||||
@@ -552,7 +552,7 @@ func (self *SQLStorage) SetTPActions(tpid string, acts map[string][]*Action) err
|
||||
}
|
||||
|
||||
func (self *SQLStorage) GetTPActions(tpid, actsId string) (*utils.TPActions, error) {
|
||||
rows, err := self.Db.Query(fmt.Sprintf("SELECT action,balance_type,direction,units,expiry_time,destination_tag,rate_type,rate, minutes_weight,weight FROM %s WHERE tpid='%s' AND tag='%s'", utils.TBL_TP_ACTIONS, tpid, actsId))
|
||||
rows, err := self.Db.Query(fmt.Sprintf("SELECT action,balance_type,direction,units,expiry_time,destination_tag,rate_subject,balance_weight,extra_parameters,weight FROM %s WHERE tpid='%s' AND tag='%s'", utils.TBL_TP_ACTIONS, tpid, actsId))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ type Action struct {
|
||||
Units float64 // Number of units to add/deduct
|
||||
ExpiryTime string // Time when the units will expire
|
||||
DestinationId string // Destination profile id
|
||||
RateSubject string // Type of rate <*absolute|*percent>
|
||||
RateSubject string // Reference a rate subject defined in RatingProfiles
|
||||
BalanceWeight float64 // Balance weight
|
||||
ExtraParameters string
|
||||
Weight float64 // Action's weight
|
||||
|
||||
Reference in New Issue
Block a user