Script Example-Apply Average Unit Cost (AUC) from a Rate
TASK: Grab a unit cost variable. (EnergyCAP now has a new Rate Variable table that wasn’t available when this was written).
The method that was originally intended to be used for things like this was to store the value in a Rate Property and update the Rate Version when the value changes. This is where the Simple Rate Create comes in really handy.
Set up an arbitrary Vendor to be the holder of the Rates. Create a simple rate for the Commodity and give it a name like UNIT_COST_NG (for Natural Gas). In the Rate Properties Interface create an Input for each Unit Cost you need. This gives you the opportunity to have different unit costs for different units (THERM, CCF, etc.) and for different usage types. The only thing is to make the name unique.
Then in the VBScript for the bill you retrieve the Rate (it gets the current version based on bill dates) look for the Rate Properties Interface, find the correct input by name, and retrieve the value.
If the cost changes, you can either modify the Rate Properties or preferably create a new version with new numbers (so if you ever need to recalculate you still have the old ones).
There’s code in the Virtual Bill Wizard that would retrieve any value based on the rate name and the input name:
Function GetRateInputValue (RateCode, InputName)
Dim Rate
Set Rate = GetRate(RateCode)
Dim Interfaces
Set Interfaces = Rate.Interfaces
Dim Props
Set Props = Interfaces("3")
Dim Inputs
Set Inputs = Props.Inputs
Dim ReturnValue
ReturnValue = 0.0
For Each Input In Inputs
If Input.Name = InputName Then
ReturnValue = Input.Value
Exit For
End If
Next
GetRateInputValue = ReturnValue
End Function
The method that was originally intended to be used for things like this was to store the value in a Rate Property and update the Rate Version when the value changes. This is where the Simple Rate Create comes in really handy.
Set up an arbitrary Vendor to be the holder of the Rates. Create a simple rate for the Commodity and give it a name like UNIT_COST_NG (for Natural Gas). In the Rate Properties Interface create an Input for each Unit Cost you need. This gives you the opportunity to have different unit costs for different units (THERM, CCF, etc.) and for different usage types. The only thing is to make the name unique.
Then in the VBScript for the bill you retrieve the Rate (it gets the current version based on bill dates) look for the Rate Properties Interface, find the correct input by name, and retrieve the value.
If the cost changes, you can either modify the Rate Properties or preferably create a new version with new numbers (so if you ever need to recalculate you still have the old ones).
There’s code in the Virtual Bill Wizard that would retrieve any value based on the rate name and the input name:
Function GetRateInputValue (RateCode, InputName)
Dim Rate
Set Rate = GetRate(RateCode)
Dim Interfaces
Set Interfaces = Rate.Interfaces
Dim Props
Set Props = Interfaces("3")
Dim Inputs
Set Inputs = Props.Inputs
Dim ReturnValue
ReturnValue = 0.0
For Each Input In Inputs
If Input.Name = InputName Then
ReturnValue = Input.Value
Exit For
End If
Next
GetRateInputValue = ReturnValue
End Function

