Tested the resolved panic with evChargers in account

This commit is contained in:
porosnicuadrian
2021-10-07 17:13:24 +03:00
committed by Dan Christian Bogos
parent 9ef188e3eb
commit 05e7900aea
4 changed files with 81 additions and 30 deletions

View File

@@ -174,50 +174,40 @@ func (ec *EventCharges) AsExtEventCharges() (eEc *ExtEventCharges, err error) {
if ec.Accounting != nil {
eEc.Accounting = make(map[string]*ExtAccountCharge, len(eEc.Accounting))
for key, val := range ec.Accounting {
if extAcc, err := val.AsExtAccountCharge(); err != nil {
if eEc.Accounting[key], err = val.AsExtAccountCharge(); err != nil {
return nil, err
} else {
eEc.Accounting[key] = extAcc
}
}
}
if ec.UnitFactors != nil {
eEc.UnitFactors = make(map[string]*ExtUnitFactor, len(ec.UnitFactors))
for key, val := range ec.UnitFactors {
if extUnit, err := val.AsExtUnitFactor(); err != nil {
if eEc.UnitFactors[key], err = val.AsExtUnitFactor(); err != nil {
return nil, err
} else {
eEc.UnitFactors[key] = extUnit
}
}
}
if ec.Rating != nil {
eEc.Rating = make(map[string]*ExtRateSInterval, len(ec.Rating))
for key, val := range ec.Rating {
if extRate, err := val.AsExtRateSInterval(); err != nil {
if eEc.Rating[key], err = val.AsExtRateSInterval(); err != nil {
return nil, err
} else {
eEc.Rating[key] = extRate
}
}
}
if ec.Rates != nil {
eEc.Rates = make(map[string]*ExtIntervalRate, len(ec.Rates))
for key, val := range ec.Rates {
if extRate, err := val.AsExtIntervalRate(); err != nil {
if eEc.Rates[key], err = val.AsExtIntervalRate(); err != nil {
return nil, err
} else {
eEc.Rates[key] = extRate
}
}
}
if ec.Accounts != nil {
eEc.Accounts = make(map[string]*ExtAccount, len(ec.Accounts))
for acntID, acnt := range ec.Accounts {
if extAccs, err := acnt.AsExtAccount(); err != nil {
if eEc.Accounts[acntID], err = acnt.AsExtAccount(); err != nil {
return nil, err
} else {
eEc.Accounts[acntID] = extAccs
}
}
}

View File

@@ -324,11 +324,6 @@ func (rI *RateSInterval) AsRatesIntervalsCost() (rIc *RateSIntervalCost) {
rIc = &RateSIntervalCost{
CompressFactor: rI.CompressFactor,
}
/*
if rI.cost != nil {
rIc.cost = rI.cost
}
*/
if rI.Increments != nil {
rIc.Increments = make([]*RateSIncrementCost, len(rI.Increments))
for idx, incr := range rI.Increments {
@@ -508,8 +503,6 @@ type RateProfileCost struct {
type RateSIntervalCost struct {
Increments []*RateSIncrementCost
CompressFactor int64
cost *decimal.Big // unexported total interval cost
}
// RateSIncrementCost is used in the RateProfileCost to reflect RateSIncrement
@@ -518,8 +511,6 @@ type RateSIncrementCost struct {
RateID string
RateIntervalIndex int
CompressFactor int64
cost *decimal.Big // unexported total increment cost
}
// AsRateSIncrementCost converts RateSIncrement to RateSIncrementCost
@@ -533,11 +524,6 @@ func (rI *RateSIncrement) AsRateSIncrementCost() (rIc *RateSIncrementCost) {
if rI.Usage != nil {
rIc.Usage = rI.Usage
}
/*
if rI.cost != nil {
rIc.cost = rI.cost
}
*/
return
}
@@ -720,6 +706,7 @@ func (rIcr *RateSIncrement) Cost(rts map[string]*IntervalRate) (cost *decimal.Bi
return rIcr.cost
}
/*
// CostForIntervals sums the costs for all intervals
func CostForIntervals(rtIvls []*RateSInterval, rts map[string]*IntervalRate) (cost *decimal.Big) {
cost = new(decimal.Big)
@@ -728,6 +715,7 @@ func CostForIntervals(rtIvls []*RateSInterval, rts map[string]*IntervalRate) (co
}
return
}
*/
// CompressIntervals will compress intervals which equal
func CompressIntervals(rtIvls []*RateSInterval) {