...
Date: | Author: | Version: | Changes: | Completed | Ext. | Int. | Is in Core | Jira Ref. |
---|---|---|---|---|---|---|---|---|
11 September 2012 | Antoni Piotr Oleksicki | 1.0 | Doc. created | Yes | x |
| N/A |
|
22 February 2016 | Allan Rolschau | 1.1 | Added migration information | x |
Summary
Rollover bundles are used to enable transfer of remaining free units from one period to another subsequent period. The purpose of this document is to describe how this functionality is implemented as part of the core project.
...
Design and Implementation
Drawio | ||||
---|---|---|---|---|
|
The starting point of the design was the fact, that a subscription bundle has to work in two contexts:
...
Name | Description |
---|---|
ROLLOVER.PERIOD.ORDER | Defines whether older or newer surplus should be used first. Two possible values are possible: NEWER_FIRST and OLDER_FIRST |
ROLLOVER.USAGE.MODE | Indicates whether surplus should be used before or after the SubscriptionBundles. Again two values are possible: USE_ROLLOVER_BEFORE_BUNDLE, USE_ROLLOVER_AFTER_BUNDLE |
ROLLOVER.PERIODS | Amount of previous SubscriptionBundles used in rollover. In other words, the number defines how many times a surplus can be rolled over |
UPDATE_MANAGER | DEFAULT for the standard functionality without rollover. This is the standard implementation used if this parameter is not set. ROLLOVER for enabling the rollover functionality. Meta data properties are: UNLIMITED for a variation of the standard functionality, where zero free units (VALUE_1=0) are considered unlimited number of free units. |
Migration of existing subscription bundles
When existing bundles are re-configured to have rollover functionality then the existing subscription bundles need to be updated.
First initialize the field for the max rollover.
Code Block | ||
---|---|---|
| ||
update subscription_bundle set value3 = (select value3 from bundle b where
b.id = subscription_bundle.bundle_id) where
exists (select * from bundle b where b.id = subscription_bundle.bundle_id and
b.parameters like '%UPDATE_MANAGER=ROLLOVER%'); |
Next set the field for used rollover units. If this one (value4) has a value (other than 0) then it is because the usage (value2) started leaching of the amount that can be rolled over. Value4 is the excess amount past value1-value3.
Code Block | ||
---|---|---|
| ||
update subscription_bundle set value4=case when value2 > (value1-value3) then
value2 - (value1-value3) else 0 end where
exists (select * from bundle b where b.id = subscription_bundle.bundle_id and
b.parameters like '%UPDATE_MANAGER=ROLLOVER%'); |