mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-24 16:48:45 +05:00
working on duration expire time
This commit is contained in:
@@ -28,14 +28,15 @@ import (
|
||||
Structure to be filled for each tariff plan with the bonus value for received calls minutes.
|
||||
*/
|
||||
type Action struct {
|
||||
Id string
|
||||
ActionType string
|
||||
BalanceId string
|
||||
Direction string
|
||||
ExpirationDate time.Time
|
||||
Units float64
|
||||
Weight float64
|
||||
MinuteBucket *MinuteBucket
|
||||
Id string
|
||||
ActionType string
|
||||
BalanceId string
|
||||
Direction string
|
||||
ExpirationString string
|
||||
ExpirationDate time.Time
|
||||
Units float64
|
||||
Weight float64
|
||||
MinuteBucket *MinuteBucket
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -379,19 +379,17 @@ func (csvr *CSVReader) LoadActions() (err error) {
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Could not parse action units: %v", err))
|
||||
}
|
||||
unix, err := strconv.ParseInt(record[5], 10, 64)
|
||||
if err != nil {
|
||||
return errors.New(fmt.Sprintf("Could not parse expiration date: %v", err))
|
||||
}
|
||||
expDate := time.Unix(unix, 0)
|
||||
var a *Action
|
||||
if record[2] != MINUTES {
|
||||
a = &Action{
|
||||
ActionType: record[1],
|
||||
BalanceId: record[2],
|
||||
Direction: record[3],
|
||||
Units: units,
|
||||
ExpirationDate: expDate,
|
||||
ActionType: record[1],
|
||||
BalanceId: record[2],
|
||||
Direction: record[3],
|
||||
Units: units,
|
||||
ExpirationString: record[5],
|
||||
}
|
||||
if _, err := utils.ParseDate(a.ExpirationString); err != nil {
|
||||
return errors.New(fmt.Sprintf("Could not parse expiration time: %v", err))
|
||||
}
|
||||
} else {
|
||||
value, err := strconv.ParseFloat(record[8], 64)
|
||||
@@ -407,21 +405,25 @@ func (csvr *CSVReader) LoadActions() (err error) {
|
||||
return errors.New(fmt.Sprintf("Could not parse action weight: %v", err))
|
||||
}
|
||||
a = &Action{
|
||||
Id: utils.GenUUID(),
|
||||
ActionType: record[1],
|
||||
BalanceId: record[2],
|
||||
Direction: record[3],
|
||||
Weight: weight,
|
||||
ExpirationDate: expDate,
|
||||
Id: utils.GenUUID(),
|
||||
ActionType: record[1],
|
||||
BalanceId: record[2],
|
||||
Direction: record[3],
|
||||
Weight: weight,
|
||||
ExpirationString: record[5],
|
||||
MinuteBucket: &MinuteBucket{
|
||||
Seconds: units,
|
||||
Weight: minutesWeight,
|
||||
Price: value,
|
||||
PriceType: record[7],
|
||||
DestinationId: record[6],
|
||||
ExpirationDate: expDate,
|
||||
Seconds: units,
|
||||
Weight: minutesWeight,
|
||||
Price: value,
|
||||
PriceType: record[7],
|
||||
DestinationId: record[6],
|
||||
ExpirationString: record[5],
|
||||
},
|
||||
}
|
||||
if _, err := utils.ParseDate(a.ExpirationString); err != nil {
|
||||
return errors.New(fmt.Sprintf("Could not parse expiration time: %v", err))
|
||||
}
|
||||
|
||||
}
|
||||
csvr.actions[tag] = append(csvr.actions[tag], a)
|
||||
}
|
||||
|
||||
@@ -25,13 +25,14 @@ import (
|
||||
)
|
||||
|
||||
type MinuteBucket struct {
|
||||
Seconds float64
|
||||
Weight float64
|
||||
Price float64 // percentage from standard price or absolute value depending on Type
|
||||
PriceType string
|
||||
DestinationId string
|
||||
ExpirationDate time.Time
|
||||
precision int
|
||||
Seconds float64
|
||||
Weight float64
|
||||
Price float64 // percentage from standard price or absolute value depending on Type
|
||||
PriceType string
|
||||
DestinationId string
|
||||
ExpirationString string
|
||||
ExpirationDate time.Time
|
||||
precision int
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -23,8 +23,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type SQLStorage struct {
|
||||
@@ -552,8 +550,7 @@ func (self *SQLStorage) GetTPActions(tpid, actsId string) (*utils.TPActions, err
|
||||
i := 0
|
||||
for rows.Next() {
|
||||
i++ //Keep here a reference so we know we got at least one result
|
||||
var action, balanceId, dir, destId, rateType string
|
||||
var expTime int64
|
||||
var action, balanceId, dir, destId, rateType, expTime string
|
||||
var units, rate, minutesWeight, weight float64
|
||||
if err = rows.Scan(&action, &balanceId, &dir, &units, &expTime, &destId, &rateType, &rate, &minutesWeight, &weight); err != nil {
|
||||
return nil, err
|
||||
@@ -1081,36 +1078,31 @@ func (self *SQLStorage) GetTpActions(tpid, tag string) (map[string][]*Action, er
|
||||
if err := rows.Scan(&id, &tpid, &tag, &action, &balance_tag, &direction, &units, &expirationDate, &destinations_tag, &rate_type, &rate, &minutes_weight, &weight); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
unix, err := strconv.ParseInt(expirationDate, 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
expDate := time.Unix(unix, 0)
|
||||
var a *Action
|
||||
if balance_tag != MINUTES {
|
||||
a = &Action{
|
||||
ActionType: action,
|
||||
BalanceId: balance_tag,
|
||||
Direction: direction,
|
||||
Units: units,
|
||||
ExpirationDate: expDate,
|
||||
ActionType: action,
|
||||
BalanceId: balance_tag,
|
||||
Direction: direction,
|
||||
Units: units,
|
||||
ExpirationString: expirationDate,
|
||||
}
|
||||
} else {
|
||||
var price float64
|
||||
a = &Action{
|
||||
Id: utils.GenUUID(),
|
||||
ActionType: action,
|
||||
BalanceId: balance_tag,
|
||||
Direction: direction,
|
||||
Weight: weight,
|
||||
ExpirationDate: expDate,
|
||||
Id: utils.GenUUID(),
|
||||
ActionType: action,
|
||||
BalanceId: balance_tag,
|
||||
Direction: direction,
|
||||
Weight: weight,
|
||||
ExpirationString: expirationDate,
|
||||
MinuteBucket: &MinuteBucket{
|
||||
Seconds: units,
|
||||
Weight: minutes_weight,
|
||||
Price: price,
|
||||
PriceType: rate_type,
|
||||
DestinationId: destinations_tag,
|
||||
ExpirationDate: expDate,
|
||||
Seconds: units,
|
||||
Weight: minutes_weight,
|
||||
Price: price,
|
||||
PriceType: rate_type,
|
||||
DestinationId: destinations_tag,
|
||||
ExpirationString: expirationDate,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user