Skip to content

Commit

Permalink
Merge for v21.0.5 Approved (#766)
Browse files Browse the repository at this point in the history
* Updated rule 118 to handle the consolidated items axis correctly

* Update version.xule

* Fixed rule 118 for timing issues and legal entity axis

* Updated 118 for variable dei.

---------

Co-authored-by: Campbell
  • Loading branch information
davidtauriello committed Aug 2, 2023
1 parent e67ac02 commit 8ceadd7
Show file tree
Hide file tree
Showing 21 changed files with 287 additions and 165 deletions.
Binary file modified dqc_us_rules/dqc-esef-2019-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-esef-2020-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-esef-2021-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-esef-2022-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-ifrs-2018-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-ifrs-2019-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-ifrs-2020-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-ifrs-2021-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-ifrs-2022-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-ifrs-2023-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-us-2018-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-us-2019-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-us-2020-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-us-2021-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-us-2022-V21-ruleset.zip
Binary file not shown.
Binary file modified dqc_us_rules/dqc-us-2023-V21-ruleset.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion dqc_us_rules/source/lib/version.xule
Expand Up @@ -9,7 +9,7 @@ DQC Rules

/** Define the rule version **/

constant $ruleVersion = '21.0.4'
constant $ruleVersion = '21.0.5'

/** Define Additional Attribute types that can be associated with a rule **/

Expand Down
114 changes: 74 additions & 40 deletions dqc_us_rules/source/us/2020/DQC_0118.xule
Expand Up @@ -23,9 +23,36 @@ for $cube in $STATEMENT_CUBES.sort

$conceptsInCube = filter $cube.facts returns $item.concept.name;

/** Get Dimension Information **/
$dimensions = $cube.dimensions;
$dimObjects = filter $dimensions returns $item.concept.name

/** No default defined for a dimension. If Dont add a default then rule will not run **/

$DefaultDimensions = navigate dimension-default descendants from (filter $dimensions returns $item.concept.name) returns set (source-name);
$MissingDefaults = $dimObjects - $DefaultDimensions

/** Label Check If put the text "default" in the preferred label **/
$DefaultPresentation = navigate parent-child children from (filter $dimensions returns $item.concept.name) role $cube.drs-role returns set (source-name, preferred-label, target-name);
$textDefault = filter $DefaultPresentation where $item[2].text.lower-case.contains('default')
$MissingDefaultLabel = filter $textDefault returns $item[1]

$legalEntityAxis = qname($dei_namespace,'LegalEntityAxis')
/** Check if the statement cube contains any facts with the legal entity Axis **/
$LegalEntityFactsInCube = list({nonils covered @concept = * @cube = $cube @$legalEntityAxis = *})

$LegalEntityAxisInCube = if $LegalEntityFactsInCube.length > 0
filter $dimObjects where $item.local-name == 'LegalEntityAxis' returns $item
else
set()

for $concept_item in $calcNetworkSource

/**DOnt run the rule if the concept is none or the concept has no value in the cube or the total uses PledgedStatusAxis**/

/**Add to AxisNotToCheck any fact total we do not want to check adds because it has an axis that will not apply across all children of the calc **/
$AxisNotToCheck = set(PledgedStatusAxis)
/** first value is used to eliminate none value **/
$TotalsWithAxisNotToCheckFlag = (first-value(sum(set({covered nonils @concept = $concept_item @cube.drs-role = $cube.drs-role }.dimensions.keys.name)),set()) intersect $AxisNotToCheck).length > 0
if $concept_item == none or (length(first-value($calcNetworkSource,set()).intersect($conceptsInCube.to-set))==0) or $TotalsWithAxisNotToCheckFlag
skip
Expand All @@ -40,25 +67,33 @@ for $cube in $STATEMENT_CUBES.sort

/** Sum the children to get a total. If the child has no value in the default then check if it has values using the dimension being processed. If it does the function takes the members of the dimension and adds them up. This way if the components of a calc are dimensionalized with no default we will calculate the total.**/

$addend = sum(list(for $x in $calcComponents
$addendComponents = (list(for $x in $calcComponents
$targetElement = $x[1];
$targetWeight = $x[2];

$factValue = first-value({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals == $fs_decimals}, first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals >= $fs_decimals})), max(list(getDimensionSums($targetElement, $cube, 1, $concept_item))), max(list(getDimensionSums($targetElement, $cube, 2, $concept_item))), first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals < $fs_decimals})));

if exists($factValue)
list($factValue, $targetWeight, $targetElement, $factValue.string, $factValue.decimals)
else
skip
)
);

$addend = sum(list(for $j in $addendComponents
/** IMPORTANT **/
/**
** If a number is reported twice and the value is the same but they have different decimals then the arelle
** processor will eliminate the fact with the lower decimal value and keep the most accurate fact where the
** values are the same. Both facts will not be available in the processor. The first(list()) was included for
** safety so lines don't duplicate.
**/

first-value({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals == $fs_decimals} * $targetWeight, first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals >= $fs_decimals})) * $targetWeight, max(list(getDimensionSums($targetElement, $cube, 1, $concept_item))) * $targetWeight, max(list(getDimensionSums($targetElement, $cube, 2, $concept_item))) * $targetWeight, first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals < $fs_decimals})) * $targetWeight)
)
);

/** Capture in a string what calc was performed above to report in the rule message. **/
$addend_string = sum(list(for $x in $calcComponents.sort
$targetElement = $x[1];
$j[1] * $j[2]
)
);
/** Capture in a string what calc was performed above to report in the rule message. **/
$addend_string = sum(list(for $k in $addendComponents
$targetElement = $k[3];
$defaultFact = if exists({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role})
true
else
Expand All @@ -70,18 +105,11 @@ for $cube in $STATEMENT_CUBES.sort
$DimString2 = $DimString.join(' | ');
$DefaultMessage = if $defaultFact "" else " (" + $DimString2 + ")";

$factAmt = first-value(
{nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals == $fs_decimals}.string,
first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals >= $fs_decimals})).string,
max(list(getDimensionSums($targetElement , $cube, 1, $concept_item))).string, max(list(getDimensionSums($targetElement , $cube,2, $concept_item))).string,
first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals < $fs_decimals})).string)

$factDecimals = first-value(
{nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals == $fs_decimals}.decimals,
first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals >= $fs_decimals})).decimals,
max(list(getDimensionSums($targetElement, $cube, 1, $concept_item))).decimals, max(list(getDimensionSums($targetElement, $cube, 2, $concept_item))).decimals,
first(list({nonils @concept = $targetElement @cube.drs-role = $cube.drs-role where $fact.decimals < $fs_decimals})).decimals)
$weight = if $x[2] == 1
$factAmt = $k[4]


$factDecimals = $k[5]
$weight = if $k[2] == 1
"+"
else
"-";
Expand All @@ -94,39 +122,45 @@ for $cube in $STATEMENT_CUBES.sort
)
);

/** Compare the addends to the sum. This is only done for the current reporting period. This is to prevent bleed though from incomplete periods, and we know the current period should always be complete.**/
$addend_facts = (list(for $x in $addendComponents
$x[1]
)
);
$addend_Concepts = (list(for $x in $addendComponents
$x[3]
)
);

/** Get the reported total to compare the addends to the sum. This is only done for the current reporting period. This is to prevent bleed though from incomplete periods, and we know the current period should always be complete.**/
$sum2 = if taxonomy().concept($concept_item).period-type == duration
{nonils @concept = $concept_item @cube.drs-role = $cube.drs-role @@period.end = $document_period_end_date @@period.start = $document_period_start_date where $fact.decimals == $fs_decimals}
else
{nonils @concept = $concept_item @cube.drs-role = $cube.drs-role @@period.end = $document_period_end_date where $fact.decimals == $fs_decimals};

/** REMOVE DEFAULT FROM CALCULATION TEST **/
$dimensions = $cube.dimensions;
$dimObjects = filter $dimensions returns $item.concept.name

$sum2Dimensions = $sum2.dimensions.keys.name

/** Option 3 built into Arelle **/
/** Identify if the current calculation uses any fact values that are including the consolidated entities axis **/

/** No default defined for a dimension - Option 4 **/
$valid_addend_facts = (filter $addend_facts where $item.is-fact)
$Addends_Do_Not_Use_Consolidated_Entities_Axis = (filter $valid_addend_facts where $item.dimensions.keys.name.contains(srt:ConsolidatedEntitiesAxis) returns $item).length == 0

$DefaultDimensions = navigate dimension-default descendants from (filter $dimensions returns $item.concept.name) returns set (source-name);
$MissingDefaults = $dimObjects - $DefaultDimensions

/** Label Check - Option 5 **/
$DefaultPresentation = navigate parent-child children from (filter $dimensions returns $item.concept.name) role $cube.drs-role returns set (source-name, preferred-label, target-name);
$textDefault = filter $DefaultPresentation where $item[2].text.lower-case.contains('default')
$MissingDefaultLabel = filter $textDefault returns $item[1]
/** HANDLE CONSOLIDATED ITEMS AXIS FACTS **/
/** Identify if facts exist for the ConsolidatedEntitiesAxis dimension in a notes hypercube that could possibly bleed though in the financials **/
$factsInNotes = list([nonils @concept in $addend_Concepts @cube in $NOTES_CUBES @srt:ConsolidatedEntitiesAxis = *])

/** Label Check - Option 6 **/
/** Check any table with legal entity Axis don't check default **/

$LegalEntityAxisInCube = filter $dimObjects where $item.local-name == 'LegalEntityAxis'returns $item
$ConsolidatedEntityAxisInCube = filter $dimObjects where $item == srt:ConsolidatedEntitiesAxis returns $item
$noFactsInNotes = $factsInNotes.length == 0;

/** FLAG if the rule should not run because of consolidated Entity Axis Complications **/
$ConsolidatedEntityAxisInCube = if $noFactsInNotes and $Addends_Do_Not_Use_Consolidated_Entities_Axis
set()
else
filter $dimObjects where $item == srt:ConsolidatedEntitiesAxis returns $item

/** Dimension to check **/
/** Identify the axis that indicate their default values should not have a calculation check**/
$AxisDefaultsNotToCheck = $MissingDefaultLabel + $MissingDefaults + $LegalEntityAxisInCube + $ConsolidatedEntityAxisInCube

/** Identify if the current iteration is a default by taking the table dimensions deducting the dimensions
of the fact and seeing if the resulting set intersects with the axis that are not checked. If this is greater than zero
it means that the sum fact does not have a dimension (default) and the default of the dimensions has been tagged not to add. **/
Expand Down

0 comments on commit 8ceadd7

Please sign in to comment.