mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
Updated cfg/tp and test for session discout
This commit is contained in:
committed by
Dan Christian Bogos
parent
5c062e7ea7
commit
9f5cbbb176
@@ -322,7 +322,9 @@ func maxDebitAbstractsFromConcretes(ctx *context.Context, aUnits *decimal.Big,
|
||||
aPaid = decimal.New(0, 0)
|
||||
ec = utils.NewEventCharges()
|
||||
}
|
||||
// ec.Abstracts = &utils.Decimal{roundUnitsWithIncrements(aPaid, costIcrm.Increment.Big)}
|
||||
/*
|
||||
utils.Logger.Debug(fmt.Sprintf("aPaid %v, incr: %v, round: %v", aPaid, costIcrm.Increment.Big, roundUnitsWithIncrements(aPaid, costIcrm.Increment.Big)))
|
||||
*/
|
||||
ec.Abstracts = &utils.Decimal{aPaid}
|
||||
restoreUnitsFromClones(cncrtBlncs, paidConcrtUnts)
|
||||
return
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
{
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
// Used for sessions/sessions_volume_discount_it_test.go
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"reply_timeout": "10s",
|
||||
},
|
||||
|
||||
"data_db": {
|
||||
"db_type": "*internal"
|
||||
"db_type": "*internal"
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "*internal"
|
||||
},
|
||||
@@ -29,26 +30,39 @@
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"cdrs": { // CDRs config
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"accounts_conns":["*localhost"],
|
||||
"chargers_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*localhost"],
|
||||
"chargers_conns":["*localhost"],
|
||||
"opts": {
|
||||
"*chargerS": { //
|
||||
"": true,
|
||||
},
|
||||
"ees_conns":["*localhost"],
|
||||
"opts": {
|
||||
"*chargerS": {
|
||||
"*notstring:~*req.Account:sipp": true,
|
||||
},
|
||||
"*rateS": {
|
||||
"*string:~*req.Account:dan.bogos;*string:~*req.RunID:supplier": false,
|
||||
"": true,
|
||||
"*notstring:~*req.Account:sipp|dan.bogos": true,
|
||||
"*string:~*req.RunID:customers": true,
|
||||
},
|
||||
"*accountS": {
|
||||
"*string:~*req.Account:dan.bogos;*string:~*req.RunID:supplier": true,
|
||||
"": false,
|
||||
"*accountS": {
|
||||
"*string:~*req.Account:dan.bogos;*string:~*req.RunID:suppliers": true,
|
||||
},
|
||||
"*eeS": {
|
||||
"*default": true,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
"ees": {
|
||||
"enabled": true,
|
||||
"exporters": [
|
||||
{
|
||||
"id": "MyLogger",
|
||||
"type": "*log",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
@@ -57,11 +71,24 @@
|
||||
|
||||
"rates": {
|
||||
"enabled": true,
|
||||
"string_indexed_fields": ["*req.RunID"],
|
||||
"rate_string_indexed_fields": [],
|
||||
"rate_prefix_indexed_fields": ["*req.Destination"],
|
||||
"opts":{
|
||||
"*profileIgnoreFilters": {
|
||||
"*default": true,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
"accounts": {
|
||||
"enabled": true,
|
||||
"rates_conns": ["*localhost"],
|
||||
"opts":{
|
||||
"*usage": {
|
||||
"": "1m",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"loaders": [
|
||||
@@ -69,7 +96,7 @@
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/sessions_discount_volume",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/sessions_discount_volume/routes1",
|
||||
"tp_out_dir": "",
|
||||
"lockfile_path": "",
|
||||
},
|
||||
@@ -79,13 +106,15 @@
|
||||
"enabled": true,
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*localhost"],
|
||||
"default_opts":{
|
||||
"*ignoreErrors": true
|
||||
}
|
||||
"opts":{
|
||||
"*ignoreErrors": {
|
||||
"": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
@@ -1,30 +1,32 @@
|
||||
{
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
// Used for sessions/sessions_volume_discount_it_test.go
|
||||
|
||||
// CGRateS Configuration file
|
||||
//
|
||||
// Used for sessions/sessions_volume_discount_it_test.go
|
||||
|
||||
"general": {
|
||||
"log_level": 7,
|
||||
"reply_timeout": "10s",
|
||||
},
|
||||
|
||||
|
||||
"data_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "10",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
"stor_db": {
|
||||
"db_type": "mongo",
|
||||
"db_name": "cgrates",
|
||||
"db_port": 27017,
|
||||
},
|
||||
|
||||
|
||||
"sessions": {
|
||||
"enabled": true,
|
||||
"routes_conns": ["*localhost"],
|
||||
"cdrs_conns": ["*localhost"],
|
||||
},
|
||||
|
||||
|
||||
"attributes": {
|
||||
"enabled": true,
|
||||
"opts":{ //
|
||||
@@ -34,62 +36,90 @@
|
||||
},
|
||||
},
|
||||
|
||||
"cdrs": { // CDRs config
|
||||
"cdrs": {
|
||||
"enabled": true,
|
||||
"accounts_conns":["*localhost"],
|
||||
"chargers_conns": ["*localhost"],
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*localhost"],
|
||||
"chargers_conns":["*localhost"],
|
||||
"opts":
|
||||
{ //
|
||||
"*chargerS": { //
|
||||
"": true,
|
||||
},
|
||||
"*rateS": {
|
||||
"*string:~*req.Account:dan.bogos;*string:~*req.RunID:supplier": false,
|
||||
"": true,
|
||||
"ees_conns":["*localhost"],
|
||||
"opts": {
|
||||
"*chargerS": {
|
||||
"*notstring:~*req.Account:sipp": true,
|
||||
},
|
||||
"*accountS": {
|
||||
"*string:~*req.Account:dan.bogos;*string:~*req.RunID:supplier": true,
|
||||
"": false,
|
||||
},
|
||||
"*rateS": {
|
||||
"*notstring:~*req.Account:sipp|dan.bogos": true,
|
||||
"*string:~*req.RunID:customers": true,
|
||||
},
|
||||
"*accountS": {
|
||||
"*string:~*req.Account:dan.bogos;*string:~*req.RunID:suppliers": true,
|
||||
},
|
||||
"*eeS": {
|
||||
"*default": true,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"attributes_conns": ["*localhost"],
|
||||
"ees": {
|
||||
"enabled": true,
|
||||
"exporters": [
|
||||
{
|
||||
"id": "MyLogger",
|
||||
"type": "*log",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
|
||||
"chargers": {
|
||||
"enabled": true,
|
||||
"attributes_conns": ["*localhost"],
|
||||
},
|
||||
|
||||
"rates": {
|
||||
"enabled": true,
|
||||
"string_indexed_fields": ["*req.RunID"],
|
||||
"rate_string_indexed_fields": [],
|
||||
"rate_prefix_indexed_fields": ["*req.Destination"],
|
||||
"opts":{
|
||||
"*profileIgnoreFilters": {
|
||||
"*default": true,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"accounts": {
|
||||
"enabled": true,
|
||||
"rates_conns": ["*localhost"],
|
||||
"opts":{
|
||||
"*usage": {
|
||||
"": "1m",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"loaders": [
|
||||
{
|
||||
"id": "*default",
|
||||
"enabled": true,
|
||||
"tenant": "cgrates.org",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/sessions_discount_volume",
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/sessions_discount_volume/routes1",
|
||||
"tp_out_dir": "",
|
||||
"lockfile_path": "",
|
||||
},
|
||||
],
|
||||
|
||||
|
||||
"routes": {
|
||||
"enabled": true,
|
||||
"accounts_conns": ["*localhost"],
|
||||
"rates_conns": ["*localhost"],
|
||||
"default_opts":{
|
||||
"*ignoreErrors": true
|
||||
}
|
||||
"opts":{
|
||||
"*ignoreErrors": {
|
||||
"": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
"admins": {
|
||||
"enabled": true,
|
||||
},
|
||||
|
||||
}
|
||||
@@ -44,7 +44,7 @@
|
||||
"*notstring:~*req.Account:sipp": true,
|
||||
},
|
||||
"*rateS": {
|
||||
"*notstring:~*req.Account:sipp;*notstring:~*req.Account:dan.bogos": true,
|
||||
"*notstring:~*req.Account:sipp|dan.bogos": true,
|
||||
"*string:~*req.RunID:customers": true,
|
||||
},
|
||||
"*accountS": {
|
||||
@@ -102,35 +102,6 @@
|
||||
"tp_out_dir": "",
|
||||
"lockfile_path": "",
|
||||
},
|
||||
{
|
||||
"id": "OsipsTestLoader",
|
||||
"enabled": true,
|
||||
"tp_in_dir": "/usr/share/cgrates/tariffplans/sessions_discount_volume/osips1",
|
||||
"tp_out_dir": "",
|
||||
"data":[
|
||||
{
|
||||
"type": "*routes",
|
||||
"file_name": "Routes.csv",
|
||||
"fields": [
|
||||
{"tag": "Tenant", "path": "Tenant", "type": "*variable", "value": "~*req.0", "mandatory": true},
|
||||
{"tag": "ID", "path": "ID", "type": "*variable", "value": "~*req.1", "mandatory": true},
|
||||
{"tag": "FilterIDs", "path": "FilterIDs", "type": "*variable", "value": "~*req.2"},
|
||||
{"tag": "Weights", "path": "Weights", "type": "*variable", "value": "~*req.3"},
|
||||
{"tag": "Sorting", "path": "Sorting", "type": "*variable", "value": "~*req.4"},
|
||||
{"tag": "SortingParameters", "path": "SortingParameters", "type": "*variable", "value": "~*req.5"},
|
||||
{"tag": "RouteID", "path": "RouteID", "type": "*variable", "value": "~*req.6"},
|
||||
{"tag": "RouteFilterIDs", "path": "RouteFilterIDs", "type": "*variable", "value": "~*req.7"},
|
||||
{"tag": "RouteAccountIDs", "path": "RouteAccountIDs", "type": "*variable", "value": "~*req.8"},
|
||||
{"tag": "RouteRateProfileIDs", "path": "RouteRateProfileIDs", "type": "*variable", "value": "~*req.9"},
|
||||
{"tag": "RouteResourceIDs", "path": "RouteResourceIDs", "type": "*variable", "value": "~*req.10"},
|
||||
{"tag": "RouteStatIDs", "path": "RouteStatIDs", "type": "*variable", "value": "~*req.11"},
|
||||
{"tag": "RouteWeights", "path": "RouteWeights", "type": "*variable", "value": "~*req.12"},
|
||||
{"tag": "RouteBlocker", "path": "RouteBlocker", "type": "*variable", "value": "~*req.13"},
|
||||
{"tag": "RouteParameters", "path": "RouteParameters", "type": "*variable", "value": "~*req.14"}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
|
||||
"routes": {
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
#Tenant,ID,FilterIDs,Weight,RunID,AttributeIDs
|
||||
opensips.org,DEFAULT,,0,*default,*none
|
||||
|
@@ -1,5 +0,0 @@
|
||||
#Tenant,ID,FilterIDs,Weight,Sorting,SortingParameters,RouteID,RouteFilterIDs,RouteAccountIDs,RouteRateProfileIDs,RouteResourceIDs,RouteStatIDs,RouteWeight,RouteBlocker,RouteParameters
|
||||
|
||||
opensips.org,DEFAULT_ROUTES,,,*weight,,,,,,,,,,
|
||||
opensips.org,DEFAULT_ROUTES,,,,,carrier1,,,,,,;20,,
|
||||
opensips.org,DEFAULT_ROUTES,,,,,carrier2,,,,,,;10,,
|
||||
|
@@ -360,7 +360,7 @@ func testSessVolDiscProcessCDRSupplier(t *testing.T) {
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.StartTime: time.Date(2020, time.January, 7, 16, 60, 0, 0, time.UTC),
|
||||
utils.MetaUsage: 15 * time.Minute,
|
||||
utils.MetaUsage: 15 * time.Minute, // 179219039us
|
||||
},
|
||||
}
|
||||
|
||||
@@ -379,7 +379,7 @@ func testSessVolDiscProcessCDRCustomer(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
ID: "TestSSv1ItProcessCDR",
|
||||
Event: map[string]interface{}{
|
||||
utils.AccountField: "DIFFERENT_ACCOUNT1",
|
||||
utils.AccountField: "sipp",
|
||||
utils.Destination: "1002",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
@@ -401,32 +401,42 @@ func testSessVolDiscProcessCDRCustomer(t *testing.T) {
|
||||
func testSessVolDiscAccountAfterDebiting(t *testing.T) {
|
||||
expectedAcc := utils.Account{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ACCOUNT1",
|
||||
ID: "ACNT_VOL1",
|
||||
FilterIDs: []string{},
|
||||
Balances: map[string]*utils.Balance{
|
||||
"ABS_BALANCE1": {
|
||||
ID: "ABS_BALANCE1",
|
||||
"ABS_VOLUME1": {
|
||||
ID: "ABS_VOLUME1",
|
||||
Weights: utils.DynamicWeights{
|
||||
{
|
||||
FilterIDs: nil,
|
||||
Weight: 30,
|
||||
},
|
||||
},
|
||||
Type: "*abstract",
|
||||
Units: &utils.Decimal{utils.SumDecimalAsBig(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0))}, // this should be -0
|
||||
RateProfileIDs: []string{"RP_ABS_BALANCE1"},
|
||||
Type: "*abstract",
|
||||
Units: &utils.Decimal{utils.SumDecimalAsBig(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0))}, // this should be -0
|
||||
CostIncrements: []*utils.CostIncrement{
|
||||
{
|
||||
Increment: utils.NewDecimal(int64(time.Second), 0),
|
||||
FixedFee: utils.NewDecimal(0, 0),
|
||||
},
|
||||
},
|
||||
},
|
||||
"ABS_BALANCE2": {
|
||||
ID: "ABS_BALANCE2",
|
||||
"ABS_VOLUME2": {
|
||||
ID: "ABS_VOLUME2",
|
||||
Weights: utils.DynamicWeights{
|
||||
{
|
||||
FilterIDs: nil,
|
||||
Weight: 20,
|
||||
},
|
||||
},
|
||||
Type: "*abstract",
|
||||
Units: utils.NewDecimal(0, 0),
|
||||
RateProfileIDs: []string{"RP_ABS_BALANCE2"},
|
||||
Type: "*abstract",
|
||||
Units: &utils.Decimal{utils.SumDecimalAsBig(&utils.Decimal{utils.NewDecimal(0, 0).Neg(utils.NewDecimal(1, 0).Big)}, utils.NewDecimal(1, 0))},
|
||||
CostIncrements: []*utils.CostIncrement{
|
||||
{
|
||||
Increment: utils.NewDecimal(int64(time.Second), 0),
|
||||
},
|
||||
},
|
||||
RateProfileIDs: []string{"RP_ABS_VOLUME2"},
|
||||
},
|
||||
"CNCRT_BALANCE1": {
|
||||
ID: "CNCRT_BALANCE1",
|
||||
@@ -439,9 +449,14 @@ func testSessVolDiscAccountAfterDebiting(t *testing.T) {
|
||||
Opts: map[string]interface{}{
|
||||
utils.MetaBalanceUnlimited: "true",
|
||||
},
|
||||
Type: "*concrete",
|
||||
Units: utils.NewDecimal(98800, 2),
|
||||
RateProfileIDs: []string{"RP_CNCRT_BALANCE1"},
|
||||
Type: "*concrete",
|
||||
Units: utils.NewDecimal(9882400, 4),
|
||||
CostIncrements: []*utils.CostIncrement{
|
||||
{
|
||||
Increment: utils.NewDecimal(int64(time.Second), 0),
|
||||
},
|
||||
},
|
||||
RateProfileIDs: []string{"RP_SUPPLIER1"},
|
||||
},
|
||||
},
|
||||
ThresholdIDs: []string{},
|
||||
@@ -451,7 +466,7 @@ func testSessVolDiscAccountAfterDebiting(t *testing.T) {
|
||||
&utils.TenantIDWithAPIOpts{
|
||||
TenantID: &utils.TenantID{
|
||||
Tenant: "cgrates.org",
|
||||
ID: "ACCOUNT1",
|
||||
ID: "ACNT_VOL1",
|
||||
},
|
||||
}, &result); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user