Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

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 2016Allan Rolschau1.1Added 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
diagramNameRollover design.drawio
revision1

The starting point of the design was the fact, that a subscription bundle has to work in two contexts:

...

  • When the bundle is used as a surplus bundle by another bundle, then value_4 is updated with the amount of units used by that other bundle.
    • Note that the process that updates value_4 shall make sure to also update value_2 with the same amount of units.
  • When value_2 is updated it needs to be checked if the total units available in the bundle is now less than the number of units that can be used as surplus. If this is the case, then value_4 needs to be updated such that this is no longer the case.
    • In more mathematical terms, if (value_1-value_2)<(value_3-value_4), then adjust value_4 such that the '<' becomes '='. This means that value_4 shall be set equal to value_3-(value_1-value_2).

ExamplesExample how value_4 is used for current period

Suppose a bundle has value_1 = 500, value_3 = 200. This means the bundle has 500 units for charges in actual period, from which 200 units may be used by charges from other periods.

...

 value_1value_2value_3value_4comment
 50002000Initial values
usage 1905001902000value_2 = 0+190. Still 310 units left.
usage 805002702000value_2 = 190+80. Still 230 units left.
usage 10050037020070value_2 = 270+100. Still 130 units left.
value_4 is incremented as free units in current period now is less than rollover units
usage 550037520075value_2 = 370+5. Still 125 units left. 
value_4 is incremented as free units in current period now is less than rollover units 

 

 

Suppose now that 190 units have been used in a period, i.e. value_2 = 190 and value_4 = 0.

...

usage 200500500200200value_2 = 500 as 375+200 exceeds value_1.
value_4 = 200 as available rollover units are exhausted. 

Example how value_4 is used for rollover periods

Now lets assume a subscription bundle is created initially but no usage is added for the subscription bundle period. Now the subscription bundle period is used by another period using rollover functionality:

 value_1value_2value_3value_4comment
 50002000Initial values
usage 905009020090value_2 = 0+90. Still 410 units left.
value_4 = 0+90 as usage is added due to rollover. Still 110 units left for rollover.
usage 80500170200170value_2 = 90+80. Still 330 units left.
value_4 = 90+80 as usage is added due to rollover. Still 30 units left for rollover.
usage 30500200200200

value_2 = 270+30. Still 200 units left.
value_4 = 200+30 as usage is added due to rollover. No units left for rollover.

Note, the last usage may actually be higher than 30, however the actual subscription bundle do only allow usage up to 30 units to be handled.

Example how value_4 is used for combined usage in current and rollover periods

Actual periodOther periods
(rollover) 
value_1value_2value_3value_4comment
  50002000Initial values
usage 190

 

5001902000value_2 = 0+190. Still 310 units left.
Still 200 units available for rollover. 
 

usage 80

50027020080value_2 = 190+80. Still 230 units left.
value_4 = 0+80 as used for rollover. 
usage 100 50037020070value_2 = 270+100. Still 130 units left.
value_4 is incremented as free units in current period now is less than rollover units
 usage 550037520075value_2 = 370+5. Still 125 units left. 
value_4 = 70+5 as used for rollover 
usage 200 500500200200value_2 = 500 as 375+200 exceeds value_1.
value_4 = 200 as available rollover units are exhausted. 


Subscription Bundle Update Manager

...

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:
Rollover periods: The number of periods considered for rollover.
Rollover before or after: Indicates whether the surplus should be used before or after the actual subscription bundle.
Rollover order: Either NEWER_FIRST for using the newest free units, or OLDER_FIRST for using the oldest free units. 

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
titleMigration step 1
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
titleMigration step 2
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%');