Skip to main content

standard_billing_determinants_calculation

Purpose

The purpose of the rule is to calculate billing determinants based on an incoming billing request.

Detailed description

!()[images/standard_billing_determinants_calculation.png]

  1. Load timeslice groups, if present
  2. Create ‘determinants’ list to store the values that are calculated throughout the rule
  3. Calculate billing determinants for interval channels , if they exist:
    1. If there are any timeslice channles in the request:
      1. Get holiday calendar information stored in datasource tag. If the tag does not exist, a FLowCancelException is thrown
      2. Create a mask that defines which timeslices to apply to each timestamp. Mask checks whether timestamp is dst or not, holiday or not, weekend or weekday. Note: holiday takes precedent over weekend/weekday
      3. Make a pd.DataFrame where each column is a tariff channel, and keep only information relevant to that tariff.
    2. If split_by_month = True:
      1. Create sub period per month for the billing period in the request
    3. For each period requested, calculate determinants and quality
      1. Sum all intervals in the period, and take the lowest quality status in the period as the determinant's quality status
      2. Store results in a dict and append to ‘determinants’ list
  4. Calculate billing determinants for Pmax channels , if they exist:
    1. Find max value per month present in the billing period, store it in a pd.DataFrame
    2. Find max value in the billing period, the quality is set to the lowest quality status in that period. This is done in the pd.DataFrame from step ‘a’
    3. Store results in a dict and append to ‘determinants’ list
    4. If split_by_month = True
      1. Get the max per sub-period, calculated in step ‘a’. Status is set to the min quality status in the period
      2. Store it in a dict and append to ‘determinants’ list.
  5. Calculate billing determinants for register channels , if they exist
    1. If split_by_month = True:
      1. Create sub period per month for the billing period in the request
    2. For each period requested, calculate determinants and quality
      1. Get the value and quality from the timestamp of the end of the sub-period
      2. Store results in a dict and append to ‘determinants’ list
  6. Store billing information in respective BILLING channel classifier
    1. Billing channel name is deduced based on determinants information
    2. Start and end period are added to an annotation
    3. Flow timestamp is added to the annotation
    4. If pmax, information on the timestamp of when the Pmax occured is added as an annotation.
    5. Quality information is added to the Quality_Status DPA
    6. Channels are saved into self.datasource.id
  7. Create billing message and add it to the flow properties
    1. Loop through ‘determinants’ list and add the information to the message dict
    2. Create a json file from the ‘message’ dict
    3. Add message to the flow properties with key = self.datasource.id - this is later used to build the message and send it out later