From a90356d62c904b9206bcbfd645980bef59aa5c4d Mon Sep 17 00:00:00 2001 From: DanB Date: Thu, 15 May 2014 16:00:34 +0200 Subject: [PATCH] Fixup re-rating not using cost -1 --- apier/apier_local_test.go | 11 +++++++++++ engine/storage_sql.go | 3 +++ 2 files changed, 14 insertions(+) diff --git a/apier/apier_local_test.go b/apier/apier_local_test.go index 8b4dd1d83..87d645b58 100644 --- a/apier/apier_local_test.go +++ b/apier/apier_local_test.go @@ -1423,6 +1423,17 @@ func TestExportCdrsToFile(t *testing.T) { */ } +func TestLocalGetCdrs(t *testing.T) { + if !*testLocal { + return + } + var reply []*utils.StoredCdr + req := utils.AttrGetCdrs{} + if err := rater.Call("ApierV1.GetCdrs", req, &reply); err != nil { + t.Error("Unexpected error: ", err.Error()) + } +} + func TestLocalSetDC(t *testing.T) { if !*testLocal { return diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 4b172ea12..fa81363ec 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -912,6 +912,9 @@ func (self *SQLStorage) GetStoredCdrs(cgrIds, runIds, tors, cdrHosts, cdrSources SetupTime: setupTime.Time, AnswerTime: answerTime.Time, Duration: time.Duration(usage.Int64), ExtraFields: extraFieldsMp, MediationRunId: runid.String, Cost: cost.Float64, } + if !cost.Valid { //There was no cost provided, will fakely insert 0 if we do not handle it and reflect on re-rating + storCdr.Cost = -1 + } cdrs = append(cdrs, storCdr) } return cdrs, nil