diff --git a/cdrs/fscdr.go b/cdrs/fscdr.go
index 689b0d917..e51fee794 100644
--- a/cdrs/fscdr.go
+++ b/cdrs/fscdr.go
@@ -19,10 +19,8 @@ along with this program. If not, see
package cdrs
import (
- "crypto/sha1"
"encoding/json"
"errors"
- "fmt"
"github.com/cgrates/cgrates/rater"
"github.com/cgrates/cgrates/utils"
"strconv"
@@ -70,10 +68,7 @@ func (fsCdr FSCdr) New(body []byte) (rater.CDR, error) {
}
func (fsCdr FSCdr) GetCgrId() string {
- hasher := sha1.New()
- hasher.Write([]byte(fsCdr[FS_IP]))
- hasher.Write([]byte(fsCdr[UUID]))
- return fmt.Sprintf("%x", hasher.Sum(nil))
+ return utils.FSCgrId(fsCdr[UUID])
}
func (fsCdr FSCdr) GetAccId() string {
return fsCdr[UUID]
diff --git a/mediator/mediator.go b/mediator/mediator.go
index 9654881e9..cc4c23b12 100644
--- a/mediator/mediator.go
+++ b/mediator/mediator.go
@@ -218,6 +218,7 @@ func (m *Mediator) getCostsFromRater(record []string, runIdx int) (cc *rater.Cal
if err != nil {
m.loggerDb.LogError(record[m.uuidIndexs[runIdx]], rater.MEDIATOR_SOURCE, err.Error())
} else {
+ // If the mediator calculated a price it will write it to logdb
m.loggerDb.LogCallCost(record[m.uuidIndexs[runIdx]], rater.MEDIATOR_SOURCE, cc)
}
return
diff --git a/utils/coreutils.go b/utils/coreutils.go
index 721069bbd..37999a8f0 100644
--- a/utils/coreutils.go
+++ b/utils/coreutils.go
@@ -18,6 +18,11 @@ along with this program. If not, see
package utils
+import (
+ "crypto/sha1"
+ "fmt"
+)
+
// Returns first non empty string out of vals. Useful to extract defaults
func FirstNonEmpty(vals ...string) string {
for _, val := range vals {
@@ -27,3 +32,9 @@ func FirstNonEmpty(vals ...string) string {
}
return ""
}
+
+func FSCgrId(uuid string) string {
+ hasher := sha1.New()
+ hasher.Write([]byte(uuid))
+ return fmt.Sprintf("%x", hasher.Sum(nil))
+}