CDRs refundCDR method implementation

This commit is contained in:
DanB
2019-11-19 20:15:50 +01:00
parent 8aeeda4885
commit 18999bcbbd
2 changed files with 19 additions and 2 deletions

View File

@@ -286,9 +286,20 @@ func (cdrS *CDRServer) rateCDRWithErr(cdr *CDRWithArgDispatcher) (ratedCDRs []*C
return
}
// refundCDR will refund the EventCost within the CDR
func (cdrS *CDRServer) refundCDR(cdr *CDR) (err error) {
return
if !AccountableRequestTypes.HasField(cdr.RequestType) || cdr.CostDetails == nil {
return // non refundable
}
cd := cdr.CostDetails.AsRefundIncrements(cdr.ToR)
if cd == nil || len(cd.Increments) == 0 {
return
}
var acnt engine.Account
if err = cdrS.rals.Call(utils.ResponderRefundIncrements,
&engine.CallDescriptorWithArgDispatcher{CallDescriptor: cd}, &acnt); err != nil {
return
}
}
// chrgProcessEvent will process the CGREvent with ChargerS subsystem

View File

@@ -35,6 +35,12 @@ var NonMonetaryBalances = MapEvent{
utils.GENERIC: struct{}{},
}
var AccountableRequestTypes = MapEvent{
utils.MetaPrepaid: struct{}{},
utils.MetaPostpaid: struct{}{},
utils.MetaPseudoprepaid: struct{}{},
}
// ChargingInterval represents one interval out of Usage providing charging info
// eg: PEAK vs OFFPEAK
type ChargingInterval struct {