mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-14 20:59:53 +05:00
Added constINcr default value
This commit is contained in:
committed by
Dan Christian Bogos
parent
9a0cc738e4
commit
e6b6394c13
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
package accounts
|
||||
|
||||
import (
|
||||
|
||||
"github.com/cgrates/birpc/context"
|
||||
"github.com/cgrates/cgrates/engine"
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -53,7 +54,6 @@ func (aB *abstractBalance) id() string {
|
||||
// debitAbstracts implements the balanceOperator interface
|
||||
func (aB *abstractBalance) debitAbstracts(ctx *context.Context, usage *decimal.Big,
|
||||
cgrEv *utils.CGREvent, dbted *decimal.Big) (ec *utils.EventCharges, err error) {
|
||||
|
||||
evNm := utils.MapStorage{
|
||||
utils.MetaOpts: cgrEv.APIOpts,
|
||||
utils.MetaReq: cgrEv.Event,
|
||||
@@ -94,7 +94,6 @@ func (aB *abstractBalance) debitAbstracts(ctx *context.Context, usage *decimal.B
|
||||
//dbtUnits = utils.MultiplyBig(dbtUnits, uF.Factor.Big)
|
||||
hasUF = true
|
||||
}
|
||||
|
||||
if blncLmt != nil {
|
||||
maxBlcDbt := new(decimal.Big).Copy(aB.blnCfg.Units.Big)
|
||||
if hasUF {
|
||||
@@ -105,7 +104,6 @@ func (aB *abstractBalance) debitAbstracts(ctx *context.Context, usage *decimal.B
|
||||
usage = maxBlcDbt
|
||||
}
|
||||
}
|
||||
|
||||
var ecCost *utils.EventCharges
|
||||
if costIcrm != nil && ((costIcrm.FixedFee != nil &&
|
||||
costIcrm.FixedFee.Cmp(decimal.New(0, 0)) != 0) ||
|
||||
@@ -123,7 +121,6 @@ func (aB *abstractBalance) debitAbstracts(ctx *context.Context, usage *decimal.B
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var dbtUnits *decimal.Big
|
||||
if ecCost != nil {
|
||||
usage = ecCost.Abstracts.Big
|
||||
@@ -173,6 +170,7 @@ func (aB *abstractBalance) debitAbstracts(ctx *context.Context, usage *decimal.B
|
||||
RecurrentFee: costIcrm.RecurrentFee,
|
||||
}
|
||||
} else { // take it from first increment, not copying since it will be done bellow
|
||||
|
||||
ratingID = ecCost.Accounting[ecCost.Charges[0].ChargingID].RatingID
|
||||
}
|
||||
// AccountingID
|
||||
|
||||
@@ -115,7 +115,7 @@ func rateSCostForEvent(ctx *context.Context, connMgr *engine.ConnManager, cgrEv
|
||||
if len(rateSConns) == 0 {
|
||||
return nil, utils.NewErrNotConnected(utils.RateS)
|
||||
}
|
||||
if cgrEv.APIOpts[utils.OptsRatesRateProfileIDs] != nil {
|
||||
if _, has := cgrEv.APIOpts[utils.OptsRatesRateProfileIDs]; !has {
|
||||
cgrEv.APIOpts[utils.OptsRatesRateProfileIDs] = utils.CloneStringSlice(rpIDs)
|
||||
}
|
||||
var tmpReply utils.RateProfileCost
|
||||
@@ -129,6 +129,12 @@ func rateSCostForEvent(ctx *context.Context, connMgr *engine.ConnManager, cgrEv
|
||||
// costIncrement computes the costIncrement for the event
|
||||
func costIncrement(ctx *context.Context, cfgCostIncrmts []*utils.CostIncrement,
|
||||
fltrS *engine.FilterS, tnt string, ev utils.DataProvider) (costIcrm *utils.CostIncrement, err error) {
|
||||
// no cost increment in our balance, return a default increment to query to rateS
|
||||
if len(cfgCostIncrmts) == 0 {
|
||||
return &utils.CostIncrement{
|
||||
Increment: utils.NewDecimal(1, 0),
|
||||
}, nil
|
||||
}
|
||||
for _, cIcrm := range cfgCostIncrmts {
|
||||
var pass bool
|
||||
if pass, err = fltrS.Pass(ctx, tnt, cIcrm.FilterIDs, ev); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user