Creating an EDI Script Version

Managing EDI Bill Imports

Overview: Importing EDI Data

Electronic Data Interchange (EDI) is a standard method used by utility vendors to transmit electronic billing data.  In EnergyCAP, the EDI Processor executes user-defined formulas (scripts) associated with the account to create bills from imported data. 

EnergyCAP’s part in the EDI process is simply to receive the EDI 810 v 4010 (X.12 compliant) transaction and to import specified billing invoice data into the database.  EnergyCAP does not produce any EDI compliant response transaction such as an EDI 997 acknowledgement.  EnergyCAP will not generate an EDI 820 Remittance. 

Each utility company’s implementation of EDI is different and each has rules and guidelines which govern the arrangement between the customer and the utility.  Most arrangements require that a VAN (Value Added Network) partner is in place to handle the distribution of the EDI transactions.  In addition, some utilities mandate a paperless invoice process with payments made via ACH/EFT methods through an EDI 820 Remittance transaction.

Contact your vendor(s) to determine the specific rules for their EDI offerings.  In most cases, there will be a trial period for a test group of accounts prior to switching from paper invoices to EDI transactions only.  The trial period helps to ensure that the bill detail is being captured properly and that the payment methods are working as expected.

If you are interested in implementing EDI for your organization, first contact your utility companies and begin discussions with them regarding EDI requirements.  Then contact EnergyCAP Sales (sales@energycap.com) to determine pricing for implementing EDI transactions in EnergyCAP.  You may also find the following online resources helpful as you investigate the benefits of EDI for your organization.

Southern California – Edison EDI Overview:
http://en.wikipedia.org/wiki/Electronic_Data_Interchange

A Bit About Scripts

EnergyCAP Enterprise maintains a history of a vendor's bill scripts in order to match the bill period to the applicable EDI script version when importing bills.

Before importing EDI data, use the EDI Script Editor (accessible from the Contact Manager via the Contact menu item, or by right-clicking the desired account-View Script option) to create a script for the desired vendor.

EDI Overview 01.JPG

Import Prerequisites

In order to import EDI data into EnergyCAP Enterprise, first verify the following:

  • The data in the import file matches your EnergyCAP Enterprise dataset (account code, commodity, and meter code).
  • The vendor’s EDI import ID matches the ID used in the import file. This ID is the concatenation of the vendor’s two-character ISA sender ID qualifier and the fifteen-character ISA sender ID code.

EDI Overview 02.JPG

  • The vendor is associated with an active, bill-enabled account for which the effective date is the same as or earlier than the effective date of the data to be imported.

NOTE: EnergyCAP Enterprise lists any errors that occur during the import process in the EDI Processor Problem folder of the Work Flow Manager.

The ediprofile.ini file, located in the Local Settings\Application Data\EnergyCAP Enterprise directory under the Documents and Settings directory for your Windows login profile, allows you to toggle global settings for the bill import processor:

  • ReadDuplicates, for allowing the import of bills with duplicate bill dates for the same account (1=Yes, the default, or 0=No).
  • UseTemplates, for specifying if an import bill mirrors the details that a manually-entered bill would inherit from the assigned bill entry template (1=Yes, the default, or 0=No); additional details which do not correspond to template details still get added to the end of the bill, while template details with no corresponding import details will not have values assigned.

Managing EDI Bill Imports

Using the EDI Script Editor

EDI scripts are written in Visual Basic programming language. The EDI import process uses the script to supply values to bills. Energy CAP Enterprise maintains a history of the vendor's EDI script versions.

When editing a bill script, the modified script applies to the current version and all future versions of this bill.

Editing scripts should only be attempted by advanced users with Visual Basic programming skills.

  1. Select Setup > Contacts. The Contact Manager appears.

  2. From the Contact menu, select View > Vendors.

  3. Select the applicable vendor.

  4. From the Contact menu, select View Script. The EDI Script Editor window appears.

  5. You can:

To save a script file:

  1. Click save.gif. The Save As window appears.

  2. In the Save in field, select the directory location for the file.

  3. In the File name field, enter a name for the file.

  4. After making your selections, click Save. The script is saved as a file to the location you specified.

To open a script file:

  1. Click open.gif. The Open dialog box appears.

  2. In the Look in field, select the directory location of the script file.

  3. In the File List section, select the appropriate script file.

  4. Click Open. The opened script file text replaces the existing script text.

To search the script text:

  1. Click srch_icon.gif. The Find window appears.

  2. Enter the text you want to find.

  3. Select any search options:

    • Match whole word only Finds only whole words instead of searching for your text inside longer words.

    • Match case Finds only text that has the same pattern of upper and lower case as the text you specified in the Find What field.

  4. Click Find Next. A search begins for the instance of the text you specified in the Find What field. Matching text is highlighted in the Script Editor.

  5. To search for the next occurrence, click Find Next.

  6. Exit the Find dialog by clicking Cancel.

To print a script:

  • Click print.gif. The script text is printed to your default printer.

  • Exit the EDI Script Editor dialog box by clicking Cancel.


  • Managing EDI Bill Imports

    Creating an EDI Script Version

    EDI scripts are written in Visual Basic programming language. The EDI import process uses the script to supply values to bills. Energy CAP Enterprise maintains a history of the vendor's EDI script versions.

    1. Select Setup | Contacts. The Contact Manager appears.

    2. From the Contact menu, select View | Vendors.

    3. Select the applicable vendor.

    4. From the Contact menu, select View Script. The EDI Script Editor dialog box appears.

    5. Enter the script effective date by clicking . The Choose a date dialog box appears.

      1. Enter an effective date or use the drop-down arrow to select the date from a calendar.

      2. Click OK. The Choose a date dialog box closes and the text area of the Bill Script Editor displays <enter script>.

    6. Clear the text area of the Bill Script Editor.

    7. Enter your script text.

    8. When complete, click OK.


    Managing EDI Bill Imports

    Editing an EDI Script Version

    When editing a script, the modified script applies to all imported bills transmitted between the version begin and end dates.

    Script editing should only be attempted by advanced users with Visual Basic programming skills. EnergyCAP, Inc. does not support or troubleshoot user-edited custom scripts without previous contractual agreement.

    1. Select Setup > Contacts. The Contact Manager appears.

    2. From the Contact menu, select View > Vendors.

    3. Select the applicable vendor.

    4. From the Contact menu, select View Script. The EDI Script Editor window appears.

    5. Place the cursor in the area of the script text to edit.

    6. Make the necessary modifications.

    7. Click OK. The modified bill script is saved and the EDI Script Editor window closes.


    Managing EDI Bill Imports

    Deleting an EDI Script Version

    1. Click Setup > Contacts. The Contact Manager appears.
    2. From the Contact menu, click View > Vendors.
    3. Select the applicable vendor.
    4. From the Contact menu, select View Script. The EDI Script Editor window appears.
    5. Select the appropriate EDI script version in the Version drop-down list.
    6. Click minus.gif .
    7. Repeat steps 5 and 6 to delete other EDI script versions for this vendor.
    8. Click OK to save your changes. The EDI Script Editor window closes.

     


    Managing EDI Bill Imports

    Importing EDI Data

    When importing EDI data, the data used is available to all vendors having the same import ID (Vendor Properties / Other tab) as the EDI ID used in the EDI file. The EDI ID is a concatenation of elements 5 and 6 from the ISA envelope segment.

    1. Select Accounting > Accounts. The Account Manager is displayed.
    2. From the File menu, select Import. The Import File window appears.
    3. In the Look in field, select the directory location of the EDI file.
    4. In the File List section, select the appropriate EDI file.
    5. Click Open. A progress indicator appears (If necessary, it is possible to cancel the import operation by clicking Abort). When the process is complete, the Log window appears, displaying the status of the import process, the file import path, and any errors that occurred during the process. If errors did occur, they are listed, and will need to be corrected in order to successfully import the file into the database. If the import was successful, this will be indicated in the log.
    6. Save the log file by clicking save.gif. The Save As window appears.
      1. In the Save in field, select the directory location for the file.
      2. Print the log file by clicking print.gif. The log file display is printed to the default printer.
      3. Exit the Log window by clicking Close.
    7. View EDI Processor problem messages from the Work Flow Manager. If necessary, correct problems and reimport.

    Managing EDI Bill Imports

    Viewing EDI Processor Problem Messages

    1. Select Accounting > Work Flow Manager. The Work Flow Manager appears.

    2. Click grp_lst.gif to open the Bill Import Processor folder and navigate to the Problem folder.

    3. Select the appropriate bill. Problems resulting from running the EDI import processor have a message beginning with "ED".
      EDI Overview 03.JPG

      EDI Overview 03a.jpg

    4. From the File menu, select Properties. The Kickout Properties window appears and displays the following information:

      • Account

      • Kickout code

      • Information

      • Kickout text

    5. Exit the Kickout Properties window by clicking Close.

    EDI Import Error Messages

    Could not open EDI file filename.
    Error reading from EDI file filename.
    Could not open translated EDI file.
    Error reading from translated EDI file.
    File is unreadable. ISA delimiter not found.
    File is unreadable. End-of-line delimiter not found.
    File is unreadable. GS segment not found. Unable to process consolidated invoice. Invoiced discarded.
    Unable to process credit/debit memo. Invoice discarded.
    Invoice is of an unknown type. Invoice discarded.
    Account 'EDI account number' is not found. Invoice discarded.
    Account 'EDI account number' is not a billing account. Invoice discarded.
    Account 'EDI account number' is not in service during this service period (start date to end date).  Invoice discarded.
    Vendor 'EDI vendor code' account 'EDI account number' is now assigned to vendor ‘account vendor code’. Invoice discarded.
    Service period start date (start date) must be less than end date (end date). Invoice discarded.
    'EDI commodity code' meter count (EDI meter count) does not match account meter count (account meter count). Invoice discarded.
    'EDI commodity code' meter 'EDI meter code' is not found. Invoice discarded.
    Meter 'EDI meter code' commodity 'EDI commodity code' does not match account meter commodity 'account meter commodity'. Invoice discarded.
    'EDI commodity code' meter 'EDI meter code' is not assigned to account 'EDI account number'. Invoice discarded.
    'EDI commodity code' meter 'EDI meter code' is not in service during the service period from start date to end date. Invoice discarded.
    'EDI commodity code' meter 'EDI meter code' is not in service on account 'EDI account number' during the service period from start date to end date. Invoice discarded.
    Mandatory invoice detail 'observation type' is not set. Invoice discarded.
    Invoice total cost is not set. Invoice discarded.
    Test import. Invoice discarded.
    This is an adjustment invoice. Please verify processed invoice.
    This is a corrected invoice. Please verify processed invoice.
    This is a duplicate invoice. Please verify processed invoice.
    This is a final invoice. Please deactivate account.
    Account number 'Old EDI account number' has changed to 'EDI account number'. Please update database.
    'EDI commodity code' meter 'EDI meter code' could not be matched using meter code; meter matched by commodity only.
    Multiple 'EDI commodity code' meter matches (account meter count) occurred based on EDI import code; first meter selected.
    Multiple 'EDI commodity code' meter matches (account meter count) occurred based on serial number; first meter selected.
    Multiple 'EDI commodity code' meter matches (account meter count) occurred based on device code; first meter selected.
    Multiple 'EDI commodity code' meter matches (account meter count) occurred based on commodity; first meter selected.
    Commodity 'EDI commodity code' is not found. Invoice detail discarded.
    Observation type 'observation type' is not found. Invoice detail discarded.
    Observation method 'observation method' is not found. Invoice detail discarded.
    Unit code 'unit code' is not found. Invoice detail discarded.


    Managing EDI Bill Imports

    Reimporting EDI Data

    EDI bills are reimported using the Bill Reimport Processor.

    The Bill Reimport Processor attempts to reimport ALL bills that were successfully read but were NOT successfully imported. These bills can be viewed in the Bill Import Processor problem folder of the Work Flow Manager.

    Kickout messages beginning with "ED" are produced by the EDI import processor. Only kickout records with entries in the kickout text field are eligible for reimport. Currently, it is impossible to edit EDI transactions in EnergyCAP.

    1. From the Tools menu, select Processor > Bill Reimport. A progress indicator appears.

      • If necessary, it is possible to cancel the operation by clicking Abort.
    1. When the process is complete, the Log window appears the status of the import process. If errors did occur, they are listed in the log, and it will be necessary to correct these errors in order to successfully reimport the file into the database. If the reimport was successful, this will be indicated in the log.

      1. To save the log file, click save.gif. The Save As window appears.

        1. In the Save in field, select the directory location for the file.

        2. In the File name field, enter a name for the file.

        3. Click Save.

      2. Print the log file by clicking print.gif. The log file display is printed to the default printer.

      3. Exit the Log window by clicking Close.


    Managing EDI Bill Imports

    EnergyCAP EDI Bill Import Process

    To import EDI files into EnergyCAP:

    1. Select File > Import from the Account Manager. The Import File window will appear.
    2. Click to browse/select the import file. EDI 810 files should have a file type of .EDI or .DAT. Then click Open.
    3. All imported bills are listed in the Waiting to Verify folder. They can be audited and edited. Use the control totals at bottom to validate record count and total amount. If necessary, all can be deleted at once (select bills, then right-click, and select Delete Bill from Database from the right-click menu) if it is desirable to re-run the import.
    4. To ‘accept’ the bills, highlight and click Verify.

     

    NOTES: Any ‘kickouts’ are shown in the Bill Import Processor Problem folder. Kickouts can be edited and re-imported using the Reimport Processor.

     

     


    Managing EDI Bill Imports

    Sample EDI 810 v4010 Import Script

    EnergyCAP Enterprise uses Visual Basic scripts to interpret incoming EDI invoices from utility company vendors. Following is a sample of an EDI 810 v4010 import script for PG&E.

    ______________________________

     

    ' -- Start Main EDI Import Script --

     

    '

    ' EDI Version Check

    '

    Select Case EdiTransaction.TransactionSet

    Case "810"

    Select Case EdiTransaction.Version

    Case "002040"

    Import810Version2040

    Case "003030"

    Import810Version3030

    Case "003040"

    Import810Version3040

    Case "004010"

    Import810Version4010

    Case Else

    AddMessage("Cannot read this version of 810 transaction.\r\nInvoice discarded.")

    ExitScript

    End Select

    Case Else

    '

    ' Do nothing; just ignore data

    '

    End Select

     

    ' -- End Main EDI Import Script --

     

    ' -- Start EDI Version Import Scripts --

     

    Sub Import810Version2040

    AddMessage("Script to read version 2040 810 transactions not yet implemented.\r\nInvoice discarded.")

    ExitScript

    End Sub

     

    Sub Import810Version3030

    AddMessage("Script to read version 3030 810 transactions not yet implemented.\r\nInvoice discarded.")

    ExitScript

    End Sub

     

    Sub Import810Version3040

    AddMessage("Script to read version 3040 810 transactions not yet implemented.\r\nInvoice discarded.")

    ExitScript

    End Sub

     

    Sub Import810Version4010

    Dim Seg1

    Dim Seg2

    Dim Elem1

    Dim Elem2

     

    Dim AccountCode

    Dim OldAccountCode

    Dim InvoiceNumber

    Dim InvoiceType

    Dim DocumentCode

    Dim StartDate

    Dim EndDate

    Dim InvoiceDate

    Dim DueDate

    Dim Estimated

    Dim MeterCode

    Dim CommodityCode

    Dim ObservationType

    Dim ValueUnitCode

    Dim Value

    Dim CostUnitCode

    Dim Cost

    Dim RoundoffError

    Dim Caption

    Dim Bill

    Dim FoundUseMEA

    Dim FoundDemandMEA

    Dim MeterMultiplier

     

    '

    ' Importer settings

    '

    RoundoffMethod = rmAmount ' do a fixed-amount roundoff compensation

    RoundoffAmount = 2 ' allow two cents per detail

     

    '

    ' Find transaction account number

    '

    Set Seg1 = EdiTransaction.FindSegment("BIG", "", sdFirst)

    If (IsObject(Seg1)) Then

    Set Elem1 = Seg1.FindElement("2")

    ' Begin method one

    ' AccountCode = Elem1.Value

    ' End method one

     

    ' Begin method two

    If (Len(Elem1.Value) > 6) Then

    AccountCode = Left(Elem1.Value, Len(Elem1.Value) - 6)

    Else

    AccountCode = ""

    End If

    ' End method two

    Else

    AccountCode = ""

    End If

    ' Set Seg1 = EdiTransaction.FindSegment("REF", "REF:01='11'", sdFirst)

    ' If (IsObject(Seg1)) Then

    ' AccountCode = Seg1.FindElement("2").Value

    ' End If

     

     

    '

    ' Find transaction invoice number

    '

    ' Set Seg1 = EdiTransaction.FindSegment("BIG", "", sdFirst)

    If (IsObject(Seg1)) Then

    InvoiceNumber = Seg1.FindElement("2").Value

    Else

    InvoiceNumber = ""

    End If

     

    '

    ' Find invoice type

    '

    ' Element 7 of the BIG segment contains a code indicating

    ' what kind of invoice is being processed. The types of invoices

    ' to expect will vary by vendor. These codes are

    ' typically one of the following:

    '

    ' Invoice type code Invoice type

    ' --------------------------------------- -------------------------

    ' CI (consolidated invoice) itConsolidated

    ' CO (corrected invoice) itCorrected

    ' DU (duplicate invoice) itDuplicate

    ' FB (final invoice) itFinal

    ' FE (memorandum, final invoice) itFinal

    ' ME (memorandum) itMemo

    ' PR (original invoice) itOriginal

    ' <other> itUnknown

    '

    ' Element 8 of the BIG segment may contain a code additionally indicating

    ' what kind of invoice is being processed. These codes are

    ' typically one of the following:

    '

    ' Invoice action code Invoice type

    ' --------------------------------------- -------------------------

    ' 00 (original invoice) itOriginal

    ' 01 (cancel invoice) itCancelled

    ' 05 (replace invoice) itCorrected

    ' 07 (duplicate invoice) itDuplicate

    ' CO (corrected invoice) itCorrected

    ' <other> <ignore code>, or itUnknown

    '

    ' Invoice type itAdjustment is also available for invoices which

    ' contain only adjustments to a prior invoice, rather than

    ' an entirely new invoice to replace a prior one. There are currently

    ' no known EDI codes to indicate this type of invoice.

    '

    If (IsObject(Seg1)) Then

    Select Case Seg1.FindElement("7").Value

    Case "PR"

    InvoiceType = itOriginal

    Case Else

    ' Don't know how to implement other types of invoices at this time

    InvoiceType = itUnknown

    End Select

    Else

    InvoiceType = itUnknown

    End If

     

    '

    ' Find control code

    '

    DocumentCode = Right("000000000" & EdiTransaction.IchgCtrlNumber, 9)

    DocumentCode = DocumentCode & Right("000000000" & EdiTransaction.FcnlGrpCtrlNumber, 9)

    DocumentCode = DocumentCode & Right("000000000" & EdiTransaction.TrxCtrlNumber, 9)

     

    '

    ' Find invoice date

    '

    If (IsObject(Seg1)) Then

    Set Elem1 = Seg1.FindElement("1")

    InvoiceDate = CDate(Mid(Elem1.Value, 5, 2) & "/" & Mid(Elem1.Value, 7, 2) & "/" & Mid(Elem1.Value, 1, 4))

    Else

    InvoiceDate = 0

    End If

     

    '

    ' Find payment due date

    '

    Set Seg1 = EdiTransaction.FindSegment("ITD", "", sdFirst)

    If (IsObject(Seg1)) Then

    Set Elem1 = Seg1.FindElement("6")

    DueDate = CDate(Mid(Elem1.Value, 5, 2) & "/" & Mid(Elem1.Value, 7, 2) & "/" & Mid(Elem1.Value, 1, 4))

    Else

    DueDate = 0

    End If

     

    '

    ' Find transaction old account number (if it exists)

    '

    Set Seg1 = EdiTransaction.FindSegment("REF", "REF:01='45'", sdFirst)

    If (IsObject(Seg1)) Then

    OldAccountCode = Seg1.FindElement("2").Value

    Else

    OldAccountCode = ""

    End If

     

    '

    ' Find service period start date

    '

    Set Seg1 = EdiTransaction.FindSegment("DTM", "DTM:01='150'", sdFirst)

    If (Not IsObject(Seg1)) Then

    Set Seg1 = EdiTransaction.FindSegment("DTM", "DTM:01='186'", sdFirst)

    End If

    If (IsObject(Seg1)) Then

    Set Elem1 = Seg1.FindElement("2")

    If (Elem1.Value = "") Then

    Set Elem1 = Seg1.FindElement("6")

    End If

    StartDate = CDate(Mid(Elem1.Value, 5, 2) & "/" & Mid(Elem1.Value, 7, 2) & "/" & Mid(Elem1.Value, 1, 4))

    Else

    StartDate = 0

    End If

     

    '

    ' Find service period end date

    '

    Set Seg1 = EdiTransaction.FindSegment("DTM", "DTM:01='151'", sdFirst)

    If (Not IsObject(Seg1)) Then

    Set Seg1 = EdiTransaction.FindSegment("DTM", "DTM:01='187'", sdFirst)

    End If

    If (IsObject(Seg1)) Then

    Set Elem1 = Seg1.FindElement("2")

    If (Elem1.Value = "") Then

    Set Elem1 = Seg1.FindElement("6")

    End If

    EndDate = CDate(Mid(Elem1.Value, 5, 2) & "/" & Mid(Elem1.Value, 7, 2) & "/" & Mid(Elem1.Value, 1, 4))

    Else

    EndDate = 0

    End If

     

    '

    ' Set "estimated bill" flag

    '

    Set Seg1 = EdiTransaction.FindSegment("MEA", "MEA:01='AE' OR MEA:01='EE'", sdFirst)

    If (IsObject(Seg1)) Then

    Estimated = True

    Else

    Estimated = False

    End If

     

    '

    ' Create an EnergySense bill object to populate;

    ' set the bill properties for the data that we've read

    '

    Set Bill = CreateBill(AccountCode, StartDate, EndDate)

    Bill.OldAccountNumber = OldAccountCode

    Bill.InvoiceNumber = InvoiceNumber

    Bill.InvoiceType = InvoiceType

    Bill.DocumentCode = DocumentCode

    If (InvoiceDate > 0) Then

    Bill.StatementDate = InvoiceDate

    End If

    If (DueDate > 0) Then

    Bill.DueDate = DueDate

    End If

    Bill.Estimated = Estimated

     

    '

    ' Read account balance data and store it as information-only line items

    '

    ' The ToNumber function used below is defined in the utility subroutine

    ' section of this script.

    '

    MeterCode = ""

    CommodityCode = "MONEY"

    Value = 0 ' these are all cost details

    ValueUnitCode = "" ' these are all cost details

    CostUnitCode = "USDOLLARS"

    RoundoffError = False

    Set Seg1 = EdiTransaction.FindSegment("BAL", "", sdFirst)

    While (IsObject(Seg1))

    Cost = CDbl(ToNumber(Seg1.FindElement("3").Value))

    Select Case Seg1.FindElement("2").Value

    Case "PB"

    ObservationType = "PRIORBALANCE"

    Caption = "Balance From Previous Period"

    Case "YB" ' not sure what this is meant to convey

    ObservationType = "PRIORBALANCE"

    Caption = "Unknown Prior Balance"

    Case Else ' don't know what to do

    ObservationType = "PRIORBALANCE"

    Caption = "Unknown Prior Balance"

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

     

    '

    ' Add cost detail to bill and find next BAL segment

    '

    If ((Cost <> 0) And (ObservationType <> "")) Then

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    Set Seg1 = EdiTransaction.FindSegment("BAL", "", sdNext)

    Wend

     

    '

    ' Find account charge section and assign bill with details

    '

    Set Seg1 = EdiTransaction.FindSegment("IT1(TDS)", "IT1:09='ACCOUNT'", sdFirst)

    If (IsObject(Seg1)) Then

    '

    ' Read account cost details inside the current IT1 segment loop.

    '

    MeterCode = ""

    CommodityCode = "MONEY"

    Value = 0 ' these are all cost details

    ValueUnitCode = "" ' these are all cost details

    RoundoffError = False

    Set Seg2 = Seg1.FindSegment("SAC", "", sdNext)

    While (IsObject(Seg2))

    Cost = GetSACCostNoCharge(Seg2)

    GetSACObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Add cost detail to bill and find next SAC segment

    '

    If ((Cost <> 0) And (ObservationType <> "")) Then

    If (Seg2.FindElement("1").Value = "N") Then

    ObservationType = "NOCHARGE"

    End If

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, "", 0, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    Set Seg2 = Seg1.FindSegment("SAC", "", sdNext)

    Wend

     

    '

    ' Read TXI segments now

    '

    Value = 0 ' these are all cost details

    ValueUnitCode = "" ' these are all cost details

    Set Seg1 = EdiTransaction.FindSegment("IT1(TDS)", "", sdCurrent) ' get another IT1 segment object positioned at beginning of loop to use for TXI search

    Set Seg2 = Seg1.FindSegment("TXI", "", sdNext)

    While (IsObject(Seg2))

    Cost = CDbl(ToNumber(Seg2.FindElement("2").Value))

    GetTXIObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Add cost detail to bill and find next TXI segment

    '

    If ((Cost <> 0) And (ObservationType <> "")) Then

    If (Seg2.FindElement("7").Value = "O") Then

    ObservationType = "NOCHARGE"

    End If

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    Set Seg2 = Seg1.FindSegment("TXI", "", sdNext)

    Wend

    End If

     

    '

    ' Find meter charge section and assign bill with details

    '

    CommodityCode = ""

    Set Seg1 = EdiTransaction.FindSegment("IT1(TDS)", "IT1:09='METER' OR IT1:09='UNMET'", sdFirst)

    While (IsObject(Seg1))

    '

    ' Read meter commodity

    '

    Set Elem1 = Seg1.FindElement("7")

    If (CommodityCode <> Elem1.Value) Then ' only reading one meter code per commodity

    MeterCode = ""

    End If

    CommodityCode = Elem1.Value

     

    '

    ' Find meter code

    '

    ' There is no requirement that meter serial numbers

    ' be provided in the invoice. If there is one here, read it.

    '

    Set Seg2 = Seg1.FindSegment("IT1(TDS)", "", sdCurrent, False)

    Set Seg2 = Seg2.FindSegment("REF", "REF:01='MG'", sdNext)

    If (IsObject(Seg2)) Then

    If (MeterCode = "") Then

    MeterCode = Seg2.FindElement("2").Value

    End If

    End If

     

    '

    ' Spin through all measurement segments within the current IT1 segment loop

    ' to see if there are any "use" or "demand" segments, and find meter multiplier

    '

    FoundUseMEA = 0

    FoundDemandMEA = 0

    MeterMultiplier = 1

    Set Seg2 = Seg1.FindSegment("MEA", "", sdNext)

    While (IsObject(Seg2))

    GetMEAObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Set "found" flags and/or meter multiplier

    '

    If (Seg2.FindElement("2").Value = "MU") Then

    MeterMultiplier = CDbl(ToNumber(Seg2.FindElement("3").Value))

    ElseIf (ObservationType <> "") Then

    Select Case ValueUnitCode

    Case "KWH"

    FoundUseMEA = FoundUseMEA + 1

    Case "KW"

    FoundDemandMEA = FoundDemandMEA + 1

    Case Else ' don't know what type of measurement

    End Select

    End If

    Set Seg2 = Seg1.FindSegment("MEA", "", sdNext)

    Wend

     

    '

    ' Read all measurement segments within the current IT1 segment loop;

    '

    Set Seg1 = EdiTransaction.FindSegment("IT1(TDS)", "", sdCurrent) ' get another IT1 segment object positioned at beginning of loop to use for SAC search

    Set Seg2 = Seg1.FindSegment("MEA", "", sdNext)

    While (IsObject(Seg2))

    Value = CDbl(ToNumber(Seg2.FindElement("6").Value))

    GetMEAObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Add value detail to bill and find next MEA segment

    '

    If ((FoundDemandMEA > 1) And (ValueUnitCode = "KW") And (Seg2.FindElement("7").Value = "51")) Then

    ObservationType = "" ' don't add this detail to bill - it is a duplicate

    End If

    If ((Value <> 0) And (ObservationType <> "")) Then

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, 0, False, ctDebit, Caption

    Else

    '

    ' See if we need to add demand detail

    '

    Value = (Value - CDbl(ToNumber(Seg2.FindElement("5").Value))) * MeterMultiplier

    If ((FoundDemandMEA = 0) And (Value <> 0) And (ObservationType <> "") And (ValueUnitCode = "KW")) Then

    ObservationType = "DEMAND"

    End If

    If ((Value <> 0) And (ObservationType <> "")) Then

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, 0, False, ctDebit, Caption

    End If

    End If

    Set Seg2 = Seg1.FindSegment("MEA", "", sdNext)

    Wend

     

    '

    ' Read all invoice consumption/cost details inside

    ' the current IT1 segment loop

    '

    RoundoffError = False

    Set Seg1 = EdiTransaction.FindSegment("IT1(TDS)", "", sdCurrent) ' get another IT1 segment object positioned at beginning of loop to use for SAC search

    Set Seg2 = Seg1.FindSegment("SAC", "", sdNext)

    While (IsObject(Seg2))

    Value = CDbl(ToNumber(Seg2.FindElement("10").Value))

    Cost = GetSACCostNoCharge(Seg2)

    Select Case Seg2.FindElement("9").Value

    Case "KH"

    ValueUnitCode = "KWH"

    Case "K1"

    ValueUnitCode = "KW"

    Case "EA"

    Value = 0 ' don't use value

    ValueUnitCode = ""

    Case Else ' don't know what unit to assign if not one of the codes above

    ValueUnitCode = ""

    End Select

    GetSACObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Add value and cost details to bill and find next SAC segment

    ' (add value and cost as seperate details so that "no charge"

    ' details can be captured correctly regardless of template setup.

    '

    If ((FoundUseMEA = 0) And (ObservationType = "GENERATIONUSE")) Then

    ObservationType = "USE" ' no generation use, just normal use

    Caption = "Use"

    End If

    If (ObservationType <> "") Then

    If (Seg2.FindElement("1").Value = "N") Then

    If (Value <> 0) Then

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, 0, False, ctDebit, Caption

    End If

    If (Cost <> 0) Then

    ObservationType = "NOCHARGE"

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, "", 0, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    Else

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    End If

    Set Seg2 = Seg1.FindSegment("SAC", "", sdNext)

    Wend

     

    '

    ' Read TXI segments now

    '

    Value = 0 ' these are all cost details

    ValueUnitCode = "" ' these are all cost details

    Set Seg1 = EdiTransaction.FindSegment("IT1(TDS)", "", sdCurrent) ' get another IT1 segment object positioned at beginning of loop to use for TXI search

    Set Seg2 = Seg1.FindSegment("TXI", "", sdNext)

    While (IsObject(Seg2))

    Cost = CDbl(ToNumber(Seg2.FindElement("2").Value))

    GetTXIObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Add cost detail to bill and find next TXI segment

    '

    If (ObservationType <> "") Then

    If (Seg2.FindElement("7").Value = "O") Then

    ObservationType = "NOCHARGE"

    End If

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    Set Seg2 = Seg1.FindSegment("TXI", "", sdNext)

    Wend

    Set Seg1 = EdiTransaction.FindSegment("IT1(TDS)", "", sdNext)

    Wend

     

    '

    ' Read the total invoice cost

    '

    Set Seg1 = EdiTransaction.FindSegment("TDS", "", sdNext)

    If (IsObject(Seg1)) Then

    Bill.Cost = CDbl(ToNumber(Seg1.FindElement("1").Value) / 100)

     

    '

    ' Read all invoice consumption/cost details

    ' that follow the TDS segment

    '

    MeterCode = ""

    CommodityCode = "MONEY"

    Value = 0 ' these are all cost details

    ValueUnitCode = "" ' these are all cost details

    RoundoffError = False

    Set Seg2 = Seg1.FindSegment("SAC", "", sdNext)

    While (IsObject(Seg2))

    Cost = GetSACCostNoCharge(Seg2)

    GetSACObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Add cost detail to bill and find next SAC segment

    '

    If ((Cost <> 0) And (ObservationType <> "")) Then

    If (Seg2.FindElement("1").Value = "N") Then

    ObservationType = "NOCHARGE"

    End If

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    Set Seg2 = Seg1.FindSegment("SAC", "", sdNext)

    Wend

     

    '

    ' Read TXI segments now

    '

    Set Seg1 = EdiTransaction.FindSegment("TDS", "", sdCurrent) ' get another TDS segment object positioned at beginning of summary section to use for TXI search

    Set Seg2 = Seg1.FindSegment("TXI", "", sdNext)

    While (IsObject(Seg2))

    Cost = CDbl(ToNumber(Seg2.FindElement("2").Value))

    GetTXIObsTypeAndCaption Seg2, ObservationType, ValueUnitCode, Value, Caption

     

    '

    ' Add cost detail to bill and find next TXI segment

    '

    If ((Cost <> 0) And (ObservationType <> "")) Then

    If (Seg2.FindElement("7").Value = "O") Then

    ObservationType = "NOCHARGE"

    End If

    Bill.AddLineItem MeterCode, CommodityCode, ObservationType, ValueUnitCode, Value, CostUnitCode, Cost, RoundoffError, ctDebit, Caption

    End If

    Set Seg2 = Seg1.FindSegment("TXI", "", sdNext)

    Wend

    End If

     

    '

    ' Save the bill into ES

    '

    Bill.Save

    End Sub

     

    ' -- End EDI Version Import Scripts --

     

    ' -- Start Utility Subroutines --

     

    '

    ' This function performs the operations required to extract

    ' cost data correctly from ITA segments. Cost value

    ' is returned normally if "no charge" indicator is set.

    '

    ' Element 1 contains a debit/credit/no charge indicator.

    ' Element 4 may contain another debit/credit/no charge indicator.

    ' Element 7 contains the cost value in cents.

    '

    Function GetITACostNoCharge(Seg)

    If ((Seg.FindElement("1").Value = "A") Or (Seg.FindElement("4").Value = "04")) Then

    GetITACostNoCharge = -Abs(CDbl(ToNumber(Seg.FindElement("7").Value)) / 100)

    Else

    GetITACostNoCharge = CDbl(ToNumber(Seg.FindElement("7").Value)) / 100

    End If

    End Function

     

    '

    ' This function performs the operations required to extract

    ' cost data correctly from ITA segments.

    '

    ' Element 1 contains a debit/credit/no charge indicator.

    ' Element 4 may contain another debit/credit/no charge indicator.

    ' Element 7 contains the cost value in cents.

    '

    Function GetITACost(Seg)

    If (Seg.FindElement("1").Value = "N") Then

    GetITACost = 0

    Else

    GetITACost = GetITACostNoCharge(Seg)

    End If

    End Function

     

    '

    ' This function performs the operations required to extract

    ' cost data correctly from SAC segments. Cost value

    ' is returned normally if "no charge" indicator is set.

    '

    ' Element 1 contains a debit/credit/no charge indicator.

    ' Element 5 contains the cost value in cents.

    ' Element 12 may contain another debit/credit/no charge indicator.

    '

    Function GetSACCostNoCharge(Seg)

    If ((Seg.FindElement("1").Value = "A") Or (Seg.FindElement("12").Value = "04")) Then

    GetSACCostNoCharge = -Abs(CDbl(ToNumber(Seg.FindElement("5").Value)) / 100)

    Else

    GetSACCostNoCharge = CDbl(ToNumber(Seg.FindElement("5").Value)) / 100

    End If

    End Function

     

    '

    ' This function performs the operations required to extract

    ' cost data correctly from SAC segments.

    '

    ' Element 1 contains a debit/credit/no charge indicator.

    ' Element 5 contains the cost value in cents.

    ' Element 12 may contain another debit/credit/no charge indicator.

    '

    Function GetSACCost(Seg)

    If (Seg.FindElement("1").Value = "N") Then

    GetSACCost = 0

    Else

    GetSACCost = GetSACCostNoCharge(Seg)

    End If

    End Function

     

    '

    ' This function is basically here to

    ' convert empty text strings into numeric values of zero.

    '

    Function ToNumber(Value)

    If (Trim(Value) = "") Then

    ToNumber = 0

    Else

    ToNumber = Trim(Value)

    End If

    End Function

     

    '

    ' This subroutine interprets elements 4 and 15 of SAC segments

    ' and translates them into observation types and captions

    '

    Sub GetSACObsTypeAndCaption(Seg, ObservationType, ValueUnitCode, Value, Caption)

    Dim SAC04Code, SAC15Code

     

    SAC04Code = Seg.FindElement("4").Value

    SAC15Code = Seg.FindElement("15").Value

    Select Case SAC04Code

    Case "SER000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Service Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "SER001"

    ObservationType = "CHARGE"

    Caption = "Service Charge"

    Case "SER002"

    ObservationType = "CHARGE"

    Caption = "Cost of Service"

    Case "SER003"

    ObservationType = "CHARGE"

    Caption = "Customer Switching Charge"

    Case "SER004"

    ObservationType = "CHARGE"

    Caption = "Service Charge (Off-Peak Demand)"

    Case "SER005"

    ObservationType = "CHARGE"

    Caption = "Third Party Adminstrative Fee"

    Case "SER006"

    ObservationType = "CHARGE"

    Caption = "Schedule Service Charge"

    Case "SER007"

    ObservationType = "CHARGE"

    Caption = "Change of Account Info Charge"

    Case "SER008"

    ObservationType = "CHARGE"

    Caption = "Special Metering Fee"

    Case "ADJ000"

    Select Case SAC15Code

    Case "ELECTRIC REFUND ADJUSTMENT"

    ObservationType = "CHARGE"

    Caption = "Electric Refund Adjustment"

    Case "REBATE-NON TAXABLE"

    ObservationType = "CHARGE"

    Caption = "Rebate"

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Adjustment"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "ADJ001"

    ObservationType = "CHARGE"

    Caption = "Cost Recovery Adjustment"

    Case "ADJ002"

    ObservationType = "CHARGE"

    Caption = "Adjustment"

    Case "ADJ003"

    ObservationType = "CHARGE"

    Caption = "Bank Adjustment"

    Case "ADJ004"

    ObservationType = "CHARGE"

    Caption = "Baseline Adjustment"

    Case "ADJ005"

    ObservationType = "CHARGE"

    Caption = "Collection Charge Adjustment"

    Case "ADJ006"

    ObservationType = "CHARGE"

    Caption = "Franchise Fee Adjustment"

    Case "ADJ007"

    ObservationType = "CHARGE"

    Caption = "Metering Adjustment"

    Case "ADJ008"

    ObservationType = "CHARGE"

    Caption = "Policy Adjustment"

    Case "BAS000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Account Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "BAS001"

    ObservationType = "CHARGE"

    Caption = "Basic Customer Charge"

    Case "BAS002"

    ObservationType = "CHARGE"

    Caption = "Special Billing Charge"

    Case "BAS003"

    ObservationType = "CHARGE"

    Caption = "Delivery Point Charge"

    Case "BAS004"

    ObservationType = "CHARGE"

    Caption = "Field Service Charge"

    Case "BAS005" ' this code is supposed to be obsolete

    ObservationType = "CHARGE"

    Caption = "Baseline Energy Charge"

    Case "BAS006" ' this code is supposed to be obsolete

    ObservationType = "CHARGE"

    Caption = "Above Baseline Energy Charge"

    Case "BUD000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Budget Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "BUD001"

    ObservationType = "CHARGE"

    Caption = "Budget Billing Amount"

    Case "BUD002"

    ObservationType = "CHARGE"

    Caption = "Budget Billing Settlement"

    Case "BUD003"

    ObservationType = "CHARGE"

    Caption = "Budget Billing Interest"

    Case "COL000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Collection Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "COL001"

    ObservationType = "CHARGE"

    Caption = "Collection Charge"

    Case "CRE000"

    Select Case SAC15Code

    Case "ANNUAL MERGER SAVINGS CREDIT"

    ObservationType = "CHARGE"

    Caption = "Annual Merger Savings Credit"

    Case "DIRECT ACCESS FRANCHISE FEE CREDIT"

    ObservationType = "CHARGE"

    Caption = "Direct Access Franchise Credit"

    Case "REVENUE CYCLE SERVICE CREDIT"

    ObservationType = "CHARGE"

    Caption = "Revenue Cycle Service Credit"

    Case "UTILITY SERVICE CREDIT"

    ObservationType = "CUSTOMERCHARGE"

    Caption = "Utility Service Charge"

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Credit"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "CRE001"

    ObservationType = "CHARGE"

    Caption = "Credit"

    Case "CRE002"

    ObservationType = "CHARGE"

    Caption = "Bill Limiter Credit"

    Case "CRE003"

    ObservationType = "CHARGE"

    Caption = "Cash Discount Credit"

    Case "CRE004"

    ObservationType = "CHARGE"

    Caption = "Transformer Credit"

    Case "CRE005"

    ObservationType = "CHARGE"

    Caption = "Generation Credit"

    Case "CRE006"

    ObservationType = "CHARGE"

    Caption = "Equipment Credit"

    Case "CRE007"

    ObservationType = "CHARGE"

    Caption = "Energy Assistance Credit"

    Case "CRE008"

    ObservationType = "CHARGE"

    Caption = "Master Meter Credit"

    Case "CRE009"

    ObservationType = "CHARGE"

    Caption = "Interruptible Credit"

    Case "CRE010"

    ObservationType = "CHARGE"

    Caption = "Off Peak Credit"

    Case "CRE011"

    ObservationType = "CHARGE"

    Caption = "Service Guarantee Credit"

    Case "CRE012"

    ObservationType = "CHARGE"

    Caption = "Zone Credit"

    Case "CRE013"

    ObservationType = "CHARGE"

    Caption = "NGV 3rd Party Credit"

    Case "CRE014"

    ObservationType = "CHARGE"

    Caption = "Direct Access Energy Credit"

    Case "CRE015"

    ObservationType = "CHARGE"

    Caption = "Hourly PX Pricing Optn Energy Cr"

    Case "CRE016"

    ObservationType = "CHARGE"

    Caption = "CTC Exemption Credit"

    Case "CRE017"

    ObservationType = "CHARGE"

    Caption = "Baseline Credit"

    Case "CRE018"

    ObservationType = "CHARGE"

    Caption = "One-Phase Service Credit"

    Case "CRE019"

    ObservationType = "CHARGE"

    Caption = "PX Energy Credit"

    Case "CRE020"

    ObservationType = "CHARGE"

    Caption = "Meter Owner Credit"

    Case "CRE021"

    ObservationType = "CHARGE"

    Caption = "Meter Service Credit"

    Case "CRE022"

    ObservationType = "CHARGE"

    Caption = "Meter Reading Credit"

    Case "CRE023"

    ObservationType = "CHARGE"

    Caption = "Billing and Payment Credit"

    Case "DMD000"

    Select Case SAC15Code

    Case Else

    ObservationType = "DEMAND"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Demand"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "DMD001"

    ObservationType = "DEMAND"

    Caption = "Demand"

    Case "DMD002"

    ObservationType = "CONTRACTDEMAND"

    Caption = "Contract Demand"

    Case "DMD003"

    ObservationType = "DEMAND"

    Caption = "Baseline Demand"

    Case "DMD004"

    ObservationType = "REACTIVEDEMAND"

    Caption = "Reactive Demand"

    Case "DMD005"

    ObservationType = "DEMAND"

    Caption = "Summer Demand"

    Case "DMD006"

    ObservationType = "OFFPEAKDEM"

    Caption = "Off-Peak Demand"

    Case "DMD007"

    ObservationType = "ONPEAKDEM"

    Caption = "On-Peak Demand"

    Case "DMD008"

    ObservationType = "MIDPEAKDEM"

    Caption = "Mid-Peak Demand"

    Case "DMD009" ' not sure if this is an adjusted demand or a demand adjustment...

    ObservationType = "DEMAND"

    Caption = "Demand Adjustment"

    Case "DMD010"

    ObservationType = "DEMAND"

    Caption = "Prior Period Demand"

    Case "DMD011"

    ObservationType = "OFFPEAKDEM"

    Caption = "Summer Off-Peak Demand"

    Case "DMD012"

    ObservationType = "ONPEAKDEM"

    Caption = "Summer On-Peak Demand"

    Case "DMD013"

    ObservationType = "MIDPEAKDEM"

    Caption = "Summer Mid-Peak Demand"

    Case "DMD014"

    ObservationType = "SUPPEAKDEM"

    Caption = "Summer Super On-Peak Demand"

    Case "DMD015" ' no valid codes for super off-peak measurements

    ObservationType = "OFFPEAKDEM"

    Caption = "Summer Super Off-Peak Demand"

    Case "DMD016"

    ObservationType = "ONPEAKDEM"

    Caption = "Winter On-Peak Demand"

    Case "DMD017"

    ObservationType = "OFFPEAKDEM"

    Caption = "Winter Off-Peak Demand"

    Case "DMD018"

    ObservationType = "MIDPEAKDEM"

    Caption = "Winter Mid-Peak Demand"

    Case "DMD019" ' no valid codes for super off-peak measurements

    ObservationType = "OFFPEAKDEM"

    Caption = "Winter Super Off-Peak Demand"

    Case "DMD020" ' no specific codes for daytime measurements

    ObservationType = "ONPEAKDEM"

    Caption = "Summer Daytime Demand"

    Case "DMD021" ' no specific codes for nighttime measurements

    ObservationType = "OFFPEAKDEM"

    Caption = "Summer Nighttime Demand"

    Case "DMD022" ' no specific codes for daytime measurements

    ObservationType = "ONPEAKDEM"

    Caption = "Winter Daytime Demand"

    Case "DMD023" ' no specific codes for nighttime measurements

    ObservationType = "OFFPEAKDEM"

    Caption = "Winter Nighttime Demand"

    Case "DMD024"

    ObservationType = "DEMAND"

    Caption = "Summer Demand"

    Case "DMD025"

    ObservationType = "DEMAND"

    Caption = "Winter Demand"

    Case "DMD026" ' no specific codes for daytime measurements

    ObservationType = "ONPEAKDEM"

    Caption = "Daytime Demand"

    Case "DMD027" ' no specific codes for nighttime measurements

    ObservationType = "OFFPEAKDEM"

    Caption = "Nighttime Demand"

    Case "DMD028"

    ObservationType = "DEMAND"

    Caption = "Demand (Gas)"

    Case "DMD029"

    ObservationType = "SHDPEAKDEM"

    Caption = "Shoulder Demand"

    Case "DAB000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Deposit"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "DAB001"

    ObservationType = "CHARGE"

    Caption = "Deposit"

    Case "DAB002"

    ObservationType = "CHARGE"

    Caption = "Deposit Interest"

    Case "DAB003"

    ObservationType = "CHARGE"

    Caption = "Deposit Applied"

    Case "DAB004"

    ObservationType = "CHARGE"

    Caption = "Deposit Reduction"

    Case "DCS000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Disconnect Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "DCS001"

    ObservationType = "CHARGE"

    Caption = "Disconnect Charge"

    Case "DCS002"

    ObservationType = "CHARGE"

    Caption = "Disconnect Visit Charge"

    Case "DCS003"

    ObservationType = "CHARGE"

    Caption = "Land Owner Disconnect Charge"

    Case "DSC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Discount"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "DSC001"

    ObservationType = "CHARGE"

    Caption = "Discount"

    Case "DSC002"

    ObservationType = "CHARGE"

    Caption = "Equipment Cycle Discount"

    Case "DSC003"

    ObservationType = "CHARGE"

    Caption = "Rate Limit Discount"

    Case "DSC004"

    ObservationType = "CHARGE"

    Caption = "Economic Development Discount"

    Case "DSC005"

    ObservationType = "CHARGE"

    Caption = "Energy Discount"

    Case "DSC006"

    ObservationType = "CHARGE"

    Caption = "Church Discount"

    Case "DSC007"

    ObservationType = "CHARGE"

    Caption = "Government Service Discount"

    Case "DSC008"

    ObservationType = "CHARGE"

    Caption = "School Discount"

    Case "DSC009"

    ObservationType = "CHARGE"

    Caption = "Energy Assistance Discount"

    Case "DSC010"

    ObservationType = "CHARGE"

    Caption = "Multi-Family Discount"

    Case "DSC011"

    ObservationType = "CHARGE"

    Caption = "Legislated Rate Reduction Discnt"

    Case "DSC012"

    ObservationType = "CHARGE"

    Caption = "Demand Voltage Discount"

    Case "DSC013"

    ObservationType = "CHARGE"

    Caption = "Energy Voltage Discount"

    Case "DIS000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Distribution Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "DIS001"

    ObservationType = "CHARGE"

    Caption = "Distribution Charge"

    Case "DIS002"

    ObservationType = "CHARGE"

    Caption = "Gas Delivery Charge"

    Case "DIS003"

    ObservationType = "CHARGE"

    Caption = "Interstate Transportation Charge"

    Case "ENC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "USE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Use"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "ENC001"

    ObservationType = "GENERATIONUSE"

    Caption = "Generation Use"

    Case "ENC002"

    ObservationType = "USE"

    Caption = "Use Tier"

    Case "ENC003"

    ObservationType = "OFFPEAKUSE"

    Caption = "Off-Peak Use"

    Case "ENC004"

    ObservationType = "OFFPEAKUSE"

    Caption = "Summer Off-Peak Use"

    Case "ENC005"

    ObservationType = "ONPEAKUSE"

    Caption = "Summer On-Peak Use"

    Case "ENC006"

    ObservationType = "MIDPEAKUSE"

    Caption = "Summer Mid-Peak Use"

    Case "ENC007"

    ObservationType = "SUPPEAKUSE"

    Caption = "Summer Super On-Peak Use"

    Case "ENC008" ' no valid codes for super off-peak measurements

    ObservationType = "OFFPEAKUSE"

    Caption = "Summer Super Off-Peak Use"

    Case "ENC009"

    ObservationType = "ONPEAKUSE"

    Caption = "Winter On-Peak Use"

    Case "ENC010"

    ObservationType = "MIDPEAKUSE"

    Caption = "Winter Mid-Peak Use"

    Case "ENC011"

    ObservationType = "OFFPEAKUSE"

    Caption = "Winter Off-Peak Use"

    Case "ENC012" ' no valid codes for super off-peak measurements

    ObservationType = "OFFPEAKUSE"

    Caption = "Winter Super Off-Peak Use"

    Case "ENC013" ' no specific codes for daytime measurements

    ObservationType = "ONPEAKUSE"

    Caption = "Summer Daytime Use"

    Case "ENC014" ' no specific codes for nighttime measurements

    ObservationType = "OFFPEAKUSE"

    Caption = "Summer Nighttime Use"

    Case "ENC015" ' no specific codes for daytime measurements

    ObservationType = "ONPEAKUSE"

    Caption = "Winter Daytime Use"

    Case "ENC016" ' no specific codes for nighttime measurements

    ObservationType = "OFFPEAKUSE"

    Caption = "Winter Nighttime Use"

    Case "ENC017"

    ObservationType = "USE"

    Caption = "Summer Use"

    Case "ENC018"

    ObservationType = "USE"

    Caption = "Winter Use"

    Case "ENC019" ' no specific codes for daytime measurements

    ObservationType = "USE"

    Caption = "Daytime Use"

    Case "ENC020" ' no specific codes for nighttime measurements

    ObservationType = "USE"

    Caption = "Nighttime Use"

    Case "ENC021"

    ObservationType = "USE"

    Caption = "Commodity Charge"

    Case "ENC022"

    ObservationType = "USE"

    Caption = "Interconnect Access Transmit Ch"

    Case "ENC023"

    ObservationType = "USE"

    Caption = "Volume Tier 1 Charge"

    Case "ENC024"

    ObservationType = "USE"

    Caption = "Volume Tier 1 Negotiated Rate"

    Case "ENC025"

    ObservationType = "USE"

    Caption = "Volume Tier 2 Charge"

    Case "ENC026"

    ObservationType = "USE"

    Caption = "Volume Tier 3 Charge"

    Case "ENC027"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 1 Charge"

    Case "ENC028"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 1 Negot Rate"

    Case "ENC029"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 2 Charge"

    Case "ENC030"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 2 Negot Rate"

    Case "ENC031"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 3 Charge"

    Case "ENC032"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 3 Negot Rate"

    Case "ENC033"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 4 Charge"

    Case "ENC034"

    ObservationType = "USE"

    Caption = "Volume G30 Size Cat 4 Negot Rate"

    Case "ENC035"

    ObservationType = "USE"

    Caption = "3rd Party Procurement Charge"

    Case "ENC036"

    ObservationType = "USE"

    Caption = "ESP Charge"

    Case "ENC037"

    ObservationType = "USE"

    Caption = "Baseline Energy Charge"

    Case "ENC038"

    ObservationType = "USE"

    Caption = "Above Baseline Energy Charge"

    Case "ENC039"

    ObservationType = "ONPEAKUSE"

    Caption = "On-Peak Use"

    Case "ENC040"

    ObservationType = "USE"

    Caption = "Block 1 Use"

    Case "ENC041"

    ObservationType = "USE"

    Caption = "Block 2 Use"

    Case "FAC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Facility Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "FAC001"

    ObservationType = "CHARGE"

    Caption = "Equipment and Service Charge"

    Case "FAC002"

    ObservationType = "CHARGE"

    Caption = "Facilities Rental Charge"

    Case "FAC003"

    ObservationType = "CHARGE"

    Caption = "Facilities Installation Charge"

    Case "FAC004"

    ObservationType = "CHARGE"

    Caption = "Facilities Removal Charge"

    Case "FFR000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Flat-Rate Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "FFR001"

    ObservationType = "CHARGE"

    Caption = "Unmetered Service Charge"

    Case "FUE000"

    Select Case SAC15Code

    Case Else

    ObservationType = "FUELADJUSTCHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Fuel Adjustment Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "FUE001"

    ObservationType = "FUELADJUSTCHARGE"

    Caption = "Fuel Adjustment Charge"

    Case "FUE002"

    ObservationType = "FUELADJUSTCHARGE"

    Caption = "On-Peak Fuel Adjustment Charge"

    Case "FUE003"

    ObservationType = "FUELADJUSTCHARGE"

    Caption = "Off-Peak Fuel Adjustment Charge"

    Case "FUE004"

    ObservationType = "FUELADJUSTCHARGE"

    Caption = "In-Kind Fuel Charge"

    Case "FUE005"

    ObservationType = "FUELADJUSTCHARGE"

    Caption = "GITC Interconnect Access Fuel Ch"

    Case "GEN000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Generation Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "GEN001" ' don't know if this is use or demand

    ObservationType = "GENERATIONUSE"

    Caption = "Generation Use"

    Case "GEN002" ' don't know if this is use or demand

    ObservationType = "GENERATIONUSE"

    Caption = "Measured Generation Use"

    Case "GEN003" ' don't know if this is use or demand

    ObservationType = "GENERATIONUSE"

    Caption = "Adjusted Generation Use"

    Case "GEN004" ' don't know if this is use or demand

    ObservationType = "GENBILLEDUSE"

    Caption = "Billed Generation Use"

    Case "GEN005" ' don't know if this is use or demand

    ObservationType = "GENERATIONUSE"

    Caption = "On-Peak Generation Use"

    Case "GEN006" ' don't know if this is use or demand

    ObservationType = "GENERATIONUSE"

    Caption = "Off-Peak Generation Use"

    Case "GTC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Gen/Trans Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "GTC001"

    ObservationType = "CHARGE"

    Caption = "Gen/Trans Charge"

    Case "GTC002"

    ObservationType = "CHARGE"

    Caption = "Measured Gen/Trans Charge"

    Case "GTC003"

    ObservationType = "CHARGE"

    Caption = "Adjusted Gen/Trans Charge"

    Case "GTC004"

    ObservationType = "CHARGE"

    Caption = "Billed Gen/Trans Charge"

    Case "GTC005"

    ObservationType = "CHARGE"

    Caption = "On-Peak Gen/Trans Charge"

    Case "GTC006"

    ObservationType = "CHARGE"

    Caption = "Off-Peak Gen/Trans Charge"

    Case "HOC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Service Connect Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "HOC001"

    ObservationType = "CHARGE"

    Caption = "Service Connect Charge"

    Case "IBC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "IMBALANCEUSE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Imbalance Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "IBC001"

    ObservationType = "IMBALANCEUSE"

    Caption = "Core Standby Service Charge"

    Case "IBC002"

    ObservationType = "IMBALANCEUSE"

    Caption = "Non-core Retail Standby Svc Ch"

    Case "IBC003"

    ObservationType = "IMBALANCEUSE"

    Caption = "Wholesale Standby Service Ch"

    Case "IBC004"

    ObservationType = "IMBALANCEUSE"

    Caption = "Core Buyback Charge"

    Case "IBC005"

    ObservationType = "IMBALANCEUSE"

    Caption = "Daily Bal WS Standby Proc Ch"

    Case "IBC006"

    ObservationType = "IMBALANCEUSE"

    Caption = "Non-core Buyback Charge"

    Case "IBC007"

    ObservationType = "IMBALANCEUSE"

    Caption = "Wholesale Buyback"

    Case "IBC008"

    ObservationType = "IMBALANCEUSE"

    Caption = "Retail Buyback"

    Case "IBC009"

    ObservationType = "IMBALANCEUSE"

    Caption = "Daily Bal Core Standby Proc Ch"

    Case "IBC010"

    ObservationType = "IMBALANCEUSE"

    Caption = "Daily Bal N-Core Standby Proc Ch"

    Case "IBC011"

    ObservationType = "IMBALANCEUSE"

    Caption = "Over-Nominations Buyback"

    Case "IBC012"

    ObservationType = "IMBALANCEUSE"

    Caption = "Standby Curtailment Charge"

    Case "IBC013"

    ObservationType = "IMBALANCEUSE"

    Caption = "Curtailment Diversion Credit"

    Case "IBC014"

    ObservationType = "IMBALANCEUSE"

    Caption = "Curtailment Violation Charge"

    Case "IBC015"

    ObservationType = "IMBALANCEUSE"

    Caption = "Op Flow Order Curtail Pd Penalty"

    Case "IBC016"

    ObservationType = "IMBALANCEUSE"

    Caption = "SL2 Surcharge"

    Case "IBC017"

    ObservationType = "IMBALANCEUSE"

    Caption = "SL345 Credit"

    Case "INT000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Interest Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "INT001"

    ObservationType = "CHARGE"

    Caption = "Interest on Sale"

    Case "INT002"

    ObservationType = "CHARGE"

    Caption = "Interest on Loan"

    Case "INT003"

    ObservationType = "CHARGE"

    Caption = "ITC Adjustment Interest"

    Case "LAA000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Labor Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "LAA001"

    ObservationType = "CHARGE"

    Caption = "Billing for Work Done"

    Case "LPC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "LATECHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Late Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "LPC001"

    ObservationType = "LATECHARGE"

    Caption = "Late Payment Charge"

    Case "ODL000"

    Select Case SAC15Code

    Case Else

    ObservationType = "USE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Unmetered Lighting"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "ODL001"

    ObservationType = "USE"

    Caption = "Outdoor Lighting"

    Case "ODL002"

    ObservationType = "USE"

    Caption = "Street Lighting"

    Case "ODL003"

    ObservationType = "USE"

    Caption = "Traffic Signals"

    Case "MAD000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Minimum Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "MAD001"

    ObservationType = "CHARGE"

    Caption = "Minimum Bill"

    Case "MAD002"

    ObservationType = "CHARGE"

    Caption = "Minimum Energy Charge"

    Case "MAD003"

    ObservationType = "CHARGE"

    Caption = "Minimum Contract"

    Case "MAD004"

    ObservationType = "CHARGE"

    Caption = "Minimum Demand Charge"

    Case "MSC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Misc Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "MSC001"

    Select Case SAC15Code

    Case "LOOP SUBTOTAL" ' do nothing for now - this contains a cost subtotal for all charges in this IT1 loop

    ObservationType = ""

    Caption = ""

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Misc Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "MSC002"

    ObservationType = "CHARGE"

    Caption = "Set-time Appointment Charge"

    Case "MSC003"

    ObservationType = "CHARGE"

    Caption = "Meter Seal Replacement Charge"

    Case "MSC004"

    ObservationType = "CHARGE"

    Caption = "Rescheduled Appointment Charge"

    Case "MSC005"

    ObservationType = "CHARGE"

    Caption = "Benefits/Insurance Charge"

    Case "MSC006"

    ObservationType = "CHARGE"

    Caption = "Diversion Gas"

    Case "MSC007"

    ObservationType = "CHARGE"

    Caption = "Property Damage Charge"

    Case "MSC008"

    ObservationType = "CHARGE"

    Caption = "Punitive Damage Charge"

    Case "MSC009"

    ObservationType = "CHARGE"

    Caption = "Preferred Due Date Setup Fee"

    Case "MSC010"

    ObservationType = "CHARGE"

    Caption = "Select Read Cycle Monthly Fee"

    Case "MSC011"

    ObservationType = "CHARGE"

    Caption = "Wrap and Strap Charge"

    Case "MSC012"

    ObservationType = "CHARGE"

    Caption = "Water Heater Strapping Charge"

    Case "MSC013"

    ObservationType = "CHARGE"

    Caption = "Water Heater Wrapping Charge"

    Case "MSC014"

    ObservationType = "CHARGE"

    Caption = "Appliance Connection Charge"

    Case "MSC015"

    ObservationType = "CHARGE"

    Caption = "Injection O&M Charge"

    Case "MSC016"

    ObservationType = "CHARGE"

    Caption = "Storage Procurement Charge"

    Case "MSC017"

    ObservationType = "CHARGE"

    Caption = "Storage Transmission Charge"

    Case "MSC018"

    ObservationType = "CHARGE"

    Caption = "Withdrawal O&M Charge"

    Case "MSC019"

    ObservationType = "CHARGE"

    Caption = "Base EBB Charge"

    Case "MSC020"

    ObservationType = "CHARGE"

    Caption = "Manual Imbalance Processing Fee"

    Case "MSC021"

    ObservationType = "CHARGE"

    Caption = "EBB Use Charge"

    Case "MSC022"

    ObservationType = "CHARGE"

    Caption = "Competition Transition Charge"

    Case "MSC023"

    ObservationType = "CHARGE"

    Caption = "Trust Transfer Amount"

    Case "MSC024"

    ObservationType = "CHARGE"

    Caption = "Public Purpose Program"

    Case "MSC025"

    ObservationType = "CHARGE"

    Caption = "Nuclear Decommissioning Charge"

    Case "MSC026"

    ObservationType = "CHARGE"

    Caption = "Interruptible Penalty Charge"

    Case "PAY000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Payment Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "PAY001"

    ObservationType = "CHARGE"

    Caption = "Payment Plan Amount"

    Case "PAY002"

    ObservationType = "CHARGE"

    Caption = "Payment Plan Settlement"

    Case "PRB000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Prior Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "PRB001"

    ObservationType = "CHARGE"

    Caption = "Past Due Balance"

    Case "PRB002"

    ObservationType = "CHARGE"

    Caption = "Unpaid Balance"

    Case "PFA000"

    Select Case SAC15Code

    Case Else

    ObservationType = "POWERFACTOR"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Power Factor Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "PFA001"

    Value = CDbl(ToNumber(Seg.FindElement("7").Value)) ' value is in element 7

    ValueUnitCode = "PERCENT" ' couldn't tell correct unit from SAC09 because it wasn't supplied

    ObservationType = "POWERFACTOR"

    Caption = "Power Factor Adjustment"

    Case "PFA002"

    Value = CDbl(ToNumber(Seg.FindElement("7").Value)) ' value is in element 7

    ValueUnitCode = "PERCENT" ' couldn't tell correct unit from SAC09 because it wasn't supplied

    ObservationType = "POWERFACTOR"

    Caption = "Winter Power Factor Adjustment"

    Case "PFA003"

    Value = CDbl(ToNumber(Seg.FindElement("7").Value)) ' value is in element 7

    ValueUnitCode = "PERCENT" ' couldn't tell correct unit from SAC09 because it wasn't supplied

    ObservationType = "POWERFACTOR"

    Caption = "Summer Power Factor Adjustment"

    Case "RSC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Reconnect Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "RSC001"

    ObservationType = "CHARGE"

    Caption = "Reconnect Charge"

    Case "RRR000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Regulatory Refund"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "RRR001"

    ObservationType = "CHARGE"

    Caption = "State/Intrastate Refund"

    Case "RRR002"

    ObservationType = "CHARGE"

    Caption = "Local Refund"

    Case "RRR003"

    ObservationType = "CHARGE"

    Caption = "Municipal Refund"

    Case "RRR004"

    ObservationType = "CHARGE"

    Caption = "Federal/Interstate Refund"

    Case "RRR005"

    ObservationType = "CHARGE"

    Caption = "Targeted Sales Refund"

    Case "RRR006"

    ObservationType = "CHARGE"

    Caption = "Reg Commission Mandated Refund"

    Case "RRR007"

    ObservationType = "CHARGE"

    Caption = "Interest on Refund"

    Case "RES000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Reservation Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "RES001"

    ObservationType = "CHARGE"

    Caption = "Core Subscription Reserve Charge"

    Case "RES002"

    ObservationType = "CHARGE"

    Caption = "Core Subscr Reserve Charge Adj"

    Case "RES003"

    ObservationType = "CHARGE"

    Caption = "Injection Reservation Charge"

    Case "RES004"

    ObservationType = "CHARGE"

    Caption = "Withdrawal Reservation Charge"

    Case "RES005"

    ObservationType = "CHARGE"

    Caption = "Inventory Reservation Charge"

    Case "RES006"

    ObservationType = "CHARGE"

    Caption = "Storage Reserve Charge Prepaymnt"

    Case "RES007"

    ObservationType = "CHARGE"

    Caption = "Interconnect Assess Firm Res Ch"

    Case "RES008"

    ObservationType = "CHARGE"

    Caption = "ITC Reservation Charge"

    Case "RTC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Return Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "RTC001"

    ObservationType = "CHARGE"

    Caption = "Return Check Fee"

    Case "RTC002"

    ObservationType = "CHARGE"

    Caption = "Return Check Amount"

    Case "SMD000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Sales/Merchandise Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "SMD001"

    ObservationType = "CHARGE"

    Caption = "Appliance Contract Installment"

    Case "SMD002"

    ObservationType = "CHARGE"

    Caption = "Cash Sales/Stores Purchase"

    Case "SMD003"

    ObservationType = "CHARGE"

    Caption = "Comm Heat Pump/Water Heater Ch"

    Case "SMD004"

    ObservationType = "CHARGE"

    Caption = "Contract Installment"

    Case "SMD005"

    ObservationType = "CHARGE"

    Caption = "Grain Drying Service Charge"

    Case "SMD006"

    ObservationType = "CHARGE"

    Caption = "Heat Pump/Comm Equip Charge"

    Case "SMD007"

    ObservationType = "CHARGE"

    Caption = "Heat Pump Installment Charge"

    Case "SMD008"

    ObservationType = "CHARGE"

    Caption = "Home Wiring Inspection Charge"

    Case "SMD009"

    ObservationType = "CHARGE"

    Caption = "Delinquent Merchandise Chargeoff"

    Case "SMD010"

    ObservationType = "CHARGE"

    Caption = "Miscellaneous Materials Charge"

    Case "SMD011"

    ObservationType = "CHARGE"

    Caption = "Other Services/Merch Charge"

    Case "SMD012"

    ObservationType = "CHARGE"

    Caption = "Power Protection Equip Charge"

    Case "SMD013"

    ObservationType = "CHARGE"

    Caption = "Purchased Parts Charge"

    Case "SMD014"

    ObservationType = "CHARGE"

    Caption = "Meter Installation Charge"

    Case "SMD015"

    ObservationType = "CHARGE"

    Caption = "Meter Maintenance/Repair Charge"

    Case "SMD016"

    ObservationType = "CHARGE"

    Caption = "Meter Read Charge"

    Case "SMD017"

    ObservationType = "CHARGE"

    Caption = "Meter Removal Charge"

    Case "SMD018"

    ObservationType = "CHARGE"

    Caption = "Other Meter Services"

    Case "SMD019"

    ObservationType = "CHARGE"

    Caption = "Special Meter Read Charge"

    Case "SMD020"

    ObservationType = "CHARGE"

    Caption = "Meter Changeout Charge"

    Case "SUR000"

    Select Case SAC15Code

    Case "ELECTRIC EMERGENCY PROCUREMENT SURCHARGE"

    ObservationType = "CHARGE"

    Caption = "Emergency Procurement Charge"

    Case "ENERGY SURCHARGE: 131% - 200% OF BASELINE"

    ObservationType = "CHARGE"

    Caption = "Excess Use Charge (131%-200%)"

    Case "ENERGY SURCHARGE: 201% - 300% OF BASELINE"

    ObservationType = "CHARGE"

    Caption = "Excess Use Charge (201%-300%)"

    Case "ENERGY SURCHARGE: OVER 300% OF BASELINE"

    ObservationType = "CHARGE"

    Caption = "Excess Use Charge (>300%)"

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Surcharge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "SUR001"

    ObservationType = "CHARGE"

    Caption = "State/Intrastate Surcharge"

    Case "SUR002"

    ObservationType = "CHARGE"

    Caption = "Local Surcharge"

    Case "SUR003"

    ObservationType = "CHARGE"

    Caption = "Federal/Interstate Surcharge"

    Case "SUR004"

    ObservationType = "CHARGE"

    Caption = "Mobile Home Park Surcharge"

    Case "SUR005"

    ObservationType = "CHARGE"

    Caption = "Imputed Transportation Charge"

    Case "SUR006"

    ObservationType = "CHARGE"

    Caption = "GITC Interconnect Cost Surch"

    Case "SUR007"

    ObservationType = "CHARGE"

    Caption = "Low Income Surcharge"

    Case "SUR008"

    ObservationType = "CHARGE"

    Caption = "Interstate Transition Cost Surch"

    Case "SUR009"

    ObservationType = "CHARGE"

    Caption = "Interstate Transition Surch Cr"

    Case "TEM000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Surcharge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "TEM001"

    ObservationType = "CHARGE"

    Caption = "Temporary Service Charge"

    Case "TPI000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown 3rd Party Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "TPI001"

    ObservationType = "CHARGE"

    Caption = "Utility-Initiated Line Item"

    Case "TPI002"

    ObservationType = "CHARGE"

    Caption = "ESP-Initiated Line Item"

    Case "TRS000"

    Select Case SAC15Code

    Case "TRANSFER DEBIT"

    ObservationType = "CHARGE"

    Caption = "Transfer Debit"

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Transfer Amount"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "TRS001"

    ObservationType = "CHARGE"

    Caption = "Transfer From Other Account"

    Case "TRS002"

    ObservationType = "CHARGE"

    Caption = "Transfer To Deposit Amount"

    Case "TRN000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Transmission Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "TRN001"

    ObservationType = "CHARGE"

    Caption = "Transmission Charge"

    Case "VOC000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Voltage Charge"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "VOC001" ' this code is supposed to be obsolete

    ObservationType = "CHARGE"

    Caption = "Demand Voltage Discount"

    Case "VOC002" ' this code is supposed to be obsolete

    ObservationType = "CHARGE"

    Caption = "Energy Voltage Discount"

    Case "VOC003"

    ObservationType = "CHARGE"

    Caption = "General Primary Voltage Charge"

    Case "VOC004"

    ObservationType = "CHARGE"

    Caption = "General Secondary Voltage Charge"

    Case "VCR000"

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Contribution"

    End If

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    Case "VCR001"

    ObservationType = "CHARGE"

    Caption = "Charitable Contribution"

    Case Else ' any other code is an unknown

    Select Case SAC15Code

    Case Else

    ObservationType = "CHARGE"

    If (Len(SAC15Code) > 0) Then

    Caption = SAC15Code

    Else

    Caption = "Unknown Charge"

    End If

    End Select

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    End Sub

     

    Sub GetTXIObsTypeAndCaption(Seg, ObservationType, ValueUnitCode, Value, Caption)

    Select Case Seg.FindElement("1").Value

    Case "CA"

    ObservationType = "CITYTAX"

    Caption = "City Tax"

    Case "ET" ' some kind of energy tax; just use generic tax code

    ObservationType = "TAX"

    Caption = "Energy Comm. Tax"

    Case "MP"

    ObservationType = "MUNICIPALTAX"

    Caption = "Municipal Tax"

    Case Else ' don't know what kind of taxes to expect, so just make a general tax line

    ObservationType = "TAX"

    Caption = "Unknown Tax"

    Caption = UCase(Caption) ' make it stand out on screen

    End Select

    End Sub

     

    Sub GetMEAObsTypeAndCaption(Seg, ObservationType, ValueUnitCode, Value, Caption)

    Select Case Seg.FindElement("4").Value

    Case "KH"

    ValueUnitCode = "KWH"

    Case "K1"

    ValueUnitCode = "KW"

    Case "K3"

    ValueUnitCode = "KVARH"

    Case "TD"

    ValueUnitCode = "THERM"

    Case Else ' don't know what unit to assign if not one of the codes above

    ValueUnitCode = ""

    End Select

    Select Case Seg.FindElement("7").Value

    Case "41"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "OFFPEAKUSE"

    Caption = "Off-Peak Distribution Use"

    Case "KW"

    ObservationType = "OFFPEAKDEM"

    Caption = "Off-Peak Distribution Demand"

    Case "KVARH"

    ObservationType = "OFFPKREACTIVEUSE"

    Caption = "Off-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "42"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "ONPEAKUSE"

    Caption = "On-Peak Distribution Use"

    Case "KW"

    ObservationType = "ONPEAKDEM"

    Caption = "On-Peak Distribution Demand"

    Case "KVARH"

    ObservationType = "ONPKREACTIVEUSE"

    Caption = "On-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "43"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "MIDPEAKUSE"

    Caption = "Mid-Peak Distribution Use"

    Case "KW"

    ObservationType = "MIDPEAKDEM"

    Caption = "Mid-Peak Distribution Demand"

    Case "KVARH"

    ObservationType = "MIDPKREACTIVEUSE"

    Caption = "Mid-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "45"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "ONPEAKUSE"

    Caption = "Summer On-Peak Distribution Use"

    Case "KW"

    ObservationType = "ONPEAKDEM"

    Caption = "Summer On-Peak Distribution Dem"

    Case "KVARH"

    ObservationType = "ONPKREACTIVEUSE"

    Caption = "Summer On-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "49"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "ONPEAKUSE"

    Caption = "Winter On-Peak Distribution Use"

    Case "KW"

    ObservationType = "ONPEAKDEM"

    Caption = "Winter On-Peak Distribution Dem"

    Case "KVARH"

    ObservationType = "ONPKREACTIVEUSE"

    Caption = "Winter On-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "50"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "MIDPEAKUSE"

    Caption = "Witner Mid-Peak Distribution Use"

    Case "KW"

    ObservationType = "MIDPEAKDEM"

    Caption = "Witner Mid-Peak Distribution Dem"

    Case "KVARH"

    ObservationType = "MIDPKREACTIVEUSE"

    Caption = "Witner Mid-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "51"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "USE"

    Caption = "Distribution Use"

    Case "KW"

    ObservationType = "DEMAND"

    Caption = "Distribution Demand"

    Case "KVARH"

    ObservationType = "REACTIVEUSE"

    Caption = "Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "73"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "OFFPEAKUSE"

    Caption = "Summer Off-Peak Distribution Use"

    Case "KW"

    ObservationType = "OFFPEAKDEM"

    Caption = "Summer Off-Peak Distribution Dem"

    Case "KVARH"

    ObservationType = "OFFPKREACTIVEUSE"

    Caption = "Summer Off-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "74"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "MIDPEAKUSE"

    Caption = "Summer Mid-Peak Distribution Use"

    Case "KW"

    ObservationType = "MIDPEAKDEM"

    Caption = "Summer Mid-Peak Distribution Dem"

    Case "KVARH"

    ObservationType = "MIDPKREACTIVEUSE"

    Caption = "Summer Mid-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case "75"

    Select Case ValueUnitCode

    Case "KWH"

    ObservationType = "OFFPEAKUSE"

    Caption = "Winter Off-Peak Distribution Use"

    Case "KW"

    ObservationType = "OFFPEAKDEM"

    Caption = "Winter Off-Peak Distribution Dem"

    Case "KVARH"

    ObservationType = "OFFPKREACTIVEUSE"

    Caption = "Winter Off-Peak Reactive Use"

    Case Else ' don't know what type of measurement

    ObservationType = ""

    Caption = ""

    End Select

    Case Else ' don't know what unit to assign if not one of the codes above

    ObservationType = ""

    Caption = ""

    End Select

    End Sub

     

    ' -- End Utility Subroutines --