mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 02:26:26 +05:00
sending amount in get max session time
This commit is contained in:
@@ -55,6 +55,7 @@ func (rsd *SessionDelegate) OnChannelPark(ev Event, sm SessionManager) {
|
||||
Subject: ev.GetSubject(),
|
||||
Account: ev.GetAccount(),
|
||||
Destination: ev.GetDestination(),
|
||||
Amount: rsd.DebitPeriod.Seconds(),
|
||||
TimeStart: startTime}
|
||||
var remainingSeconds float64
|
||||
err = rsd.Connector.GetMaxSessionTime(cd, &remainingSeconds)
|
||||
|
||||
@@ -292,11 +292,13 @@ func (cd *CallDescriptor) GetMaxSessionTime() (seconds float64, err error) {
|
||||
_, err = cd.LoadActivationPeriods()
|
||||
now := time.Now()
|
||||
availableCredit, availableSeconds := 0.0, 0.0
|
||||
Logger.Debug(fmt.Sprintf("cd: %+v", cd))
|
||||
if userBalance, err := cd.getUserBalance(); err == nil && userBalance != nil {
|
||||
if userBalance.Type == UB_TYPE_POSTPAID {
|
||||
return -1, nil
|
||||
} else {
|
||||
availableSeconds, availableCredit, _ = userBalance.getSecondsForPrefix(cd.Destination)
|
||||
Logger.Debug(fmt.Sprintf("available sec: %v credit: %v", availableSeconds, availableCredit))
|
||||
}
|
||||
} else {
|
||||
return cd.Amount, err
|
||||
@@ -305,7 +307,6 @@ func (cd *CallDescriptor) GetMaxSessionTime() (seconds float64, err error) {
|
||||
if availableCredit == 0 {
|
||||
return availableSeconds, nil
|
||||
}
|
||||
|
||||
// the price of a seccond cannot be determined because all the seconds can have a different cost.
|
||||
// therfore we get the cost for the whole period and then if there are not enough money we backout in steps of 10%.
|
||||
maxSessionSeconds := cd.Amount
|
||||
|
||||
Reference in New Issue
Block a user