Virtual Bill Sample Script
' Sample Virtual Account Script
' This Virtual Account Script must be assigned to the Account having its bills calculated.
' This script uses interval data from a Meter Use Channel to determine the bill consumption.
' This script uses an EnergyCAP Rate to calculate the bill cost.
'
'=======
' Declare the Source Meter and Rate
'=======
DIM ChannelMeterCode
ChannelMeterCode = "METER123"
'
DIM RateCode
RateCode = "RATE_01"
'
'=======
' Define any Customer Charge, Line Loss Factor, or Bill Factor
'=======
'
' Monthly Customer Charge in addition to any calculated charges.
' If none, or if Customer Charge included in Rate, set equal to zero.
DIM CustomerCharge
CustomerCharge = 0.00
'
' Line Loss within internal delivery network.
' A Line Loss Factor of 1.05 corresponds to an assumption of a 5 percent line loss.
' If Line Losses not being included, set equal to 1.00.
DIM LineLossFactor
LineLossFactor = 1.00
'
' Bill Factor is used to adjust the consumption determined by the interval data or meter readings.
' A Bill Factor of 0.20 will result in the consumption being 20 percent of the metered consumption.
' If consumption is not being adjusted, set equal to 1.00.
DIM BillFactor
BillFactor = 1.00
'
'=======
' Get the consumption from a Use Channel
'=======
'
' Adjust the FormTemplate Dates to be the Dest.StartDate and Dest.EndDate
' Not necessary to AdjustDates when using Interval Data (15-minute, hourly, or daily)
' Must add 1 to obtain Meter Reading Channel Data for the Destination Bill Period
'AdjustDates Dest.StartDate + 1, Dest.EndDate + 1
'
Dim ChannelUse
ChannelUse = TotalUse(ChannelMeterCode)
'
' Use this Msgbox to check for returned data while debugging code
'Msgbox ("Channel for Source Meter Code " & ChannelMeterCode & " Returned Use of " & ChannelUse)
'
' A Channel Use less than or equal to zero may indicate a problem with the interval data
If ChannelUse = 0.0 Then
Msgbox ("Channel Data for Source Meter Code " & ChannelMeterCode & " Returned Zero Use!")
End If
If ChannelUse < 0.0 Then
MsgBox ("Channel Data for Source Meter Code " & ChannelMeterCode & " returned NEGATIVE Use of " & ChannelUse)
End If
'
'=======
' Declare and initialize temporary variables to store the Usage and Cost
' The Cost variable will trap the calculated cost returned by the Rate (below)
'=======
'
DIM tmpUse, tmpCost
' Initialize tmpUse and incorporate the usage factors from above
tmpUse = (ChannelUse * (LineLossFactor * BillFactor))
'
' Initialize tmpCost to zero
tmpCost = 0.00
'
' Adjust the FormTemplate Dates back to the original dates, IF adjusted above.
'AdjustDates Dest.StartDate - 1, Dest.EndDate - 1
'
'=======
' Initialize the Rate and create a dummy bill to pass the Inputs needed for the Rate Calculation
' The Rate.CreateBillEx(StartDate, EndDate) function creates a bill with Line Items that correspond
' to the Inputs needed for the Rate.
'=======
'
DIM Rate
Set Rate = GetRate(RateCode)
'
Dim DummyBill
' THE STARTDATE AND ENDDATE ARE SET TO THE MANUAL PROCESS STARTDATE AND ENDDATE, UNLESS AN ADJUSTDATE IS USED ABOVE.
' Use this MsgBox to check data while debugging code
'MsgBox("StartDate = " & StartDate & " EndDate = " & EndDate)
Set DummyBill = Rate.CreateBillEx(StartDate, EndDate)
'
'=======
' Set the DummyBill Line Item values to be used as Inputs for the Rate
' There may be many more than just the Usage, depending on the complexity of the Rate
' To see how many Line Items exist, use the following:
' MsgBox("Number of DummyBill Line Items = " & DummyBill.Lines.Count)
' To see what the Line Item Captions are, edit and use the following as many times as needed (up to the count of line items):
' MsgBox("Line Item 1 Caption = " & DummyBill.Lines(1).Caption)
'=======
'
DummyBill.Lines("Usage").value = tmpUse
'
'=======
' Now have the Rate perform the cost calculations and return the Outputs
' There are several Outputs including Total Cost, Taxes, and Customer Charges
'=======
'
DIM Outputs
Set Outputs = Rate.Calculate(DummyBill)
' Set the cost variable equal to the TotalCost Output from the Rate Calculation
tmpCost = Outputs("TotalCost").value
'
' Use these MsgBoxes to check the data while debugging code
' What cost value was calculated by the Rate?
'MsgBox ("Cost returned from the Rate = " & tmpCost)
' Is the tmpCost value being returned correct?
' Double check that usage value is retained
'MsgBox ("Current Usage value = " & tmpUse)
'
'=======
' Calculate the Destination Bill Charges
'=======
'
DIM DestBillCost
' Include any additional monthly Customer Charges from above.
DestBillCost = tmpCost + CustomerCharge
'
' Use this MsgBox to check the data while debugging code
'MsgBox ("Destination Bill Cost = " & DestBillCost)
'
'=======
' Generate the Destination Bill
' Destination bill has Template "KWH_01" Assigned
' Line items are for "Usage" and "Total Cost"
'=======
'
Dest.Lines("Usage").Value = tmpUse
Dest.Lines("Total Cost").Cost = DestBillCost
Dest.Cost = DestBillCost
'
'=======
' end script

