From c3cd02f02b36e64a4e07facbef145b7b4d03dd0c Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Fri, 14 May 2021 16:42:57 +0300 Subject: [PATCH] Remove ActivationInterval from RateProfile --- .../tariffplans/hundredrates/RateProfiles.csv | 264 +++++++++--------- data/tariffplans/oldaccvsnew/RateProfiles.csv | 6 +- data/tariffplans/testit/RateProfiles.csv | 8 +- data/tariffplans/tutrates/RateProfiles.csv | 4 +- engine/libtest.go | 10 +- engine/model_helpers.go | 44 +-- engine/model_helpers_test.go | 121 +++----- engine/models.go | 29 +- general_tests/export_it_test.go | 7 +- loaders/loader_test.go | 168 ++++------- rates/rates.go | 5 +- rates/rates_test.go | 65 +---- utils/apitpdata.go | 19 +- utils/librates.go | 26 +- utils/librates_test.go | 18 +- 15 files changed, 292 insertions(+), 502 deletions(-) diff --git a/data/tariffplans/hundredrates/RateProfiles.csv b/data/tariffplans/hundredrates/RateProfiles.csv index f9e797e21..9cc0953e4 100644 --- a/data/tariffplans/hundredrates/RateProfiles.csv +++ b/data/tariffplans/hundredrates/RateProfiles.csv @@ -1,132 +1,132 @@ -#Tenant,ID,FilterIDs,ActivationInterval,Weight,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeight,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement -cgrates.org,RP1,,,,,,,RT_100,*string:~*req.PrefixDestination:100,,,,0s,0.82,0.9603,60s,60s -cgrates.org,RP1,,,,,,,RT_100,,,,,60s,0,0.4801,60s,1s -cgrates.org,RP1,,,,,,,RT_101,*string:~*req.PrefixDestination:101,,,,0s,0.37,0.3478,60s,60s -cgrates.org,RP1,,,,,,,RT_101,,,,,60s,0,0.1739,60s,1s -cgrates.org,RP1,,,,,,,RT_102,*string:~*req.PrefixDestination:102,,,,0s,0.94,0.7972,60s,60s -cgrates.org,RP1,,,,,,,RT_102,,,,,60s,0,0.3986,60s,1s -cgrates.org,RP1,,,,,,,RT_103,*string:~*req.PrefixDestination:103,,,,0s,0.46,0.2151,60s,60s -cgrates.org,RP1,,,,,,,RT_103,,,,,60s,0,0.1076,60s,1s -cgrates.org,RP1,,,,,,,RT_104,*string:~*req.PrefixDestination:104,,,,0s,0.01,0.5396,60s,60s -cgrates.org,RP1,,,,,,,RT_104,,,,,60s,0,0.2698,60s,1s -cgrates.org,RP1,,,,,,,RT_105,*string:~*req.PrefixDestination:105,,,,0s,0.57,0.9269,60s,60s -cgrates.org,RP1,,,,,,,RT_106,*string:~*req.PrefixDestination:106,,,,0s,0.13,0.3689,1s,1s -cgrates.org,RP1,,,,,,,RT_107,*string:~*req.PrefixDestination:107,,,,0s,0.66,0.7610,60s,60s -cgrates.org,RP1,,,,,,,RT_107,,,,,60s,0,0.3805,60s,1s -cgrates.org,RP1,,,,,,,RT_108,*string:~*req.PrefixDestination:108,,,,0s,0.22,0.1169,60s,60s -cgrates.org,RP1,,,,,,,RT_108,,,,,60s,0,0.0585,60s,1s -cgrates.org,RP1,,,,,,,RT_109,*string:~*req.PrefixDestination:109,,,,0s,0.77,0.5041,60s,60s -cgrates.org,RP1,,,,,,,RT_110,*string:~*req.PrefixDestination:110,,,,0s,0.30,0.9540,60s,60s -cgrates.org,RP1,,,,,,,RT_111,*string:~*req.PrefixDestination:111,,,,0s,0.85,0.3411,1s,1s -cgrates.org,RP1,,,,,,,RT_112,*string:~*req.PrefixDestination:112,,,,0s,0.41,0.6961,60s,60s -cgrates.org,RP1,,,,,,,RT_112,,,,,60s,0,0.3481,60s,1s -cgrates.org,RP1,,,,,,,RT_113,*string:~*req.PrefixDestination:113,,,,0s,0.97,0.0835,60s,60s -cgrates.org,RP1,,,,,,,RT_114,*string:~*req.PrefixDestination:114,,,,0s,0.62,0.5332,1s,1s -cgrates.org,RP1,,,,,,,RT_115,*string:~*req.PrefixDestination:115,,,,0s,0.18,0.8658,60s,60s -cgrates.org,RP1,,,,,,,RT_116,*string:~*req.PrefixDestination:116,,,,0s,0.74,0.2855,60s,60s -cgrates.org,RP1,,,,,,,RT_117,*string:~*req.PrefixDestination:117,,,,0s,0.27,0.7347,1s,1s -cgrates.org,RP1,,,,,,,RT_118,*string:~*req.PrefixDestination:118,,,,0s,0.82,0.1221,1s,1s -cgrates.org,RP1,,,,,,,RT_119,*string:~*req.PrefixDestination:119,,,,0s,0.38,0.4470,60s,60s -cgrates.org,RP1,,,,,,,RT_120,*string:~*req.PrefixDestination:120,,,,0s,0.94,0.8652,60s,60s -cgrates.org,RP1,,,,,,,RT_121,*string:~*req.PrefixDestination:121,,,,0s,0.47,0.3142,1s,1s -cgrates.org,RP1,,,,,,,RT_122,*string:~*req.PrefixDestination:122,,,,0s,0.03,0.7013,1s,1s -cgrates.org,RP1,,,,,,,RT_123,*string:~*req.PrefixDestination:123,,,,0s,0.58,0.0262,60s,60s -cgrates.org,RP1,,,,,,,RT_123,,,,,60s,0,0.0131,60s,1s -cgrates.org,RP1,,,,,,,RT_124,*string:~*req.PrefixDestination:124,,,,0s,0.11,0.4445,60s,60s -cgrates.org,RP1,,,,,,,RT_124,,,,,60s,0,0.2223,60s,1s -cgrates.org,RP1,,,,,,,RT_125,*string:~*req.PrefixDestination:125,,,,0s,0.66,0.8838,60s,60s -cgrates.org,RP1,,,,,,,RT_126,*string:~*req.PrefixDestination:126,,,,0s,0.22,0.2708,1s,1s -cgrates.org,RP1,,,,,,,RT_127,*string:~*req.PrefixDestination:127,,,,0s,0.78,0.5953,1s,1s -cgrates.org,RP1,,,,,,,RT_128,*string:~*req.PrefixDestination:128,,,,0s,0.43,0.0140,1s,1s -cgrates.org,RP1,,,,,,,RT_129,*string:~*req.PrefixDestination:129,,,,0s,0.99,0.4636,60s,60s -cgrates.org,RP1,,,,,,,RT_130,*string:~*req.PrefixDestination:130,,,,0s,0.55,0.8502,1s,1s -cgrates.org,RP1,,,,,,,RT_131,*string:~*req.PrefixDestination:131,,,,0s,0.07,0.1749,60s,60s -cgrates.org,RP1,,,,,,,RT_132,*string:~*req.PrefixDestination:132,,,,0s,0.64,0.5932,60s,60s -cgrates.org,RP1,,,,,,,RT_132,,,,,60s,0,0.2966,60s,1s -cgrates.org,RP1,,,,,,,RT_133,*string:~*req.PrefixDestination:133,,,,0s,0.19,0.0430,60s,60s -cgrates.org,RP1,,,,,,,RT_133,,,,,60s,0,0.0215,60s,1s -cgrates.org,RP1,,,,,,,RT_134,*string:~*req.PrefixDestination:134,,,,0s,0.74,0.4393,60s,60s -cgrates.org,RP1,,,,,,,RT_135,*string:~*req.PrefixDestination:135,,,,0s,0.27,0.7635,60s,60s -cgrates.org,RP1,,,,,,,RT_136,*string:~*req.PrefixDestination:136,,,,0s,0.83,0.1823,1s,1s -cgrates.org,RP1,,,,,,,RT_137,*string:~*req.PrefixDestination:137,,,,0s,0.39,0.6319,1s,1s -cgrates.org,RP1,,,,,,,RT_138,*string:~*req.PrefixDestination:138,,,,0s,0.92,0.0192,60s,60s -cgrates.org,RP1,,,,,,,RT_138,,,,,60s,0,0.0096,60s,1s -cgrates.org,RP1,,,,,,,RT_139,*string:~*req.PrefixDestination:139,,,,0s,0.47,0.3429,60s,60s -cgrates.org,RP1,,,,,,,RT_140,*string:~*req.PrefixDestination:140,,,,0s,0.03,0.7614,60s,60s -cgrates.org,RP1,,,,,,,RT_141,*string:~*req.PrefixDestination:141,,,,0s,0.59,0.2112,60s,60s -cgrates.org,RP1,,,,,,,RT_142,*string:~*req.PrefixDestination:142,,,,0s,0.24,0.5984,1s,1s -cgrates.org,RP1,,,,,,,RT_143,*string:~*req.PrefixDestination:143,,,,0s,0.80,0.9283,60s,60s -cgrates.org,RP1,,,,,,,RT_143,,,,,60s,0,0.4642,60s,1s -cgrates.org,RP1,,,,,,,RT_144,*string:~*req.PrefixDestination:144,,,,0s,0.35,0.3075,60s,60s -cgrates.org,RP1,,,,,,,RT_145,*string:~*req.PrefixDestination:145,,,,0s,0.88,0.7885,60s,60s -cgrates.org,RP1,,,,,,,RT_145,,,,,60s,0,0.3942,60s,1s -cgrates.org,RP1,,,,,,,RT_146,*string:~*req.PrefixDestination:146,,,,0s,0.44,0.1760,60s,60s -cgrates.org,RP1,,,,,,,RT_147,*string:~*req.PrefixDestination:147,,,,0s,0.00,0.5002,60s,60s -cgrates.org,RP1,,,,,,,RT_147,,,,,60s,0,0.2501,60s,1s -cgrates.org,RP1,,,,,,,RT_148,*string:~*req.PrefixDestination:148,,,,0s,0.55,0.8867,60s,60s -cgrates.org,RP1,,,,,,,RT_148,,,,,60s,0,0.4434,60s,1s -cgrates.org,RP1,,,,,,,RT_149,*string:~*req.PrefixDestination:149,,,,0s,0.08,0.3675,60s,60s -cgrates.org,RP1,,,,,,,RT_149,,,,,60s,0,0.1837,60s,1s -cgrates.org,RP1,,,,,,,RT_150,*string:~*req.PrefixDestination:150,,,,0s,0.63,0.7551,60s,60s -cgrates.org,RP1,,,,,,,RT_151,*string:~*req.PrefixDestination:151,,,,0s,0.19,0.0796,1s,1s -cgrates.org,RP1,,,,,,,RT_152,*string:~*req.PrefixDestination:152,,,,0s,0.75,0.4678,1s,1s -cgrates.org,RP1,,,,,,,RT_153,*string:~*req.PrefixDestination:153,,,,0s,0.28,0.9489,60s,60s -cgrates.org,RP1,,,,,,,RT_154,*string:~*req.PrefixDestination:154,,,,0s,0.84,0.2815,60s,60s -cgrates.org,RP1,,,,,,,RT_155,*string:~*req.PrefixDestination:155,,,,0s,0.40,0.6686,1s,1s -cgrates.org,RP1,,,,,,,RT_156,*string:~*req.PrefixDestination:156,,,,0s,0.05,0.1175,1s,1s -cgrates.org,RP1,,,,,,,RT_157,*string:~*req.PrefixDestination:157,,,,0s,0.61,0.5358,1s,1s -cgrates.org,RP1,,,,,,,RT_158,*string:~*req.PrefixDestination:158,,,,0s,0.16,0.8607,60s,60s -cgrates.org,RP1,,,,,,,RT_158,,,,,60s,0,0.4303,60s,1s -cgrates.org,RP1,,,,,,,RT_159,*string:~*req.PrefixDestination:159,,,,0s,0.72,0.2478,60s,60s -cgrates.org,RP1,,,,,,,RT_160,*string:~*req.PrefixDestination:160,,,,0s,0.25,0.6975,60s,60s -cgrates.org,RP1,,,,,,,RT_161,*string:~*req.PrefixDestination:161,,,,0s,0.80,0.1133,60s,60s -cgrates.org,RP1,,,,,,,RT_162,*string:~*req.PrefixDestination:162,,,,0s,0.36,0.4376,60s,60s -cgrates.org,RP1,,,,,,,RT_163,*string:~*req.PrefixDestination:163,,,,0s,0.89,0.8174,60s,60s -cgrates.org,RP1,,,,,,,RT_163,,,,,60s,0,0.4087,60s,1s -cgrates.org,RP1,,,,,,,RT_164,*string:~*req.PrefixDestination:164,,,,0s,0.44,0.2670,60s,60s -cgrates.org,RP1,,,,,,,RT_164,,,,,60s,0,0.1335,60s,1s -cgrates.org,RP1,,,,,,,RT_165,*string:~*req.PrefixDestination:165,,,,0s,0.00,0.6847,1s,1s -cgrates.org,RP1,,,,,,,RT_166,*string:~*req.PrefixDestination:166,,,,0s,0.56,0.0094,1s,1s -cgrates.org,RP1,,,,,,,RT_167,*string:~*req.PrefixDestination:167,,,,0s,0.08,0.3963,60s,60s -cgrates.org,RP1,,,,,,,RT_167,,,,,60s,0,0.1982,60s,1s -cgrates.org,RP1,,,,,,,RT_168,*string:~*req.PrefixDestination:168,,,,0s,0.65,0.8463,1s,1s -cgrates.org,RP1,,,,,,,RT_169,*string:~*req.PrefixDestination:169,,,,0s,0.21,0.2648,1s,1s -cgrates.org,RP1,,,,,,,RT_170,*string:~*req.PrefixDestination:170,,,,0s,0.86,0.5905,60s,60s -cgrates.org,RP1,,,,,,,RT_171,*string:~*req.PrefixDestination:171,,,,0s,0.42,0.9778,60s,60s -cgrates.org,RP1,,,,,,,RT_171,,,,,60s,0,0.4889,60s,1s -cgrates.org,RP1,,,,,,,RT_172,*string:~*req.PrefixDestination:172,,,,0s,0.97,0.4273,60s,60s -cgrates.org,RP1,,,,,,,RT_173,*string:~*req.PrefixDestination:173,,,,0s,0.53,0.8537,60s,60s -cgrates.org,RP1,,,,,,,RT_173,,,,,60s,0,0.4269,60s,1s -cgrates.org,RP1,,,,,,,RT_174,*string:~*req.PrefixDestination:174,,,,0s,0.06,0.1779,60s,60s -cgrates.org,RP1,,,,,,,RT_175,*string:~*req.PrefixDestination:175,,,,0s,0.61,0.5646,1s,1s -cgrates.org,RP1,,,,,,,RT_176,*string:~*req.PrefixDestination:176,,,,0s,0.17,0.0144,1s,1s -cgrates.org,RP1,,,,,,,RT_177,*string:~*req.PrefixDestination:177,,,,0s,0.70,0.4329,60s,60s -cgrates.org,RP1,,,,,,,RT_178,*string:~*req.PrefixDestination:178,,,,0s,0.25,0.7576,60s,60s -cgrates.org,RP1,,,,,,,RT_178,,,,,60s,0,0.3788,60s,1s -cgrates.org,RP1,,,,,,,RT_179,*string:~*req.PrefixDestination:179,,,,0s,0.81,0.1499,1s,1s -cgrates.org,RP1,,,,,,,RT_180,*string:~*req.PrefixDestination:180,,,,0s,0.37,0.5996,1s,1s -cgrates.org,RP1,,,,,,,RT_181,*string:~*req.PrefixDestination:181,,,,0s,0.89,0.9870,60s,60s -cgrates.org,RP1,,,,,,,RT_181,,,,,60s,0,0.4935,60s,1s -cgrates.org,RP1,,,,,,,RT_182,*string:~*req.PrefixDestination:182,,,,0s,0.45,0.3348,60s,60s -cgrates.org,RP1,,,,,,,RT_182,,,,,60s,0,0.1674,60s,1s -cgrates.org,RP1,,,,,,,RT_183,*string:~*req.PrefixDestination:183,,,,0s,0.02,0.7215,60s,60s -cgrates.org,RP1,,,,,,,RT_184,*string:~*req.PrefixDestination:184,,,,0s,0.66,0.1708,60s,60s -cgrates.org,RP1,,,,,,,RT_185,*string:~*req.PrefixDestination:185,,,,0s,0.23,0.5584,60s,60s -cgrates.org,RP1,,,,,,,RT_185,,,,,60s,0,0.2792,60s,1s -cgrates.org,RP1,,,,,,,RT_186,*string:~*req.PrefixDestination:186,,,,0s,0.78,0.9143,60s,60s -cgrates.org,RP1,,,,,,,RT_187,*string:~*req.PrefixDestination:187,,,,0s,0.33,0.3012,1s,1s -cgrates.org,RP1,,,,,,,RT_188,*string:~*req.PrefixDestination:188,,,,0s,0.86,0.7522,1s,1s -cgrates.org,RP1,,,,,,,RT_189,*string:~*req.PrefixDestination:189,,,,0s,0.42,0.1394,1s,1s -cgrates.org,RP1,,,,,,,RT_190,*string:~*req.PrefixDestination:190,,,,0s,0.97,0.4955,1s,1s -cgrates.org,RP1,,,,,,,RT_191,*string:~*req.PrefixDestination:191,,,,0s,0.51,0.8824,60s,60s -cgrates.org,RP1,,,,,,,RT_191,,,,,60s,0,0.4412,60s,1s -cgrates.org,RP1,,,,,,,RT_192,*string:~*req.PrefixDestination:192,,,,0s,0.06,0.3393,60s,60s -cgrates.org,RP1,,,,,,,RT_193,*string:~*req.PrefixDestination:193,,,,0s,0.62,0.6639,1s,1s -cgrates.org,RP1,,,,,,,RT_194,*string:~*req.PrefixDestination:194,,,,0s,0.18,0.0824,1s,1s -cgrates.org,RP1,,,,,,,RT_195,*string:~*req.PrefixDestination:195,,,,0s,0.70,0.5322,60s,60s -cgrates.org,RP1,,,,,,,RT_196,*string:~*req.PrefixDestination:196,,,,0s,0.26,0.9193,60s,60s -cgrates.org,RP1,,,,,,,RT_196,,,,,60s,0,0.4597,60s,1s -cgrates.org,RP1,,,,,,,RT_197,*string:~*req.PrefixDestination:197,,,,0s,0.82,0.2411,1s,1s -cgrates.org,RP1,,,,,,,RT_198,*string:~*req.PrefixDestination:198,,,,0s,0.47,0.6596,60s,60s -cgrates.org,RP1,,,,,,,RT_198,,,,,60s,0,0.3298,60s,1s -cgrates.org,RP1,,,,,,,RT_199,*string:~*req.PrefixDestination:199,,,,0s,0.03,0.1095,60s,60s \ No newline at end of file +#Tenant,ID,FilterIDs,Weight,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeight,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement +cgrates.org,RP1,,,,,,RT_100,*string:~*req.PrefixDestination:100,,,,0s,0.82,0.9603,60s,60s +cgrates.org,RP1,,,,,,RT_100,,,,,60s,0,0.4801,60s,1s +cgrates.org,RP1,,,,,,RT_101,*string:~*req.PrefixDestination:101,,,,0s,0.37,0.3478,60s,60s +cgrates.org,RP1,,,,,,RT_101,,,,,60s,0,0.1739,60s,1s +cgrates.org,RP1,,,,,,RT_102,*string:~*req.PrefixDestination:102,,,,0s,0.94,0.7972,60s,60s +cgrates.org,RP1,,,,,,RT_102,,,,,60s,0,0.3986,60s,1s +cgrates.org,RP1,,,,,,RT_103,*string:~*req.PrefixDestination:103,,,,0s,0.46,0.2151,60s,60s +cgrates.org,RP1,,,,,,RT_103,,,,,60s,0,0.1076,60s,1s +cgrates.org,RP1,,,,,,RT_104,*string:~*req.PrefixDestination:104,,,,0s,0.01,0.5396,60s,60s +cgrates.org,RP1,,,,,,RT_104,,,,,60s,0,0.2698,60s,1s +cgrates.org,RP1,,,,,,RT_105,*string:~*req.PrefixDestination:105,,,,0s,0.57,0.9269,60s,60s +cgrates.org,RP1,,,,,,RT_106,*string:~*req.PrefixDestination:106,,,,0s,0.13,0.3689,1s,1s +cgrates.org,RP1,,,,,,RT_107,*string:~*req.PrefixDestination:107,,,,0s,0.66,0.7610,60s,60s +cgrates.org,RP1,,,,,,RT_107,,,,,60s,0,0.3805,60s,1s +cgrates.org,RP1,,,,,,RT_108,*string:~*req.PrefixDestination:108,,,,0s,0.22,0.1169,60s,60s +cgrates.org,RP1,,,,,,RT_108,,,,,60s,0,0.0585,60s,1s +cgrates.org,RP1,,,,,,RT_109,*string:~*req.PrefixDestination:109,,,,0s,0.77,0.5041,60s,60s +cgrates.org,RP1,,,,,,RT_110,*string:~*req.PrefixDestination:110,,,,0s,0.30,0.9540,60s,60s +cgrates.org,RP1,,,,,,RT_111,*string:~*req.PrefixDestination:111,,,,0s,0.85,0.3411,1s,1s +cgrates.org,RP1,,,,,,RT_112,*string:~*req.PrefixDestination:112,,,,0s,0.41,0.6961,60s,60s +cgrates.org,RP1,,,,,,RT_112,,,,,60s,0,0.3481,60s,1s +cgrates.org,RP1,,,,,,RT_113,*string:~*req.PrefixDestination:113,,,,0s,0.97,0.0835,60s,60s +cgrates.org,RP1,,,,,,RT_114,*string:~*req.PrefixDestination:114,,,,0s,0.62,0.5332,1s,1s +cgrates.org,RP1,,,,,,RT_115,*string:~*req.PrefixDestination:115,,,,0s,0.18,0.8658,60s,60s +cgrates.org,RP1,,,,,,RT_116,*string:~*req.PrefixDestination:116,,,,0s,0.74,0.2855,60s,60s +cgrates.org,RP1,,,,,,RT_117,*string:~*req.PrefixDestination:117,,,,0s,0.27,0.7347,1s,1s +cgrates.org,RP1,,,,,,RT_118,*string:~*req.PrefixDestination:118,,,,0s,0.82,0.1221,1s,1s +cgrates.org,RP1,,,,,,RT_119,*string:~*req.PrefixDestination:119,,,,0s,0.38,0.4470,60s,60s +cgrates.org,RP1,,,,,,RT_120,*string:~*req.PrefixDestination:120,,,,0s,0.94,0.8652,60s,60s +cgrates.org,RP1,,,,,,RT_121,*string:~*req.PrefixDestination:121,,,,0s,0.47,0.3142,1s,1s +cgrates.org,RP1,,,,,,RT_122,*string:~*req.PrefixDestination:122,,,,0s,0.03,0.7013,1s,1s +cgrates.org,RP1,,,,,,RT_123,*string:~*req.PrefixDestination:123,,,,0s,0.58,0.0262,60s,60s +cgrates.org,RP1,,,,,,RT_123,,,,,60s,0,0.0131,60s,1s +cgrates.org,RP1,,,,,,RT_124,*string:~*req.PrefixDestination:124,,,,0s,0.11,0.4445,60s,60s +cgrates.org,RP1,,,,,,RT_124,,,,,60s,0,0.2223,60s,1s +cgrates.org,RP1,,,,,,RT_125,*string:~*req.PrefixDestination:125,,,,0s,0.66,0.8838,60s,60s +cgrates.org,RP1,,,,,,RT_126,*string:~*req.PrefixDestination:126,,,,0s,0.22,0.2708,1s,1s +cgrates.org,RP1,,,,,,RT_127,*string:~*req.PrefixDestination:127,,,,0s,0.78,0.5953,1s,1s +cgrates.org,RP1,,,,,,RT_128,*string:~*req.PrefixDestination:128,,,,0s,0.43,0.0140,1s,1s +cgrates.org,RP1,,,,,,RT_129,*string:~*req.PrefixDestination:129,,,,0s,0.99,0.4636,60s,60s +cgrates.org,RP1,,,,,,RT_130,*string:~*req.PrefixDestination:130,,,,0s,0.55,0.8502,1s,1s +cgrates.org,RP1,,,,,,RT_131,*string:~*req.PrefixDestination:131,,,,0s,0.07,0.1749,60s,60s +cgrates.org,RP1,,,,,,RT_132,*string:~*req.PrefixDestination:132,,,,0s,0.64,0.5932,60s,60s +cgrates.org,RP1,,,,,,RT_132,,,,,60s,0,0.2966,60s,1s +cgrates.org,RP1,,,,,,RT_133,*string:~*req.PrefixDestination:133,,,,0s,0.19,0.0430,60s,60s +cgrates.org,RP1,,,,,,RT_133,,,,,60s,0,0.0215,60s,1s +cgrates.org,RP1,,,,,,RT_134,*string:~*req.PrefixDestination:134,,,,0s,0.74,0.4393,60s,60s +cgrates.org,RP1,,,,,,RT_135,*string:~*req.PrefixDestination:135,,,,0s,0.27,0.7635,60s,60s +cgrates.org,RP1,,,,,,RT_136,*string:~*req.PrefixDestination:136,,,,0s,0.83,0.1823,1s,1s +cgrates.org,RP1,,,,,,RT_137,*string:~*req.PrefixDestination:137,,,,0s,0.39,0.6319,1s,1s +cgrates.org,RP1,,,,,,RT_138,*string:~*req.PrefixDestination:138,,,,0s,0.92,0.0192,60s,60s +cgrates.org,RP1,,,,,,RT_138,,,,,60s,0,0.0096,60s,1s +cgrates.org,RP1,,,,,,RT_139,*string:~*req.PrefixDestination:139,,,,0s,0.47,0.3429,60s,60s +cgrates.org,RP1,,,,,,RT_140,*string:~*req.PrefixDestination:140,,,,0s,0.03,0.7614,60s,60s +cgrates.org,RP1,,,,,,RT_141,*string:~*req.PrefixDestination:141,,,,0s,0.59,0.2112,60s,60s +cgrates.org,RP1,,,,,,RT_142,*string:~*req.PrefixDestination:142,,,,0s,0.24,0.5984,1s,1s +cgrates.org,RP1,,,,,,RT_143,*string:~*req.PrefixDestination:143,,,,0s,0.80,0.9283,60s,60s +cgrates.org,RP1,,,,,,RT_143,,,,,60s,0,0.4642,60s,1s +cgrates.org,RP1,,,,,,RT_144,*string:~*req.PrefixDestination:144,,,,0s,0.35,0.3075,60s,60s +cgrates.org,RP1,,,,,,RT_145,*string:~*req.PrefixDestination:145,,,,0s,0.88,0.7885,60s,60s +cgrates.org,RP1,,,,,,RT_145,,,,,60s,0,0.3942,60s,1s +cgrates.org,RP1,,,,,,RT_146,*string:~*req.PrefixDestination:146,,,,0s,0.44,0.1760,60s,60s +cgrates.org,RP1,,,,,,RT_147,*string:~*req.PrefixDestination:147,,,,0s,0.00,0.5002,60s,60s +cgrates.org,RP1,,,,,,RT_147,,,,,60s,0,0.2501,60s,1s +cgrates.org,RP1,,,,,,RT_148,*string:~*req.PrefixDestination:148,,,,0s,0.55,0.8867,60s,60s +cgrates.org,RP1,,,,,,RT_148,,,,,60s,0,0.4434,60s,1s +cgrates.org,RP1,,,,,,RT_149,*string:~*req.PrefixDestination:149,,,,0s,0.08,0.3675,60s,60s +cgrates.org,RP1,,,,,,RT_149,,,,,60s,0,0.1837,60s,1s +cgrates.org,RP1,,,,,,RT_150,*string:~*req.PrefixDestination:150,,,,0s,0.63,0.7551,60s,60s +cgrates.org,RP1,,,,,,RT_151,*string:~*req.PrefixDestination:151,,,,0s,0.19,0.0796,1s,1s +cgrates.org,RP1,,,,,,RT_152,*string:~*req.PrefixDestination:152,,,,0s,0.75,0.4678,1s,1s +cgrates.org,RP1,,,,,,RT_153,*string:~*req.PrefixDestination:153,,,,0s,0.28,0.9489,60s,60s +cgrates.org,RP1,,,,,,RT_154,*string:~*req.PrefixDestination:154,,,,0s,0.84,0.2815,60s,60s +cgrates.org,RP1,,,,,,RT_155,*string:~*req.PrefixDestination:155,,,,0s,0.40,0.6686,1s,1s +cgrates.org,RP1,,,,,,RT_156,*string:~*req.PrefixDestination:156,,,,0s,0.05,0.1175,1s,1s +cgrates.org,RP1,,,,,,RT_157,*string:~*req.PrefixDestination:157,,,,0s,0.61,0.5358,1s,1s +cgrates.org,RP1,,,,,,RT_158,*string:~*req.PrefixDestination:158,,,,0s,0.16,0.8607,60s,60s +cgrates.org,RP1,,,,,,RT_158,,,,,60s,0,0.4303,60s,1s +cgrates.org,RP1,,,,,,RT_159,*string:~*req.PrefixDestination:159,,,,0s,0.72,0.2478,60s,60s +cgrates.org,RP1,,,,,,RT_160,*string:~*req.PrefixDestination:160,,,,0s,0.25,0.6975,60s,60s +cgrates.org,RP1,,,,,,RT_161,*string:~*req.PrefixDestination:161,,,,0s,0.80,0.1133,60s,60s +cgrates.org,RP1,,,,,,RT_162,*string:~*req.PrefixDestination:162,,,,0s,0.36,0.4376,60s,60s +cgrates.org,RP1,,,,,,RT_163,*string:~*req.PrefixDestination:163,,,,0s,0.89,0.8174,60s,60s +cgrates.org,RP1,,,,,,RT_163,,,,,60s,0,0.4087,60s,1s +cgrates.org,RP1,,,,,,RT_164,*string:~*req.PrefixDestination:164,,,,0s,0.44,0.2670,60s,60s +cgrates.org,RP1,,,,,,RT_164,,,,,60s,0,0.1335,60s,1s +cgrates.org,RP1,,,,,,RT_165,*string:~*req.PrefixDestination:165,,,,0s,0.00,0.6847,1s,1s +cgrates.org,RP1,,,,,,RT_166,*string:~*req.PrefixDestination:166,,,,0s,0.56,0.0094,1s,1s +cgrates.org,RP1,,,,,,RT_167,*string:~*req.PrefixDestination:167,,,,0s,0.08,0.3963,60s,60s +cgrates.org,RP1,,,,,,RT_167,,,,,60s,0,0.1982,60s,1s +cgrates.org,RP1,,,,,,RT_168,*string:~*req.PrefixDestination:168,,,,0s,0.65,0.8463,1s,1s +cgrates.org,RP1,,,,,,RT_169,*string:~*req.PrefixDestination:169,,,,0s,0.21,0.2648,1s,1s +cgrates.org,RP1,,,,,,RT_170,*string:~*req.PrefixDestination:170,,,,0s,0.86,0.5905,60s,60s +cgrates.org,RP1,,,,,,RT_171,*string:~*req.PrefixDestination:171,,,,0s,0.42,0.9778,60s,60s +cgrates.org,RP1,,,,,,RT_171,,,,,60s,0,0.4889,60s,1s +cgrates.org,RP1,,,,,,RT_172,*string:~*req.PrefixDestination:172,,,,0s,0.97,0.4273,60s,60s +cgrates.org,RP1,,,,,,RT_173,*string:~*req.PrefixDestination:173,,,,0s,0.53,0.8537,60s,60s +cgrates.org,RP1,,,,,,RT_173,,,,,60s,0,0.4269,60s,1s +cgrates.org,RP1,,,,,,RT_174,*string:~*req.PrefixDestination:174,,,,0s,0.06,0.1779,60s,60s +cgrates.org,RP1,,,,,,RT_175,*string:~*req.PrefixDestination:175,,,,0s,0.61,0.5646,1s,1s +cgrates.org,RP1,,,,,,RT_176,*string:~*req.PrefixDestination:176,,,,0s,0.17,0.0144,1s,1s +cgrates.org,RP1,,,,,,RT_177,*string:~*req.PrefixDestination:177,,,,0s,0.70,0.4329,60s,60s +cgrates.org,RP1,,,,,,RT_178,*string:~*req.PrefixDestination:178,,,,0s,0.25,0.7576,60s,60s +cgrates.org,RP1,,,,,,RT_178,,,,,60s,0,0.3788,60s,1s +cgrates.org,RP1,,,,,,RT_179,*string:~*req.PrefixDestination:179,,,,0s,0.81,0.1499,1s,1s +cgrates.org,RP1,,,,,,RT_180,*string:~*req.PrefixDestination:180,,,,0s,0.37,0.5996,1s,1s +cgrates.org,RP1,,,,,,RT_181,*string:~*req.PrefixDestination:181,,,,0s,0.89,0.9870,60s,60s +cgrates.org,RP1,,,,,,RT_181,,,,,60s,0,0.4935,60s,1s +cgrates.org,RP1,,,,,,RT_182,*string:~*req.PrefixDestination:182,,,,0s,0.45,0.3348,60s,60s +cgrates.org,RP1,,,,,,RT_182,,,,,60s,0,0.1674,60s,1s +cgrates.org,RP1,,,,,,RT_183,*string:~*req.PrefixDestination:183,,,,0s,0.02,0.7215,60s,60s +cgrates.org,RP1,,,,,,RT_184,*string:~*req.PrefixDestination:184,,,,0s,0.66,0.1708,60s,60s +cgrates.org,RP1,,,,,,RT_185,*string:~*req.PrefixDestination:185,,,,0s,0.23,0.5584,60s,60s +cgrates.org,RP1,,,,,,RT_185,,,,,60s,0,0.2792,60s,1s +cgrates.org,RP1,,,,,,RT_186,*string:~*req.PrefixDestination:186,,,,0s,0.78,0.9143,60s,60s +cgrates.org,RP1,,,,,,RT_187,*string:~*req.PrefixDestination:187,,,,0s,0.33,0.3012,1s,1s +cgrates.org,RP1,,,,,,RT_188,*string:~*req.PrefixDestination:188,,,,0s,0.86,0.7522,1s,1s +cgrates.org,RP1,,,,,,RT_189,*string:~*req.PrefixDestination:189,,,,0s,0.42,0.1394,1s,1s +cgrates.org,RP1,,,,,,RT_190,*string:~*req.PrefixDestination:190,,,,0s,0.97,0.4955,1s,1s +cgrates.org,RP1,,,,,,RT_191,*string:~*req.PrefixDestination:191,,,,0s,0.51,0.8824,60s,60s +cgrates.org,RP1,,,,,,RT_191,,,,,60s,0,0.4412,60s,1s +cgrates.org,RP1,,,,,,RT_192,*string:~*req.PrefixDestination:192,,,,0s,0.06,0.3393,60s,60s +cgrates.org,RP1,,,,,,RT_193,*string:~*req.PrefixDestination:193,,,,0s,0.62,0.6639,1s,1s +cgrates.org,RP1,,,,,,RT_194,*string:~*req.PrefixDestination:194,,,,0s,0.18,0.0824,1s,1s +cgrates.org,RP1,,,,,,RT_195,*string:~*req.PrefixDestination:195,,,,0s,0.70,0.5322,60s,60s +cgrates.org,RP1,,,,,,RT_196,*string:~*req.PrefixDestination:196,,,,0s,0.26,0.9193,60s,60s +cgrates.org,RP1,,,,,,RT_196,,,,,60s,0,0.4597,60s,1s +cgrates.org,RP1,,,,,,RT_197,*string:~*req.PrefixDestination:197,,,,0s,0.82,0.2411,1s,1s +cgrates.org,RP1,,,,,,RT_198,*string:~*req.PrefixDestination:198,,,,0s,0.47,0.6596,60s,60s +cgrates.org,RP1,,,,,,RT_198,,,,,60s,0,0.3298,60s,1s +cgrates.org,RP1,,,,,,RT_199,*string:~*req.PrefixDestination:199,,,,0s,0.03,0.1095,60s,60s \ No newline at end of file diff --git a/data/tariffplans/oldaccvsnew/RateProfiles.csv b/data/tariffplans/oldaccvsnew/RateProfiles.csv index 48b90d455..b785d7439 100644 --- a/data/tariffplans/oldaccvsnew/RateProfiles.csv +++ b/data/tariffplans/oldaccvsnew/RateProfiles.csv @@ -1,3 +1,3 @@ -#Tenant,ID,FilterIDs,ActivationInterval,Weight,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeight,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement -cgrates.org,RP_ANY,,,,,,,RT_ANY,,,,,0s,0,0.2,60s,60s -cgrates.org,RP_ANY,,,,,,,RT_ANY,,,,,60s,0,0.1,60s,1s \ No newline at end of file +#Tenant,ID,FilterIDs,Weight,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeight,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement +cgrates.org,RP_ANY,,,,,,RT_ANY,,,,,0s,0,0.2,60s,60s +cgrates.org,RP_ANY,,,,,,RT_ANY,,,,,60s,0,0.1,60s,1s \ No newline at end of file diff --git a/data/tariffplans/testit/RateProfiles.csv b/data/tariffplans/testit/RateProfiles.csv index 353008802..adeb31216 100644 --- a/data/tariffplans/testit/RateProfiles.csv +++ b/data/tariffplans/testit/RateProfiles.csv @@ -1,5 +1,5 @@ -#Tenant,ID,FilterIDs,ActivationInterval,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement -cgrates.org,RT_SPECIAL_1002,*string:~*req.Account:1002,,;10,0,0,*free,RT_ALWAYS,,"* * * * *",;0,false,0s,,0.01,1m,1s -cgrates.org,RT_RETAIL1,,,;0,0,0,*free,RT_ALWAYS,,"* * * * *",;0,false,0s,,0.4,1m,30s -cgrates.org,RT_RETAIL1,,,,,,,RT_ALWAYS,,"* * * * *",;0,false,1m,,0.2,1m,10s +#Tenant,ID,FilterIDs,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement +cgrates.org,RT_SPECIAL_1002,*string:~*req.Account:1002,;10,0,0,*free,RT_ALWAYS,,"* * * * *",;0,false,0s,,0.01,1m,1s +cgrates.org,RT_RETAIL1,,;0,0,0,*free,RT_ALWAYS,,"* * * * *",;0,false,0s,,0.4,1m,30s +cgrates.org,RT_RETAIL1,,,,,,RT_ALWAYS,,"* * * * *",;0,false,1m,,0.2,1m,10s diff --git a/data/tariffplans/tutrates/RateProfiles.csv b/data/tariffplans/tutrates/RateProfiles.csv index 5cd0711df..522637787 100644 --- a/data/tariffplans/tutrates/RateProfiles.csv +++ b/data/tariffplans/tutrates/RateProfiles.csv @@ -1,5 +1,5 @@ -#Tenant,ID,FilterIDs,ActivationInterval,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement -cgrates.org,RP1,*string:~*req.Subject:1001,,;0,0.1,0.6,*free,RT_WEEK,,"* * * * 1-5",;0,false,0s,,0.12,1m,1m +#Tenant,ID,FilterIDs,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement +cgrates.org,RP1,*string:~*req.Subject:1001,;0,0.1,0.6,*free,RT_WEEK,,"* * * * 1-5",;0,false,0s,,0.12,1m,1m cgrates.org,RP1,,,,,,,RT_WEEK,,,,,1m,,0.6,1m,1s cgrates.org,RP1,,,,,,,RT_WEEKEND,,"* * * * 0,6",;10,false,0s,,0.06,1m,1s cgrates.org,RP1,,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,,0.06,1m,1s \ No newline at end of file diff --git a/engine/libtest.go b/engine/libtest.go index 8bb55adeb..6d22fa056 100644 --- a/engine/libtest.go +++ b/engine/libtest.go @@ -145,11 +145,11 @@ cgrates.org,D1,,,,*first,,C2,*lt:~*req.Usage:10,10,false,192.168.56.204 cgrates.org,ALL1,127.0.0.1:2012,*json,true ` RateProfileCSVContent = ` -#Tenant,ID,FilterIDs,ActivationInterval,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement -cgrates.org,RP1,*string:~*req.Subject:1001,,;0,0.1,0.6,*free,RT_WEEK,,"* * * * 1-5",;0,false,0s,0,0.12,1m,1m -cgrates.org,RP1,,,,,,,RT_WEEK,,,,,1m,1.234,0.06,1m,1s -cgrates.org,RP1,,,,,,,RT_WEEKEND,,"* * * * 0,6",;10,false,0s,0.089,0.06,1m,1s -cgrates.org,RP1,,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,0.0564,0.06,1m,1s +#Tenant,ID,FilterIDs,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationStart,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement +cgrates.org,RP1,*string:~*req.Subject:1001,;0,0.1,0.6,*free,RT_WEEK,,"* * * * 1-5",;0,false,0s,0,0.12,1m,1m +cgrates.org,RP1,,,,,,RT_WEEK,,,,,1m,1.234,0.06,1m,1s +cgrates.org,RP1,,,,,,RT_WEEKEND,,"* * * * 0,6",;10,false,0s,0.089,0.06,1m,1s +cgrates.org,RP1,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,0.0564,0.06,1m,1s ` ActionProfileCSVContent = ` #Tenant,ID,FilterIDs,ActivationInterval,Weight,Schedule,TargetType,TargetIDs,ActionID,ActionFilterIDs,ActionBlocker,ActionTTL,ActionType,ActionOpts,ActionPath,ActionValue diff --git a/engine/model_helpers.go b/engine/model_helpers.go index 352e497cb..968f78cbe 100644 --- a/engine/model_helpers.go +++ b/engine/model_helpers.go @@ -1953,16 +1953,6 @@ func (tps RateProfileMdls) AsTPRateProfile() (result []*utils.TPRateProfile) { if tp.MaxCostStrategy != utils.EmptyString { rPrf.MaxCostStrategy = tp.MaxCostStrategy } - if tp.ActivationInterval != utils.EmptyString { - rPrf.ActivationInterval = new(utils.TPActivationInterval) - aiSplt := strings.Split(tp.ActivationInterval, utils.InfieldSep) - if len(aiSplt) == 2 { - rPrf.ActivationInterval.ActivationTime = aiSplt[0] - rPrf.ActivationInterval.ExpiryTime = aiSplt[1] - } else if len(aiSplt) == 1 { - rPrf.ActivationInterval.ActivationTime = aiSplt[0] - } - } if tp.FilterIDs != utils.EmptyString { if _, has := filterMap[tenID]; !has { filterMap[tenID] = make(utils.StringSet) @@ -2002,14 +1992,6 @@ func APItoModelTPRateProfile(tPrf *utils.TPRateProfile) (mdls RateProfileMdls) { mdl.FilterIDs += val } - if tPrf.ActivationInterval != nil { - if tPrf.ActivationInterval.ActivationTime != utils.EmptyString { - mdl.ActivationInterval = tPrf.ActivationInterval.ActivationTime - } - if tPrf.ActivationInterval.ExpiryTime != utils.EmptyString { - mdl.ActivationInterval += utils.InfieldSep + tPrf.ActivationInterval.ExpiryTime - } - } mdl.Weights = tPrf.Weights mdl.MinCost = tPrf.MinCost mdl.MaxCost = tPrf.MaxCost @@ -2061,11 +2043,6 @@ func APItoRateProfile(tpRp *utils.TPRateProfile, timezone string) (rp *utils.Rat for i, stp := range tpRp.FilterIDs { rp.FilterIDs[i] = stp } - if tpRp.ActivationInterval != nil { - if rp.ActivationInterval, err = tpRp.ActivationInterval.AsActivationInterval(timezone); err != nil { - return nil, err - } - } for key, rate := range tpRp.Rates { rp.Rates[key] = &utils.Rate{ ID: rate.ID, @@ -2101,13 +2078,12 @@ func APItoRateProfile(tpRp *utils.TPRateProfile, timezone string) (rp *utils.Rat func RateProfileToAPI(rp *utils.RateProfile) (tpRp *utils.TPRateProfile) { tpRp = &utils.TPRateProfile{ - Tenant: rp.Tenant, - ID: rp.ID, - FilterIDs: make([]string, len(rp.FilterIDs)), - ActivationInterval: new(utils.TPActivationInterval), - Weights: rp.Weights.String(";", "&"), - MaxCostStrategy: rp.MaxCostStrategy, - Rates: make(map[string]*utils.TPRate), + Tenant: rp.Tenant, + ID: rp.ID, + FilterIDs: make([]string, len(rp.FilterIDs)), + Weights: rp.Weights.String(";", "&"), + MaxCostStrategy: rp.MaxCostStrategy, + Rates: make(map[string]*utils.TPRate), } if rp.MinCost != nil { //there should not be an invalid value of converting from Decimal into float64 @@ -2154,14 +2130,6 @@ func RateProfileToAPI(rp *utils.RateProfile) (tpRp *utils.TPRateProfile) { for i, fli := range rp.FilterIDs { tpRp.FilterIDs[i] = fli } - if rp.ActivationInterval != nil { - if !rp.ActivationInterval.ActivationTime.IsZero() { - tpRp.ActivationInterval.ActivationTime = rp.ActivationInterval.ActivationTime.Format(time.RFC3339) - } - if !rp.ActivationInterval.ExpiryTime.IsZero() { - tpRp.ActivationInterval.ExpiryTime = rp.ActivationInterval.ExpiryTime.Format(time.RFC3339) - } - } return } diff --git a/engine/model_helpers_test.go b/engine/model_helpers_test.go index 0c1d8c9b2..3b4fb8b1e 100644 --- a/engine/model_helpers_test.go +++ b/engine/model_helpers_test.go @@ -2612,14 +2612,10 @@ func TestRateProfileToAPI(t *testing.T) { }, } eTPRatePrf := &utils.TPRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - Weights: ";0", - ActivationInterval: &utils.TPActivationInterval{ - ActivationTime: "", - ExpiryTime: "", - }, + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Subject:1001"}, + Weights: ";0", MinCost: 0.1, MaxCost: 0.6, MaxCostStrategy: "*free", @@ -2872,9 +2868,6 @@ func TestAPIToRateProfileError(t *testing.T) { tpRprf := &utils.TPRateProfile{ Tenant: "cgrates.org", ID: "RP1", - ActivationInterval: &utils.TPActivationInterval{ - ExpiryTime: "NOT_A_TIME", - }, Rates: map[string]*utils.TPRate{ "RT_WEEK": { ID: "RT_WEEK", @@ -2890,13 +2883,8 @@ func TestAPIToRateProfileError(t *testing.T) { }, }, } - expectedErr := "Unsupported time format" - if _, err := APItoRateProfile(tpRprf, "UTC"); err == nil || err.Error() != expectedErr { - t.Errorf("Expected %+v, received %+v", expectedErr, err) - } - expectedErr = "strconv.ParseInt: parsing \"NOT_A_TIME\": invalid syntax" - tpRprf.ActivationInterval = nil + expectedErr := "strconv.ParseInt: parsing \"NOT_A_TIME\": invalid syntax" if _, err := APItoRateProfile(tpRprf, "UTC"); err == nil || err.Error() != expectedErr { t.Errorf("Expected %+v, received %+q", expectedErr, err) } @@ -2942,7 +2930,6 @@ func TestAPItoModelTPRateProfile(t *testing.T) { Tenant: "cgrates.org", ID: "RP1", FilterIDs: "*string:~*req.Subject:1001", - ActivationInterval: "", Weights: ";0", MinCost: 0.1, MaxCost: 0.6, @@ -2964,7 +2951,6 @@ func TestAPItoModelTPRateProfile(t *testing.T) { Tenant: "cgrates.org", ID: "RP1", FilterIDs: "", - ActivationInterval: "", Weights: ";0", MinCost: 0, MaxCost: 0, @@ -2988,7 +2974,6 @@ func TestAPItoModelTPRateProfile(t *testing.T) { Tenant: "cgrates.org", ID: "RP1", FilterIDs: "*string:~*req.Subject:1001", - ActivationInterval: "", Weights: ";0", MinCost: 0.1, MaxCost: 0.6, @@ -3010,7 +2995,6 @@ func TestAPItoModelTPRateProfile(t *testing.T) { Tenant: "cgrates.org", ID: "RP1", FilterIDs: "", - ActivationInterval: "", Weights: "", MinCost: 0, MaxCost: 0, @@ -3041,7 +3025,6 @@ func TestAsTPRateProfile(t *testing.T) { Tenant: "cgrates.org", ID: "RP1", FilterIDs: "*string:~*req.Subject:1001", - ActivationInterval: "", Weights: ";0", MinCost: 0.1, MaxCost: 0.6, @@ -3063,7 +3046,6 @@ func TestAsTPRateProfile(t *testing.T) { Tenant: "cgrates.org", ID: "RP1", FilterIDs: "", - ActivationInterval: "", Weights: ";0", MinCost: 0, MaxCost: 0, @@ -3399,13 +3381,7 @@ func TestRateProfileToAPIWithActInterval(t *testing.T) { testProfile := &utils.RateProfile{ Tenant: "cgrates.org", ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - ActivationInterval: &utils.ActivationInterval{ - ActivationTime: time.Date(2020, time.April, - 11, 21, 34, 01, 0, time.UTC), - ExpiryTime: time.Date(2020, time.April, - 12, 21, 34, 01, 0, time.UTC), - }, + FilterIDs: []string{"*string:~*req.Subject:1001", "*ai:~*req.AnswerTime:2020-04-11T21:34:01Z|2020-04-12T21:34:01Z"}, Weights: utils.DynamicWeights{ { Weight: 0, @@ -3418,13 +3394,9 @@ func TestRateProfileToAPIWithActInterval(t *testing.T) { } expStruct := &utils.TPRateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - ActivationInterval: &utils.TPActivationInterval{ - ActivationTime: "2020-04-11T21:34:01Z", - ExpiryTime: "2020-04-12T21:34:01Z", - }, + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Subject:1001", "*ai:~*req.AnswerTime:2020-04-11T21:34:01Z|2020-04-12T21:34:01Z"}, Weights: ";0", MinCost: 0.1, MaxCost: 0.6, @@ -3448,11 +3420,7 @@ func TestAPItoModelTPRateProfileNil(t *testing.T) { func TestAPItoModelTPRateProfileCase2(t *testing.T) { testStruct := &utils.TPRateProfile{ - FilterIDs: []string{"test_string1", "test_string2"}, - ActivationInterval: &utils.TPActivationInterval{ - ActivationTime: "2014-07-29T15:00:00Z", - ExpiryTime: "2014-08-29T15:00:00Z", - }, + FilterIDs: []string{"test_string1", "test_string2", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-08-29T15:00:00Z"}, Rates: map[string]*utils.TPRate{"RT_CHRISTMAS": { ID: "RT_CHRISTMAS", FilterIDs: []string{"test_string1", "test_string2"}, @@ -3470,8 +3438,7 @@ func TestAPItoModelTPRateProfileCase2(t *testing.T) { }, } expStruct := RateProfileMdls{{ - FilterIDs: "test_string1;test_string2", - ActivationInterval: "2014-07-29T15:00:00Z;2014-08-29T15:00:00Z", + FilterIDs: "test_string1;test_string2;*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-08-29T15:00:00Z", RateID: "RT_CHRISTMAS", RateFilterIDs: "test_string1;test_string2", RateWeights: ";30", @@ -3660,29 +3627,24 @@ func TestChargerProfileToAPILastCase(t *testing.T) { func TestRateProfileMdlsAsTPRateProfileCase2(t *testing.T) { testRPMdls := RateProfileMdls{&RateProfileMdl{ - Tpid: "", - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: "*string:~*req.Subject:1001", - ActivationInterval: "2014-07-29T15:00:00Z;2014-08-29T15:00:00Z", - Weights: ";1.2", - MinCost: 0.1, - MaxCost: 0.6, - MaxCostStrategy: "*free", - RateID: "0", - RateFilterIDs: "test_filter_id", - RateWeights: ";2", + Tpid: "", + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: "*string:~*req.Subject:1001;*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-08-29T15:00:00Z", + Weights: ";1.2", + MinCost: 0.1, + MaxCost: 0.6, + MaxCostStrategy: "*free", + RateID: "0", + RateFilterIDs: "test_filter_id", + RateWeights: ";2", }, } expStruct := []*utils.TPRateProfile{ {TPid: "", - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - ActivationInterval: &utils.TPActivationInterval{ - ActivationTime: "2014-07-29T15:00:00Z", - ExpiryTime: "2014-08-29T15:00:00Z", - }, + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*string:~*req.Subject:1001", "*ai:~*req.AnswerTime:2014-07-29T15:00:00Z|2014-08-29T15:00:00Z"}, Weights: ";1.2", MinCost: 0.1, MaxCost: 0.6, @@ -3714,28 +3676,24 @@ func TestRateProfileMdlsAsTPRateProfileCase2(t *testing.T) { func TestRateProfileMdlsAsTPRateProfileCase3(t *testing.T) { testRPMdls := RateProfileMdls{&RateProfileMdl{ - Tpid: "", - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: "*string:~*req.Subject:1001", - ActivationInterval: "2014-07-29T15:00:00Z", - Weights: ";1.2", - MinCost: 0.1, - MaxCost: 0.6, - MaxCostStrategy: "*free", - RateID: "0", - RateFilterIDs: "test_filter_id", - RateWeights: ";2", + Tpid: "", + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: "*string:~*req.Subject:1001;*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", + Weights: ";1.2", + MinCost: 0.1, + MaxCost: 0.6, + MaxCostStrategy: "*free", + RateID: "0", + RateFilterIDs: "test_filter_id", + RateWeights: ";2", }, } expStruct := []*utils.TPRateProfile{ {TPid: "", - Tenant: "cgrates.org", - ID: "RP1", - FilterIDs: []string{"*string:~*req.Subject:1001"}, - ActivationInterval: &utils.TPActivationInterval{ - ActivationTime: "2014-07-29T15:00:00Z", - }, + Tenant: "cgrates.org", + ID: "RP1", + FilterIDs: []string{"*ai:~*req.AnswerTime:2014-07-29T15:00:00Z", "*string:~*req.Subject:1001"}, Weights: ";1.2", MinCost: 0.1, MaxCost: 0.6, @@ -3759,6 +3717,7 @@ func TestRateProfileMdlsAsTPRateProfileCase3(t *testing.T) { }, } result := testRPMdls.AsTPRateProfile() + sort.Strings(result[0].FilterIDs) if !reflect.DeepEqual(result, expStruct) { t.Errorf("\nExpecting <%+v>,\n Received <%+v>", utils.ToJSON(expStruct), utils.ToJSON(result)) } diff --git a/engine/models.go b/engine/models.go index f0d679a18..1131debca 100644 --- a/engine/models.go +++ b/engine/models.go @@ -323,21 +323,20 @@ type RateProfileMdl struct { Tenant string `index:"0" re:""` ID string `index:"1" re:""` FilterIDs string `index:"2" re:""` - ActivationInterval string `index:"3" re:""` - Weights string `index:"4" re:""` - MinCost float64 `index:"5" re:"\d+\.?\d*""` - MaxCost float64 `index:"6" re:"\d+\.?\d*"` - MaxCostStrategy string `index:"7" re:""` - RateID string `index:"8" re:""` - RateFilterIDs string `index:"9" re:""` - RateActivationTimes string `index:"10" re:""` - RateWeights string `index:"11" re:""` - RateBlocker bool `index:"12" re:""` - RateIntervalStart string `index:"13" re:""` - RateFixedFee float64 `index:"14" re:"\d+\.?\d*"` - RateRecurrentFee float64 `index:"15" re:"\d+\.?\d*"` - RateUnit string `index:"16" re:""` - RateIncrement string `index:"17" re:""` + Weights string `index:"3" re:""` + MinCost float64 `index:"4" re:"\d+\.?\d*""` + MaxCost float64 `index:"5" re:"\d+\.?\d*"` + MaxCostStrategy string `index:"6" re:""` + RateID string `index:"7" re:""` + RateFilterIDs string `index:"8" re:""` + RateActivationTimes string `index:"9" re:""` + RateWeights string `index:"10" re:""` + RateBlocker bool `index:"11" re:""` + RateIntervalStart string `index:"12" re:""` + RateFixedFee float64 `index:"13" re:"\d+\.?\d*"` + RateRecurrentFee float64 `index:"14" re:"\d+\.?\d*"` + RateUnit string `index:"15" re:""` + RateIncrement string `index:"16" re:""` CreatedAt time.Time } diff --git a/general_tests/export_it_test.go b/general_tests/export_it_test.go index 06bd52621..92ed759d5 100644 --- a/general_tests/export_it_test.go +++ b/general_tests/export_it_test.go @@ -376,10 +376,9 @@ func testExpVerifyRateProfiles(t *testing.T) { } splPrf := &utils.RateProfile{ - Tenant: "cgrates.org", - ID: "RT_SPECIAL_1002", - FilterIDs: []string{"*string:~*req.Account:1002"}, - ActivationInterval: nil, + Tenant: "cgrates.org", + ID: "RT_SPECIAL_1002", + FilterIDs: []string{"*string:~*req.Account:1002"}, Weights: utils.DynamicWeights{ { Weight: 10, diff --git a/loaders/loader_test.go b/loaders/loader_test.go index 2ce0ac032..6bd1db44a 100644 --- a/loaders/loader_test.go +++ b/loaders/loader_test.go @@ -64,8 +64,8 @@ func TestLoaderProcessContentSingleFile(t *testing.T) { Path: "FilterIDs", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, - {Tag: "ActivationInterval", - Path: "ActivationInterval", + {Tag: "Weight", + Path: "Weight", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.4", utils.InfieldSep)}, {Tag: "AttributeFilterIDs", @@ -88,10 +88,6 @@ func TestLoaderProcessContentSingleFile(t *testing.T) { Path: "Blocker", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.9", utils.InfieldSep)}, - {Tag: "Weight", - Path: "Weight", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, }, } rdr := io.NopCloser(strings.NewReader(engine.AttributesCSVContent)) @@ -277,8 +273,8 @@ func TestLoaderProcessResource(t *testing.T) { Path: "FilterIDs", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.2", utils.InfieldSep)}, - {Tag: "ActivationInterval", - Path: "ActivationInterval", + {Tag: "Weight", + Path: "Weight", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, {Tag: "TTL", @@ -301,14 +297,10 @@ func TestLoaderProcessResource(t *testing.T) { Path: "Stored", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.8", utils.InfieldSep)}, - {Tag: "Weight", - Path: "Weight", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.9", utils.InfieldSep)}, {Tag: "Thresholds", Path: "Thresholds", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.9", utils.InfieldSep)}, }, } rdr := io.NopCloser(strings.NewReader(engine.ResourcesCSVContent)) @@ -328,7 +320,7 @@ func TestLoaderProcessResource(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, UsageTTL: time.Second, AllocationMessage: "call", - Weight: 0, + Weight: 10, Limit: 2, Blocker: true, Stored: true, @@ -340,7 +332,7 @@ func TestLoaderProcessResource(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:dan"}, UsageTTL: 3600 * time.Second, AllocationMessage: "premium_call", - Weight: 0, + Weight: 10, Limit: 2, Blocker: true, Stored: true, @@ -841,8 +833,8 @@ func TestLoaderProcessRoutes(t *testing.T) { Path: "FilterIDs", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.2", utils.InfieldSep)}, - {Tag: "ActivationInterval", - Path: "ActivationInterval", + {Tag: "Weight", + Path: "Weight", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, {Tag: "Sorting", @@ -889,10 +881,6 @@ func TestLoaderProcessRoutes(t *testing.T) { Path: "RouteParameters", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.14", utils.InfieldSep)}, - {Tag: "Weight", - Path: "Weight", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.15", utils.InfieldSep)}, }, } rdr := io.NopCloser(strings.NewReader(engine.RoutesCSVContent)) @@ -949,7 +937,7 @@ func TestLoaderProcessRoutes(t *testing.T) { RouteParameters: utils.EmptyString, }, }, - Weight: 0, + Weight: 20, } sort.Slice(eSp.Routes, func(i, j int) bool { return strings.Compare(eSp.Routes[i].ID+strings.Join(eSp.Routes[i].FilterIDs, utils.ConcatenatedKeySep), @@ -1068,8 +1056,8 @@ func TestLoaderProcessChargers(t *testing.T) { Path: "FilterIDs", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.2", utils.InfieldSep)}, - {Tag: "ActivationInterval", - Path: "ActivationInterval", + {Tag: "Weight", + Path: "Weight", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, {Tag: "RunID", @@ -1080,10 +1068,6 @@ func TestLoaderProcessChargers(t *testing.T) { Path: "AttributeIDs", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.5", utils.InfieldSep)}, - {Tag: "Weight", - Path: "Weight", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.6", utils.InfieldSep)}, }, } rdr := io.NopCloser(strings.NewReader(engine.ChargersCSVContent)) @@ -1106,7 +1090,7 @@ func TestLoaderProcessChargers(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, RunID: "*rated", AttributeIDs: []string{"ATTR_1001_SIMPLEAUTH"}, - Weight: 0, + Weight: 20, } if rcv, err := ldr.dm.GetChargerProfile("cgrates.org", "Charger1", @@ -1169,8 +1153,8 @@ func TestLoaderProcessDispatches(t *testing.T) { Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep), }, { - Tag: "ActivationInterval", - Path: "ActivationInterval", + Tag: "Weight", + Path: "Weight", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.4", utils.InfieldSep), }, @@ -1216,12 +1200,6 @@ func TestLoaderProcessDispatches(t *testing.T) { Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.11", utils.InfieldSep), }, - { - Tag: "Weight", - Path: "Weight", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.12", utils.InfieldSep), - }, }, } rdr := io.NopCloser(strings.NewReader(engine.DispatcherCSVContent)) @@ -1249,7 +1227,7 @@ func TestLoaderProcessDispatches(t *testing.T) { FilterIDs: []string{"*string:~*req.Account:1001"}, StrategyParams: map[string]interface{}{}, Strategy: "*first", - Weight: 0, + Weight: 20, Hosts: engine.DispatcherHostProfiles{ &engine.DispatcherHostProfile{ ID: "C1", @@ -1523,66 +1501,62 @@ func TestLoaderProcessRateProfile(t *testing.T) { Path: "FilterIDs", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.2", utils.InfieldSep)}, - {Tag: "ActivationInterval", - Path: "ActivationInterval", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, {Tag: "Weights", Path: "Weights", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.4", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, {Tag: "MinCost", Path: "MinCost", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.5", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.4", utils.InfieldSep)}, {Tag: "MaxCost", Path: "MaxCost", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.6", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.5", utils.InfieldSep)}, {Tag: "MaxCostStrategy", Path: "MaxCostStrategy", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.7", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.6", utils.InfieldSep)}, {Tag: "RateID", Path: "RateID", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.8", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.7", utils.InfieldSep)}, {Tag: "RateFilterIDs", Path: "RateFilterIDs", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.9", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.8", utils.InfieldSep)}, {Tag: "RateActivationTimes", Path: "RateActivationTimes", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.9", utils.InfieldSep)}, {Tag: "RateWeights", Path: "RateWeights", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.11", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, {Tag: "RateBlocker", Path: "RateBlocker", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.12", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.11", utils.InfieldSep)}, {Tag: "RateIntervalStart", Path: "RateIntervalStart", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.13", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.12", utils.InfieldSep)}, {Tag: "RateFixedFee", Path: "RateFixedFee", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.14", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.13", utils.InfieldSep)}, {Tag: "RateRecurrentFee", Path: "RateRecurrentFee", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.15", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.14", utils.InfieldSep)}, {Tag: "RateUnit", Path: "RateUnit", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.16", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.15", utils.InfieldSep)}, {Tag: "RateIncrement", Path: "RateIncrement", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.17", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.16", utils.InfieldSep)}, }, } rdr := io.NopCloser(strings.NewReader(engine.RateProfileCSVContent)) @@ -1735,77 +1709,73 @@ func TestLoaderProcessRateProfileRates(t *testing.T) { Path: "FilterIDs", Type: utils.MetaComposed, Value: config.NewRSRParsersMustCompile("~*req.2", utils.InfieldSep)}, - {Tag: "ActivationInterval", - Path: "ActivationInterval", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, {Tag: "Weights", Path: "Weights", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.4", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.3", utils.InfieldSep)}, {Tag: "MinCost", Path: "MinCost", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.5", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.4", utils.InfieldSep)}, {Tag: "MaxCost", Path: "MaxCost", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.6", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.5", utils.InfieldSep)}, {Tag: "MaxCostStrategy", Path: "MaxCostStrategy", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.7", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.6", utils.InfieldSep)}, {Tag: "RateID", Path: "RateID", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.8", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.7", utils.InfieldSep)}, {Tag: "RateFilterIDs", Path: "RateFilterIDs", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.9", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.8", utils.InfieldSep)}, {Tag: "RateActivationTimes", Path: "RateActivationTimes", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.9", utils.InfieldSep)}, {Tag: "RateWeights", Path: "RateWeights", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.11", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.10", utils.InfieldSep)}, {Tag: "RateBlocker", Path: "RateBlocker", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.12", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.11", utils.InfieldSep)}, {Tag: "RateIntervalStart", Path: "RateIntervalStart", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.13", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.12", utils.InfieldSep)}, {Tag: "RateFixedFee", Path: "RateFixedFee", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.14", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.13", utils.InfieldSep)}, {Tag: "RateRecurrentFee", Path: "RateRecurrentFee", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.15", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.14", utils.InfieldSep)}, {Tag: "RateUnit", Path: "RateUnit", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.16", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.15", utils.InfieldSep)}, {Tag: "RateIncrement", Path: "RateIncrement", Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.17", utils.InfieldSep)}, + Value: config.NewRSRParsersMustCompile("~*req.16", utils.InfieldSep)}, }, } ratePrfCnt1 := ` -#Tenant,ID,FilterIDs,ActivationInterval,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationTimes,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement -cgrates.org,RP1,*string:~*req.Subject:1001,,;0,0.1,0.6,*free,RT_WEEK,,"* * * * 1-5",;0,false,0s,0.4,0.12,1m,1m -cgrates.org,RP1,,,,,,,RT_WEEK,,,,,1m,,0.06,1m,1s +#Tenant,ID,FilterIDs,Weights,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationTimes,RateWeights,RateBlocker,RateIntervalStart,RateFixedFee,RateRecurrentFee,RateUnit,RateIncrement +cgrates.org,RP1,*string:~*req.Subject:1001,;0,0.1,0.6,*free,RT_WEEK,,"* * * * 1-5",;0,false,0s,0.4,0.12,1m,1m +cgrates.org,RP1,,,,,,RT_WEEK,,,,,1m,,0.06,1m,1s ` ratePrfCnt2 := ` -#Tenant,ID,FilterIDs,ActivationInterval,Weights,RoundingMethod,RoundingDecimals,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationTimes,RateWeights,RateBlocker,RateIntervalStart,RateValue,RateUnit,RateIncrement -cgrates.org,RP1,,,,,,,RT_WEEKEND,,"* * * * 0,6",;10,false,0s,,0.06,1m,1s -cgrates.org,RP1,,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,,0.06,1m,1s +#Tenant,ID,FilterIDs,Weights,RoundingMethod,RoundingDecimals,MinCost,MaxCost,MaxCostStrategy,RateID,RateFilterIDs,RateActivationTimes,RateWeights,RateBlocker,RateIntervalStart,RateValue,RateUnit,RateIncrement +cgrates.org,RP1,,,,,,RT_WEEKEND,,"* * * * 0,6",;10,false,0s,,0.06,1m,1s +cgrates.org,RP1,,,,,,RT_CHRISTMAS,,* * 24 12 *,;30,false,0s,,0.06,1m,1s ` rdr1 := io.NopCloser(strings.NewReader(ratePrfCnt1)) csvRdr1 := csv.NewReader(rdr1) @@ -3342,44 +3312,6 @@ NOT_UINT } } -func TestLoadRateProfilesAsStructErrConversion(t *testing.T) { - data := engine.NewInternalDB(nil, nil, true) - ldr := &Loader{ - ldrID: "TestLoadRateProfilesAsStructErrConversion", - bufLoaderData: make(map[string][]LoaderData), - dm: engine.NewDataManager(data, config.CgrConfig().CacheCfg(), nil), - timezone: "UTC", - } - ldr.dataTpls = map[string][]*config.FCTemplate{ - utils.MetaRateProfiles: { - {Tag: "ActivationInterval", - Path: "ActivationInterval", - Type: utils.MetaComposed, - Value: config.NewRSRParsersMustCompile("~*req.0", utils.InfieldSep)}, - }, - } - thresholdsCsv := ` -#ActivationInterval -* * * * * * -` - rdr := io.NopCloser(strings.NewReader(thresholdsCsv)) - rdrCsv := csv.NewReader(rdr) - rdrCsv.Comment = '#' - ldr.rdrs = map[string]map[string]*openedCSVFile{ - utils.MetaRateProfiles: { - utils.RateProfilesCsv: &openedCSVFile{ - fileName: utils.RateProfilesCsv, - rdr: rdr, - csvRdr: rdrCsv, - }, - }, - } - expectedErr := "Unsupported time format" - if err := ldr.processContent(utils.MetaRateProfiles, utils.EmptyString); err == nil || err.Error() != expectedErr { - t.Errorf("Expected %+v, received %+v", expectedErr, err) - } -} - func TestLoadAccountsAsStructErrConversion(t *testing.T) { data := engine.NewInternalDB(nil, nil, true) ldr := &Loader{ diff --git a/rates/rates.go b/rates/rates.go index 5fad2b40f..3f2768369 100644 --- a/rates/rates.go +++ b/rates/rates.go @@ -95,15 +95,12 @@ func (rS *RateS) matchingRateProfileForEvent(ctx *context.Context, tnt string, r if rPf, err = rS.dm.GetRateProfile(ctx, tnt, rPfID, true, true, utils.NonTransactional); err != nil { if err == utils.ErrNotFound { + fmt.Println(err) err = nil continue } return } - if rPf.ActivationInterval != nil && args.CGREvent.Time != nil && - !rPf.ActivationInterval.IsActiveAtTime(*args.CGREvent.Time) { // not active - continue - } var pass bool if pass, err = rS.filterS.Pass(ctx, tnt, rPf.FilterIDs, evNm); err != nil { return diff --git a/rates/rates_test.go b/rates/rates_test.go index b462206c5..09414b60b 100644 --- a/rates/rates_test.go +++ b/rates/rates_test.go @@ -58,59 +58,6 @@ func TestNewRateS(t *testing.T) { } } -func TestMatchingRateProfileForEventActivationInterval(t *testing.T) { - dftCfg := config.NewDefaultCGRConfig() - - data := engine.NewInternalDB(nil, nil, true) - dm := engine.NewDataManager(data, dftCfg.CacheCfg(), nil) - filterS := engine.NewFilterS(dftCfg, nil, dm) - rateS := RateS{ - cfg: dftCfg, - filterS: filterS, - dm: dm, - } - - rPrf := &utils.RateProfile{ - Tenant: "cgrates.org", - ID: "RP1", - Weights: utils.DynamicWeights{ - { - Weight: 10, - }, - }, - FilterIDs: []string{"*string:~*req.Account:1001|1002|1003", "*prefix:~*req.Destination:10"}, - ActivationInterval: &utils.ActivationInterval{ - ActivationTime: time.Date(2020, 7, 21, 0, 0, 0, 0, time.UTC), - ExpiryTime: time.Date(2020, 7, 21, 10, 0, 0, 0, time.UTC), - }, - } - - err := dm.SetRateProfile(context.Background(), rPrf, true) - if err != nil { - t.Error(err) - } - if _, err := rateS.matchingRateProfileForEvent(context.TODO(), "cgrates.org", []string{}, - &utils.ArgsCostForEvent{ - CGREvent: &utils.CGREvent{ - Tenant: "cgrates.org", - ID: "CACHE1", - Time: utils.TimePointer(time.Date(2020, 7, 21, 11, 0, 0, 0, time.UTC)), - Event: map[string]interface{}{ - utils.AccountField: "1001", - utils.Destination: 1002, - utils.AnswerTime: rPrf.ActivationInterval.ExpiryTime.Add(-10 * time.Second), - }, - }, - }); err != utils.ErrNotFound { - t.Error(err) - } - - err = dm.RemoveRateProfile(context.Background(), rPrf.Tenant, rPrf.ID, utils.NonTransactional, true) - if err != nil { - t.Error(err) - } -} - func TestRateProfileCostForEvent(t *testing.T) { defaultCfg := config.NewDefaultCGRConfig() data := engine.NewInternalDB(nil, nil, true) @@ -343,9 +290,6 @@ func TestMatchingRateProfileEvent(t *testing.T) { }, }, FilterIDs: []string{"*string:~*req.Account:1001|1002|1003", "*prefix:~*req.Destination:10"}, - ActivationInterval: &utils.ActivationInterval{ - ExpiryTime: t1, - }, } err := dm.SetRateProfile(context.Background(), rpp, true) if err != nil { @@ -989,10 +933,7 @@ func TestRateSMatchingRateProfileForEventErrFltr(t *testing.T) { FilterIDs: []string{"fi"}, }, }, - ActivationInterval: &utils.ActivationInterval{ - ActivationTime: time.Date(2020, 7, 21, 0, 0, 0, 0, time.UTC), - ExpiryTime: time.Date(9999, 7, 21, 10, 0, 0, 0, time.UTC), - }, + FilterIDs: []string{"*ai:~*req.AnswerTime:2020-07-21T00:00:00Z|9999-07-21T10:00:00Z"}, } err := dm.SetRateProfile(context.Background(), rPrf, true) @@ -1008,11 +949,11 @@ func TestRateSMatchingRateProfileForEventErrFltr(t *testing.T) { Event: map[string]interface{}{ utils.AccountField: "1001", utils.Destination: 1002, - utils.AnswerTime: rPrf.ActivationInterval.ExpiryTime.Add(-10 * time.Second), + utils.AnswerTime: time.Date(9999, 7, 21, 10, 0, 0, 0, time.UTC).Add(-10 * time.Second), }, }, }) - expectedErr := "NOT_FOUND:fi" + expectedErr := "NOT_FOUND" if err == nil || err.Error() != expectedErr { t.Errorf("\nExpected <%+v>, \nReceived <%+v>", expectedErr, err) } diff --git a/utils/apitpdata.go b/utils/apitpdata.go index 5cd65693b..a988363cb 100644 --- a/utils/apitpdata.go +++ b/utils/apitpdata.go @@ -899,16 +899,15 @@ type ArgCacheReplicateRemove struct { } type TPRateProfile struct { - TPid string - Tenant string - ID string - FilterIDs []string - ActivationInterval *TPActivationInterval - Weights string - MinCost float64 - MaxCost float64 - MaxCostStrategy string - Rates map[string]*TPRate + TPid string + Tenant string + ID string + FilterIDs []string + Weights string + MinCost float64 + MaxCost float64 + MaxCostStrategy string + Rates map[string]*TPRate } type TPRate struct { diff --git a/utils/librates.go b/utils/librates.go index 5adead759..1f77aca74 100644 --- a/utils/librates.go +++ b/utils/librates.go @@ -30,15 +30,14 @@ import ( // RateProfile represents the configuration of a Rate profile type RateProfile struct { - Tenant string - ID string - FilterIDs []string - ActivationInterval *ActivationInterval - Weights DynamicWeights - MinCost *Decimal - MaxCost *Decimal - MaxCostStrategy string - Rates map[string]*Rate + Tenant string + ID string + FilterIDs []string + Weights DynamicWeights + MinCost *Decimal + MaxCost *Decimal + MaxCostStrategy string + Rates map[string]*Rate } func (rp *RateProfile) TenantID() string { @@ -778,11 +777,10 @@ func CompressIntervals(rtIvls []*RateSInterval) { // AsRateProfile converts APIRateProfile to RateProfile func (ext *APIRateProfile) AsRateProfile() (rp *RateProfile, err error) { rp = &RateProfile{ - Tenant: ext.Tenant, - ID: ext.ID, - FilterIDs: ext.FilterIDs, - ActivationInterval: ext.ActivationInterval, - MaxCostStrategy: ext.MaxCostStrategy, + Tenant: ext.Tenant, + ID: ext.ID, + FilterIDs: ext.FilterIDs, + MaxCostStrategy: ext.MaxCostStrategy, } if ext.Weights != EmptyString { if rp.Weights, err = NewDynamicWeightsFromString(ext.Weights, ";", "&"); err != nil { diff --git a/utils/librates_test.go b/utils/librates_test.go index da5235320..f1ed409f7 100644 --- a/utils/librates_test.go +++ b/utils/librates_test.go @@ -1236,11 +1236,10 @@ func TestLibratesAsRateProfile(t *testing.T) { Weights: "testWeight", } rp := &RateProfile{ - Tenant: ext.Tenant, - ID: ext.ID, - FilterIDs: ext.FilterIDs, - ActivationInterval: ext.ActivationInterval, - MaxCostStrategy: ext.MaxCostStrategy, + Tenant: ext.Tenant, + ID: ext.ID, + FilterIDs: ext.FilterIDs, + MaxCostStrategy: ext.MaxCostStrategy, } received, err := ext.AsRateProfile() @@ -1308,11 +1307,10 @@ func TestLibratesAsRateProfileNon0Len(t *testing.T) { }, } rp := &RateProfile{ - Tenant: ext.Tenant, - ID: ext.ID, - FilterIDs: ext.FilterIDs, - ActivationInterval: ext.ActivationInterval, - MaxCostStrategy: ext.MaxCostStrategy, + Tenant: ext.Tenant, + ID: ext.ID, + FilterIDs: ext.FilterIDs, + MaxCostStrategy: ext.MaxCostStrategy, } expected := rp