diff --git a/go.mod b/go.mod
index 63a15de97..6528c2beb 100644
--- a/go.mod
+++ b/go.mod
@@ -28,6 +28,7 @@ require (
github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e
github.com/creack/pty v1.1.7
github.com/dgrijalva/jwt-go v3.2.0+incompatible
+ github.com/ericlagergren/decimal v0.0.0-20191206042408-88212e6cfca9
github.com/fiorix/go-diameter v3.0.3-0.20190716165154-f4823472d0e0+incompatible
github.com/fortytw2/leaktest v1.3.0 // indirect
github.com/fsnotify/fsnotify v1.4.8-0.20190312181446-1485a34d5d57
diff --git a/go.sum b/go.sum
index 391ae0dac..0ee3f54fd 100644
--- a/go.sum
+++ b/go.sum
@@ -41,6 +41,7 @@ github.com/antchfx/xmlquery v1.0.1-0.20190615060324-ebb6e8b1d119/go.mod h1:/+Cny
github.com/antchfx/xpath v1.0.1-0.20190715042825-b6dbe470e102 h1:8Vh/deU7GhGg8nJMQCR1vmdjkd437KMupkfcMsTuTM4=
github.com/antchfx/xpath v1.0.1-0.20190715042825-b6dbe470e102/go.mod h1:Yee4kTMuNiPYJ7nSNorELQMr1J33uOpXDMByNYhvtNk=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
+github.com/apmckinlay/gsuneido v0.0.0-20190404155041-0b6cd442a18f/go.mod h1:JU2DOj5Fc6rol0yaT79Csr47QR0vONGwJtBNGRD7jmc=
github.com/aws/aws-lambda-go v1.8.1/go.mod h1:zUsUQhAUjYzR8AuduJPCfhBuKWUaDbQiPOG+ouzmE1A=
github.com/aws/aws-sdk-go v1.23.18 h1:ADU/y1EO8yPzUJJYjcvJ0V9/suezxPh0u6hb5bSYIGQ=
github.com/aws/aws-sdk-go v1.23.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
@@ -70,6 +71,7 @@ github.com/cgrates/sipingo v1.0.1-0.20200514110619-25b61a652a0b/go.mod h1:0f2+3d
github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e h1:izFjZB83/XRXInc+gMIssUxdbleGsGIuGCPj2u7RQo0=
github.com/cgrates/sipingo v1.0.1-0.20200514112313-699ebc1cdb8e/go.mod h1:0f2+3dq5Iiv3VlcuY83VPJ0QzqRlzDG1Cr8okogQE3g=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -83,6 +85,8 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
+github.com/ericlagergren/decimal v0.0.0-20191206042408-88212e6cfca9 h1:mMVotm9OVwoOS2IFGRRS5AfMTFWhtf8wj34JEYh47/k=
+github.com/ericlagergren/decimal v0.0.0-20191206042408-88212e6cfca9/go.mod h1:ZWP59etEywfyMG2lAqnoi3t8uoiZCiTmLtwt6iESIsQ=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
github.com/fiorix/go-diameter v3.0.3-0.20190716165154-f4823472d0e0+incompatible h1:Xf8Q9AW9zNFFV4h5R/1bcMjMcbtZy1FFbCy/bzf/ZSw=
@@ -147,6 +151,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
+github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
@@ -194,6 +199,7 @@ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/segmentio/kafka-go v0.3.3 h1:V4Ou5vOe0HXux6G/ZdheugcvgmSRFG3IA69btTGrYdo=
github.com/segmentio/kafka-go v0.3.3/go.mod h1:OT5KXBPbaJJTcvokhWR2KFmm0niEx3mnccTwjmLvSi4=
+github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 h1:WhxRHzgeVGETMlmVfqhRn8RIeeNoPr2Czh33I4Zdccw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
@@ -329,6 +335,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
diff --git a/rates/rateprofile.go b/rates/rateprofile.go
index 412448641..e06d7cbdf 100644
--- a/rates/rateprofile.go
+++ b/rates/rateprofile.go
@@ -31,23 +31,22 @@ type RateProfile struct {
FilterIDs []string
ActivationInterval *utils.ActivationInterval
Weight float64
- ConnectFee float64 // #ToDo: replace here with decimal.Big
+ ConnectFee *utils.Decimal
RoundingMethod string
RoundingDecimals int
- MinCost float64 // #ToDo: replace here with decimal.Big
- MaxCost float64 // #ToDo: replace here with decimal.Big
+ MinCost *utils.Decimal
+ MaxCost *utils.Decimal
MaxCostStrategy string
Rates []*Rate
}
// Route defines rate related information used within a RateProfile
type Rate struct {
- ID string // RateID
- FilterIDs []string // RateFilterIDs
- Weight float64 // RateWeight
- Value float64 // RateValue, #ToDo: replace here with decimal.Big
- Unit time.Duration // RateUnit
- Increment time.Duration // RateIncrement
- Blocker bool // RateBlocker will make this rate recurrent
-
+ ID string // RateID
+ FilterIDs []string // RateFilterIDs
+ Weight float64 // RateWeight
+ Value *utils.Decimal // RateValue
+ Unit time.Duration // RateUnit
+ Increment time.Duration // RateIncrement
+ Blocker bool // RateBlocker will make this rate recurrent
}
diff --git a/utils/chrgdaccount.go b/utils/chrgdaccount.go
new file mode 100644
index 000000000..4dd717d46
--- /dev/null
+++ b/utils/chrgdaccount.go
@@ -0,0 +1,21 @@
+/*
+Real-time Online/Offline Charging System (OerS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package utils
+
+type ChargedAccount struct{} // placeholder for now
diff --git a/utils/chrgdaccounting.go b/utils/chrgdaccounting.go
new file mode 100644
index 000000000..1be8c140f
--- /dev/null
+++ b/utils/chrgdaccounting.go
@@ -0,0 +1,21 @@
+/*
+Real-time Online/Offline Charging System (OerS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package utils
+
+type ChargedAccounting struct{} // placeholder for now
diff --git a/utils/chrgdcost.go b/utils/chrgdcost.go
new file mode 100644
index 000000000..a9a63f37b
--- /dev/null
+++ b/utils/chrgdcost.go
@@ -0,0 +1,33 @@
+/*
+Real-time Online/Offline Charging System (OerS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package utils
+
+import "time"
+
+type ChargedCost struct {
+ CGRID string
+ RunID string
+ StartTime time.Time
+ Usage *time.Duration
+ Cost *Decimal
+ Charges []*ChargedInterval
+ AccountSummary ChargedAccount
+ Accounting ChargedAccounting
+ Rating ChargedRating
+}
diff --git a/rates/chrgincrement.go b/utils/chrgdincrement.go
similarity index 86%
rename from rates/chrgincrement.go
rename to utils/chrgdincrement.go
index 61f7f27a1..089aff749 100644
--- a/rates/chrgincrement.go
+++ b/utils/chrgdincrement.go
@@ -16,14 +16,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
*/
-package rates
+package utils
import "time"
// ChargedIncrement represents one unit charged inside an interval
type ChargedIncrement struct {
Usage time.Duration
- Cost float64 // #ToDo: replace here with decimal.Big
- AccountSID string // AccountS charged information
+ Cost *Decimal
+ AccountSID string // AccountS charged information
CompressFactor int
}
diff --git a/rates/chrginterval.go b/utils/chrgdinterval.go
similarity index 93%
rename from rates/chrginterval.go
rename to utils/chrgdinterval.go
index 0179e1af9..30316f958 100644
--- a/rates/chrginterval.go
+++ b/utils/chrgdinterval.go
@@ -16,14 +16,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see
*/
-package rates
+package utils
import "time"
type ChargedInterval struct {
Increments []*ChargedIncrement // specific increments applied to this interval
CompressFactor int
- ecUsageIdx *time.Duration // computed value of totalUsage at the starting of the interval
+ ccUsageIdx *time.Duration // computed value of totalUsage at the starting of the interval
usage *time.Duration // cache usage computation for this interval
cost *float64 // cache cost calculation on this interval // #ToDo: replace here with decimal.Big
}
diff --git a/utils/chrgdrating.go b/utils/chrgdrating.go
new file mode 100644
index 000000000..095e30b9f
--- /dev/null
+++ b/utils/chrgdrating.go
@@ -0,0 +1,21 @@
+/*
+Real-time Online/Offline Charging System (OerS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package utils
+
+type ChargedRating struct{} // placeholder for now
diff --git a/utils/decimal.go b/utils/decimal.go
new file mode 100644
index 000000000..a25110761
--- /dev/null
+++ b/utils/decimal.go
@@ -0,0 +1,27 @@
+/*
+Real-time Online/Offline Charging System (OerS) for Telecom & ISP environments
+Copyright (C) ITsysCOM GmbH
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see
+*/
+
+package utils
+
+import (
+ "github.com/ericlagergren/decimal"
+)
+
+type Decimal struct {
+ val *decimal.Big
+}