Add dryrun for CDRsV2ProcessEvent

This commit is contained in:
arberkatellari
2023-11-07 11:55:10 -05:00
committed by Dan Christian Bogos
parent 8781b968ac
commit 681cd3c58a
6 changed files with 229 additions and 2 deletions

View File

@@ -137,6 +137,7 @@ type CallDescriptor struct {
DenyNegativeAccount bool // prevent account going on negative during debit
account *Account
testCallcost *CallCost // testing purpose only!
DryRun bool
}
// AsCGREvent converts the CallDescriptor into CGREvent
@@ -769,7 +770,7 @@ func (cd *CallDescriptor) Debit(fltrS *FilterS) (cc *CallCost, err error) {
}
}
return guardian.Guardian.Guard(func() (err error) {
cc, err = cd.debit(account, false, !cd.DenyNegativeAccount, fltrS)
cc, err = cd.debit(account, cd.DryRun, !cd.DenyNegativeAccount, fltrS)
if err == nil {
cc.AccountSummary = cd.AccountSummary(initialAcnt)
}

View File

@@ -202,6 +202,11 @@ func (rs *Responder) Debit(ctx *context.Context, arg *CallDescriptorWithAPIOpts,
err = utils.ErrMaxUsageExceeded
return
}
if ralsDryRun, exists := arg.APIOpts[utils.MetaRALsDryRun]; exists {
if arg.DryRun, err = utils.IfaceAsBool(ralsDryRun); err != nil {
return err
}
}
var r *CallCost
if r, err = arg.Debit(rs.FilterS); err != nil {
return