Skip to content

Envelope

Sergio Ocón edited this page Nov 8, 2017 · 2 revisions

Envelope

A group of items associated to a resource, to be used by billing. An envelope has_many data rollups associated through data views.

An envelope is always associated to a resource (VM, tenant, user, group, etc), and links different data rollups. For example: an envelope for a user will store data views for every single item to be charged. (i.e. all Vm, all IP assigned, etc).

An Envelope is the basis for a bill, or a bill equivalent. It identifies all data, and stores a view of the relevant data to be used by rating. For that reason, they have the same lifecycle of a bill, and are related to a time period. If you want to generate a series of bills, you need to generate a bill for each billing period you want to store.

An *Envelope also associates to a price plan, through the resource it belongs to. When calling rating on data views, you use the resource that is pointed by the envelope to find the price plan to use.

As the same data rollup can be associated to different envelopes, it is possible to charge the same concept several times at different levels. For example, you could have a VM associated to a user, and generate a bill to both the user and the group that the user belongs to. In that case, you will need two envelopes, one associated to the user, and another associated to the group, that will add both the same data rollup through independent data views. The function that associates data rollups to envelopes does so associating the data rollups as many times as needed.

An envelope can not be confused with a bill. Although an envelope can only be associated to a bill, it is possible that a bill is comprised of many envelopes. For instance, in those cases where the price plan changes one time in a period, a new envelope is created to associate the data rollups with the new price plan. in that case, the bill will consist on two envelopes: one with the former price plan, from the beginning of the period to the rate change, and another from the rate change to the end of the period.