Skip to content

lib-tariff 库参考 ​

原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793259390/FIN+5.3.1+lib-tariff 中文整理基于 FIN 5.3.1

导读: 公用事业费率引擎

以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。


目录(导读) ​

  • lib
  • meta
  • docs
  • tags
  • funcs
  • views
  • Overview
  • Tariffs
  • Charges
    • Usage-Based Charges
    • Consumption Charges
    • Demand Charges
    • Fixed Charges
    • Percentage Charges
    • Axon Charges
  • Configuring Bill Periods
  • Historical Fees
  • Utility Functions
  • tariffBillPeriod(meter, date)
  • tariffConsumptionCharge(tariff, dis, meterType, strategy, ranges, optTags: {})
  • tariffCost(meter, dates, opts: {})
  • tariffCostToHis(rec, dates, opts, yield)
    • src
  • tariffCreate(dis, currency)
  • tariffCreateBillHis(rec: null, his: null, opts: {})
  • tariffDemandCharge(tariff, dis, meterType, strategy, ranges, optTags: {})
  • tariffFixedCharge(tariff, dis, fee, freq: "bill")
  • tariffPercentageCharge(tariff, dis, percentage, charges)

概述(中译) ​

公用事业费率引擎


API 正文(英文) ​

docs ​

Overview • Tariffs • Charges • Configuring Bill Periods • Historical Fees • Utility Functions


tags ​

tariffA tariff rec
tariffAxonChargeAn Axon charge rec
tariffChargeA tariff charge rec
tariffChargeFuncThe name of the function that tariff engine should call to compute the cost
tariffChargeRefReference to an entity
tariffChargeRefsThe charges that a percentage charge applies to
tariffConsumptionChargeA consumption charge rec
tariffContractMinThe minimum contractual demand necessary for this charge to apply
tariffDemandChargeA demand charge rec
tariffFeeA fixed numeric fee for the charge
tariffFeeFreqThe frequency that the charge applies per bill period
tariffFeeHisRefThe ref to the history point that contains the historical fee data
tariffFixedChargeA fixed charge rec
tariffHisIdentifies the tariff history point for a meter
tariffHisRefIf multiple meters share the same tariff history, then you can use this tag to reference the "master" point containing the tariff history
tariffPercentageChargeA percentage charge rec
tariffRangeStrategyWhen a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges
tariffRangesThe fee ranges for a usage-based charge
tariffRatchetPercentageThe peak demand identified during the ratchet period will be multiplied by this percentage to obtain the minimum peak demand
tariffRatchetPeriodA value representing how far back to go when calculating the minimum peak demand for a billing period
tariffRefThe tariff a charge belongs to
tariffUsageOnAn axon filter used by the tariff engine to identify the charge's historical usage data

funcs ​

tariffBillPeriodFor the given meter, get the date span of the bill period containing the given date
tariffConsumptionChargeCreate a consumption charge
tariffCostCalculate the cost of energy for a meter
tariffCostToHisFunction to create a computed history for the tariff cost associated with that meter
tariffCreateCreate a new tariff
tariffCreateBillHisCreate the billing period history point
tariffDemandChargeCreate a demand charge
tariffFixedChargeCreate a fixed charge
tariffPercentageChargeCreate a percentage charge

views ​

tariffBillPeriodsManage tariff billing periods
tariffCostAnalyze tariff costs against energy usage
tariffsTariff builder used to edit tariff and charge records

lib tariff ​

Overview ​

The TariffExt provides a common model for describing energy tariffs in SkySpark.

To setup a tariff and apply it to a meter, the following high-level steps need to be completed. The rest of this guide describes these steps in more details

  1. Create a tariff record
  2. Create records for all the charges in your tariff
  3. Create the tariff history point that defines the bill periods for your meter

Tariffs ​

A tariff models a collection of charges that apply to an energy meter. The following tags are used on records to define a tariff.

  • tariff: Marker tag that identifies the record as a tariff.
  • currency: Str for the currency unit of this tariff. All charges in the tariff must be expressed in terms of this unit.
dis: "Schedule 1B"
tariff
currency: "€"

Charges ​

A charge is the term used to describe the different cost components of a tariff. Energy tariffs often define many cost components. For example: service charges, consumption and demand charges, and taxes. The tariff ext provides models for these different kinds of charges.

All charges share the following tags.

  • tariffCharge: Marker tag that identifies the record as a tariff charge.
  • tariffRef: Ref of the tariff that this charge belongs to.
  • scheduleRef: (optional) Ref for the schedule that defines when this charge applies.
  • scheduleVal: Str. When a schedule is applied to this charge, the charge only applies when the schedule has this value. Schedules are most commonly used with "usage-based" charges. For example, if the tag's value is onPeak, then only data in the periods when the schedule's value is onPeak will be used for calculating the charge. This tag is required if scheduleRef is specified.

The following sections describe the different charge types in more detail.

Usage-Based Charges ​

A usage-based charge is any charge this is calculated as a function of usage data. Usage data in the tariff ext falls into one of two categories: 1) consumption, and 2) demand. Consumption data measures the amount of energy/resource consumed, and demand data measures the rate at which the energy/resource is consumed.

A usage-based charge uses the tariffUsageOn tag to define an Axon filter to find the sensor point that contains the historical usage data for that charge. The filter is based on the meter type (elec, gas, water), and whether the charge is for consumption or demand. The tariff engine will ensure the filter is applied to the relevant meter. For example, this filter will would find the energy consumption data:

energy and sensor

Internally, the engine will constrain this filter to the current meter as

energy and sensor and equipRef == meterRef

The history data from the matched point is then used for calculating the cost of the charge.

Ranges ​

It is common for usage-based charges to have different costs based on the amount of energy/resource used. For example, a consumption charge might be specified as:

  1. First 1,400 kWh @ 3.722¢ per kWh
  2. Over 1,400 kWh @ 4.995¢ per kWh

Ranges allow us to express these types of charge costs. Ranges are modeled as a grid on the usage charge and are stored in the tariffRanges tag. The rows specify ranges, and the columns are

  • min: (Number) the minimum value for this range (exclusive).
  • max: (Number) the maximum value for this range (inclusive).
  • tariffFee: (Number) the numeric fee for this range.
  • tariffFeeHisRef: (Ref) the point with historical fee data for this range

You must specify a min, max, and one of tariffFee or tariffFeeHisRef.

So, for the example above, the ranges tag would be

tariffRanges:Zinc:
  ver:"3.0"
  min,  max,   tariffFee
  0,    1400,  3.722
  1400, INF,   4.995

All usage charges must have at least one range. It is not necessary for the ranges to be contiguous. The tariff ext will fill all gaps with zero-cost ranges.

Single, all-inclusive range:

tariffRanges:Zinc:
  ver:"3.0"
  min,  max,   tariffFee
  0,    INF,   4.115

Partial, non-contiguous range:

tariffRanges:Zinc:
  ver:"3.0"
  min,  max,   tariffFee
  1400, INF,   4.995

Range Strategy ​

The tariffRanges tag allows us to define the ranges for our usage-based charges. The tariffRangeStrategy tag tells the tariff engine how to calculate the cost for a usage-based charge based on those defined ranges. It can have one of three values:

  1. cumulative: All ranges up-to-and-including the range containing the total/peak usage are used in calculating the cost.
  2. inRange: Only the range containing the total/peak usage is used in calculating the cost.
  3. perReading: Instead of looking at the total or peak usage, the cost for each individual data reading is calculated based on the range it falls in.

To illustrate the difference between the strategies, consider this demand charge specification

  1. 0-100 kW @ $1.00 per kW
  2. 100-150 kW @ $2.00 per kW
  3. Over 150 kW @ $3.00 per kW

Suppose the customer's peak demand is 125 kW. For the cumulative range strategy we look at each range and calculate the cost based on how much of that range contributed to the total/peak usage. In this case, all 100kW of the first range contributed to the peak demand of 125kW. For the second range, only 25kW contributed, and for the last range 0kW contributed. So the cost is:

(100kW * $1.00/kW) + (25kW * $2.00/kW) + (0kW * $3.00/kW) = $150

For the inRange strategy, we find the one and only range that contains the total/peak usage and use that for calculating the cost. Since 125kW falls into the second range the cost is:

(125kW * $2.00/kW) = $250

The cumulative and inRange strategies are essentially looking at rolled up values - total (sum) for consumption data, and peak (max) for demand data. The perReading strategy looks at each individual data reading and calculates the cost for that reading based on the range it falls into. This table shows how the cost would be calculated for the given demand data based on the different strategies.

ts      demand  perReading Cost  cumulative Cost  inRange Cost
-----   ------  ---------------  ---------------  ------------
00:00   5 kW    $5               $0               $0
00:15   50 kW   $50              $0               $0
00:30   125 kW  $250             $150             $250
00:45   10 kW   $10              $0               $0

Consumption Charges ​

A consumption charge is a usage-based charge that calculates cost based on the amount of energy/resource consumed. It applies only to consumption sensor data. A consumption charge is tagged with the tariffCharge and tariffConsumptionCharge tags. There are no additional tags required to configure a consumption charge.

Consider this example consumption charge specification

  1. Generation kWh Charge
    1. For the Billing Months of June - September
      1. First 1,400 kWh @ 3.722¢ per kWh
      2. Over 1,400 kWh @ 4.995¢ per kWh

If the tariff's currency is in $, then this consumption charge could be modeled as

dis: "Generation kWh Charge - Summer"
tariffRef: @ExampleTariff
tariffUsageOn: "energy and sensor"
tariffCharge
tariffConsumptionCharge
scheduleRef: @SeasonSchedule
scheduleVal: "summer"
tariffRangeStrategy: "cumulative"
tariffRanges:Zinc:
  ver:"3.0"
  min,    max,    tariffFee
  0,      1400,   0.03722
  1400,   INF,    0.04995

Demand Charges ​

A demand charge is a usage-based charge that calculates cost based on the rate at which energy or a resource is consumed. It applies only to demand sensor data. A deman charge is tagged with the tariffCharge and tariffDemandCharge tags. Except in the case where the range strategy is perReading, a demand charge looks at historical usage and finds the peak (maximum) demand interval. It then uses this peak value as the basis for calculating the cost.

In addition to all the standard charge and usage-based charge tags, a demand charge may be configured with the following optional tags

  • tariffContractMin: (Number) - the minimum contracted demand for this charge. When specified, the peak demand used to calculate the cost is never less than this value. This is sometimes referred to as a simple "ratchet" demand charge.

  • tariffRatchetPeriod: (Str) - A value representing how far back to go when calculating the minimum peak demand for a billing period. This is sometimes referred to as a "historical" ratchet.

    Currently, the tariff engine can only look back by bill periods. Its value must be of the form "{N}bills", where "N" is the number of bill periods to consider and includes the current bill period. For example, 12bills indicates we should look at this bill period's data as well as the previous 11 months to determine the minimum peak demand.

    NOTE: the tariffContractMin is still in effect if both are specified.

  • tariffRatchetPercentage: (Number) - This tag is only valid when tariffRatchetPeriod is also specified. When this tag is present, the peak demand identified during the ratchet period is multiplied by this percentage to obtain the minimum peak demand. If it is not specified, the default value is logically 100%.

The following is an example of modeling a basic peak demand charge.

  1. Generation Demand Charge
    1. For the Billing Months of June - September

      All kW of Demand @ $2.119 per kW

    2. For the Billing Months of October - May

      All kW of Demand @ $0.681 per kW

dis: "Generation Demand Charge - Summer"
tariffRef: @ExampleTariff
tariffUsageOn: "demand and sensor"
tariffCharge
tariffDemandCharge
scheduleRef: @SeasonSchedule
scheduleVal: "summer"
tariffRangeStrategy: "inRange"
tariffRanges:Zinc:
  ver:"3.0"
  min,    max,    tariffFee
  0,      INF,    2.119

dis: "Generation Demand Charge - Winter"
tariffRef: @ExampleTariff
tariffUsageOn: "demand and sensor"
tariffCharge
tariffDemandCharge
scheduleRef: @SeasonSchedule
scheduleVal: "winter"
tariffRangeStrategy: "inRange"
tariffRanges:Zinc:
  ver:"3.0"
  min,    max,    tariffFee
  0,      INF,    0.681

This example demonstrates modeling a peak demand charge with a historical ratchet and contract minimum.

  1. The distribution demand shall be such as may be contracted for but not less than the highest of:
    1. The highest average kW measured at the location during any 30-minute interval of the current and previous 11 billing months.
    2. 30 kW.
  2. Transmission Demand Charge
    1. All on-peak ES kW of Demand @ $2.313 per kW
dis: "On-Peak Demand Charge Winter"
tariffRef: @ExampleTariff
tariffUsageOn: "demand and sensor"
scheduleRef: @TOUSched
scheduleVal: "onPeak"
tariffCharge
tariffDemandCharge
tariffRangeStrategy: "inRange"
tariffRanges:Zinc:
  ver:"3.0"
  min,    max,    tariffFee
  0,      INF,    2.313
tariffContractMin: 30
tariffRatchetPeriod: "12bills"
tariffRatchetPercentage: 100

Fixed Charges ​

A fixed charge is for a charge that applies on a regular interval. A fixed charge is tagged with the tariffCharge and tariffFixedCharge tags. Typical examples of fixed charges are service charges, or rental fees. A fixed charge defines some additional configuration tags:

  • tariffFee (Number): The numeric fee for the charge.
  • tariffFeeHisRef (Ref): The Ref to a history point that contains the historical fee data
  • tariffFeeFreq (optional) (Str): the frequency that the charge applies within a bill period. It supports two types of values:
    1. If set to "bill" then the charge applies per bill period. This is the default value.
    2. The Str encoding of a Duration. In this case it specifies how often within a bill period the charge applies. For example "1day", or "1hr"
dis: "Service Charge"
tariffRef: @ExampleTariff
tariffCharge
tariffFixedCharge
tariffFee: 102.50
tariffFeeFreq: "bill"

dis: "Rental Fee"
tariffRef: @ExampleTariff
tariffCharge
tariffFixedCharge
tariffFee: 2.50
tariffFeeFreq: "1day"

Percentage Charges ​

A percentage charge is used for any cost component that represents a percentage of one or more other cost components. The typical use case is for taxes. A percentage charge is tagged with the tariffCharge and tariffPercentageCharge tags. A percentage charge defines some additional configuration tags:

  • tariffChargeRefs (Ref[]) - The refs of the charges that this percentage charge applies to It is valid to reference other percentage charges, but it is an error to create a circular dependency.
  • percentage (Number): The percentage to apply to the sum of the referenced charges. This should be a number between 0 and 100.
// a 3.5% state tax on the service charge and consumption charge
dis: "State Tax"
tariffRef: @ExampleTariff
tariffCharge
tariffPercentageCharge
percentage: 3.5
tariffChargeRefs: [@ServiceCharge,@ConsumptionCharge]

Axon Charges ​

(This charge type is incubating and is subject to change)

An axon charge allows you to delegate the cost calculation to a custom Axon function that you have written. Is can be used if one of the other charge types does not adequately model your charge. Ax Axon charge is tagged with the tariffCharge and tariffAxonCharge tags. An axon charge defines some additional configuration tags:

  • tariffChargeFunc (Str) - The name of the axon function that performs the cost calculation.

The func must have the following signature

myChargeFunc(meter, dates, charge)

It is passed the meter to calculate cost against, the date span of the current billing period being calculated, and the axon charge record itself. You should put any custom configuration tags on the charge record. The function should return a grid with a single row, and the following columns

  • "cost" (Grid) - This column is required. Its value is a history grid. The history grid should be the computed cost for the entire date span passed into the axon charge function.
  • "data" (Grid) - You may optionally return a history grid containing the raw data values used to calculate the cost for the axon charge.

Note: the tariff engine completely delegates computation to the axon function. In particular, it does not do any schedule filtering.

dis: "Custom Charge"
tariffRef: @ExampleTariff
tariffCharge
tariffAxonCharge
tariffChargeFunc: "myChargeFunc"

Here is a very simple axon charge function that calculates just a constant value

(meter, dates, charge) => do
   {
     cost: {ts: dates.start, v0: 100$}.toGrid
   }.toGrid
end

Configuring Bill Periods ​

A meter is billed by an energy company on a semi-regular basis. The date span for each bill is called the bill period. In order to more accurately report the cost for arbitrary date ranges, the tariff engine needs to know when a bill period begins, and how long it lasts. Further, it needs to know which tariff to apply for a given bill period.

The tariff engine models a bill period as a historized point on an energy meter. The timestamp of each record indicates when a bill period begins. The value of the record is the id of the tariff to use for that bill period. A bill period implicitly ends when the next one begins.

To setup a meter's bill period history do the following:

  1. Create a standard history point with type Str
  2. Add the tariffHis marker tag to the point
  3. Add an equipRef tag that points to the meter

For example, if you have an elec meter called @ElecMeterMain, you would create a point with at least these tags:

his
point
hisSize: 0
kind: "Str"
tz: "New_York"
tariffHis
siteRef: @Campus
equipRef: @ElecMeterMain

If this meter is billed on the first of each month, then its bill period history might look like this.

ts                 v0
----------------   ----------------------
2015-01-01T00:00   Tariff-SmallCommercial
2015-02-01T00:00   Tariff-SmallCommercial
2015-03-01T00:00   Tariff-MediumCommmercialTOU
2015-04-01T00:00   Tariff-MediumCommmercialTOU
...

If you have multiple meters that share the same tariff history, you don't have to create a tariffHis point for each of them. Instead, create the tariffHis point once as indicated above, then on subsequent meters you can use the tariffHisRef tag to reference that point.

Historical Fees ​

It is common for the fee within a charge to change on a regular basis (e.g. daily or monthly). Anywhere a fee tag is used, instead of using a Number you can give a Ref to a history point that tracks the fee for that charge.

Utility Functions ​

  • The tariffCreate() function can be used to create a tariff.
  • The tariffConsumptionCharge() function can be used to create a consumption charge.
  • The tariffDemandCharge() function can be used to create a demand charge.
  • The tariffFixedCharge() function can be used to create a fixed charge.
  • The tariffPercentageCharge() function can be used to create a fixed charge.
  • The tariffCreateBillHis() function can be used to create an initial bill history.


def ​

func:tariffBillPeriod ​

tariffBillPeriod(meter, date) ​

For the given meter, get the date span of the bill period containing the given date.


meta ​

deffunc:tariffBillPeriod
isfunc
liblib:tariff
nametariffBillPeriod

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:tariffConsumptionCharge ​

tariffConsumptionCharge(tariff, dis, meterType, strategy, ranges, optTags: {}) ​

Create a consumption charge. The parameters are the same as tariffDemandCharge. Returns the new consumption charge record.


meta ​

admin✓
deffunc:tariffConsumptionCharge
isfunc
liblib:tariff
nametariffConsumptionCharge

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:tariffCost ​

tariffCost(meter, dates, opts: {}) ​

Calculate the cost of energy for a meter. The parameters:

  • meter: The energy meter to calculate the cost for. May be any target accepted by toRec().
  • dates: the date range to query.

The opts parameter is a Dict and supports the following options:

  • interval: a Duration between 1min and 1day. If specified, then the tariff engine will calculate the cost of each charge for every interval in the dates range. For example, if dates is yesterday, and interval is 1hr, then the tariff engine will break down the cost into 24 hourly slices for yesterday.
  • tariffHisRef: a Ref that can be used to override the tariff history that would normally be used for the meter.
  • tariffRef: a Ref that can be used to override the tariff that is used to calculate cost. Can be used in conjunction with the tariffHisRef option. If specified, this tariff will be used for all bill periods in the date span.
  • data: The data option allows you to override the historical data that the tariff engine would normally run against. The value of this option is a map where where the keys are string encodings of a point's id. The values are history grids. See the discussion below for more details.

The function returns the cost as a history grid where each value column corresponds to a charge in the tariff.

The data option: Normally, the tariff engine will determine the history point to use for a charge by looking at the tariffUsageOn tag for a charge, and then resolve that filter to the appropriate point. However, if the data map has a key with the same id as the resolved usageOn point, then the history grid in the data map will be used instead. Care should be taken to ensure that the history grid you give the tariff engine has data for the entire billing period(s) you are calculating cost for. The tariffBillPeriod() function can help you in this regard.

Example:

// Get the cost for yesterday without any timestamp adjustment for intervals.
tariffCost(@Carytown.ElecMeter-Main, yesterday)

// Get the cost for yesterday at 1hr intervals
tariffCost(@Carytown.ElecMeter-Main, yesterday, {interval: 1hr})

meta ​

deffunc:tariffCost
isfunc
liblib:tariff
nametariffCost

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:tariffCostToHis ​

tariffCostToHis(rec, dates, opts, yield) ​

Function to create a computed history for the tariff cost associated with that meter. The function computes the history by calling tariffCost() for the meter associated with this point (it should be a siteMeter). All the charges for a ts are then folded into a single value using sum.


meta ​

deffunc:tariffCostToHis
hisFuncReady✓
isfunc
liblib:tariff
nametariffCostToHis
overridable✓

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function

src ​

(rec, dates, opts, yield) => do
  meter: readById(rec->equipRef)
  if (meter.missing("siteMeter")) return null

  tariffCost(meter, dates)
    .hisFoldCols(sum)
    .each(row => yield(row["ts"], row["v0"]))
end


def ​

func:tariffCreate ​

tariffCreate(dis, currency) ​

Create a new tariff. Creates a new tariff with the given display name and currency, and returns the new tariff Dict record.


meta ​

admin✓
deffunc:tariffCreate
isfunc
liblib:tariff
nametariffCreate

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:tariffCreateBillHis ​

tariffCreateBillHis(rec: null, his: null, opts: {}) ​

Create the billing period history point. The parameters:

  • rec (optional): If specified, must be the site or meter to create the history point on. May be any target accepted by toRec(). If null, then the point will be created "project-wide".
  • his (optional): If specified, this grid will be written as the initial billing period history. The grid must have the following columns:
    1. date (Date): the date marking the beginning of a bill period.
    2. tariff (Str or Ref): the id of the tariff for that bill period.
  • opts (optional): A Dict with additional options to create the point. Supported options:
    • tz: Str containing the name of the time zone to use for this point. This option is ignored if the rec parameter is non-null.
    • navName: The Str navName to use for this point. (default: "Tariff His")

If rec is null or is a site, then you can associate meters with the tariff billing history by using the tariffHisRef tag.

Returns the new billing period history point record.


meta ​

admin✓
deffunc:tariffCreateBillHis
isfunc
liblib:tariff
nametariffCreateBillHis

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:tariffDemandCharge ​

tariffDemandCharge(tariff, dis, meterType, strategy, ranges, optTags: {}) ​

Create a demand charge. The parameters:

  • tariff: The tariff to assign the charge to. May be any target accepted by toRec().
  • dis: The display name for the charge.
  • meterType: The meter type this charge applies to. Must be one of elec, gas, water or steam. The tariffUsageOn tag will be configured based on the meter type. You can override the tariffUsageOn by setting it explicitly in the optTags parameter.
  • strategy: The range strategy to use. Must be one of cumulative, inRange, or perReading
  • ranges: A list of range specifications where a range specifcation is a list with format [min, max, fee].
  • optTags: Any additional tags to apply to the charge. You can override any of the other settings by explicitly setting them in this Dict.

Returns the new demand charge record.

Example:

tariffDemandCharge(@Schedule1B, "Peak Demand Charge", "elec", "inRange",
                   [[0, 1000, 3.225], [1000, posInf(), 4.662]])

meta ​

admin✓
deffunc:tariffDemandCharge
isfunc
liblib:tariff
nametariffDemandCharge

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:tariffFixedCharge ​

tariffFixedCharge(tariff, dis, fee, freq: "bill") ​

Create a fixed charge. The parameters:

  • tariff: The tariff to assign the charge to. May be any target accepted by toRec().
  • dis: The display name for the charge.
  • fee (Number or Ref): the fee for this charge.
  • freq (Str or Duration): bill (the default) if the charge applies to the entire bill period, or a Duration for the frequency of the charge.

Returns the new fixed charge record.

Example:

// A fixed charge that applies to the entire bill period
tariffFixedCharge(@Schedule1B, "Service Charge", 102.50, "bill")

// A fixed charge that applies every day
tariffFixedCharge(@Schedule1B, "Rental Fee", 7.25, 1day)

meta ​

admin✓
deffunc:tariffFixedCharge
isfunc
liblib:tariff
nametariffFixedCharge

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

func:tariffPercentageCharge ​

tariffPercentageCharge(tariff, dis, percentage, charges) ​

Create a percentage charge. The parameters:

  • tariff: The tariff to assign the charge to. May be any target accepted by toRec().
  • dis: The display name for the charge.
  • percentage: The percentage for this charge.
  • charges: the charges this charge applies to. Maybe be any result target accepted by toRecList().

Returns the new percentage charge record.

Example:

// A 3.5% tax on two other charges
tariffPercentageCharge(@Schedule1B, "State Tax", 3.5, "@ServiceCharge,@ConsumptionCharge")

meta ​

admin✓
deffunc:tariffPercentageCharge
isfunc
liblib:tariff
nametariffPercentageCharge

supertypes ​

featureFeature namespace of definitions formatted as feature:name
funcAxon function


def ​

tariff ​

A tariff rec.


meta ​

deftariff
iconbill
isentity
liblib:tariff
mandatory✓

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier

tags ​

currencyThe currency unit related to the entity
disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type


def ​

tariffAxonCharge ​

An Axon charge rec.


meta ​

deftariffAxonCharge
disKeytariffExt::tariff.axonCharge
icondollar
istariffCharge
liblib:tariff

usage ​

tariffAxonCharge  tariffCharge

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
tariffChargeA tariff charge rec

tags ​

disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type
scheduleRefAssociates a schedulable with its schedule
scheduleValThe string name/encoding of a schedule value
tariffChargeFuncThe name of the function that tariff engine should call to compute the cost
tariffRefThe tariff a charge belongs to
tariffUsageOnAn axon filter used by the tariff engine to identify the charge's historical usage data


def ​

tariffCharge ​

A tariff charge rec.


meta ​

deftariffCharge
icondollar
isentity
liblib:tariff
mandatory✓

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier

subtypes ​

tariffAxonChargeAn Axon charge rec
tariffConsumptionChargeA consumption charge rec
tariffDemandChargeA demand charge rec
tariffFixedChargeA fixed charge rec
tariffPercentageChargeA percentage charge rec

tags ​

disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type
scheduleRefAssociates a schedulable with its schedule
scheduleValThe string name/encoding of a schedule value
tariffRefThe tariff a charge belongs to


def ​

tariffChargeFunc ​

The name of the function that tariff engine should call to compute the cost.


meta ​

deftariffChargeFunc
isstr
liblib:tariff
tagOntariffAxonCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

tariffChargeRef ​

Reference to an entity. Ref values are ASCII strings limited to the following chars: a-z, A-Z, 0-9, underbar, colon, dash, dot, or tilde. See Kinds chapter.


meta ​

deftariffChargeRef
isref
liblib:tariff
oftariffCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity


def ​

tariffChargeRefs ​

The charges that a percentage charge applies to.


meta ​

deftariffChargeRefs
islist
liblib:tariff
oftariffChargeRef
tagOntariffPercentageCharge
uiInputui::NavInput

supertypes ​

valData value type
listOrdered list of zero or more values


def ​

tariffConsumptionCharge ​

A consumption charge rec.


meta ​

deftariffConsumptionCharge
disKeytariffExt::tariff.consumptionCharge
icondollar
istariffCharge
liblib:tariff

usage ​

tariffConsumptionCharge  tariffCharge

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
tariffChargeA tariff charge rec

tags ​

disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type
scheduleRefAssociates a schedulable with its schedule
scheduleValThe string name/encoding of a schedule value
tariffRangeStrategyWhen a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges
tariffRangesThe fee ranges for a usage-based charge
tariffRefThe tariff a charge belongs to
tariffUsageOnAn axon filter used by the tariff engine to identify the charge's historical usage data


def ​

tariffContractMin ​

The minimum contractual demand necessary for this charge to apply.


meta ​

deftariffContractMin
isnumber
liblib:tariff
tagOntariffDemandCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit


def ​

tariffDemandCharge ​

A demand charge rec.


meta ​

deftariffDemandCharge
disKeytariffExt::tariff.demandCharge
icondollar
istariffCharge
liblib:tariff

usage ​

tariffDemandCharge  tariffCharge

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
tariffChargeA tariff charge rec

tags ​

disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type
scheduleRefAssociates a schedulable with its schedule
scheduleValThe string name/encoding of a schedule value
tariffContractMinThe minimum contractual demand necessary for this charge to apply
tariffRangeStrategyWhen a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges
tariffRangesThe fee ranges for a usage-based charge
tariffRatchetPercentageThe peak demand identified during the ratchet period will be multiplied by this percentage to obtain the minimum peak demand
tariffRatchetPeriodA value representing how far back to go when calculating the minimum peak demand for a billing period
tariffRefThe tariff a charge belongs to
tariffUsageOnAn axon filter used by the tariff engine to identify the charge's historical usage data


def ​

tariffFee ​

A fixed numeric fee for the charge. This value should be unitless since it inherits the currency of its tariff.


meta ​

deftariffFee
isnumber
liblib:tariff
tagOntariffFixedCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit


def ​

tariffFeeFreq ​

The frequency that the charge applies per bill period. It supports two values:

  1. If set to bill then the charge applies per bill period. This is the default value.
  2. The string encoding of a duration. In this case it specifies how often within a bill period the charge applies. For example 1day or 1hr.

meta ​

deftariffFeeFreq
isstr
liblib:tariff
tagOntariffFixedCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

tariffFeeHisRef ​

The ref to the history point that contains the historical fee data.


meta ​

deftariffFeeHisRef
isref
liblib:tariff
ofpoint
tagOntariffFixedCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity


def ​

tariffFixedCharge ​

A fixed charge rec.


meta ​

deftariffFixedCharge
disKeytariffExt::tariff.fixedCharge
icondollar
istariffCharge
liblib:tariff

usage ​

tariffFixedCharge  tariffCharge

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
tariffChargeA tariff charge rec

tags ​

disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type
scheduleRefAssociates a schedulable with its schedule
scheduleValThe string name/encoding of a schedule value
tariffFeeA fixed numeric fee for the charge
tariffFeeFreqThe frequency that the charge applies per bill period
tariffFeeHisRefThe ref to the history point that contains the historical fee data
tariffRefThe tariff a charge belongs to


def ​

tariffHis ​

Identifies the tariff history point for a meter. See bill periods for details.


meta ​

deftariffHis
ishis-point
liblib:tariff

usage ​

tariffHis  point

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
pointData point such as a sensor or actuator
his-pointHistorized point with a history log of timestamp/value pairs

tags ​

curSupports current value
disDisplay name for an entity
disMacroDisplay name using macro syntax
disabledIndicates the entity is in a disabled state
enumDefines an eumeration of string key names
equipRefReference to equip which contains this entity
ghgFactorHisIdentifies point record with interval emission factor data that the Greenhouse Gas Emission Engine uses to calculate emissions
hisSupports historization of data
hisAppendNASpecifies the amount of time after a history point's hisEnd that the hisRead() function should append an NA
hisCollectCovEnables COV history collection of the curVal
hisCollectCovRateLimitRate limits the frequency for hisCollectCov
hisCollectIntervalEnables interval history collection of the curVal
hisCollectNAHistorize the NA value whenever the curVal is null or curStatus is not equal to "ok"
hisCollectWriteFreqThis tag configures how long to buffer collected history items in memory before flushing them to the historian
hisEndTimestamp of newest item in history
hisErrError description when hisStatus indicates error condition
hisInterpolateModeExplicitly configures the interpolation mode to use for this point
hisModeIndicates the way that history data is collected for a point
hisRollupAutoMinIntervalForces hisRollupAuto() to do a rollup using this interval when none is specified and the range of the source history grid is less than 2 days
hisSizeApproximate number of timestamp/value pairs stored in history
hisStartTimestamp of oldest item in history
hisStatusStatus of point's history collection or synchronization
hisTotalizedIndicates values which are a continuous stream of totalization
idDefines the unique identifier of an entity in system using a ref value type
kindKind name used to identity a value data type
maxValInclusive maximum for a numeric value
minValInclusive minimum for a numeric value
navNameNavigation name commonly used with disMacro to create computed display strings
pointFunctionClassifies the point as a sensor, command, or setpoint
pointQuantityQuantity the point senses or controls
pointSubjectWhat the point senses or controls
siteRefReference to site which contains the entity
spaceRefReference to space which contains this entity
systemRefReference to system
tzTimezone identifier from standard timezone database
unitUnit identifier from standard unit database
writableSupports writing data


def ​

tariffHisRef ​

If multiple meters share the same tariff history, then you can use this tag to reference the "master" point containing the tariff history. See bill periods for details.


meta ​

deftariffHisRef
isref
liblib:tariff
tagOnmeter

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity


def ​

tariffPercentageCharge ​

A percentage charge rec.


meta ​

deftariffPercentageCharge
disKeytariffExt::tariff.percentageCharge
icondollar
istariffCharge
liblib:tariff

usage ​

tariffPercentageCharge  tariffCharge

supertypes ​

markerMarker labels a dict with typing information
entityTop-level dicts with a unique identifier
tariffChargeA tariff charge rec

tags ​

disDisplay name for an entity
idDefines the unique identifier of an entity in system using a ref value type
percentageA percentage specified as as <percent> * 100
scheduleRefAssociates a schedulable with its schedule
scheduleValThe string name/encoding of a schedule value
tariffChargeRefsThe charges that a percentage charge applies to
tariffRefThe tariff a charge belongs to


def ​

tariffRangeStrategy ​

When a charge has multiple ranges this tag indicates to the tariff engine how to interpret and calculate costs based on those ranges. See ranges for details.


meta ​

deftariffRangeStrategy
enumSee below
isstr
liblib:tariff
tagOntariffConsumptionCharge, tariffDemandCharge

enum ​

cumulativeAll ranges up-to-and-including the range containing the total/peak usage are used in calculating the cost.
inRangeOnly the range containing the total/peak is used in calculating the cost.
perReadingInstead of looking at the total or peak usage, the cost for each individual data reading is calculated based on the range it falls in.

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

tariffRanges ​

The fee ranges for a usage-based charge. See ranges for details.


meta ​

deftariffRanges
isgrid
liblib:tariff
tagOntariffConsumptionCharge, tariffDemandCharge

supertypes ​

valData value type
gridTwo dimension table of columns and rows


def ​

tariffRatchetPercentage ​

The peak demand identified during the ratchet period will be multiplied by this percentage to obtain the minimum peak demand. Must be specified as a number between 0 and 100.


meta ​

deftariffRatchetPercentage
isnumber
liblib:tariff
tagOntariffDemandCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
numberInteger or floating point numbers annotated with an optional unit


def ​

tariffRatchetPeriod ​

A value representing how far back to go when calculating the minimum peak demand for a billing period. Its value must be specified as {N}bills where N is the number of bill periods to consider and includes the current bill period.


meta ​

deftariffRatchetPeriod
isstr
liblib:tariff
tagOntariffDemandCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters


def ​

tariffRef ​

The tariff a charge belongs to.


meta ​

containedBytariff
deftariffRef
isref
liblib:tariff
oftariff
tagOntariffCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
refReference to an entity


def ​

tariffUsageOn ​

An axon filter used by the tariff engine to identify the charge's historical usage data. See usage-based charges.


meta ​

deftariffUsageOn
isfilterStr
liblib:tariff
tagOntariffConsumptionCharge, tariffDemandCharge, tariffAxonCharge

supertypes ​

valData value type
scalarScalar is an atomic value kind
strUnicode string of characters
filterStrHaystack filter string


def ​

view:tariffBillPeriods ​

Manage tariff billing periods


meta ​

appNameenergy
defview:tariffBillPeriods
disKeytariffExt::tariff.billPeriods
iconview
isview
liblib:tariff
order62

supertypes ​

featureFeature namespace of definitions formatted as feature:name
viewFresco UI view

src ​

view: {inherit:"tile"}
layout: {var kind:"Str" defVal:"grid 6x6; 0 0 6 3; 0 3 6 3"}
meterTariffConfig: Trio:
  view: {inherit:"table"}
  selectedMeter: {var kind:"Ref" bindSelect:"id"}
  editTariffHisRef: {disMacro:"$<ui::edit> $<tariffExt::tariff.tariffHisRef>"  action:"tariffExt::TariffMeterActions.editAction" select}
  createTariffHisPoint: { disMacro: "$<ui::new> $<tariffExt::tariff.childHisPoint>" action:"tariffCreateHisOnMeter" select}
  data: {expr:"tariffShowMeterHisConfig()"}
tariffHis: Trio:
  view: {inherit:"table"}
  selectedMeter: {var input binding:"../meterTariffConfig/selectedMeter"}
  span: {var input kind:"Span" defExpr: "pastYear().toSpan"}
  enterBillPeriod: {disMacro:"$<ui::submit> $<tariffExt::tariff.billPeriod>" action:"tariffExt::TariffHisActions.newAction" }
  removeBillPeriod: {disMacro:"$<ui::remove> $<tariffExt::tariff.billPeriod>" action:"tariffExt::TariffHisActions.removeAction" select confirm: { icon:"warn" disKey:"tariffExt::tariff.confirmBillPeriodRemove" detailsKey:"tariffExt::tariff.detailsBillPeriodRemove"} }
  data: {expr:"tariffBillHis({{selectedMeter}}, {{span}})"}


def ​

view:tariffCost ​

Analyze tariff costs against energy usage


meta ​

appNameenergy
defview:tariffCost
disKeytariffExt::tariffCostView
iconview
isview
liblib:tariff
order60

supertypes ​

featureFeature namespace of definitions formatted as feature:name
viewFresco UI view

src ​

view:   {inherit:"chart"}
sites:  {input var disKey:"ui::sites" kind:"Ref<site>[]" navCluster navSelAny share}
span:   {input var defVal:Span("today") share}
opts:Trio:
  var
  kind:"Dict"
  disKey:"ui::options"
  input
  templateName:"tariffCostOpts"
  defVal:Trio:
    meter:"elec"
    rollup: {fold:"sum", interval:"1day"}
data:   {expr:"tariffCostView({{sites}}, {{span}}, {{opts}})"}


def ​

view:tariffs ​

Tariff builder used to edit tariff and charge records


meta ​

appNameenergy
defview:tariffs
disKeyui::tariffs
iconview
isview
liblib:tariff
order61

supertypes ​

featureFeature namespace of definitions formatted as feature:name
viewFresco UI view

src ​

view: {inherit:"tile"}
layout: {var kind:"Str" defVal:"grid 6x6; 0 0 6 3; 0 3 6 3"}
tariffs: Trio:
  view: {inherit:"table" defName:"tariff"}
  selectedTariff: {var kind:"Ref" bindSelect:"id"}
  new: {disMacro:"$<ui::new> $<ui::tariff>" action:"recNew"}
  edit: {disMacro:"$<ui::edit> $<ui::tariff>" action:"recEdit" select}
  trash: {disMacro:"$<ui::trash> $<ui::tariff>" action:"recTrash" select}
  newCharge: {action:"recNew" uiInput:"tariffExt::TariffChargeActions.newAction" select}
  data: {expr:"readAll(tariff)"}
charges: Trio:
  view: {inherit:"table" defName:"tariffCharge"}
  selectedTariff: {var input binding:"../tariffs/selectedTariff"}
  edit: {disMacro:"$<ui::edit> $<ui::charge>" action:"recEdit" select}
  trash: {disMacro:"$<ui::trash> $<ui::charge>" action:"recTrash" select}
  data: {expr:"readAll(tariffCharge and tariffRef == {{selectedTariff}})"}