Commit Graph

5136 Commits

Author SHA1 Message Date
ionutboangiu
a5d29d5d7b Stop sending BalanceUpdate events to thresholds/stats 2024-04-08 17:34:13 +02:00
ionutboangiu
d6c5ddf08e Remove unused debitUnits and debitMoney funcs
They seem to have been replaced by the more generic debit
2024-04-08 13:15:41 +02:00
ionutboangiu
31842bf3f5 Add possibility to set/overwrite balance Factors through API
Constructor looks inside the params' balance map for the Factors key.
It expects either a string representing a JSON serialized map or the
map itself.

BalanceFilter Clone function has been updated to set a deep copy of
the original Factors map instead of a shallow one.

BalanceFilter getter function for Factors now returns nil instead of
an empty map. It's slightly more memory efficient and assignment to
this map will not be attempted, so it's panic proof.

BalanceFilter.ModifyBalance now updates Factors only if the key is
found in the request params' Balance map. Setting Factors to null is also
possible as long as the Factors key exists and is set to null.

Note: only *set_balance can overwrite the Factors map, all the others
can only set it if the balance does exist prior to sending the request.

Update balance integration tests.
2024-04-08 13:15:41 +02:00
ionutboangiu
3062113a61 Make go vet pass
The rpcclient constructor could not see the centralized
Encoding flag because it didn't have the necessary build
constraints. Added the constraints in lib_test.go files
where it wasn't alone. In all the other cases, it was
moved to the first file where it was needed.
2024-04-08 13:14:02 +02:00
ionutboangiu
821b5d05cc Remove unnecessary dependency between tests
Deleted a helper function that was directly calling strings.Trim in
favor of using strings.Trim directly.
2024-04-08 13:14:02 +02:00
ionutboangiu
bbf441f83c Add flaky build constrait to unstable tests 2024-04-08 13:14:02 +02:00
ionutboangiu
16eb745f00 Centralize test flags in utils for shared use across tests 2024-04-08 13:14:02 +02:00
ionutboangiu
9c004b069d Ignore factors equal to 1 when creating EventCost 2024-04-01 20:48:57 +03:00
ionutboangiu
6db11e87bc Rename Factor to BalanceFactor inside Accounting 2024-04-01 20:48:57 +03:00
ionutboangiu
50d0103c7b Move BalanceFactor value from Increments to Accounting
Retrieve the Accounting BalanceCharge inside a new variable and reuse
that instead of repeatedly indexing the map. It is always assumed that
the BalanceCharge exists in the map and is non-nil. A comment was
added as a reminder.

TotalCost cannot be calculated anymore from ChargingIncrement alone.
The function is not used, so it will not be causing any issues for
now.

BalanceCharge clone function now handles the case where it is nil
to avoid any possible nil pointer dereference.
2024-04-01 20:48:57 +03:00
ionutboangiu
a7ca167039 Add BalanceFactor value to Increments
For both the Increment and ChargingIncrement types.
2024-04-01 20:48:57 +03:00
ionutboangiu
cc72aa92d9 Slightly optimize debit for balances with non-nil Factor
Factor will be computed only once at the start of the function, instead
of doing it on every Increments iteration.

'amount' variable will be updated and rounded only when the computed
balances factor is different from its default value (1).
2024-04-01 20:48:57 +03:00
ionutboangiu
bd4aa99458 Refactor balance's Factor field name with its plural form
Stored balances previous to this commit, that had a non-nil Factors map, will
now have Factors nil due to field name mismatch.
2024-04-01 19:58:04 +03:00
ionutboangiu
45066b2d2f Rename Factor field to Factors in BalanceSummaries 2024-04-01 19:58:04 +03:00
ionutboangiu
6d61fd479d Add Factor map and Weight to BalanceSummaries
Added additional tests + updated old ones.
2024-04-01 19:58:04 +03:00
ionutboangiu
e987139e9c Revert to supporting *asm for ThresholdS acc publish 2024-03-22 15:12:04 +01:00
ionutboangiu
843eee3b8d Pass clone of original acc for *cdrlog actions 2024-03-13 18:25:06 +01:00
ionutboangiu
b457768a33 Update actions to share Time ref variable 2024-03-13 18:25:06 +01:00
ionutboangiu
5ac08799e1 Update *remove actions to support multiple balance types at once 2024-03-12 18:11:34 +01:00
ionutboangiu
58c1d639f3 Update handling of ees event after processing attributes 2024-03-11 16:41:09 +01:00
ionutboangiu
28e53cecc9 Add requests_cache_key field to radagent cfg 2024-03-07 17:20:23 +01:00
ionutboangiu
87db26b4ec Implement *force_disconnect_sessions action 2024-03-07 17:20:23 +01:00
ionutboangiu
41b9b719d5 Ensure AccountSummary is of *AccountSummary type when parsing ddp 2024-03-07 17:20:23 +01:00
ionutboangiu
eaeb04404e Add sessions_conns to rals section
Update ActionConnCfg constructor to take into account this new field.
2024-03-07 17:20:23 +01:00
ionutboangiu
8dc3a9e28f Remove getConnWithConfig unused parameter 2024-03-04 19:17:31 +01:00
ionutboangiu
49d6b8d565 Ensure CostDetails is of *EventCost type when parsing dynamicDP
CGREventWithEeIDs has also been optimized and properly tested. Comments
have been added explaining the process.

When sending a request to AttributeS from EEs, CostDetails from the reply
will now be overwritten by the original CostDetails to preserve its type.
The downside is that we are assuming that CostDetails was not altered by
AttributeS. We might consider adding a type check against *engine.EventCost
to at least stay backwards compatible with *gob and *internal connections.

general_tests/ees_it_test.go has been updated to ensure changes are working
properly.
2024-03-04 09:49:15 +01:00
ionutboangiu
221f6e2c91 Update *transfer_balance action
Now it creates the destination balance if it doesn't exist.
2024-03-04 09:49:15 +01:00
ionutboangiu
f1ad73b902 Add support for filtering to *remove_expired action 2024-03-04 09:49:15 +01:00
ionutboangiu
3269393141 Retrieve BalanceFactorID from Event
It will be added to CallDescriptor in ExtraFields.

Ensure CDR ExtraFields are passed to CallDescriptor before
sending it to RALs.

Ensure Clone function of CallDescriptor also clones the
ExtraFields map.
2024-03-04 09:49:15 +01:00
ionutboangiu
0aea8ac641 Revert "Move CGREvent from utils to engine"
This reverts commit 02195c47ed.
2024-03-04 09:49:15 +01:00
ionutboangiu
02195c47ed Move CGREvent from utils to engine 2024-02-27 17:16:57 +01:00
ionutboangiu
a9079154da Add possibility to pass conn cfg to actions 2024-02-27 16:28:48 +01:00
ionutboangiu
1f7e0b33a2 Update *alter_sessions action
Will now support two extra parameters: address and codec. For *internal
connections, the birpc.Service object will be retrieved from rpcParamsMap
from utils. Supported codecs: <*gob|*json|*http_jsonrpc> (ingored for
*internal address).

Action does not bother with setting defaults anymore, lets the API
handle them.

Improve action comments.

Add unit tests for the action. UnregisterRpcParams' implementation was
required.

Updated *alter_sessions action tariffplan for radius coa integration test
to include address and codec.

Some birpc clients that are set up in integration tests were still registering
a SessionSv1 object. Updated them to register an AgentV1 object instead.
2024-02-27 16:28:48 +01:00
ionutboangiu
c67ec00baa Implement *alter_sessions action 2024-02-21 18:43:53 +01:00
ionutboangiu
52bb1c2970 Add support for *transfer_balance inside *cdrlog action 2024-02-20 11:11:39 +01:00
ionutboangiu
87da08f7fd Revise *transfer_balance action and its API
Ensure parameter fields are not abbreviated.

The action will not depend on balance type anymore. It will go through all
balances.

*default balance from source balance can go negative during transfer.
2024-02-19 11:28:52 +01:00
ionutboangiu
41976e5721 Update *cdrlog action to support *remove_expired actions
Will also be able to process more than one CDR per
action.
2024-02-19 11:28:52 +01:00
ionutboangiu
267e6109e1 Implement CDRsv1.ProcessEvents API 2024-02-19 11:28:52 +01:00
arberkatellari
e730ef4eb2 Update integration tests 2024-02-15 17:02:41 +01:00
ionutboangiu
d182d6f601 Revise behaviour of balance factor
Now it multiplies instead of dividing.
2024-02-06 10:06:30 +01:00
ionutboangiu
f01ae9fb37 Add compatibility support between *remove_balance and *cdrlog actions 2024-01-30 18:46:48 +01:00
ionutboangiu
8c0bee1a1a Add error constant for INSUFFICIENT_CREDIT_BALANCE_BLOCKER 2024-01-29 09:57:49 +01:00
ionutboangiu
050af6032c Include DestinationIDs and Factor when cloning balances
This fixes an issue where, if data_db is of type *internal, the Factor value is lost
on GetAccount
2024-01-29 09:57:49 +01:00
gezimbll
dfb8011a1a Fix encoding dataprovider as json body for *http filter 2024-01-26 12:11:46 +01:00
ionutboangiu
911cd1b607 Update SMCostRetries backoff increment unit to ms 2024-01-25 18:41:17 +01:00
ionutboangiu
5c96ecf27e Update balance factor to depend on category
Updated unit tests to reflect that also.
2024-01-25 18:41:17 +01:00
ionutboangiu
dca2c4b6a1 Revise unit tests following the blocker update 2024-01-23 14:12:33 +01:00
ionutboangiu
36bdc41e97 Add support for kafka ssl encryption
For both poster and reader.
Added integration test.
2024-01-23 14:12:33 +01:00
DanB
e0d15f1a9e Prevent balance Blocker to partially debit 2024-01-19 16:28:09 +01:00
gezimbll
6f6374abb9 added *http attribute type 2024-01-15 16:17:02 +01:00