📜 ⬆️ ⬇️

XBRL: just about the complex - Chapter 6. Immersion in XBRL - Part 3. Calculations and validation

6.3. Calculations and validations


Now that we have a taxonomy that allows us to build a good report, it is time to begin to solve another issue - validation.


As you remember, one 'gifted' mathematician works in our company. Despite the fact that the report as a whole looks good, 27 men and 15 women can not give a total number of employees equal to 41.


Fortunately, XBRL has a solution for this case - the calculation reference base (calculation linkbases).


6.3.1. Taxonomy scheme


We need to make a few changes to the taxonomy scheme in order to start using the reference database of calculations:



6.3.1.1. Link base link

To include the reference base of computations in DTS (associated set of taxonomies), it is necessary to determine the relationship with it.


<link:linkbaseRef xlink:type="simple" xlink:href="sample-2006-01-03-calculation.xml" xlink:role="http://www.xbrl.org/2003/role/calculationLinkbaseRef" xlink:arcrole="http://www.w3.org/1999/xlink/properties/linkbase" /> 

We refer to the document containing the base of reference calculations using the href attribute. The role attribute is set to calcLinkbaseRef , indicating the type of linkbase.


6.3.1.2. Calculation Roles

There are two calculations we can do:



Since we have only one concept for the total number of employees, each of the calculations must have its own role. Forget it, and we get the total number of employees doubled - the detailed values ​​of both hierarchies will be added.


Earlier, we have already defined the roles for the base of links of presentations, let's allow their use also for calculations.


 <link:roleType roleURI="http://www.sample.com/genderDemographics" id="genderDemographics"> <link:definition>Gender related demographics on employees</link:definition> <link:usedOn>link:presentationLink</link:usedOn> <link:usedOn>link:calculationLink</link:usedOn> </link:roleType> <link:roleType roleURI="http://www.sample.com/ageDemographics" id="ageDemographics"> <link:definition>Age related demographics on employees</link:definition> <link:usedOn>link:presentationLink</link:usedOn> <link:usedOn>link:calculationLink</link:usedOn> </link:roleType> 

Allowing the use of a role in a reference calculation base simply means adding the usedOn element to usedOn with the calculationLink value.


6.3.2. Computation Reference Database


The beginning of a document containing a linkbase should look familiar to you.


 <?xml version="1.0" encoding="utf-8"?> <linkbase xmlns="http://www.xbrl.org/2003/linkbase" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xbrli="http://www.xbrl.org/2003/instance" xsi:schemaLocation="http://www.xbrl.org/2003/instance http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > </linkbase> 

6.3.2.1. Role relationships

As in the case of the link base of presentations, we need to determine the link to the roles from the taxonomy scheme.


 <roleRef xlink:type="simple" xlink:href="sample-2006-01-03.xsd#genderDemographics" roleURI="http://www.sample.com/genderDemographics" /> <roleRef xlink:type="simple" xlink:href="sample-2006-01-03.xsd#ageDemographics" roleURI="http://www.sample.com/ageDemographics" /> 

Again, there should be no surprises for you here.


6.3.2.2. Calculation Links

We define the calculationLink element for each calculation, using roles to distinguish them.


 <calculationLink xlink:type="extended" xlink:role="http://www.sample.com/genderDemographics" > </calculationLink> <calculationLink xlink:type="extended" xlink:role="http://www.sample.com/ageDemographics" > </calculationLink> 

6.3.2.3. Locators

Locators are completely similar to what we defined in the link bases of labels and presentations, so we will not repeat.


6.3.2.4. Calculation arcs

Now we can finally define calculation arcs, combining the concepts of each section of the report with the total number of employees.


 <calculationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item" xlink:from="concept_nr_employees_total" xlink:to="concept_nr_employees_male" weight="1.0" order="1" /> <calculationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item" xlink:from="concept_nr_employees_total" xlink:to="concept_nr_employees_female" weight="1.0" order="2" /> 

 <calculationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item" xlink:from="concept_nr_employees_total" xlink:to="concept_nr_employees_age_up_to_20" weight="1.0" order="1" /> <calculationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item" xlink:from="concept_nr_employees_total" xlink:to="concept_nr_employees_age_21_to_40" weight="1.0" order="2" /> <calculationArc xlink:type="arc" xlink:arcrole="http://www.xbrl.org/2003/arcrole/summation-item" xlink:from="concept_nr_employees_total" xlink:to="concept_nr_employees_age_41_and_up" weight="1.0" order="3" /> 

The arcrole attribute arcrole set to summation-item , meaning that the from-concept is the sum of the to-concepts.


Here you can also see the useful weight attribute - it determines the coefficient by which the to-concept is multiplied when calculating the total amount. In our case, for simple summation, we always use the coefficients '1.0'. And to subtract the to-concept from the total amount, it is enough to specify the coefficient '-1.0'.


6.3.3. What is the result?


When we build the report in our application, here’s what we’ll see:


image


Calculation by gender demography led to a validation error: the specified value of '41' does not match the calculated value of '42'. All as we expected.


But here you can also see one of the limitations of the calculation base: our report visualization application could not determine for which fact the error was shown. Facts on the concept of 'Total number of employees' (total number of employees) are indicated in each section of the report, therefore, the error is also displayed in each section.


Perhaps some of the more functional report visualization applications will find that the role of computing belongs to the gender demography section and only shows an error in it. But this is not the best solution, since we could create new roles for the computation base and lose touch with the presentation base. In this case, the application will not be able to determine where to show the error.


Apparently, at the moment the only solution is to use different concepts for the total number of employees in each section of the report. However, this is contrary to the principle of a one-time transmission of each fact.


6.3.3.1. Adjustment

If we correct the report data by changing the number of male employees to 26, then there will be no error when generating the report.


image






')

Source: https://habr.com/ru/post/336114/


All Articles