Dynamic Balance Base and Dynamic Balance Instance

A dynamic balance instance can be a balance or meter, can represent a quantity of a currency or an asset, and can be simple or periodic. For periodic balances, the instance has period boundaries and a sliding window until the end time.

For information about restrictions, see the discussion about dynamic balance and meter restrictions.

Note: A dynamic balance cannot be an on-demand periodic balance.

A dynamic balance instance has its own resource ID, validity times, and thresholds.

A dynamic meter can be a charge meter, discount meter, or a usage quantity meter. You can use dynamic meter instance creation filters to prevent creating instances that do not meet the filter criteria. For more information, see the discussion about dynamic meter instance creation filters and the discussion about configuring meter template filters in My MATRIXX Help.

When a catalog item is purchased or activated, and it requires a dynamic balance, a dynamic balance base is created in the wallet's dynamic balance base array; no actual balance instance is created. The dynamic balance base contains the list of key field definitions, resource ID, balance template ID, start and end times, and other metadata, but does not contain balance values.

When an impact occurs, the key field definitions are evaluated to generate the key. If a field is used in a key field definition and the field is not set, a null value is used as the key value. If a matrix is used in a key field definition, the specified aggregation selector (string value) object is evaluated. A matrix cell can have a SKIP value so that the next matrix in the list is applied. If every matrix applied in the list results in a SKIP value, an error occurs and the transaction is canceled.

When a valid key is generated, the Charging Server searches for a dynamic balance instances in the wallet. If an instance with that key exists and has not expired, it is used. Otherwise, a new balance instance is created, containing the resource ID of the dynamic balance base and the key.

When an older event is received, an existing balance instance might be selected for impact. For example, at 2023-06-10T08:00:00, a usage event created a dynamic balance instance with start time of 2023-06-10T08:00:00, then an event with event time of 2023-06-10T07:59:50 is received. Instead of creating another dynamic balance instance with start time of 2023-06-10T07:59:50, the existing dynamic balance instance with start time of 2023-06-10T08:00:00 is selected for impact.

Purging a Dynamic Balance Instance

Each dynamic balance instance is purged using the same rules as any balance instance. If a purge profile is specified, the dynamic base is purged after the specified amount of time in the purge profile. When all instances of a dynamic balance base expire and the dynamic balance base is no longer referenced by any purchased offers, it is purged from the wallet.

Tentative Dynamic Balance Instance

A tentative dynamic balance instance has reservations for usage charges only. When a dynamic balance instance is created in the wallet to reserve usage charges, the instance is flagged as tentative and no MtxDynamicBalanceInstanceCreateEvent is generated. Once there is a charge or grant balance impact on a tentative dynamic balance instance, the instance is no longer tentative, and the start and end times are calculated based on the settings in the dynamic balance or meter template, and an MtxDynamicBalanceInstanceCreateEvent event is generated.

When the last tentative dynamic balance instance reservation is released and there is no charge or grant impact, the instance is deleted.