Business rules don't belong in code, they should be metadata. Why do people sometimes put what should be metadata into code? Well, I did it because I am not that good of a programmer.
But now it is time to separate the code and metadata.
First, let me explain the metadata. This is a list of what I call "report frame codes". A report frame is simply a style of reporting. Here is the list in human readable form. Here is that same list in machine readable form (RSS). And here is another version of the list in machine readable form (RDF).
Those human and machine readable lists point to information about each report frame. I will use ONE report frame as an example, INTBX-BSU-CF1-ISS-IEMIX-OILN. For each report frame you get:
- A human readable summary. This lets you look at the stuff in the report frame. This includes.
- A schema file. This is a machine readable version of the information in the report frame. The mapping rules are connected to this schema file.
- Mapping rules. These are mappings from fundamental accounting concepts to US GAAP XBRL Taxonomy concepts.
- Impute rules. These are rules for deriving values of information that was not explicitly reported. For example, most economic entities do not explicitly report the line item "Noncurrent assets". Some do. You can use the rules of logical deduction to arrive at the value if certain other values are reported. For example if "Assets" is reported and "Current assets" is reported and you know that "Assets = Current assets + Noncurrent Assets"; then "Noncurrent assets = Assets - Current assets". There is ONE ISSUE with these impute rules. They are NOT represented in the XBRL syntax. (I will correct that by eventually expressing these impute rules using XBRL Formula.)
So, that is all the metadata.
Now, here is my mistake. This Excel application does the following:
- For a list of economic entities that use the report frame INTBX-BSU-CF1-ISS-IEMIX-OILN that is provided in the "List" worksheet;
- It gets the XBRL-based filing from the SEC web site,
- reads the fundamental accounting concept information per the mapping rules,
- goes through the impute rules to derive values for fundamental accounting concepts that were not explicitly reported,
- tests the relations between the fundamental accounting concepts,
- and then puts all that information into the Excel spreadsheet.
So, what is the problem? If you look at the Excel code, it DOES NOT use that metadata. The mapping rules and the impute rules are HARD CODED into the Excel application. This Excel spreadsheet uses the style of getting the fundamental accounting concept relations of the very first version of the tool used to obtain this information. I modified the rules to match as much as possible the current rules of the INTBX-BSU-CF1-ISS-IEMIX-OILN report frame. So, it works; but it ONLY WORKS FOR ONE REPORT FRAME!
And THAT is the problem.
What if I wanted to do the same thing for a DIFFERENT report frame? Simple, create another Excel application that is hard coded for THAT report frame. Repeat this same process for all 143 report frames! Not a good idea.
Alternatively, the Excel application could be modified to use the metadata above rather than hard coding the mapping rules and impute rules with massive numbers of IF...THEN statements that are hard to change, hard to maintain, and therefore not very flexible.
A better way is to point the Excel application to a report frame, read the metadata for that report frame, and then point to the list of filings with that report frame.
If someone who understands how to program reads the code, they will immediately see the problems of the IF...THEN statements in the code.
(PLEASE NOTE!!! The metadata available now is not the most current version of this metadata. The reason is that I am constantly updating this metadata for new mappings, new impute rules, fixing bugs, adding new report frames and so on as I try and get the fundamental accounting concepts dialed in. If you need the most current version of the metadata please contact me. I will update this information publically at the end of the year.)
(PLEASE NOTE!!!! All of this metadata is represented in XBRL, except the impute rules. Not representing the impute rules in XBRL was a mistake. Future versions of this will also provide the impute rules in XBRL Formula.)