updated report schema

updated report schema

Contains bla bla

Fundamental Accounting Concepts [Line Items]

Fundamental Accounting Concepts [Hierarchy]

Equity Attributable to Noncontrolling Interest

Nonoperating Income (Loss) + Interest and Debt Expense

Income (Loss) Before Equity Method Investments

Income (Loss) from Equity Method Investments

Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments

Income (Loss) from Continuing Operations Before Tax

Income (Loss) from Continuing Operations After Tax

Income (Loss) from Discontinued Operations, Net of Tax

Extraordinary Items of Income (Expense), Net of Tax

Net Income Attributable to Noncontrolling Interest

Preferred Stock Dividends and Other Adjustments

Net Income (Loss) Available to Common Stockholders, Basic

Statement of Comprehensive Income [Hierarchy]

Comprehensive Income (Loss) Attributable to Parent

Comprehensive Income (Loss) Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities, Continuing

Net Cash Flows from Operating Activities, Discontinued

Net Cash Flows from Operating Activities

Net Cash Flows from Investing Activities, Continuing

Net Cash Flows from Investing Activities, Discontinued

Net Cash Flows from Investing Activities

Net Cash Flows from Financing Activities, Continuing

Net Cash Flows from Financing Activities, Discontinued

Net Cash Flows from Financing Activities

Skipped Validations (unmet preconditions)

Fact Validation Rule Results [Hierarchy]

Equity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

Assets = CurrentAssets + NoncurrentAssets

Liabilities = CurrentLiabilities + NoncurrentLiabilities

LiabilitiesAndEquity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

OperatingIncomeLoss = GrossProfit - OperatingExpenses + OtherOperatingIncomeExpenses

IncomeBeforeEquityMethodInvestments = OperatingIncomeLoss + NonoperatingIncomeLossPlusInterestAndDebtExpense

IncomeLossFromContinuingOperationsBeforeTax = IncomeBeforeEquityMethodInvestments + IncomeLossFromEquityMethodInvestments

IncomeLossFromContinuingOperationsAfterTax = IncomeLossFromContinuingOperationsBeforeTax - IncomeTaxExpenseBenefit

NetIncomeLoss = IncomeLossFromContinuingOperationsAfterTax + IncomeLossFromDiscontinuedOperationsNetTax + ExtraordinaryItemsIncomeExpenseNetTax

NetIncomeLoss = NetIncomeAttributableToParent + NetIncomeAttributableToNoncontrollingInterest

NetIncomeLossAvailableToCommonStockholdersBasic = NetIncomeAttributableToParent - PreferredStockDividendsAndOtherAdjustments

ComprehensiveIncomeLoss = ComprehensiveIncomeLossAttributableToParent + ComprehensiveIncomeLossAttributableToNoncontrollingInterest

ComprehensiveIncome = NetIncomeLoss + OtherComprehensiveIncome

OperatingIncomeLoss = Revenues - CostsAndExpenses + OtherOperatingIncomeExpenses

NetCashFlows = NetCashFlowsFromOperatingActivities + NetCashFlowsFromInvestingActivities + NetCashFlowsFromFinancingActivities [+ ExchangeGainsLosses]

NetCashFlowsContinuing = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesContinuing

NetCashFlowsDiscontinued = NetCashFlowsFromOperatingActivitiesDiscontinued + NetCashFlowsFromInvestingActivitiesDiscontinued + NetCashFlowsFromFinancingActivitiesDiscontinued

NetCashFlowsFromOperatingActivities = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromOperatingActivitiesDiscontinued

NetCashFlowsFromInvestingActivities = NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesDiscontinued

NetCashFlowsFromFinancingActivities = NetCashFlowsFromFinancingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesDiscontinued

Preferred Stock Dividends and Other Adjustments

Net Cash Flows from Investing Activities

Income (Loss) Before Equity Method Investments

Net Income (Loss) Available to Common Stockholders, Basic

Income (Loss) from Continuing Operations Before Tax

Comprehensive Income (Loss) Attributable to Parent

Net Cash Flows from Financing Activities, Continuing

Income (Loss) from Continuing Operations After Tax

Net Cash Flows from Investing Activities, Discontinued

Net Cash Flows from Financing Activities, Discontinued

Net Income Attributable to Noncontrolling Interest

Equity Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities

Income (Loss) from Discontinued Operations, Net of Tax

Extraordinary Items of Income (Expense), Net of Tax

Net Cash Flows from Operating Activities, Discontinued

Net Cash Flows from Investing Activities, Continuing

Income (Loss) from Equity Method Investments

Comprehensive Income (Loss) Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities, Continuing

Net Cash Flows from Financing Activities

Skipped Validations (unmet preconditions)

IncomeBeforeEquityMethodInvestments = OperatingIncomeLoss + NonoperatingIncomeLossPlusInterestAndDebtExpense

IncomeLossFromContinuingOperationsBeforeTax = IncomeBeforeEquityMethodInvestments + IncomeLossFromEquityMethodInvestments

IncomeLossFromContinuingOperationsAfterTax = IncomeLossFromContinuingOperationsBeforeTax - IncomeTaxExpenseBenefit

NetIncomeLoss = IncomeLossFromContinuingOperationsAfterTax + IncomeLossFromDiscontinuedOperationsNetTax + ExtraordinaryItemsIncomeExpenseNetTax

NetIncomeLoss = NetIncomeAttributableToParent + NetIncomeAttributableToNoncontrollingInterest

NetIncomeLossAvailableToCommonStockholdersBasic = NetIncomeAttributableToParent - PreferredStockDividendsAndOtherAdjustments

ComprehensiveIncomeLoss = ComprehensiveIncomeLossAttributableToParent + ComprehensiveIncomeLossAttributableToNoncontrollingInterest

ComprehensiveIncome = NetIncomeLoss + OtherComprehensiveIncome

OperatingIncomeLoss = GrossProfit - OperatingExpenses + OtherOperatingIncomeExpenses

OperatingIncomeLoss = Revenues - CostsAndExpenses + OtherOperatingIncomeExpenses

Fact Validation Rule Results [Hierarchy]

LiabilitiesAndEquity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

Liabilities = CurrentLiabilities + NoncurrentLiabilities

Assets = CurrentAssets + NoncurrentAssets

Equity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

NetCashFlows = NetCashFlowsFromOperatingActivities + NetCashFlowsFromInvestingActivities + NetCashFlowsFromFinancingActivities [+ ExchangeGainsLosses]

NetCashFlowsContinuing = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesContinuing

NetCashFlowsDiscontinued = NetCashFlowsFromOperatingActivitiesDiscontinued + NetCashFlowsFromInvestingActivitiesDiscontinued + NetCashFlowsFromFinancingActivitiesDiscontinued

NetCashFlowsFromOperatingActivities = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromOperatingActivitiesDiscontinued

NetCashFlowsFromInvestingActivities = NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesDiscontinued

NetCashFlowsFromFinancingActivities = NetCashFlowsFromFinancingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesDiscontinued

Fundamental Accounting Concepts [Line Items]

Fundamental Accounting Concepts [Hierarchy]

Equity Attributable to Noncontrolling Interest

Nonoperating Income (Loss) + Interest and Debt Expense

Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments

Income (Loss) Before Equity Method Investments

Income (Loss) from Equity Method Investments

Income (Loss) from Continuing Operations Before Tax

Income (Loss) from Continuing Operations After Tax

Income (Loss) from Discontinued Operations, Net of Tax

Extraordinary Items of Income (Expense), Net of Tax

Net Income Attributable to Noncontrolling Interest

Preferred Stock Dividends and Other Adjustments

Net Income (Loss) Available to Common Stockholders, Basic

Statement of Comprehensive Income [Hierarchy]

Comprehensive Income (Loss) Attributable to Parent

Comprehensive Income (Loss) Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities, Continuing

Net Cash Flows from Operating Activities, Discontinued

Net Cash Flows from Operating Activities

Net Cash Flows from Investing Activities, Continuing

Net Cash Flows from Investing Activities, Discontinued

Net Cash Flows from Investing Activities

Net Cash Flows from Financing Activities, Continuing

Net Cash Flows from Financing Activities, Discontinued

Net Cash Flows from Financing Activities

Redeemable Noncontrolling Interest Equity Common Carrying Amount

Income Statement Start Period imputation

for $facts in facts:facts-for-internal(( "fac:CostOfRevenue", "fac:GrossProfit", "fac:Revenues", "fac:CostsAndExpenses", "fac:OperatingIncomeLoss", "fac:OtherOperatingIncomeExpenses", "fac:OperatingExpenses"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"] let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"] let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"] let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"] return switch(true) case (exists($facts)) return let $source-fact := $facts[1] let $computed-value := facts:duration-for-fact($source-fact).Start let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Concept" : "fac:IncomeStatementStartPeriod" }, Value: $computed-value, Type: "NonNumericValue" }) || " = " || "facts:duration-for-fact(" || rules:fact-trail($source-fact) || ").Start" return copy $newfact := rules:create-computed-fact( $source-fact, "fac:IncomeStatementStartPeriod", $computed-value, $rule, $audit-trail-message, $source-fact, $options) modify ( replace value of json $newfact("Type") with "NonNumericValue" ) return $newfact default return ()

fac:GrossProfit fac:Revenues fac:CostsAndExpenses fac:OperatingIncomeLoss fac:OtherOperatingIncomeExpenses fac:OperatingExpenses

import module namespace entities = "http://xbrl.io/modules/bizql/entities"; for $facts in facts:facts-for-internal(( "fac:TradingSymbol", "fac:Assets"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $TradingSymbol as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:TradingSymbol"] let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch (true) case (exists($TradingSymbol)) return $TradingSymbol case (exists($Assets)) return let $computed-value := entities:entities($Assets.Aspects."xbrl:Entity").Profiles.SEC.Tickers[[1]] let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:TradingSymbol" }, Value: $computed-value }) || " = external source" return copy $newfact := rules:create-computed-fact( $Assets, "fac:TradingSymbol", if (exists($computed-value)) then $computed-value else "N/A", $rule, $audit-trail-message, $Assets, $options) modify ( replace value of json $newfact("Type") with "NonNumericValue" ) return $newfact default return {}

for $facts in facts:facts-for-internal(( "fac:BalanceSheetFormat", "fac:DocumentType", "fac:CurrentAssets", "fac:NoncurrentAssets", "fac:NoncurrentLiabilities", "fac:CurrentLiabilities"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1] group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", $facts:PERIOD, $facts:UNIT, "Balance")), $aligned-period let $BalanceSheetFormat as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:BalanceSheetFormat"] let $DocumentType as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:DocumentType"] let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"] let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"] let $NoncurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentLiabilities"] let $CurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentLiabilities"] return switch (true) case exists($BalanceSheetFormat) return $BalanceSheetFormat case(exists($DocumentType)) return let $computed-value := if (rules:decimal-value($CurrentAssets) eq 0 and rules:decimal-value($NoncurrentAssets) eq 0 and rules:decimal-value($NoncurrentLiabilities) eq 0 and rules:decimal-value($CurrentLiabilities) eq 0) then "Unclassified" else "Classified" let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Concept" : "fac:BalanceSheetFormat" }, Value: $computed-value , Type: "NonNumericValue" }) || " = " || $computed-value || " (because " || rules:fact-trail($CurrentAssets, "fac:CurrentAssets") || ", " || rules:fact-trail($NoncurrentAssets, "fac:NoncurrentAssets") || ", " || rules:fact-trail($NoncurrentLiabilities, "fac:NoncurrentLiabilities") || ", " || rules:fact-trail($CurrentLiabilities, "fac:CurrentLiabilities") || ")" let $source-facts := ( $CurrentAssets, $NoncurrentAssets, $NoncurrentLiabilities, $CurrentLiabilities) return copy $newfact := rules:create-computed-fact( ($DocumentType, $source-facts)[1], "fac:BalanceSheetFormat", $computed-value, $rule, $audit-trail-message, $source-facts, $options) modify ( replace value of json $newfact("Type") with "NonNumericValue" ) return $newfact default return ()

fac:DocumentType fac:CurrentAssets fac:NoncurrentAssets fac:NoncurrentLiabilities fac:CurrentLiabilities

for $facts in facts:facts-for-internal(( "fac:Equity", "fac:EquityAttributableToNoncontrollingInterest", "fac:EquityAttributableToParent"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] let $EquityAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToNoncontrollingInterest"] let $EquityAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToParent"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($Equity)) return $Equity case (exists($EquityAttributableToNoncontrollingInterest) or exists($EquityAttributableToParent)) return let $computed-value := rules:decimal-value($EquityAttributableToNoncontrollingInterest) + rules:decimal-value($EquityAttributableToParent) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:Equity" }, Value: $computed-value }) || " = " || rules:fact-trail($EquityAttributableToNoncontrollingInterest, "EquityAttributableToNoncontrollingInterest") || " + " || rules:fact-trail($EquityAttributableToParent, "EquityAttributableToParent") let $source-facts := ($EquityAttributableToNoncontrollingInterest, $EquityAttributableToParent) return rules:create-computed-fact( $source-facts[1], "fac:Equity", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:EquityAttributableToParent", "fac:Equity", "fac:EquityAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $EquityAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToParent"] let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] let $EquityAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToNoncontrollingInterest"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($EquityAttributableToParent)) return $EquityAttributableToParent case (exists($Equity)) return let $computed-value := rules:decimal-value($Equity) - rules:decimal-value($EquityAttributableToNoncontrollingInterest) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:EquityAttributableToParent" }, Value: $computed-value }) || " = " || rules:fact-trail($Equity, "Equity") || " - " || rules:fact-trail($EquityAttributableToNoncontrollingInterest, "EquityAttributableToNoncontrollingInterest") let $source-facts := ($Equity, $EquityAttributableToNoncontrollingInterest) return rules:create-computed-fact( $Equity, "fac:EquityAttributableToParent", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return()

for $facts in facts:facts-for-internal(( "fac:LiabilitiesAndEquity", "fac:Assets"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"] let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($LiabilitiesAndEquity)) return $LiabilitiesAndEquity case(exists($Assets)) return let $computed-value := rules:decimal-value($Assets) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:LiabilitiesAndEquity" }, Value: $computed-value }) || " = " || rules:fact-trail($Assets, "Assets") let $source-facts := $Assets return rules:create-computed-fact( $Assets, "fac:LiabilitiesAndEquity", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:Liabilities", "fac:Equity", "fac:LiabilitiesAndEquity", "fac:CommitmentsAndContingencies", "fac:TemporaryEquity", "fac:CurrentLiabilities", "fac:NoncurrentLiabilities"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $Liabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Liabilities"] let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"] let $CommitmentsAndContingencies as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CommitmentsAndContingencies"] let $TemporaryEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:TemporaryEquity"] let $CurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentLiabilities"] let $NoncurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentLiabilities"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($Liabilities)) return $Liabilities case(exists($Equity)) return let $computed-value := rules:decimal-value($LiabilitiesAndEquity) - ( rules:decimal-value($CommitmentsAndContingencies) + rules:decimal-value($TemporaryEquity) + rules:decimal-value($Equity) ) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:Liabilities" }, Value: $computed-value }) || " = " || rules:fact-trail($LiabilitiesAndEquity, "LiabilitiesAndEquity") || " - (" || rules:fact-trail($CommitmentsAndContingencies, "CommitmentsAndContingencies") || " + " || rules:fact-trail($TemporaryEquity, "TemporaryEquity") || " + " || rules:fact-trail($Equity) || ")" let $source-facts := ($LiabilitiesAndEquity, $CommitmentsAndContingencies, $TemporaryEquity, $Equity) return rules:create-computed-fact( $Equity, "fac:Liabilities", $computed-value, $rule, $audit-trail-message, $source-facts, $options) case(exists($CurrentLiabilities) and exists($NoncurrentLiabilities)) return let $computed-value := rules:decimal-value($CurrentLiabilities) + rules:decimal-value($NoncurrentLiabilities) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:Liabilities" }, Value: $computed-value }) || " = " || rules:fact-trail($CurrentLiabilities) || " + " || rules:fact-trail($NoncurrentLiabilities) let $source-facts := ($CurrentLiabilities, $NoncurrentLiabilities) return rules:create-computed-fact( $CurrentLiabilities, "fac:Liabilities", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

fac:Equity fac:LiabilitiesAndEquity fac:CommitmentsAndContingencies fac:TemporaryEquity fac:CurrentLiabilities fac:NoncurrentLiabilities

for $facts in facts:facts-for-internal(( "fac:NoncurrentLiabilities", "fac:Liabilities", "fac:CurrentLiabilities"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NoncurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentLiabilities"] let $Liabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Liabilities"] let $CurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentLiabilities"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($NoncurrentLiabilities)) return $NoncurrentLiabilities case(exists($CurrentLiabilities) and exists($Liabilities)) return let $computed-value := rules:decimal-value($Liabilities) - rules:decimal-value($CurrentLiabilities) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:NoncurrentLiabilities" }, Value: $computed-value }) || " = " || rules:fact-trail($Liabilities) || " - " || rules:fact-trail($CurrentLiabilities) let $source-facts := ($Liabilities, $CurrentLiabilities) return rules:create-computed-fact( $CurrentLiabilities, "fac:NoncurrentLiabilities", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:TemporaryEquity", "us-gaap:RedeemableNoncontrollingInterestEquityCommonCarryingAmount"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $TemporaryEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:TemporaryEquity"] let $RedeemableNoncontrollingInterestEquityCommonCarryingAmount as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "us-gaap:RedeemableNoncontrollingInterestEquityCommonCarryingAmount"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (not(exists($RedeemableNoncontrollingInterestEquityCommonCarryingAmount))) return $TemporaryEquity case (exists($RedeemableNoncontrollingInterestEquityCommonCarryingAmount)) return let $computed-value := rules:decimal-value($TemporaryEquity) + rules:decimal-value($RedeemableNoncontrollingInterestEquityCommonCarryingAmount) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:TemporaryEquity" }, Value: $computed-value }) || " = " || rules:fact-trail($TemporaryEquity, "TemporaryEquity") || " + " || rules:fact-trail($RedeemableNoncontrollingInterestEquityCommonCarryingAmount, "RedeemableNoncontrollingInterestEquityCommonCarryingAmount") let $source-facts := ($TemporaryEquity, $RedeemableNoncontrollingInterestEquityCommonCarryingAmount) return rules:create-computed-fact( $RedeemableNoncontrollingInterestEquityCommonCarryingAmount, "fac:TemporaryEquity", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:IncomeStatementFormat", "fac:GrossProfit", "fac:CostOfRevenue", "fac:Revenues"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := if(empty($facts)) then "" else facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeStatementFormat as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeStatementFormat"] let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] return switch(true) case exists($IncomeStatementFormat) return $IncomeStatementFormat case exists($Revenues) return let $computed-value := if (rules:decimal-value($GrossProfit) eq 0 and rules:decimal-value($CostOfRevenue) eq 0) then "Single-step" else "Multi-step" let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Concept" : "fac:IncomeStatementFormat" }, Value: $computed-value , Type: "NonNumericValue"}) || " = " || $computed-value || " (because " || rules:fact-trail($GrossProfit, "GrossProfit") || ", " || rules:fact-trail($CostOfRevenue, "CostOfRevenue") || ")" let $source-facts := ( $GrossProfit, $CostOfRevenue) return copy $newfact := rules:create-computed-fact( ($source-facts, $Revenues)[1], "fac:IncomeStatementFormat", $computed-value, $rule, $audit-trail-message, $source-facts, $options) modify ( replace value of json $newfact("Type") with "NonNumericValue" ) return $newfact default return ()

Equity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

for $facts in facts:facts-for-internal(( "fac:Equity", "fac:EquityAttributableToParent", "fac:EquityAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] let $EquityAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToParent"] let $EquityAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToNoncontrollingInterest"] where exists($Equity) return let $test := rules:decimal-value($Equity) eq ( rules:decimal-value($EquityAttributableToParent) + rules:decimal-value($EquityAttributableToNoncontrollingInterest)) let $audit-trail-message := rules:fact-trail($Equity) || (if($test) then " = " else " != ") || "( " || rules:fact-trail($EquityAttributableToParent,"EquityAttributableToParent") || " + " || rules:fact-trail($EquityAttributableToNoncontrollingInterest,"EquityAttributableToNoncontrollingInterest") || ")" let $source-facts := ( $EquityAttributableToParent, $EquityAttributableToNoncontrollingInterest) return rules:create-computed-fact( $Equity, "fac:EquityValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $Equity, $test)

Liabilities = CurrentLiabilities + NoncurrentLiabilities

for $facts in facts:facts-for-internal(( "fac:Liabilities", "fac:CurrentAssets", "fac:NoncurrentAssets", "fac:CurrentLiabilities", "fac:NoncurrentLiabilities"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $Liabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Liabilities"] let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"] let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"] let $CurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentLiabilities"] let $NoncurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentLiabilities"] where exists($Liabilities) and not(rules:decimal-value($CurrentAssets) eq 0 and rules:decimal-value($NoncurrentAssets) eq 0 and rules:decimal-value($CurrentLiabilities) eq 0 and rules:decimal-value($NoncurrentLiabilities) eq 0) return let $test := rules:decimal-value($Liabilities) eq (rules:decimal-value($CurrentLiabilities) + rules:decimal-value($NoncurrentLiabilities)) let $audit-trail-message := rules:fact-trail($Liabilities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($CurrentLiabilities,"CurrentLiabilities") || " + " || rules:fact-trail($NoncurrentLiabilities,"NoncurrentLiabilities") || ")" let $source-facts := ( $CurrentAssets, $NoncurrentAssets, $CurrentLiabilities, $NoncurrentLiabilities) return rules:create-computed-fact( $Liabilities, "fac:LiabilitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $Liabilities, $test)

fac:CurrentAssets fac:NoncurrentAssets fac:CurrentLiabilities fac:NoncurrentLiabilities

LiabilitiesAndEquity = Liabilities + CommitmentsAndContingencies + TemporaryEquity + Equity

for $facts in facts:facts-for-internal(( "fac:LiabilitiesAndEquity", "fac:Liabilities", "fac:CommitmentsAndContingencies", "fac:TemporaryEquity", "fac:Equity"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"] let $Liabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Liabilities"] let $CommitmentsAndContingencies as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CommitmentsAndContingencies"] let $TemporaryEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:TemporaryEquity"] let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] where exists($LiabilitiesAndEquity) return let $test := rules:decimal-value($LiabilitiesAndEquity) eq (rules:decimal-value($Liabilities) + rules:decimal-value($CommitmentsAndContingencies) + rules:decimal-value($TemporaryEquity) + rules:decimal-value($Equity)) let $audit-trail-message := rules:fact-trail($LiabilitiesAndEquity) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($Liabilities,"Liabilities") || " + " || rules:fact-trail($CommitmentsAndContingencies,"CommitmentsAndContingencies") || " + " || rules:fact-trail($TemporaryEquity,"TemporaryEquity") || " + " || rules:fact-trail($Equity,"Equity") || ")" let $source-facts := ( $Liabilities, $CommitmentsAndContingencies, $TemporaryEquity, $Equity) return rules:create-computed-fact( $LiabilitiesAndEquity, "fac:LiabilitiesAndEquityValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $LiabilitiesAndEquity, $test)

fac:Liabilities fac:CommitmentsAndContingencies fac:TemporaryEquity fac:Equity

NetCashFlows = NetCashFlowsFromOperatingActivities + NetCashFlowsFromInvestingActivities + NetCashFlowsFromFinancingActivities [+ ExchangeGainsLosses]

for $facts in facts:facts-for-internal(( "fac:NetCashFlows", "fac:NetCashFlowsFromOperatingActivities", "fac:NetCashFlowsFromInvestingActivities", "fac:NetCashFlowsFromFinancingActivities", "fac:ExchangeGainsLosses"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlows as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlows"] let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"] let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"] let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"] let $ExchangeGainsLosses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ExchangeGainsLosses"] return switch (true) case (exists($NetCashFlows) and rules:decimal-value($NetCashFlows) ne (rules:decimal-value($NetCashFlowsFromOperatingActivities) + rules:decimal-value($NetCashFlowsFromInvestingActivities) + rules:decimal-value($NetCashFlowsFromFinancingActivities))) return let $test := rules:decimal-value($NetCashFlows) eq (rules:decimal-value($NetCashFlowsFromOperatingActivities) + rules:decimal-value($NetCashFlowsFromInvestingActivities) + rules:decimal-value($NetCashFlowsFromFinancingActivities) + rules:decimal-value($ExchangeGainsLosses)) let $audit-trail-message := rules:fact-trail($NetCashFlows) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromOperatingActivities,"NetCashFlowsFromOperatingActivities") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivities,"NetCashFlowsFromInvestingActivities") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivities,"NetCashFlowsFromFinancingActivities") || " + " || rules:fact-trail($ExchangeGainsLosses,"ExchangeGainsLosses") || ")" let $source-facts := ( $NetCashFlowsFromOperatingActivities, $NetCashFlowsFromInvestingActivities, $NetCashFlowsFromFinancingActivities, $ExchangeGainsLosses) return rules:create-computed-fact( $NetCashFlows, "fac:NetCashFlowsValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlows, $test) case (exists($NetCashFlows) and rules:decimal-value($NetCashFlows) ne (rules:decimal-value($NetCashFlowsFromOperatingActivities) + rules:decimal-value($NetCashFlowsFromInvestingActivities) + rules:decimal-value($NetCashFlowsFromFinancingActivities) + rules:decimal-value($ExchangeGainsLosses))) return let $test := rules:decimal-value($NetCashFlows) eq (rules:decimal-value($NetCashFlowsFromOperatingActivities) + rules:decimal-value($NetCashFlowsFromInvestingActivities) + rules:decimal-value($NetCashFlowsFromFinancingActivities)) let $audit-trail-message := rules:fact-trail($NetCashFlows) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromOperatingActivities,"NetCashFlowsFromOperatingActivities") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivities,"NetCashFlowsFromInvestingActivities") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivities,"NetCashFlowsFromFinancingActivities") || ")" let $source-facts := ( $NetCashFlowsFromOperatingActivities, $NetCashFlowsFromInvestingActivities, $NetCashFlowsFromFinancingActivities, $ExchangeGainsLosses) return rules:create-computed-fact( $NetCashFlows, "fac:NetCashFlowsValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlows, $test) default return ()

NetCashFlowsContinuing = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesContinuing

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsContinuing", "fac:NetCashFlowsFromOperatingActivitiesContinuing", "fac:NetCashFlowsFromInvestingActivitiesContinuing", "fac:NetCashFlowsFromFinancingActivitiesContinuing"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsContinuing"] let $NetCashFlowsFromOperatingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesContinuing"] let $NetCashFlowsFromInvestingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesContinuing"] let $NetCashFlowsFromFinancingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesContinuing"] where exists($NetCashFlowsContinuing) return let $test := rules:decimal-value($NetCashFlowsContinuing) eq (rules:decimal-value($NetCashFlowsFromOperatingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromInvestingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromFinancingActivitiesContinuing)) let $audit-trail-message := rules:fact-trail($NetCashFlowsContinuing) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromOperatingActivitiesContinuing,"NetCashFlowsFromOperatingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivitiesContinuing,"NetCashFlowsFromInvestingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivitiesContinuing,"NetCashFlowsFromFinancingActivitiesContinuing") || ")" let $source-facts := ( $NetCashFlowsFromOperatingActivitiesContinuing, $NetCashFlowsFromInvestingActivitiesContinuing, $NetCashFlowsFromFinancingActivitiesContinuing) return rules:create-computed-fact( $NetCashFlowsContinuing, "fac:NetCashFlowsContinuingValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsContinuing, $test)

NetCashFlowsDiscontinued = NetCashFlowsFromOperatingActivitiesDiscontinued + NetCashFlowsFromInvestingActivitiesDiscontinued + NetCashFlowsFromFinancingActivitiesDiscontinued

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsDiscontinued", "fac:NetCashFlowsFromOperatingActivitiesDiscontinued", "fac:NetCashFlowsFromInvestingActivitiesDiscontinued", "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsDiscontinued"] let $NetCashFlowsFromOperatingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"] let $NetCashFlowsFromInvestingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"] let $NetCashFlowsFromFinancingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"] where exists($NetCashFlowsDiscontinued) return let $test := rules:decimal-value($NetCashFlowsDiscontinued) eq (rules:decimal-value($NetCashFlowsFromOperatingActivitiesDiscontinued) + rules:decimal-value($NetCashFlowsFromInvestingActivitiesDiscontinued) + rules:decimal-value($NetCashFlowsFromFinancingActivitiesDiscontinued)) let $audit-trail-message := rules:fact-trail($NetCashFlowsDiscontinued) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromOperatingActivitiesDiscontinued,"NetCashFlowsFromOperatingActivitiesDiscontinued") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivitiesDiscontinued,"NetCashFlowsFromInvestingActivitiesDiscontinued") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivitiesDiscontinued,"NetCashFlowsFromFinancingActivitiesDiscontinued") || ")" let $source-facts := ( $NetCashFlowsFromOperatingActivitiesDiscontinued, $NetCashFlowsFromInvestingActivitiesDiscontinued, $NetCashFlowsFromFinancingActivitiesDiscontinued) return rules:create-computed-fact( $NetCashFlowsDiscontinued, "fac:NetCashFlowsDiscontinuedValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsDiscontinued, $test)

NetCashFlowsFromOperatingActivities = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromOperatingActivitiesDiscontinued

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsFromOperatingActivities", "fac:NetCashFlowsFromOperatingActivitiesContinuing", "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"] let $NetCashFlowsFromOperatingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesContinuing"] let $NetCashFlowsFromOperatingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"] where exists($NetCashFlowsFromOperatingActivities) return let $test := rules:decimal-value($NetCashFlowsFromOperatingActivities) eq (rules:decimal-value($NetCashFlowsFromOperatingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromOperatingActivitiesDiscontinued)) let $audit-trail-message := rules:fact-trail($NetCashFlowsFromOperatingActivities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromOperatingActivitiesContinuing,"NetCashFlowsFromOperatingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromOperatingActivitiesDiscontinued,"NetCashFlowsFromOperatingActivitiesDiscontinued") || ")" let $source-facts := ( $NetCashFlowsFromOperatingActivitiesContinuing, $NetCashFlowsFromOperatingActivitiesDiscontinued) return rules:create-computed-fact( $NetCashFlowsFromOperatingActivities, "fac:NetCashFlowsFromOperatingActivitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsFromOperatingActivities, $test)

NetCashFlowsFromInvestingActivities = NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesDiscontinued

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsFromInvestingActivities", "fac:NetCashFlowsFromInvestingActivitiesContinuing", "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"] let $NetCashFlowsFromInvestingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesContinuing"] let $NetCashFlowsFromInvestingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"] where exists($NetCashFlowsFromInvestingActivities) return let $test := rules:decimal-value($NetCashFlowsFromInvestingActivities) eq (rules:decimal-value($NetCashFlowsFromInvestingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromInvestingActivitiesDiscontinued)) let $audit-trail-message := rules:fact-trail($NetCashFlowsFromInvestingActivities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromInvestingActivitiesContinuing,"NetCashFlowsFromInvestingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivitiesDiscontinued,"NetCashFlowsFromInvestingActivitiesDiscontinued") || ")" let $source-facts := ( $NetCashFlowsFromInvestingActivitiesContinuing, $NetCashFlowsFromInvestingActivitiesDiscontinued) return rules:create-computed-fact( $NetCashFlowsFromInvestingActivities, "fac:NetCashFlowsFromInvestingActivitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsFromInvestingActivities, $test)

NetCashFlowsFromFinancingActivities = NetCashFlowsFromFinancingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesDiscontinued

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsFromFinancingActivities", "fac:NetCashFlowsFromFinancingActivitiesContinuing", "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"] let $NetCashFlowsFromFinancingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesContinuing"] let $NetCashFlowsFromFinancingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"] where exists($NetCashFlowsFromFinancingActivities) return let $test := rules:decimal-value($NetCashFlowsFromFinancingActivities) eq (rules:decimal-value($NetCashFlowsFromFinancingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromFinancingActivitiesDiscontinued)) let $audit-trail-message := rules:fact-trail($NetCashFlowsFromFinancingActivities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromFinancingActivitiesContinuing,"NetCashFlowsFromFinancingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivitiesDiscontinued,"NetCashFlowsFromFinancingActivitiesDiscontinued") || ")" let $source-facts := ( $NetCashFlowsFromFinancingActivitiesContinuing, $NetCashFlowsFromFinancingActivitiesDiscontinued) return rules:create-computed-fact( $NetCashFlowsFromFinancingActivities, "fac:NetCashFlowsFromFinancingActivitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsFromFinancingActivities, $test)

for $facts in facts:facts-for-internal(( "fac:GrossProfit", "fac:Revenues", "fac:CostOfRevenue"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"] where exists($GrossProfit) return let $test := rules:decimal-value($GrossProfit) eq (rules:decimal-value($Revenues) - rules:decimal-value($CostOfRevenue)) let $audit-trail-message := rules:fact-trail($GrossProfit) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($Revenues,"Revenues") || " - " || rules:fact-trail($CostOfRevenue,"CostOfRevenue") || ")" let $source-facts := ( $Revenues, $CostOfRevenue) return rules:create-computed-fact( $GrossProfit, "fac:GrossProfitValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $GrossProfit, $test)

OperatingIncomeLoss = GrossProfit - OperatingExpenses + OtherOperatingIncomeExpenses

for $facts in facts:facts-for-internal(( "fac:OperatingIncomeLoss", "fac:GrossProfit", "fac:OperatingExpenses", "fac:OtherOperatingIncomeExpenses"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"] let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"] where exists($OperatingIncomeLoss) return let $test := rules:decimal-value($OperatingIncomeLoss) eq (rules:decimal-value($GrossProfit) - rules:decimal-value($OperatingExpenses) + rules:decimal-value($OtherOperatingIncomeExpenses)) let $audit-trail-message := rules:fact-trail($OperatingIncomeLoss) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($GrossProfit,"GrossProfit") || " - " || rules:fact-trail($OperatingExpenses,"OperatingExpenses") || " + " || rules:fact-trail($OtherOperatingIncomeExpenses,"OtherOperatingIncomeExpenses") || ")" let $source-facts := ( $GrossProfit, $OperatingExpenses, $OtherOperatingIncomeExpenses) return rules:create-computed-fact( $OperatingIncomeLoss, "fac:OperatingIncomeLossValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $OperatingIncomeLoss, $test)

OperatingIncomeLoss = Revenues - CostsAndExpenses + OtherOperatingIncomeExpenses

for $facts in facts:facts-for-internal(( "fac:OperatingIncomeLoss", "fac:Revenues", "fac:CostsAndExpenses", "fac:OtherOperatingIncomeExpenses"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"] let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"] where exists($OperatingIncomeLoss) return let $test := rules:decimal-value($OperatingIncomeLoss) eq (rules:decimal-value($Revenues) - rules:decimal-value($CostsAndExpenses) + rules:decimal-value($OtherOperatingIncomeExpenses)) let $audit-trail-message := rules:fact-trail($OperatingIncomeLoss) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($Revenues,"Revenues") || " - " || rules:fact-trail($CostsAndExpenses,"CostsAndExpenses") || " + " || rules:fact-trail($OtherOperatingIncomeExpenses,"OtherOperatingIncomeExpenses") || ")" let $source-facts := ( $Revenues, $CostsAndExpenses, $OtherOperatingIncomeExpenses) return rules:create-computed-fact( $OperatingIncomeLoss, "fac:OperatingIncomeLoss2Validation", $test, $rule, $audit-trail-message, $source-facts, $options, $OperatingIncomeLoss, $test)

IncomeBeforeEquityMethodInvestments = OperatingIncomeLoss + NonoperatingIncomeLossPlusInterestAndDebtExpense

for $facts in facts:facts-for-internal(( "fac:IncomeBeforeEquityMethodInvestments", "fac:OperatingIncomeLoss", "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"] let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $NonoperatingIncomeLossPlusInterestAndDebtExpense as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense"] where exists($IncomeBeforeEquityMethodInvestments) return let $test := rules:decimal-value($IncomeBeforeEquityMethodInvestments) eq rules:decimal-value($OperatingIncomeLoss) + rules:decimal-value($NonoperatingIncomeLossPlusInterestAndDebtExpense) let $audit-trail-message := rules:fact-trail($IncomeBeforeEquityMethodInvestments) || (if($test) then " = " else " != ") || "" || rules:fact-trail($OperatingIncomeLoss,"OperatingIncomeLoss") || " + " || rules:fact-trail($NonoperatingIncomeLossPlusInterestAndDebtExpense,"NonoperatingIncomeLossPlusInterestAndDebtExpense") || "" let $source-facts := ( $OperatingIncomeLoss, $NonoperatingIncomeLossPlusInterestAndDebtExpense) return rules:create-computed-fact( $IncomeBeforeEquityMethodInvestments, "fac:IncomeBeforeEquityMethodInvestmentsValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $IncomeBeforeEquityMethodInvestments, $test)

IncomeLossFromContinuingOperationsBeforeTax = IncomeBeforeEquityMethodInvestments + IncomeLossFromEquityMethodInvestments

for $facts in facts:facts-for-internal(( "fac:IncomeLossFromContinuingOperationsBeforeTax", "fac:IncomeBeforeEquityMethodInvestments", "fac:IncomeLossFromEquityMethodInvestments"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeLossFromContinuingOperationsBeforeTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsBeforeTax"] let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"] let $IncomeLossFromEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromEquityMethodInvestments"] where exists($IncomeLossFromContinuingOperationsBeforeTax) return let $test := rules:decimal-value($IncomeLossFromContinuingOperationsBeforeTax) eq rules:decimal-value($IncomeBeforeEquityMethodInvestments) + rules:decimal-value($IncomeLossFromEquityMethodInvestments) let $audit-trail-message := rules:fact-trail($IncomeLossFromContinuingOperationsBeforeTax) || (if($test) then " = " else " != ") || "" || rules:fact-trail($IncomeBeforeEquityMethodInvestments,"IncomeBeforeEquityMethodInvestments") || " + " || rules:fact-trail($IncomeLossFromEquityMethodInvestments,"IncomeLossFromEquityMethodInvestments") || "" let $source-facts := ( $IncomeBeforeEquityMethodInvestments, $IncomeLossFromEquityMethodInvestments) return rules:create-computed-fact( $IncomeLossFromContinuingOperationsBeforeTax, "fac:IncomeLossFromContinuingOperationsBeforeTaxValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $IncomeLossFromContinuingOperationsBeforeTax, $test)

IncomeLossFromContinuingOperationsAfterTax = IncomeLossFromContinuingOperationsBeforeTax - IncomeTaxExpenseBenefit

for $facts in facts:facts-for-internal(( "fac:IncomeLossFromContinuingOperationsAfterTax", "fac:IncomeLossFromContinuingOperationsBeforeTax", "fac:IncomeTaxExpenseBenefit"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeLossFromContinuingOperationsAfterTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsAfterTax"] let $IncomeLossFromContinuingOperationsBeforeTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsBeforeTax"] let $IncomeTaxExpenseBenefit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeTaxExpenseBenefit"] where exists($IncomeLossFromContinuingOperationsAfterTax) return let $test := rules:decimal-value($IncomeLossFromContinuingOperationsAfterTax) eq (rules:decimal-value($IncomeLossFromContinuingOperationsBeforeTax) - rules:decimal-value($IncomeTaxExpenseBenefit)) let $audit-trail-message := rules:fact-trail($IncomeLossFromContinuingOperationsAfterTax) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($IncomeLossFromContinuingOperationsBeforeTax,"IncomeLossFromContinuingOperationsBeforeTax") || " - " || rules:fact-trail($IncomeTaxExpenseBenefit,"IncomeTaxExpenseBenefit") || ")" let $source-facts := ( $IncomeLossFromContinuingOperationsBeforeTax, $IncomeTaxExpenseBenefit) return rules:create-computed-fact( $IncomeLossFromContinuingOperationsAfterTax, "fac:IncomeLossFromContinuingOperationsAfterTaxValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $IncomeLossFromContinuingOperationsAfterTax, $test)

NetIncomeLoss = IncomeLossFromContinuingOperationsAfterTax + IncomeLossFromDiscontinuedOperationsNetTax + ExtraordinaryItemsIncomeExpenseNetTax

for $facts in facts:facts-for-internal(( "fac:NetIncomeLoss", "fac:IncomeLossFromContinuingOperationsAfterTax", "fac:IncomeLossFromDiscontinuedOperationsNetTax", "fac:ExtraordinaryItemsIncomeExpenseNetTax"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"] let $IncomeLossFromContinuingOperationsAfterTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsAfterTax"] let $IncomeLossFromDiscontinuedOperationsNetTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromDiscontinuedOperationsNetTax"] let $ExtraordinaryItemsIncomeExpenseNetTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ExtraordinaryItemsIncomeExpenseNetTax"] where exists($NetIncomeLoss) return let $test := rules:decimal-value($NetIncomeLoss) eq rules:decimal-value($IncomeLossFromContinuingOperationsAfterTax) + rules:decimal-value($IncomeLossFromDiscontinuedOperationsNetTax) + rules:decimal-value($ExtraordinaryItemsIncomeExpenseNetTax) let $audit-trail-message := rules:fact-trail($NetIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($IncomeLossFromContinuingOperationsAfterTax,"IncomeLossFromContinuingOperationsAfterTax") || " + " || rules:fact-trail($IncomeLossFromDiscontinuedOperationsNetTax,"IncomeLossFromDiscontinuedOperationsNetTax") || " + " || rules:fact-trail($ExtraordinaryItemsIncomeExpenseNetTax,"ExtraordinaryItemsIncomeExpenseNetTax") || "" let $source-facts := ( $IncomeLossFromContinuingOperationsAfterTax, $IncomeLossFromDiscontinuedOperationsNetTax, $ExtraordinaryItemsIncomeExpenseNetTax) return rules:create-computed-fact( $NetIncomeLoss, "fac:NetIncomeLossValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetIncomeLoss, $test)

NetIncomeLoss = NetIncomeAttributableToParent + NetIncomeAttributableToNoncontrollingInterest

for $facts in facts:facts-for-internal(( "fac:NetIncomeLoss", "fac:NetIncomeAttributableToParent", "fac:NetIncomeAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"] let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"] let $NetIncomeAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToNoncontrollingInterest"] where exists($NetIncomeLoss) return let $test := rules:decimal-value($NetIncomeLoss) eq rules:decimal-value($NetIncomeAttributableToParent) + rules:decimal-value($NetIncomeAttributableToNoncontrollingInterest) let $audit-trail-message := rules:fact-trail($NetIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($NetIncomeAttributableToParent,"NetIncomeAttributableToParent") || " + " || rules:fact-trail($NetIncomeAttributableToNoncontrollingInterest,"NetIncomeAttributableToNoncontrollingInterest") || "" let $source-facts := ( $NetIncomeAttributableToParent, $NetIncomeAttributableToNoncontrollingInterest) return rules:create-computed-fact( $NetIncomeLoss, "fac:NetIncomeLoss2Validation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetIncomeLoss, $test)

NetIncomeLossAvailableToCommonStockholdersBasic = NetIncomeAttributableToParent - PreferredStockDividendsAndOtherAdjustments

for $facts in facts:facts-for-internal(( "fac:NetIncomeLossAvailableToCommonStockholdersBasic", "fac:NetIncomeAttributableToParent", "fac:PreferredStockDividendsAndOtherAdjustments"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetIncomeLossAvailableToCommonStockholdersBasic as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLossAvailableToCommonStockholdersBasic"] let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"] let $PreferredStockDividendsAndOtherAdjustments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:PreferredStockDividendsAndOtherAdjustments"] where exists($NetIncomeLossAvailableToCommonStockholdersBasic) return let $test := rules:decimal-value($NetIncomeLossAvailableToCommonStockholdersBasic) eq rules:decimal-value($NetIncomeAttributableToParent) - rules:decimal-value($PreferredStockDividendsAndOtherAdjustments) let $audit-trail-message := rules:fact-trail($NetIncomeLossAvailableToCommonStockholdersBasic) || (if($test) then " = " else " != ") || "" || rules:fact-trail($NetIncomeAttributableToParent,"NetIncomeAttributableToParent") || " - " || rules:fact-trail($PreferredStockDividendsAndOtherAdjustments,"PreferredStockDividendsAndOtherAdjustments") || "" let $source-facts := ( $NetIncomeAttributableToParent, $PreferredStockDividendsAndOtherAdjustments) return rules:create-computed-fact( $NetIncomeLossAvailableToCommonStockholdersBasic, "fac:NetIncomeLossAvailableToCommonStockholdersBasicValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetIncomeLossAvailableToCommonStockholdersBasic, $test)

ComprehensiveIncomeLoss = ComprehensiveIncomeLossAttributableToParent + ComprehensiveIncomeLossAttributableToNoncontrollingInterest

for $facts in facts:facts-for-internal(( "fac:ComprehensiveIncomeLoss", "fac:ComprehensiveIncomeLossAttributableToParent", "fac:ComprehensiveIncomeLossAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"] let $ComprehensiveIncomeLossAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLossAttributableToParent"] let $ComprehensiveIncomeLossAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLossAttributableToNoncontrollingInterest"] where exists($ComprehensiveIncomeLoss) return let $test := rules:decimal-value($ComprehensiveIncomeLoss) eq rules:decimal-value($ComprehensiveIncomeLossAttributableToParent) + rules:decimal-value($ComprehensiveIncomeLossAttributableToNoncontrollingInterest) let $audit-trail-message := rules:fact-trail($ComprehensiveIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($ComprehensiveIncomeLossAttributableToParent,"ComprehensiveIncomeLossAttributableToParent") || " + " || rules:fact-trail($ComprehensiveIncomeLossAttributableToNoncontrollingInterest,"ComprehensiveIncomeLossAttributableToNoncontrollingInterest") || "" let $source-facts := ( $ComprehensiveIncomeLossAttributableToParent, $ComprehensiveIncomeLossAttributableToNoncontrollingInterest) return rules:create-computed-fact( $ComprehensiveIncomeLoss, "fac:ComprehensiveIncomeLossValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $ComprehensiveIncomeLoss, $test)

ComprehensiveIncomeLoss = NetIncomeLoss + OtherComprehensiveIncomeLoss

for $facts in facts:facts-for-internal(( "fac:ComprehensiveIncomeLoss", "fac:NetIncomeLoss", "fac:OtherComprehensiveIncomeLoss"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"] let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"] let $OtherComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherComprehensiveIncomeLoss"] where exists($ComprehensiveIncomeLoss) return let $test := rules:decimal-value($ComprehensiveIncomeLoss) eq rules:decimal-value($NetIncomeLoss) + rules:decimal-value($OtherComprehensiveIncomeLoss) let $audit-trail-message := rules:fact-trail($ComprehensiveIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($NetIncomeLoss,"NetIncomeLoss") || " + " || rules:fact-trail($OtherComprehensiveIncomeLoss,"OtherComprehensiveIncomeLoss") || "" let $source-facts := ( $NetIncomeLoss, $OtherComprehensiveIncomeLoss) return rules:create-computed-fact( $ComprehensiveIncomeLoss, "fac:ComprehensiveIncomeLoss2Validation", $test, $rule, $audit-trail-message, $source-facts, $options, $ComprehensiveIncomeLoss, $test)

declare function local:mapToMember($concept) { switch(true) case ($concept = "oag:ReservesProvedNaturalGas") return "us-gaap:NaturalGasReservesMember" case ($concept = "oag:ReservesProvedNaturalGasLiquids") return "apa:NaturalGasLiquidsMember" case ($concept = "oag:ReservesProvedOilAndCondensateReserves") return "apa:CrudeOilAndCondensateMember" case ($concept = "oag:ReservesProvedTotal") return "us-gaap:TypeOfReserveDomain" default return () }; let $target-concept := "us-gaap:ProvedDevelopedReservesVolume" let $concepts := flatten($aligned-filter.$facts:ASPECTS.$facts:CONCEPT)[$$ = ("oag:ReservesProvedNaturalGas", "oag:ReservesProvedOilAndCondensateReserves", "oag:ReservesProvedNaturalGasLiquids", "oag:ReservesProvedTotal")] for $concept in $concepts let $filter-mod := if($concept ne "oag:ReservesProvedTotal") then local:mapToMember($concept) else () let $hypercube-mod := { "Name" : "us-gaap:ReserveQuantitiesByTypeOfReserveAxis", "Default" : "us-gaap:TypeOfReserveDomain" } let $aligned-filter := copy $f := $aligned-filter modify ( if(exists($filter-mod)) then if(exists($f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis")) then replace value of json $f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" with $filter-mod else insert json { "us-gaap:ReserveQuantitiesByTypeOfReserveAxis": [ $filter-mod ] } into $f.Aspects else (), replace value of json $f.Aspects.$facts:CONCEPT with [ $target-concept ] ) return $f let $hypercube := copy $h := $hypercube modify ( if(exists($h.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis")) then replace value of json $h.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" with $hypercube-mod else insert json {"us-gaap:ReserveQuantitiesByTypeOfReserveAxis" : $hypercube-mod } into $h.Aspects ) return $h return for $facts in facts:facts-for-internal( $target-concept, $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) return let $member := local:mapToMember($concept) for $provedReserve in $facts[$$.$facts:ASPECTS."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" eq $member] return let $source-fact := $provedReserve let $value := rules:decimal-value($provedReserve) let $original-concept := $provedReserve.$facts:ASPECTS.$facts:CONCEPT let $audit-trail-message := "concept to member mapping: '" || $concept || "' -> '" || $original-concept || "(us-gaap:ReserveQuantitiesByTypeOfReserveAxis::" || $member || ")'" return copy $f := rules:create-computed-fact( $source-fact, $concept, $value, $rule, $audit-trail-message, $source-fact, $options) modify if(exists($f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis")) then delete json $f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" else () return $f

declare function local:mapToMember($concept) { switch(true) case ($concept = ("oag:SalesVolumesNaturalGas", "oag:SalesVolumesDailyNaturalGas")) return "us-gaap:NaturalGasReservesMember" case ($concept = ("oag:SalesVolumesNaturalGasLiquids", "oag:SalesVolumesDailyNaturalGasLiquids")) return "apa:NaturalGasLiquidsMember" case ($concept = ("oag:SalesVolumesOilAndCondensate", "oag:SalesVolumesDailyOilAndCondensate")) return "apa:CrudeOilAndCondensateMember" case ($concept = ("oag:SalesVolumesTotal", "oag:SalesVolumesDailyTotal")) return "us-gaap:TypeOfReserveDomain" default return () }; declare function local:valueAdjusted($concept, $fact) { let $unit := $fact.Aspects."xbrl:Unit" return switch(true) case ($concept eq "oag:SalesVolumesNaturalGas" and contains($unit, ":MMcf")) return rules:decimal-value($fact) div 1000 case ($concept eq "oag:SalesVolumesDailyNaturalGas") return rules:decimal-value($fact) div 365 case ($concept = ("oag:SalesVolumesNaturalGasLiquids", "oag:SalesVolumesOilAndCondensate", "oag:SalesVolumesTotal") and contains($unit, ":MBbls")) return rules:decimal-value($fact) div 1000 case ($concept = ("oag:SalesVolumesDailyNaturalGasLiquids", "oag:SalesVolumesDailyOilAndCondensate", "oag:SalesVolumesDailyTotal")) return rules:decimal-value($fact) div 365 default return rules:decimal-value($fact) }; declare function local:unitsAdjusted($concept, $fact) { let $unit := $fact.Aspects."xbrl:Unit" return switch(true) case ($concept eq "oag:SalesVolumesNaturalGas" and contains($unit, ":MMcf")) return "utr:Bcf" case ($concept eq "oag:SalesVolumesDailyNaturalGas" and contains($unit, ":MMcf")) return "utr:MMcf/d" case ($concept = ("oag:SalesVolumesNaturalGasLiquids", "oag:SalesVolumesOilAndCondensate") and contains($unit, ":MBbls")) return "utr:MMBbls" case ($concept = ("oag:SalesVolumesDailyNaturalGasLiquids", "oag:SalesVolumesDailyOilAndCondensate") and contains($unit, ":MBbls")) return "utr:MBbls/d" case ($concept eq "oag:SalesVolumesTotal" and contains($unit, ":MBbls")) return "utr:MMBOE" case ($concept eq "oag:SalesVolumesDailyTotal" and contains($unit, ":MBbls")) return "utr:MBOE/d" default return $unit }; let $target-concept := "us-gaap:ProvedDevelopedAndUndevelopedReservesSalesOfMineralsInPlace" let $concepts := flatten($aligned-filter.$facts:ASPECTS.$facts:CONCEPT)[$$ = ("oag:SalesVolumesNaturalGas", "oag:SalesVolumesOilAndCondensate", "oag:SalesVolumesNaturalGasLiquids", "oag:SalesVolumesTotal", "oag:SalesVolumesDailyNaturalGas", "oag:SalesVolumesDailyOilAndCondensate", "oag:SalesVolumesDailyNaturalGasLiquids", "oag:SalesVolumesDailyTotal")] for $concept in $concepts let $filter-mod := if($concept = ("oag:SalesVolumesTotal", "oag:SalesVolumesDailyTotal")) then () else local:mapToMember($concept) let $hypercube-mod := { "Name" : "us-gaap:ReserveQuantitiesByTypeOfReserveAxis", "Default" : "us-gaap:TypeOfReserveDomain" } let $aligned-filter := copy $f := $aligned-filter modify ( if(exists($filter-mod)) then if(exists($f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis")) then replace value of json $f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" with $filter-mod else insert json { "us-gaap:ReserveQuantitiesByTypeOfReserveAxis": [ $filter-mod ] } into $f.Aspects else (), replace value of json $f.Aspects.$facts:CONCEPT with [ $target-concept ] ) return $f let $hypercube := copy $h := $hypercube modify ( if(exists($h.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis")) then replace value of json $h.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" with $hypercube-mod else insert json {"us-gaap:ReserveQuantitiesByTypeOfReserveAxis" : $hypercube-mod } into $h.Aspects ) return $h return for $facts in facts:facts-for-internal( $target-concept, $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) return let $member := local:mapToMember($concept) for $salesVolume in $facts[$$.$facts:ASPECTS."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" eq $member] return let $source-fact := $salesVolume let $value := local:valueAdjusted($concept, $salesVolume) let $unit := local:unitsAdjusted($concept, $salesVolume) let $original-concept := $salesVolume.$facts:ASPECTS.$facts:CONCEPT let $audit-trail-message := "concept to member mapping: '" || $concept || "' -> '" || $original-concept || "(us-gaap:ReserveQuantitiesByTypeOfReserveAxis::" || $member || ")'" return copy $f := rules:create-computed-fact( $source-fact, $concept, $value, $rule, $audit-trail-message, $source-fact, $options) modify ( if(exists($f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis")) then delete json $f.Aspects."us-gaap:ReserveQuantitiesByTypeOfReserveAxis" else (), replace value of json $f.Aspects."xbrl:Unit" with $unit ) return $f

oag:SalesVolumesNaturalGas oag:SalesVolumesOilAndCondensate oag:SalesVolumesNaturalGasLiquids oag:SalesVolumesTotal oag:SalesVolumesDailyNaturalGas oag:SalesVolumesDailyOilAndCondensate oag:SalesVolumesDailyNaturalGasLiquids oag:SalesVolumesDailyTotal

Rule to validate Assets (fac:Assets). It also creates a new fact (fac:AssetsValidation) that contains the validation result.

for $facts in facts:facts-for-internal((
      "fac:AssetsValidation", "fac:Assets", "fac:LiabilitiesAndEquity"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance"))
  , $aligned-period
let $AssetsValidation as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:AssetsValidation"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($AssetsValidation) return $AssetsValidation
  case (exists($Assets) and true)
  return
    let $computed-value := rules:decimal-value($Assets) eq rules:decimal-value($LiabilitiesAndEquity)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:AssetsValidation" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($Assets, "Assets") || " eq " || rules:fact-trail($LiabilitiesAndEquity, "LiabilitiesAndEquity")
	 let $source-facts := ($AssetsValidation, $Assets, $LiabilitiesAndEquity)
    return
      rules:create-computed-fact(
          $Assets,
          "fac:AssetsValidation",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Assets = CurrentAssets + NoncurrentAssets

Rule to validate Assets (fac:Assets). It also creates a new fact (fac:AssetsValidation2) that contains the validation result.

for $facts in facts:facts-for-internal((
      "fac:AssetsValidation2", "fac:Assets", "fac:CurrentAssets", "fac:NoncurrentAssets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance"))
  , $aligned-period
let $AssetsValidation2 as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:AssetsValidation2"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($AssetsValidation2) return $AssetsValidation2
  case (exists($Assets) and true)
  return
    let $computed-value := rules:decimal-value($Assets) eq rules:decimal-value($CurrentAssets) + rules:decimal-value($NoncurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:AssetsValidation2" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($Assets, "Assets") || " eq " || rules:fact-trail($CurrentAssets, "CurrentAssets") || " + " || rules:fact-trail($NoncurrentAssets, "NoncurrentAssets")
	 let $source-facts := ($AssetsValidation2, $Assets, $CurrentAssets, $NoncurrentAssets)
    return
      rules:create-computed-fact(
          $Assets,
          "fac:AssetsValidation2",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Assets = CurrentAssets + NoncurrentAssets

Rule to compute Assets (fac:Assets).

for $facts in facts:facts-for-internal((
      "fac:Assets", "fac:CurrentAssets", "fac:LiabilitiesAndEquity", "fac:NoncurrentAssets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance"))
  , $aligned-period
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"]
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($Assets) return $Assets
  case (exists($LiabilitiesAndEquity) and rules:decimal-value($CurrentAssets) eq rules:decimal-value($LiabilitiesAndEquity))
  return
    let $computed-value := rules:decimal-value($CurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:Assets" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($CurrentAssets, "CurrentAssets")
	 let $source-facts := ($Assets, $CurrentAssets, $LiabilitiesAndEquity, $NoncurrentAssets)
    return
      rules:create-computed-fact(
          $LiabilitiesAndEquity,
          "fac:Assets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  case (exists($NoncurrentAssets) and ())
  return
    let $computed-value := rules:decimal-value($CurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:Assets" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($CurrentAssets, "CurrentAssets")
	 let $source-facts := ($Assets, $CurrentAssets, $LiabilitiesAndEquity, $NoncurrentAssets)
    return
      rules:create-computed-fact(
          $NoncurrentAssets,
          "fac:Assets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

let $validations := ("fac:EquityValidation", "fac:AssetsValidation", "fac:AssetsValidation2", "fac:LiabilitiesValidation", "fac:LiabilitiesAndEquityValidation", "fac:NetCashFlowsValidation", "fac:NetCashFlowsContinuingValidation", "fac:NetCashFlowsDiscontinuedValidation", "fac:NetCashFlowsFromOperatingActivitiesValidation", "fac:NetCashFlowsFromInvestingActivitiesValidation", "fac:NetCashFlowsFromFinancingActivitiesValidation", "fac:GrossProfitValidation", "fac:OperatingIncomeLossValidation", "fac:OperatingIncomeLoss2Validation", "fac:IncomeBeforeEquityMethodInvestmentsValidation", "fac:IncomeLossFromContinuingOperationsBeforeTaxValidation", "fac:IncomeLossFromContinuingOperationsAfterTaxValidation", "fac:NetIncomeLossValidation", "fac:NetIncomeLoss2Validation", "fac:NetIncomeLossAvailableToCommonStockholdersBasicValidation", "fac:ComprehensiveIncomeLossValidation", "fac:ComprehensiveIncomeLoss2Validation") for $facts in facts:facts-for-internal($validations, $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1] group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", $facts:PERIOD, "Balance")), $aligned-period return let $passed as object* := $facts[$$.Value eq true] let $failed as object* := $facts[$$.Value eq false] let $not-applied as string* := distinct-values($validations)[not($$ = $facts.$facts:ASPECTS.$facts:CONCEPT)] for $concept in flatten($aligned-filter.$facts:ASPECTS.$facts:CONCEPT) return switch ($concept) case "fac:PassedValidations" return let $computed-value := count($passed) let $audit-trail-message := "count(" || string-join($passed.$facts:ASPECTS.$facts:CONCEPT, ", ") || ")" let $source-facts := ($passed) return copy $new := rules:create-computed-fact( ($facts[exists(facts:instant-for-fact($$))],$facts)[1], "fac:PassedValidations", $computed-value, {Label: $rule.Label || ": Passed Validations", Type: "xbrl28:formula" }, $audit-trail-message, $source-facts, $options) modify ( if(exists($new.$facts:ASPECTS.$facts:UNIT)) then replace value of json $new.$facts:ASPECTS.$facts:UNIT with "pure" else insert json {$facts:UNIT : "pure"} into $new.$facts:ASPECTS, if(exists($new.Type)) then replace value of json $new.Type with "NumericValue" else insert json { Type : "NumericValue"} into $new, if(exists($new.Decimals)) then replace value of json $new.Decimals with 0 else insert json { Decimals : 0} into $new ) return $new case "fac:FailedValidations" return let $computed-value := count($failed) let $audit-trail-message := "count(" || string-join($failed.$facts:ASPECTS.$facts:CONCEPT, ", ") || ")" let $source-facts := ($failed) return copy $new := rules:create-computed-fact( ($facts[exists(facts:instant-for-fact($$))],$facts)[1], "fac:FailedValidations", $computed-value, {Label: $rule.Label || ": Passed Validations", Type: "xbrl28:formula" }, $audit-trail-message, $source-facts, $options) modify ( if(exists($new.$facts:ASPECTS.$facts:UNIT)) then replace value of json $new.$facts:ASPECTS.$facts:UNIT with "pure" else insert json {$facts:UNIT : "pure"} into $new.$facts:ASPECTS, if(exists($new.Type)) then replace value of json $new.Type with "NumericValue" else insert json { Type : "NumericValue"} into $new, if(exists($new.Decimals)) then replace value of json $new.Decimals with 0 else insert json { Decimals : 0} into $new ) return $new case "fac:NotApplicableValidations" return let $computed-value := count($not-applied) let $audit-trail-message := "count(" || string-join($not-applied, ", ") || ")" let $source-facts := () return copy $new := rules:create-computed-fact( ($facts[exists(facts:instant-for-fact($$))],$facts)[1], "fac:NotApplicableValidations", $computed-value, {Label: $rule.Label || ": Validations that couldn't be applied", Type: "xbrl28:formula" }, $audit-trail-message, $source-facts, $options) modify ( if(exists($new.$facts:ASPECTS.$facts:UNIT)) then replace value of json $new.$facts:ASPECTS.$facts:UNIT with "pure" else insert json {$facts:UNIT : "pure"} into $new.$facts:ASPECTS, if(exists($new.Type)) then replace value of json $new.Type with "NumericValue" else insert json { Type : "NumericValue"} into $new, if(exists($new.Decimals)) then replace value of json $new.Decimals with 0 else insert json { Decimals : 0} into $new ) return $new default return ()

Rule to compute Current Assets (fac:CurrentAssets).

for $facts in facts:facts-for-internal((
      "fac:CurrentAssets", "fac:NoncurrentAssets", "fac:Assets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($CurrentAssets) return $CurrentAssets
  case (exists($Assets) and not((not(exists($NoncurrentAssets)))))
  return
    let $computed-value := rules:decimal-value($Assets) - rules:decimal-value($NoncurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:CurrentAssets" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Assets, "Assets") || " - " || rules:fact-trail($NoncurrentAssets, "NoncurrentAssets")
	 let $source-facts := ($CurrentAssets, $NoncurrentAssets, $Assets)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Assets,
            "fac:CurrentAssets",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Assets,
          "fac:CurrentAssets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Noncurrent Assets (fac:NoncurrentAssets).

for $facts in facts:facts-for-internal((
      "fac:NoncurrentAssets", "fac:CurrentAssets", "fac:Assets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NoncurrentAssets) return $NoncurrentAssets
  case (exists($Assets) and not((not(exists($CurrentAssets)))))
  return
    let $computed-value := rules:decimal-value($Assets) - rules:decimal-value($CurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NoncurrentAssets" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Assets, "Assets") || " - " || rules:fact-trail($CurrentAssets, "CurrentAssets")
	 let $source-facts := ($NoncurrentAssets, $CurrentAssets, $Assets)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Assets,
            "fac:NoncurrentAssets",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Assets,
          "fac:NoncurrentAssets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Cost of Revenues (fac:CostOfRevenue).

fac:GrossProfit fac:Revenues fac:CostsAndExpenses fac:OperatingExpenses

for $facts in facts:facts-for-internal((
      "fac:CostOfRevenue", "fac:GrossProfit", "fac:Revenues", "fac:CostsAndExpenses", "fac:OperatingExpenses"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"]
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"]
let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($CostOfRevenue) return $CostOfRevenue
  case (exists($Revenues) and not((not(exists($GrossProfit)))))
  return
    let $computed-value := rules:decimal-value($Revenues) - rules:decimal-value($GrossProfit)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:CostOfRevenue" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Revenues, "Revenues") || " - " || rules:fact-trail($GrossProfit, "GrossProfit")
	 let $source-facts := ($CostOfRevenue, $GrossProfit, $Revenues, $CostsAndExpenses, $OperatingExpenses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Revenues,
            "fac:CostOfRevenue",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Revenues,
          "fac:CostOfRevenue",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  case (exists($CostsAndExpenses) and ())
  return
    let $computed-value := rules:decimal-value($CostsAndExpenses) - rules:decimal-value($OperatingExpenses)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:CostOfRevenue" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($CostsAndExpenses, "CostsAndExpenses") || " - " || rules:fact-trail($OperatingExpenses, "OperatingExpenses")
	 let $source-facts := ($CostOfRevenue, $GrossProfit, $Revenues, $CostsAndExpenses, $OperatingExpenses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $CostsAndExpenses,
            "fac:CostOfRevenue",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $CostsAndExpenses,
          "fac:CostOfRevenue",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(CostOfRevenue)) , not(isblank(Revenues)), isblank(GrossProfit) , (Revenues - CostsAndExpenses = OperatingIncomeLoss), isblank(OperatingExpenses) , isblank(OtherOperatingIncomeExpenses))

Rule to compute Operating Expenses (fac:OperatingExpenses).

for $facts in facts:facts-for-internal((
      "fac:OperatingExpenses", "fac:CostOfRevenue", "fac:CostsAndExpenses"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"]
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($OperatingExpenses) return $OperatingExpenses
  case (exists($CostsAndExpenses) and not((not(exists($CostOfRevenue)))))
  return
    let $computed-value := rules:decimal-value($CostsAndExpenses) - rules:decimal-value($CostOfRevenue)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:OperatingExpenses" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($CostsAndExpenses, "CostsAndExpenses") || " - " || rules:fact-trail($CostOfRevenue, "CostOfRevenue")
	 let $source-facts := ($OperatingExpenses, $CostOfRevenue, $CostsAndExpenses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $CostsAndExpenses,
            "fac:OperatingExpenses",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $CostsAndExpenses,
          "fac:OperatingExpenses",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Costs and Expenses (fac:CostsAndExpenses).

fac:OperatingExpenses fac:CostOfRevenue fac:Revenues fac:OperatingIncomeLoss fac:OtherOperatingIncomeExpenses

for $facts in facts:facts-for-internal((
      "fac:CostsAndExpenses", "fac:OperatingExpenses", "fac:CostOfRevenue", "fac:Revenues", "fac:OperatingIncomeLoss", "fac:OtherOperatingIncomeExpenses"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"]
let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"]
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"]
let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($CostsAndExpenses) return $CostsAndExpenses
  case (exists($CostOfRevenue) and not((not(exists($OperatingExpenses)))))
  return
    let $computed-value := rules:decimal-value($CostOfRevenue) + rules:decimal-value($OperatingExpenses)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:CostsAndExpenses" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($CostOfRevenue, "CostOfRevenue") || " + " || rules:fact-trail($OperatingExpenses, "OperatingExpenses")
	 let $source-facts := ($CostsAndExpenses, $OperatingExpenses, $CostOfRevenue, $Revenues, $OperatingIncomeLoss, $OtherOperatingIncomeExpenses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $CostOfRevenue,
            "fac:CostsAndExpenses",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $CostOfRevenue,
          "fac:CostsAndExpenses",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  case (exists($Revenues) and ())
  return
    let $computed-value := rules:decimal-value($Revenues) - rules:decimal-value($OperatingIncomeLoss) - rules:decimal-value($OtherOperatingIncomeExpenses)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:CostsAndExpenses" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Revenues, "Revenues") || " - " || rules:fact-trail($OperatingIncomeLoss, "OperatingIncomeLoss") || " - " || rules:fact-trail($OtherOperatingIncomeExpenses, "OtherOperatingIncomeExpenses")
	 let $source-facts := ($CostsAndExpenses, $OperatingExpenses, $CostOfRevenue, $Revenues, $OperatingIncomeLoss, $OtherOperatingIncomeExpenses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Revenues,
            "fac:CostsAndExpenses",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Revenues,
          "fac:CostsAndExpenses",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(isblank(GrossProfit), not(isblank(Revenues)), not(isblank(OperatingIncomeLoss)) and not(isblank(OtherOperatingIncomeExpenses)))

Rule to compute Return on Assets (ROA) (fac:ReturnOnAssets).

for $facts in facts:facts-for-internal((
      "fac:ReturnOnAssets", "fac:Assets", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ReturnOnAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ReturnOnAssets"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ReturnOnAssets) return $ReturnOnAssets
  case (exists($Assets) and rules:decimal-value($Assets) ne 0)
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Assets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ReturnOnAssets" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Assets, "Assets")
	 let $source-facts := ($ReturnOnAssets, $Assets, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Assets,
            "fac:ReturnOnAssets",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Assets,
          "fac:ReturnOnAssets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Return on Equity (ROE) (fac:ReturnOnEquity).

for $facts in facts:facts-for-internal((
      "fac:ReturnOnEquity", "fac:Equity", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ReturnOnEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ReturnOnEquity"]
let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ReturnOnEquity) return $ReturnOnEquity
  case (exists($Equity) and rules:decimal-value($Equity) ne 0)
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Equity)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ReturnOnEquity" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Equity, "Equity")
	 let $source-facts := ($ReturnOnEquity, $Equity, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Equity,
            "fac:ReturnOnEquity",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Equity,
          "fac:ReturnOnEquity",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Return on Sales (ROS) (fac:ReturnOnSalesROS).

for $facts in facts:facts-for-internal((
      "fac:ReturnOnSalesROS", "fac:Revenues", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ReturnOnSalesROS as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ReturnOnSalesROS"]
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ReturnOnSalesROS) return $ReturnOnSalesROS
  case (exists($Revenues) and rules:decimal-value($Revenues) ne 0)
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Revenues)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ReturnOnSalesROS" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Revenues, "Revenues")
	 let $source-facts := ($ReturnOnSalesROS, $Revenues, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Revenues,
            "fac:ReturnOnSalesROS",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Revenues,
          "fac:ReturnOnSalesROS",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Other Operating Income (Expenses) (fac:OtherOperatingIncomeExpenses).

for $facts in facts:facts-for-internal((
      "fac:OtherOperatingIncomeExpenses", "fac:OperatingIncomeLoss", "fac:GrossProfit", "fac:OperatingExpenses"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"]
let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"]
let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"]
let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($OtherOperatingIncomeExpenses) return $OtherOperatingIncomeExpenses
  case (exists($OperatingIncomeLoss) and ())
  return
    let $computed-value := rules:decimal-value($OperatingIncomeLoss) - rules:decimal-value($GrossProfit) - rules:decimal-value($OperatingExpenses)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:OtherOperatingIncomeExpenses" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($OperatingIncomeLoss, "OperatingIncomeLoss") || " - " || rules:fact-trail($GrossProfit, "GrossProfit") || " - " || rules:fact-trail($OperatingExpenses, "OperatingExpenses")
	 let $source-facts := ($OtherOperatingIncomeExpenses, $OperatingIncomeLoss, $GrossProfit, $OperatingExpenses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $OperatingIncomeLoss,
            "fac:OtherOperatingIncomeExpenses",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $OperatingIncomeLoss,
          "fac:OtherOperatingIncomeExpenses",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(OperatingIncomeLoss)) and not(isblank(GrossProfit)) and not(isblank(OperatingExpenses)))

Rule to compute Operating Income (Loss) (fac:OperatingIncomeLoss).

for $facts in facts:facts-for-internal((
      "fac:OperatingIncomeLoss", "fac:IncomeBeforeEquityMethodInvestments", "fac:NonoperatingIncomeLoss", "fac:InterestAndDebtExpense"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"]
let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"]
let $NonoperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NonoperatingIncomeLoss"]
let $InterestAndDebtExpense as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:InterestAndDebtExpense"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($OperatingIncomeLoss) return $OperatingIncomeLoss
  case (exists($IncomeBeforeEquityMethodInvestments) and not((not(exists($IncomeBeforeEquityMethodInvestments)))))
  return
    let $computed-value := rules:decimal-value($IncomeBeforeEquityMethodInvestments) + rules:decimal-value($NonoperatingIncomeLoss) - rules:decimal-value($InterestAndDebtExpense)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:OperatingIncomeLoss" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($IncomeBeforeEquityMethodInvestments, "IncomeBeforeEquityMethodInvestments") || " + " || rules:fact-trail($NonoperatingIncomeLoss, "NonoperatingIncomeLoss") || " - " || rules:fact-trail($InterestAndDebtExpense, "InterestAndDebtExpense")
	 let $source-facts := ($OperatingIncomeLoss, $IncomeBeforeEquityMethodInvestments, $NonoperatingIncomeLoss, $InterestAndDebtExpense)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $IncomeBeforeEquityMethodInvestments,
            "fac:OperatingIncomeLoss",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $IncomeBeforeEquityMethodInvestments,
          "fac:OperatingIncomeLoss",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Revenues (fac:Revenues).

for $facts in facts:facts-for-internal((
      "fac:Revenues", "fac:CostOfRevenue", "fac:GrossProfit"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($Revenues) return $Revenues
  case (exists($GrossProfit) and not((not(exists($CostOfRevenue)))))
  return
    let $computed-value := rules:decimal-value($GrossProfit) + rules:decimal-value($CostOfRevenue)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:Revenues" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($GrossProfit, "GrossProfit") || " + " || rules:fact-trail($CostOfRevenue, "CostOfRevenue")
	 let $source-facts := ($Revenues, $CostOfRevenue, $GrossProfit)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $GrossProfit,
            "fac:Revenues",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $GrossProfit,
          "fac:Revenues",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Gross Profit (fac:GrossProfit).

for $facts in facts:facts-for-internal((
      "fac:GrossProfit", "fac:Revenues", "fac:CostOfRevenue"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"]
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($GrossProfit) return $GrossProfit
  case (exists($Revenues) and ())
  return
    let $computed-value := rules:decimal-value($Revenues) - rules:decimal-value($CostOfRevenue)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:GrossProfit" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Revenues, "Revenues") || " - " || rules:fact-trail($CostOfRevenue, "CostOfRevenue")
	 let $source-facts := ($GrossProfit, $Revenues, $CostOfRevenue)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Revenues,
            "fac:GrossProfit",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Revenues,
          "fac:GrossProfit",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Interest and Debt Expense (fac:InterestAndDebtExpense).

for $facts in facts:facts-for-internal((
      "fac:InterestAndDebtExpense", "fac:IncomeBeforeEquityMethodInvestments", "fac:OperatingIncomeLoss", "fac:NonoperatingIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $InterestAndDebtExpense as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:InterestAndDebtExpense"]
let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"]
let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"]
let $NonoperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NonoperatingIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($InterestAndDebtExpense) return $InterestAndDebtExpense
  case (exists($IncomeBeforeEquityMethodInvestments) and ())
  return
    let $computed-value := rules:decimal-value($IncomeBeforeEquityMethodInvestments) - rules:decimal-value($OperatingIncomeLoss) - rules:decimal-value($NonoperatingIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:InterestAndDebtExpense" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($IncomeBeforeEquityMethodInvestments, "IncomeBeforeEquityMethodInvestments") || " - " || rules:fact-trail($OperatingIncomeLoss, "OperatingIncomeLoss") || " - " || rules:fact-trail($NonoperatingIncomeLoss, "NonoperatingIncomeLoss")
	 let $source-facts := ($InterestAndDebtExpense, $IncomeBeforeEquityMethodInvestments, $OperatingIncomeLoss, $NonoperatingIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $IncomeBeforeEquityMethodInvestments,
            "fac:InterestAndDebtExpense",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $IncomeBeforeEquityMethodInvestments,
          "fac:InterestAndDebtExpense",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Nonoperating Income (Loss) + Interest and Debt Expense

Rule to compute Nonoperating Income (Loss) + Interest and Debt Expense (fac:NonoperatingIncomeLossPlusInterestAndDebtExpense).

for $facts in facts:facts-for-internal((
      "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense", "fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments", "fac:IncomeLossFromEquityMethodInvestments"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NonoperatingIncomeLossPlusInterestAndDebtExpense as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense"]
let $NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments"]
let $IncomeLossFromEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromEquityMethodInvestments"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NonoperatingIncomeLossPlusInterestAndDebtExpense) return $NonoperatingIncomeLossPlusInterestAndDebtExpense
  case (exists($NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments) and not((not(exists($NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments)))))
  return
    let $computed-value := rules:decimal-value($NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments) - rules:decimal-value($IncomeLossFromEquityMethodInvestments)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments, "NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments") || " - " || rules:fact-trail($IncomeLossFromEquityMethodInvestments, "IncomeLossFromEquityMethodInvestments")
	 let $source-facts := ($NonoperatingIncomeLossPlusInterestAndDebtExpense, $NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments, $IncomeLossFromEquityMethodInvestments)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments,
            "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments,
          "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments

Rule to compute Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments (fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments).

for $facts in facts:facts-for-internal((
      "fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments", "fac:IncomeLossFromContinuingOperationsBeforeTax", "fac:OperatingIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments"]
let $IncomeLossFromContinuingOperationsBeforeTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsBeforeTax"]
let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments) return $NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments
  case (exists($IncomeLossFromContinuingOperationsBeforeTax) and not((not(exists($IncomeLossFromContinuingOperationsBeforeTax)))))
  return
    let $computed-value := rules:decimal-value($IncomeLossFromContinuingOperationsBeforeTax) - rules:decimal-value($OperatingIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($IncomeLossFromContinuingOperationsBeforeTax, "IncomeLossFromContinuingOperationsBeforeTax") || " - " || rules:fact-trail($OperatingIncomeLoss, "OperatingIncomeLoss")
	 let $source-facts := ($NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments, $IncomeLossFromContinuingOperationsBeforeTax, $OperatingIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $IncomeLossFromContinuingOperationsBeforeTax,
            "fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $IncomeLossFromContinuingOperationsBeforeTax,
          "fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Income (Loss) from Continuing Operations Before Tax

Rule to compute Income (Loss) from Continuing Operations Before Tax (fac:IncomeLossFromContinuingOperationsBeforeTax).

for $facts in facts:facts-for-internal((
      "fac:IncomeLossFromContinuingOperationsBeforeTax", "fac:IncomeLossFromEquityMethodInvestments", "fac:IncomeBeforeEquityMethodInvestments"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $IncomeLossFromContinuingOperationsBeforeTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsBeforeTax"]
let $IncomeLossFromEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromEquityMethodInvestments"]
let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($IncomeLossFromContinuingOperationsBeforeTax) return $IncomeLossFromContinuingOperationsBeforeTax
  case (exists($IncomeLossFromEquityMethodInvestments) and ())
  return
    let $computed-value := rules:decimal-value($IncomeLossFromEquityMethodInvestments) + rules:decimal-value($IncomeBeforeEquityMethodInvestments)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:IncomeLossFromContinuingOperationsBeforeTax" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($IncomeLossFromEquityMethodInvestments, "IncomeLossFromEquityMethodInvestments") || " + " || rules:fact-trail($IncomeBeforeEquityMethodInvestments, "IncomeBeforeEquityMethodInvestments")
	 let $source-facts := ($IncomeLossFromContinuingOperationsBeforeTax, $IncomeLossFromEquityMethodInvestments, $IncomeBeforeEquityMethodInvestments)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $IncomeLossFromEquityMethodInvestments,
            "fac:IncomeLossFromContinuingOperationsBeforeTax",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $IncomeLossFromEquityMethodInvestments,
          "fac:IncomeLossFromContinuingOperationsBeforeTax",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Income (Loss) from Continuing Operations After Tax

Rule to compute Income (Loss) from Continuing Operations After Tax (fac:IncomeLossFromContinuingOperationsAfterTax).

for $facts in facts:facts-for-internal((
      "fac:IncomeLossFromContinuingOperationsAfterTax", "fac:NetIncomeLoss", "fac:IncomeLossFromDiscontinuedOperationsNetTax", "fac:ExtraordinaryItemsIncomeExpenseNetTax"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $IncomeLossFromContinuingOperationsAfterTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsAfterTax"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $IncomeLossFromDiscontinuedOperationsNetTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromDiscontinuedOperationsNetTax"]
let $ExtraordinaryItemsIncomeExpenseNetTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ExtraordinaryItemsIncomeExpenseNetTax"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($IncomeLossFromContinuingOperationsAfterTax) return $IncomeLossFromContinuingOperationsAfterTax
  case (exists($NetIncomeLoss) and not((not(exists($NetIncomeLoss)))))
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss) - rules:decimal-value($IncomeLossFromDiscontinuedOperationsNetTax) - rules:decimal-value($ExtraordinaryItemsIncomeExpenseNetTax)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:IncomeLossFromContinuingOperationsAfterTax" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " - " || rules:fact-trail($IncomeLossFromDiscontinuedOperationsNetTax, "IncomeLossFromDiscontinuedOperationsNetTax") || " - " || rules:fact-trail($ExtraordinaryItemsIncomeExpenseNetTax, "ExtraordinaryItemsIncomeExpenseNetTax")
	 let $source-facts := ($IncomeLossFromContinuingOperationsAfterTax, $NetIncomeLoss, $IncomeLossFromDiscontinuedOperationsNetTax, $ExtraordinaryItemsIncomeExpenseNetTax)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetIncomeLoss,
            "fac:IncomeLossFromContinuingOperationsAfterTax",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetIncomeLoss,
          "fac:IncomeLossFromContinuingOperationsAfterTax",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Net Income Attributable to Parent (fac:NetIncomeAttributableToParent).

for $facts in facts:facts-for-internal((
      "fac:NetIncomeAttributableToParent", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetIncomeAttributableToParent) return $NetIncomeAttributableToParent
  case (exists($NetIncomeLoss) and ())
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetIncomeAttributableToParent" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss")
	 let $source-facts := ($NetIncomeAttributableToParent, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetIncomeLoss,
            "fac:NetIncomeAttributableToParent",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetIncomeLoss,
          "fac:NetIncomeAttributableToParent",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Preferred Stock Dividends and Other Adjustments

Rule to compute Preferred Stock Dividends and Other Adjustments (fac:PreferredStockDividendsAndOtherAdjustments).

for $facts in facts:facts-for-internal((
      "fac:PreferredStockDividendsAndOtherAdjustments", "fac:NetIncomeAttributableToParent", "fac:NetIncomeLossAvailableToCommonStockholdersBasic"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $PreferredStockDividendsAndOtherAdjustments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:PreferredStockDividendsAndOtherAdjustments"]
let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"]
let $NetIncomeLossAvailableToCommonStockholdersBasic as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLossAvailableToCommonStockholdersBasic"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($PreferredStockDividendsAndOtherAdjustments) return $PreferredStockDividendsAndOtherAdjustments
  case (exists($NetIncomeAttributableToParent) and ())
  return
    let $computed-value := rules:decimal-value($NetIncomeAttributableToParent) - rules:decimal-value($NetIncomeLossAvailableToCommonStockholdersBasic)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:PreferredStockDividendsAndOtherAdjustments" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeAttributableToParent, "NetIncomeAttributableToParent") || " - " || rules:fact-trail($NetIncomeLossAvailableToCommonStockholdersBasic, "NetIncomeLossAvailableToCommonStockholdersBasic")
	 let $source-facts := ($PreferredStockDividendsAndOtherAdjustments, $NetIncomeAttributableToParent, $NetIncomeLossAvailableToCommonStockholdersBasic)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetIncomeAttributableToParent,
            "fac:PreferredStockDividendsAndOtherAdjustments",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetIncomeAttributableToParent,
          "fac:PreferredStockDividendsAndOtherAdjustments",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Income (Loss) Available to Common Stockholders, Basic

Rule to compute Net Income (Loss) Available to Common Stockholders, Basic (fac:NetIncomeLossAvailableToCommonStockholdersBasic).

for $facts in facts:facts-for-internal((
      "fac:NetIncomeLossAvailableToCommonStockholdersBasic", "fac:NetIncomeAttributableToParent"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetIncomeLossAvailableToCommonStockholdersBasic as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLossAvailableToCommonStockholdersBasic"]
let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetIncomeLossAvailableToCommonStockholdersBasic) return $NetIncomeLossAvailableToCommonStockholdersBasic
  case (exists($NetIncomeAttributableToParent) and not((not(exists($NetIncomeAttributableToParent)))))
  return
    let $computed-value := rules:decimal-value($NetIncomeAttributableToParent)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetIncomeLossAvailableToCommonStockholdersBasic" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeAttributableToParent, "NetIncomeAttributableToParent")
	 let $source-facts := ($NetIncomeLossAvailableToCommonStockholdersBasic, $NetIncomeAttributableToParent)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetIncomeAttributableToParent,
            "fac:NetIncomeLossAvailableToCommonStockholdersBasic",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetIncomeAttributableToParent,
          "fac:NetIncomeLossAvailableToCommonStockholdersBasic",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Income (Loss) Before Equity Method Investments

Rule to compute Income (Loss) Before Equity Method Investments (fac:IncomeBeforeEquityMethodInvestments).

for $facts in facts:facts-for-internal((
      "fac:IncomeBeforeEquityMethodInvestments", "fac:IncomeLossFromContinuingOperationsBeforeTax", "fac:IncomeLossFromEquityMethodInvestments"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"]
let $IncomeLossFromContinuingOperationsBeforeTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsBeforeTax"]
let $IncomeLossFromEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromEquityMethodInvestments"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($IncomeBeforeEquityMethodInvestments) return $IncomeBeforeEquityMethodInvestments
  case (exists($IncomeLossFromContinuingOperationsBeforeTax) and not((not(exists($IncomeLossFromContinuingOperationsBeforeTax)))))
  return
    let $computed-value := rules:decimal-value($IncomeLossFromContinuingOperationsBeforeTax) - rules:decimal-value($IncomeLossFromEquityMethodInvestments)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:IncomeBeforeEquityMethodInvestments" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($IncomeLossFromContinuingOperationsBeforeTax, "IncomeLossFromContinuingOperationsBeforeTax") || " - " || rules:fact-trail($IncomeLossFromEquityMethodInvestments, "IncomeLossFromEquityMethodInvestments")
	 let $source-facts := ($IncomeBeforeEquityMethodInvestments, $IncomeLossFromContinuingOperationsBeforeTax, $IncomeLossFromEquityMethodInvestments)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $IncomeLossFromContinuingOperationsBeforeTax,
            "fac:IncomeBeforeEquityMethodInvestments",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $IncomeLossFromContinuingOperationsBeforeTax,
          "fac:IncomeBeforeEquityMethodInvestments",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Other Comprehensive Income (Loss) (fac:OtherComprehensiveIncomeLoss).

for $facts in facts:facts-for-internal((
      "fac:OtherComprehensiveIncomeLoss", "fac:ComprehensiveIncomeLoss", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $OtherComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherComprehensiveIncomeLoss"]
let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($OtherComprehensiveIncomeLoss) return $OtherComprehensiveIncomeLoss
  case (exists($ComprehensiveIncomeLoss) and not((not(exists($ComprehensiveIncomeLoss)))))
  return
    let $computed-value := rules:decimal-value($ComprehensiveIncomeLoss) - rules:decimal-value($NetIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:OtherComprehensiveIncomeLoss" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($ComprehensiveIncomeLoss, "ComprehensiveIncomeLoss") || " - " || rules:fact-trail($NetIncomeLoss, "NetIncomeLoss")
	 let $source-facts := ($OtherComprehensiveIncomeLoss, $ComprehensiveIncomeLoss, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $ComprehensiveIncomeLoss,
            "fac:OtherComprehensiveIncomeLoss",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $ComprehensiveIncomeLoss,
          "fac:OtherComprehensiveIncomeLoss",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Comprehensive Income (Loss) (fac:ComprehensiveIncomeLoss).

for $facts in facts:facts-for-internal((
      "fac:ComprehensiveIncomeLoss", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ComprehensiveIncomeLoss) return $ComprehensiveIncomeLoss
  case (exists($NetIncomeLoss) and ())
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ComprehensiveIncomeLoss" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss")
	 let $source-facts := ($ComprehensiveIncomeLoss, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetIncomeLoss,
            "fac:ComprehensiveIncomeLoss",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetIncomeLoss,
          "fac:ComprehensiveIncomeLoss",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(NetIncomeLoss)),
           not(isblank(ComprehensiveIncomeLossAttributableToParent)),
           (NetIncomeLoss-ComprehensiveIncomeLossAttributableToParent=0),
           (ComprehensiveIncomeLossAttributableToNoncontrollingInterest=0),
           (OtherComprehensiveIncomeLoss=0))

Comprehensive Income (Loss) Attributable to Parent

Rule to compute Comprehensive Income (Loss) Attributable to Parent (fac:ComprehensiveIncomeLossAttributableToParent).

for $facts in facts:facts-for-internal((
      "fac:ComprehensiveIncomeLossAttributableToParent", "fac:ComprehensiveIncomeLoss", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ComprehensiveIncomeLossAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLossAttributableToParent"]
let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ComprehensiveIncomeLossAttributableToParent) return $ComprehensiveIncomeLossAttributableToParent
  case (exists($ComprehensiveIncomeLoss) and ())
  return
    let $computed-value := rules:decimal-value($ComprehensiveIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ComprehensiveIncomeLossAttributableToParent" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($ComprehensiveIncomeLoss, "ComprehensiveIncomeLoss")
	 let $source-facts := ($ComprehensiveIncomeLossAttributableToParent, $ComprehensiveIncomeLoss, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $ComprehensiveIncomeLoss,
            "fac:ComprehensiveIncomeLossAttributableToParent",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $ComprehensiveIncomeLoss,
          "fac:ComprehensiveIncomeLossAttributableToParent",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  case (exists($ComprehensiveIncomeLoss) and ())
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ComprehensiveIncomeLossAttributableToParent" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss")
	 let $source-facts := ($ComprehensiveIncomeLossAttributableToParent, $ComprehensiveIncomeLoss, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $ComprehensiveIncomeLoss,
            "fac:ComprehensiveIncomeLossAttributableToParent",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $ComprehensiveIncomeLoss,
          "fac:ComprehensiveIncomeLossAttributableToParent",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(isblank(ComprehensiveIncomeLoss), isblank(ComprehensiveIncomeLossAttributableToNoncontrollingInterest),
     isblank(IncomeBeforeEquityMethodInvestments),not(isblank(NetIncomeLoss)) )

Net Cash Flows from Operating Activities, Continuing

Rule to compute Net Cash Flows from Operating Activities, Continuing (fac:NetCashFlowsFromOperatingActivitiesContinuing).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromOperatingActivitiesContinuing", "fac:NetCashFlowsFromOperatingActivities", "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromOperatingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesContinuing"]
let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"]
let $NetCashFlowsFromOperatingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromOperatingActivitiesContinuing) return $NetCashFlowsFromOperatingActivitiesContinuing
  case (exists($NetCashFlowsFromOperatingActivities) and not((not(exists($NetCashFlowsFromOperatingActivities)))))
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromOperatingActivities) - rules:decimal-value($NetCashFlowsFromOperatingActivitiesDiscontinued)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromOperatingActivitiesContinuing" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromOperatingActivities, "NetCashFlowsFromOperatingActivities") || " - " || rules:fact-trail($NetCashFlowsFromOperatingActivitiesDiscontinued, "NetCashFlowsFromOperatingActivitiesDiscontinued")
	 let $source-facts := ($NetCashFlowsFromOperatingActivitiesContinuing, $NetCashFlowsFromOperatingActivities, $NetCashFlowsFromOperatingActivitiesDiscontinued)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromOperatingActivities,
            "fac:NetCashFlowsFromOperatingActivitiesContinuing",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromOperatingActivities,
          "fac:NetCashFlowsFromOperatingActivitiesContinuing",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Cash Flows from Operating Activities, Discontinued

Rule to compute Net Cash Flows from Operating Activities, Discontinued (fac:NetCashFlowsFromOperatingActivitiesDiscontinued).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromOperatingActivitiesDiscontinued", "fac:NetCashFlowsFromOperatingActivities"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromOperatingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"]
let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromOperatingActivitiesDiscontinued) return $NetCashFlowsFromOperatingActivitiesDiscontinued
  case (exists($NetCashFlowsFromOperatingActivities) and ())
  return
    let $computed-value := 0
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromOperatingActivitiesDiscontinued" }, Value: $computed-value }) || " = " ||
	        "0"
	 let $source-facts := ($NetCashFlowsFromOperatingActivitiesDiscontinued, $NetCashFlowsFromOperatingActivities)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromOperatingActivities,
            "fac:NetCashFlowsFromOperatingActivitiesDiscontinued",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromOperatingActivities,
          "fac:NetCashFlowsFromOperatingActivitiesDiscontinued",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(isblank(NetCashFlowsFromOperatingActivities), isblank(NetCashFlowsFromOperatingActivitiesContinuing),
     NetCashFlowsFromOperatingActivitiesContinuing=NetCashFlowsFromOperatingActivities)

Net Cash Flows from Investing Activities, Continuing

Rule to compute Net Cash Flows from Investing Activities, Continuing (fac:NetCashFlowsFromInvestingActivitiesContinuing).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromInvestingActivitiesContinuing", "fac:NetCashFlowsFromInvestingActivities", "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromInvestingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesContinuing"]
let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"]
let $NetCashFlowsFromInvestingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromInvestingActivitiesContinuing) return $NetCashFlowsFromInvestingActivitiesContinuing
  case (exists($NetCashFlowsFromInvestingActivities) and not((not(exists($NetCashFlowsFromInvestingActivities)))))
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromInvestingActivities) - rules:decimal-value($NetCashFlowsFromInvestingActivitiesDiscontinued)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromInvestingActivitiesContinuing" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromInvestingActivities, "NetCashFlowsFromInvestingActivities") || " - " || rules:fact-trail($NetCashFlowsFromInvestingActivitiesDiscontinued, "NetCashFlowsFromInvestingActivitiesDiscontinued")
	 let $source-facts := ($NetCashFlowsFromInvestingActivitiesContinuing, $NetCashFlowsFromInvestingActivities, $NetCashFlowsFromInvestingActivitiesDiscontinued)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromInvestingActivities,
            "fac:NetCashFlowsFromInvestingActivitiesContinuing",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromInvestingActivities,
          "fac:NetCashFlowsFromInvestingActivitiesContinuing",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Cash Flows from Investing Activities, Discontinued

If NetCashFlowsInvesting = NetCashFlowsInvestingContinuing then NetCashFlowsInvestingDiscontinued must be 0

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromInvestingActivitiesDiscontinued", "fac:NetCashFlowsFromInvestingActivities"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromInvestingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"]
let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromInvestingActivitiesDiscontinued) return $NetCashFlowsFromInvestingActivitiesDiscontinued
  case (exists($NetCashFlowsFromInvestingActivities) and ())
  return
    let $computed-value := 0
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromInvestingActivitiesDiscontinued" }, Value: $computed-value }) || " = " ||
	        "0"
	 let $source-facts := ($NetCashFlowsFromInvestingActivitiesDiscontinued, $NetCashFlowsFromInvestingActivities)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromInvestingActivities,
            "fac:NetCashFlowsFromInvestingActivitiesDiscontinued",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromInvestingActivities,
          "fac:NetCashFlowsFromInvestingActivitiesDiscontinued",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(NetCashFlowsFromInvestingActivities)),
           not(isblank(NetCashFlowsFromInvestingActivitiesContinuing)),
           (NetCashFlowsFromInvestingActivitiesContinuing= NetCashFlowsFromInvestingActivities))

Net Cash Flows from Investing Activities

Rule to compute Net Cash Flows from Investing Activities (fac:NetCashFlowsFromInvestingActivities).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromInvestingActivities", "fac:NetCashFlowsFromInvestingActivitiesContinuing"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"]
let $NetCashFlowsFromInvestingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesContinuing"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromInvestingActivities) return $NetCashFlowsFromInvestingActivities
  case (exists($NetCashFlowsFromInvestingActivitiesContinuing) and ())
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromInvestingActivitiesContinuing)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromInvestingActivities" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromInvestingActivitiesContinuing, "NetCashFlowsFromInvestingActivitiesContinuing")
	 let $source-facts := ($NetCashFlowsFromInvestingActivities, $NetCashFlowsFromInvestingActivitiesContinuing)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromInvestingActivitiesContinuing,
            "fac:NetCashFlowsFromInvestingActivities",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromInvestingActivitiesContinuing,
          "fac:NetCashFlowsFromInvestingActivities",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(NetCashFlowsFromInvestingActivitiesContinuing)),
          NetCashFlowsFromInvestingActivitiesDiscontinued=0)

Net Cash Flows from Financing Activities, Continuing

Rule to compute Net Cash Flows from Financing Activities, Continuing (fac:NetCashFlowsFromFinancingActivitiesContinuing).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromFinancingActivitiesContinuing", "fac:NetCashFlowsFromFinancingActivities", "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromFinancingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesContinuing"]
let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"]
let $NetCashFlowsFromFinancingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromFinancingActivitiesContinuing) return $NetCashFlowsFromFinancingActivitiesContinuing
  case (exists($NetCashFlowsFromFinancingActivities) and not((not(exists($NetCashFlowsFromFinancingActivities)))))
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromFinancingActivities) - rules:decimal-value($NetCashFlowsFromFinancingActivitiesDiscontinued)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromFinancingActivitiesContinuing" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromFinancingActivities, "NetCashFlowsFromFinancingActivities") || " - " || rules:fact-trail($NetCashFlowsFromFinancingActivitiesDiscontinued, "NetCashFlowsFromFinancingActivitiesDiscontinued")
	 let $source-facts := ($NetCashFlowsFromFinancingActivitiesContinuing, $NetCashFlowsFromFinancingActivities, $NetCashFlowsFromFinancingActivitiesDiscontinued)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromFinancingActivities,
            "fac:NetCashFlowsFromFinancingActivitiesContinuing",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromFinancingActivities,
          "fac:NetCashFlowsFromFinancingActivitiesContinuing",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Cash Flows from Financing Activities, Discontinued

RIf NetCashFlowsFinancing = NetCashFlowsFinancingContinuing then NetCashFlowsFinancingDiscontinued must be 0

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromFinancingActivitiesDiscontinued", "fac:NetCashFlowsFromFinancingActivities"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromFinancingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"]
let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromFinancingActivitiesDiscontinued) return $NetCashFlowsFromFinancingActivitiesDiscontinued
  case (exists($NetCashFlowsFromFinancingActivities) and ())
  return
    let $computed-value := 0
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromFinancingActivitiesDiscontinued" }, Value: $computed-value }) || " = " ||
	        "0"
	 let $source-facts := ($NetCashFlowsFromFinancingActivitiesDiscontinued, $NetCashFlowsFromFinancingActivities)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromFinancingActivities,
            "fac:NetCashFlowsFromFinancingActivitiesDiscontinued",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromFinancingActivities,
          "fac:NetCashFlowsFromFinancingActivitiesDiscontinued",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Cash Flows from Operating Activities

Rule to compute Net Cash Flows from Operating Activities (fac:NetCashFlowsFromOperatingActivities).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromOperatingActivities", "fac:NetCashFlowsFromOperatingActivitiesContinuing"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"]
let $NetCashFlowsFromOperatingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesContinuing"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromOperatingActivities) return $NetCashFlowsFromOperatingActivities
  case (exists($NetCashFlowsFromOperatingActivitiesContinuing) and ())
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromOperatingActivitiesContinuing)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromOperatingActivities" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromOperatingActivitiesContinuing, "NetCashFlowsFromOperatingActivitiesContinuing")
	 let $source-facts := ($NetCashFlowsFromOperatingActivities, $NetCashFlowsFromOperatingActivitiesContinuing)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromOperatingActivitiesContinuing,
            "fac:NetCashFlowsFromOperatingActivities",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromOperatingActivitiesContinuing,
          "fac:NetCashFlowsFromOperatingActivities",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Net Cash Flows, Continuing (fac:NetCashFlowsContinuing).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsContinuing", "fac:NetCashFlowsFromOperatingActivitiesContinuing", "fac:NetCashFlowsFromInvestingActivitiesContinuing", "fac:NetCashFlowsFromFinancingActivitiesContinuing"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsContinuing"]
let $NetCashFlowsFromOperatingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesContinuing"]
let $NetCashFlowsFromInvestingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesContinuing"]
let $NetCashFlowsFromFinancingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesContinuing"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsContinuing) return $NetCashFlowsContinuing
  case (exists($NetCashFlowsFromOperatingActivitiesContinuing) and ())
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromOperatingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromInvestingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromFinancingActivitiesContinuing)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsContinuing" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromOperatingActivitiesContinuing, "NetCashFlowsFromOperatingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivitiesContinuing, "NetCashFlowsFromInvestingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivitiesContinuing, "NetCashFlowsFromFinancingActivitiesContinuing")
	 let $source-facts := ($NetCashFlowsContinuing, $NetCashFlowsFromOperatingActivitiesContinuing, $NetCashFlowsFromInvestingActivitiesContinuing, $NetCashFlowsFromFinancingActivitiesContinuing)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromOperatingActivitiesContinuing,
            "fac:NetCashFlowsContinuing",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromOperatingActivitiesContinuing,
          "fac:NetCashFlowsContinuing",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(NetCashFlowsFromOperatingActivitiesContinuing)), not(isblank(NetCashFlowsFromInvestingActivitiesContinuing)),
     not(isblank(NetCashFlowsFromFinancingActivitiesContinuing)) )

Rule to compute Net Cash Flows, Discontinued (fac:NetCashFlowsDiscontinued).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsDiscontinued", "fac:NetCashFlowsFromOperatingActivitiesDiscontinued", "fac:NetCashFlowsFromInvestingActivitiesDiscontinued", "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsDiscontinued"]
let $NetCashFlowsFromOperatingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"]
let $NetCashFlowsFromInvestingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"]
let $NetCashFlowsFromFinancingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsDiscontinued) return $NetCashFlowsDiscontinued
  case (exists($NetCashFlowsFromOperatingActivitiesDiscontinued) and ())
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromOperatingActivitiesDiscontinued) + rules:decimal-value($NetCashFlowsFromInvestingActivitiesDiscontinued) + rules:decimal-value($NetCashFlowsFromFinancingActivitiesDiscontinued)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsDiscontinued" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromOperatingActivitiesDiscontinued, "NetCashFlowsFromOperatingActivitiesDiscontinued") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivitiesDiscontinued, "NetCashFlowsFromInvestingActivitiesDiscontinued") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivitiesDiscontinued, "NetCashFlowsFromFinancingActivitiesDiscontinued")
	 let $source-facts := ($NetCashFlowsDiscontinued, $NetCashFlowsFromOperatingActivitiesDiscontinued, $NetCashFlowsFromInvestingActivitiesDiscontinued, $NetCashFlowsFromFinancingActivitiesDiscontinued)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromOperatingActivitiesDiscontinued,
            "fac:NetCashFlowsDiscontinued",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromOperatingActivitiesDiscontinued,
          "fac:NetCashFlowsDiscontinued",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(NetCashFlowsFromOperatingActivitiesDiscontinued)), not(isblank(NetCashFlowsFromInvestingActivitiesDiscontinued)),
     not(isblank(NetCashFlowsFromFinancingActivitiesDiscontinued)) )

Rule to compute Net Cash Flows (fac:NetCashFlows).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlows", "fac:NetCashFlowsFromOperatingActivities", "fac:NetCashFlowsFromInvestingActivities", "fac:NetCashFlowsFromFinancingActivities", "fac:ExchangeGainsLosses"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlows as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlows"]
let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"]
let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"]
let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"]
let $ExchangeGainsLosses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ExchangeGainsLosses"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlows) return $NetCashFlows
  case (exists($NetCashFlowsFromOperatingActivities) and ())
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromOperatingActivities) + rules:decimal-value($NetCashFlowsFromInvestingActivities) + rules:decimal-value($NetCashFlowsFromFinancingActivities) + rules:decimal-value($ExchangeGainsLosses)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlows" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromOperatingActivities, "NetCashFlowsFromOperatingActivities") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivities, "NetCashFlowsFromInvestingActivities") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivities, "NetCashFlowsFromFinancingActivities") || " + " || rules:fact-trail($ExchangeGainsLosses, "ExchangeGainsLosses")
	 let $source-facts := ($NetCashFlows, $NetCashFlowsFromOperatingActivities, $NetCashFlowsFromInvestingActivities, $NetCashFlowsFromFinancingActivities, $ExchangeGainsLosses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromOperatingActivities,
            "fac:NetCashFlows",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromOperatingActivities,
          "fac:NetCashFlows",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(not(isblank(NetCashFlowsFromOperatingActivities)), not(isblank(NetCashFlowsFromInvestingActivities)),
     not(isblank(NetCashFlowsFromFinancingActivities)), not(isblank(ExchangeGainsLosses)))

Rule to compute Sustainable Growth Rate (SGR) (fac:SustainableGrowthRate).

fac:NetIncomeLoss fac:Revenues fac:Assets fac:Equity

for $facts in facts:facts-for-internal((
      "fac:SustainableGrowthRate", "fac:NetIncomeLoss", "fac:Revenues", "fac:Assets", "fac:Equity"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $SustainableGrowthRate as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:SustainableGrowthRate"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($SustainableGrowthRate) return $SustainableGrowthRate
  case (exists($Assets) and ())
  return
    let $computed-value := ((rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Revenues)) * (1 + (rules:decimal-value($Assets) - rules:decimal-value($Equity)) div rules:decimal-value($Equity))) div ((1 div (rules:decimal-value($Revenues) div rules:decimal-value($Assets))) - ((rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Revenues)) * (1 + (rules:decimal-value($Assets) - rules:decimal-value($Equity)) div rules:decimal-value($Equity))))
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:SustainableGrowthRate" }, Value: $computed-value }) || " = " ||
	        " ( " || " ( " || rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Revenues, "Revenues") || " )" || " * " || " ( " || "1" || " + " || " ( " || rules:fact-trail($Assets, "Assets") || " - " || rules:fact-trail($Equity, "Equity") || " )" || " div " || rules:fact-trail($Equity, "Equity") || " )" || " )" || " div " || " ( " || " ( " || "1" || " div " || " ( " || rules:fact-trail($Revenues, "Revenues") || " div " || rules:fact-trail($Assets, "Assets") || " )" || " )" || " - " || " ( " || " ( " || rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Revenues, "Revenues") || " )" || " * " || " ( " || "1" || " + " || " ( " || rules:fact-trail($Assets, "Assets") || " - " || rules:fact-trail($Equity, "Equity") || " )" || " div " || rules:fact-trail($Equity, "Equity") || " )" || " )" || " )"
	 let $source-facts := ($SustainableGrowthRate, $NetIncomeLoss, $Revenues, $Assets, $Equity)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Assets,
            "fac:SustainableGrowthRate",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Assets,
          "fac:SustainableGrowthRate",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

and(Equity <> 0, Assets <>0, Revenues <>0, NetIncomeLoss <> 0)

(( NetIncomeLoss / Revenues ) * (1 + ( Assets - Equity ) / Equity ))
  /
  (( 1 / ( Revenues / Assets )) - (( NetIncomeLoss / Revenues ) * (1 + ( Assets - Equity ) / Equity )))

Net Cash Flows from Financing Activities

Rule to compute Net Cash Flows from Financing Activities (fac:NetCashFlowsFromFinancingActivities).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromFinancingActivities", "fac:NetCashFlowsFromFinancingActivitiesContinuing"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"]
let $NetCashFlowsFromFinancingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesContinuing"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromFinancingActivities) return $NetCashFlowsFromFinancingActivities
  case (exists($NetCashFlowsFromFinancingActivitiesContinuing) and ())
  return
    let $computed-value := rules:decimal-value($NetCashFlowsFromFinancingActivitiesContinuing)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromFinancingActivities" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetCashFlowsFromFinancingActivitiesContinuing, "NetCashFlowsFromFinancingActivitiesContinuing")
	 let $source-facts := ($NetCashFlowsFromFinancingActivities, $NetCashFlowsFromFinancingActivitiesContinuing)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromFinancingActivitiesContinuing,
            "fac:NetCashFlowsFromFinancingActivities",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromFinancingActivitiesContinuing,
          "fac:NetCashFlowsFromFinancingActivities",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Contains bla bla

Fundamental Accounting Concepts [Line Items]

Fundamental Accounting Concepts [Hierarchy]

Equity Attributable to Noncontrolling Interest

Nonoperating Income (Loss) + Interest and Debt Expense

Income (Loss) from Equity Method Investments

Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments

Income (Loss) from Continuing Operations Before Tax

Income (Loss) from Continuing Operations After Tax

Income (Loss) from Discontinued Operations, Net of Tax

Extraordinary Items of Income (Expense), Net of Tax

Net Income Attributable to Noncontrolling Interest

Preferred Stock Dividends and Other Adjustments

Net Income (Loss) Available to Common Stockholders, Basic

Statement of Comprehensive Income [Hierarchy]

Comprehensive Income (Loss) Attributable to Parent

Comprehensive Income (Loss) Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities, Continuing

Net Cash Flows from Operating Activities, Discontinued

Net Cash Flows from Operating Activities

Net Cash Flows from Investing Activities, Continuing

Net Cash Flows from Investing Activities, Discontinued

Net Cash Flows from Investing Activities

Net Cash Flows from Financing Activities, Continuing

Net Cash Flows from Financing Activities, Discontinued

Net Cash Flows from Financing Activities

Skipped Validations (unmet preconditions)

Fact Validation Rule Results [Hierarchy]

Equity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

Assets = CurrentAssets + NoncurrentAssets

Liabilities = CurrentLiabilities + NoncurrentLiabilities

LiabilitiesAndEquity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

OperatingIncomeLoss = GrossProfit - OperatingExpenses + OtherOperatingIncomeExpenses

IncomeBeforeEquityMethodInvestments = OperatingIncomeLoss + NonoperatingIncomeLossPlusInterestAndDebtExpense

IncomeLossFromContinuingOperationsBeforeTax = IncomeBeforeEquityMethodInvestments + IncomeLossFromEquityMethodInvestments

IncomeLossFromContinuingOperationsAfterTax = IncomeLossFromContinuingOperationsBeforeTax - IncomeTaxExpenseBenefit

NetIncomeLoss = IncomeLossFromContinuingOperationsAfterTax + IncomeLossFromDiscontinuedOperationsNetTax + ExtraordinaryItemsIncomeExpenseNetTax

NetIncomeLoss = NetIncomeAttributableToParent + NetIncomeAttributableToNoncontrollingInterest

NetIncomeLossAvailableToCommonStockholdersBasic = NetIncomeAttributableToParent - PreferredStockDividendsAndOtherAdjustments

ComprehensiveIncomeLoss = ComprehensiveIncomeLossAttributableToParent + ComprehensiveIncomeLossAttributableToNoncontrollingInterest

ComprehensiveIncome = NetIncomeLoss + OtherComprehensiveIncome

OperatingIncomeLoss = Revenues - CostsAndExpenses + OtherOperatingIncomeExpenses

NetCashFlows = NetCashFlowsFromOperatingActivities + NetCashFlowsFromInvestingActivities + NetCashFlowsFromFinancingActivities [+ ExchangeGainsLosses]

NetCashFlowsContinuing = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesContinuing

NetCashFlowsDiscontinued = NetCashFlowsFromOperatingActivitiesDiscontinued + NetCashFlowsFromInvestingActivitiesDiscontinued + NetCashFlowsFromFinancingActivitiesDiscontinued

NetCashFlowsFromOperatingActivities = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromOperatingActivitiesDiscontinued

NetCashFlowsFromInvestingActivities = NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesDiscontinued

NetCashFlowsFromFinancingActivities = NetCashFlowsFromFinancingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesDiscontinued

Preferred Stock Dividends and Other Adjustments

Net Cash Flows from Investing Activities

Income (Loss) Before Equity Method Investments

Net Income (Loss) Available to Common Stockholders, Basic

Income (Loss) from Continuing Operations Before Tax

Comprehensive Income (Loss) Attributable to Parent

Net Cash Flows from Financing Activities, Continuing

Income (Loss) from Continuing Operations After Tax

Net Cash Flows from Investing Activities, Discontinued

Net Cash Flows from Financing Activities, Discontinued

Net Income Attributable to Noncontrolling Interest

Equity Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities

Income (Loss) from Discontinued Operations, Net of Tax

Extraordinary Items of Income (Expense), Net of Tax

Net Cash Flows from Operating Activities, Discontinued

Net Cash Flows from Investing Activities, Continuing

Income (Loss) from Equity Method Investments

Comprehensive Income (Loss) Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities, Continuing

Net Cash Flows from Financing Activities

Skipped Validations (unmet preconditions)

IncomeBeforeEquityMethodInvestments = OperatingIncomeLoss + NonoperatingIncomeLossPlusInterestAndDebtExpense

IncomeLossFromContinuingOperationsBeforeTax = IncomeBeforeEquityMethodInvestments + IncomeLossFromEquityMethodInvestments

IncomeLossFromContinuingOperationsAfterTax = IncomeLossFromContinuingOperationsBeforeTax - IncomeTaxExpenseBenefit

NetIncomeLoss = IncomeLossFromContinuingOperationsAfterTax + IncomeLossFromDiscontinuedOperationsNetTax + ExtraordinaryItemsIncomeExpenseNetTax

NetIncomeLoss = NetIncomeAttributableToParent + NetIncomeAttributableToNoncontrollingInterest

NetIncomeLossAvailableToCommonStockholdersBasic = NetIncomeAttributableToParent - PreferredStockDividendsAndOtherAdjustments

ComprehensiveIncomeLoss = ComprehensiveIncomeLossAttributableToParent + ComprehensiveIncomeLossAttributableToNoncontrollingInterest

ComprehensiveIncome = NetIncomeLoss + OtherComprehensiveIncome

OperatingIncomeLoss = GrossProfit - OperatingExpenses + OtherOperatingIncomeExpenses

OperatingIncomeLoss = Revenues - CostsAndExpenses + OtherOperatingIncomeExpenses

Fact Validation Rule Results [Hierarchy]

LiabilitiesAndEquity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

Liabilities = CurrentLiabilities + NoncurrentLiabilities

Assets = CurrentAssets + NoncurrentAssets

Equity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

NetCashFlows = NetCashFlowsFromOperatingActivities + NetCashFlowsFromInvestingActivities + NetCashFlowsFromFinancingActivities [+ ExchangeGainsLosses]

NetCashFlowsContinuing = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesContinuing

NetCashFlowsDiscontinued = NetCashFlowsFromOperatingActivitiesDiscontinued + NetCashFlowsFromInvestingActivitiesDiscontinued + NetCashFlowsFromFinancingActivitiesDiscontinued

NetCashFlowsFromOperatingActivities = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromOperatingActivitiesDiscontinued

NetCashFlowsFromInvestingActivities = NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesDiscontinued

NetCashFlowsFromFinancingActivities = NetCashFlowsFromFinancingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesDiscontinued

Fundamental Accounting Concepts [Line Items]

Fundamental Accounting Concepts [Hierarchy]

Equity Attributable to Noncontrolling Interest

Nonoperating Income (Loss) + Interest and Debt Expense

Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments

Income (Loss) Before Equity Method Investments

Income (Loss) from Equity Method Investments

Income (Loss) from Continuing Operations Before Tax

Income (Loss) from Continuing Operations After Tax

Income (Loss) from Discontinued Operations, Net of Tax

Extraordinary Items of Income (Expense), Net of Tax

Net Income Attributable to Noncontrolling Interest

Preferred Stock Dividends and Other Adjustments

Net Income (Loss) Available to Common Stockholders, Basic

Statement of Comprehensive Income [Hierarchy]

Comprehensive Income (Loss) Attributable to Parent

Comprehensive Income (Loss) Attributable to Noncontrolling Interest

Net Cash Flows from Operating Activities, Continuing

Net Cash Flows from Operating Activities, Discontinued

Net Cash Flows from Operating Activities

Net Cash Flows from Investing Activities, Continuing

Net Cash Flows from Investing Activities, Discontinued

Net Cash Flows from Investing Activities

Net Cash Flows from Financing Activities, Continuing

Net Cash Flows from Financing Activities, Discontinued

Net Cash Flows from Financing Activities

Redeemable Noncontrolling Interest Equity Common Carrying Amount

Income Statement Start Period imputation

for $facts in facts:facts-for-internal(( "fac:CostOfRevenue", "fac:GrossProfit", "fac:Revenues", "fac:CostsAndExpenses", "fac:OperatingIncomeLoss", "fac:OtherOperatingIncomeExpenses", "fac:OperatingExpenses"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"] let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"] let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"] let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"] return switch(true) case (exists($facts)) return let $source-fact := $facts[1] let $computed-value := facts:duration-for-fact($source-fact).Start let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Concept" : "fac:IncomeStatementStartPeriod" }, Value: $computed-value, Type: "NonNumericValue" }) || " = " || "facts:duration-for-fact(" || rules:fact-trail($source-fact) || ").Start" return copy $newfact := rules:create-computed-fact( $source-fact, "fac:IncomeStatementStartPeriod", $computed-value, $rule, $audit-trail-message, $source-fact, $options) modify ( replace value of json $newfact("Type") with "NonNumericValue" ) return $newfact default return ()

import module namespace entities = "http://xbrl.io/modules/bizql/entities"; for $facts in facts:facts-for-internal(( "fac:TradingSymbol", "fac:Assets"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $TradingSymbol as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:TradingSymbol"] let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch (true) case (exists($TradingSymbol)) return $TradingSymbol case (exists($Assets)) return let $computed-value := entities:entities($Assets.Aspects."xbrl:Entity").Profiles.SEC.Tickers[[1]] let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:TradingSymbol" }, Value: $computed-value }) || " = external source" return copy $newfact := rules:create-computed-fact( $Assets, "fac:TradingSymbol", if (exists($computed-value)) then $computed-value else "N/A", $rule, $audit-trail-message, $Assets, $options) modify ( replace value of json $newfact("Type") with "NonNumericValue" ) return $newfact default return {}

for $facts in facts:facts-for-internal(( "fac:Equity", "fac:EquityAttributableToNoncontrollingInterest", "fac:EquityAttributableToParent"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] let $EquityAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToNoncontrollingInterest"] let $EquityAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToParent"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($Equity)) return $Equity case (exists($EquityAttributableToNoncontrollingInterest) or exists($EquityAttributableToParent)) return let $computed-value := rules:decimal-value($EquityAttributableToNoncontrollingInterest) + rules:decimal-value($EquityAttributableToParent) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:Equity" }, Value: $computed-value }) || " = " || rules:fact-trail($EquityAttributableToNoncontrollingInterest, "EquityAttributableToNoncontrollingInterest") || " + " || rules:fact-trail($EquityAttributableToParent, "EquityAttributableToParent") let $source-facts := ($EquityAttributableToNoncontrollingInterest, $EquityAttributableToParent) return rules:create-computed-fact( $source-facts[1], "fac:Equity", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:EquityAttributableToParent", "fac:Equity", "fac:EquityAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $EquityAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToParent"] let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] let $EquityAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToNoncontrollingInterest"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($EquityAttributableToParent)) return $EquityAttributableToParent case (exists($Equity)) return let $computed-value := rules:decimal-value($Equity) - rules:decimal-value($EquityAttributableToNoncontrollingInterest) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:EquityAttributableToParent" }, Value: $computed-value }) || " = " || rules:fact-trail($Equity, "Equity") || " - " || rules:fact-trail($EquityAttributableToNoncontrollingInterest, "EquityAttributableToNoncontrollingInterest") let $source-facts := ($Equity, $EquityAttributableToNoncontrollingInterest) return rules:create-computed-fact( $Equity, "fac:EquityAttributableToParent", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return()

for $facts in facts:facts-for-internal(( "fac:LiabilitiesAndEquity", "fac:Assets"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"] let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($LiabilitiesAndEquity)) return $LiabilitiesAndEquity case(exists($Assets)) return let $computed-value := rules:decimal-value($Assets) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:LiabilitiesAndEquity" }, Value: $computed-value }) || " = " || rules:fact-trail($Assets, "Assets") let $source-facts := $Assets return rules:create-computed-fact( $Assets, "fac:LiabilitiesAndEquity", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:NoncurrentLiabilities", "fac:Liabilities", "fac:CurrentLiabilities"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NoncurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentLiabilities"] let $Liabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Liabilities"] let $CurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentLiabilities"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (exists($NoncurrentLiabilities)) return $NoncurrentLiabilities case(exists($CurrentLiabilities) and exists($Liabilities)) return let $computed-value := rules:decimal-value($Liabilities) - rules:decimal-value($CurrentLiabilities) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:NoncurrentLiabilities" }, Value: $computed-value }) || " = " || rules:fact-trail($Liabilities) || " - " || rules:fact-trail($CurrentLiabilities) let $source-facts := ($Liabilities, $CurrentLiabilities) return rules:create-computed-fact( $CurrentLiabilities, "fac:NoncurrentLiabilities", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:TemporaryEquity", "us-gaap:RedeemableNoncontrollingInterestEquityCommonCarryingAmount"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $TemporaryEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:TemporaryEquity"] let $RedeemableNoncontrollingInterestEquityCommonCarryingAmount as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "us-gaap:RedeemableNoncontrollingInterestEquityCommonCarryingAmount"] let $unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1] return switch(true) case (not(exists($RedeemableNoncontrollingInterestEquityCommonCarryingAmount))) return $TemporaryEquity case (exists($RedeemableNoncontrollingInterestEquityCommonCarryingAmount)) return let $computed-value := rules:decimal-value($TemporaryEquity) + rules:decimal-value($RedeemableNoncontrollingInterestEquityCommonCarryingAmount) let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Unit" : $unit, "xbrl:Concept" : "fac:TemporaryEquity" }, Value: $computed-value }) || " = " || rules:fact-trail($TemporaryEquity, "TemporaryEquity") || " + " || rules:fact-trail($RedeemableNoncontrollingInterestEquityCommonCarryingAmount, "RedeemableNoncontrollingInterestEquityCommonCarryingAmount") let $source-facts := ($TemporaryEquity, $RedeemableNoncontrollingInterestEquityCommonCarryingAmount) return rules:create-computed-fact( $RedeemableNoncontrollingInterestEquityCommonCarryingAmount, "fac:TemporaryEquity", $computed-value, $rule, $audit-trail-message, $source-facts, $options) default return ()

for $facts in facts:facts-for-internal(( "fac:IncomeStatementFormat", "fac:GrossProfit", "fac:CostOfRevenue", "fac:Revenues"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := if(empty($facts)) then "" else facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeStatementFormat as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeStatementFormat"] let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] return switch(true) case exists($IncomeStatementFormat) return $IncomeStatementFormat case exists($Revenues) return let $computed-value := if (rules:decimal-value($GrossProfit) eq 0 and rules:decimal-value($CostOfRevenue) eq 0) then "Single-step" else "Multi-step" let $audit-trail-message := rules:fact-trail({ "Aspects" : { "xbrl:Concept" : "fac:IncomeStatementFormat" }, Value: $computed-value , Type: "NonNumericValue"}) || " = " || $computed-value || " (because " || rules:fact-trail($GrossProfit, "GrossProfit") || ", " || rules:fact-trail($CostOfRevenue, "CostOfRevenue") || ")" let $source-facts := ( $GrossProfit, $CostOfRevenue) return copy $newfact := rules:create-computed-fact( ($source-facts, $Revenues)[1], "fac:IncomeStatementFormat", $computed-value, $rule, $audit-trail-message, $source-facts, $options) modify ( replace value of json $newfact("Type") with "NonNumericValue" ) return $newfact default return ()

Equity = EquityAttributableToParent + EquityAttributableToNoncontrollingInterest

for $facts in facts:facts-for-internal(( "fac:Equity", "fac:EquityAttributableToParent", "fac:EquityAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] let $EquityAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToParent"] let $EquityAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:EquityAttributableToNoncontrollingInterest"] where exists($Equity) return let $test := rules:decimal-value($Equity) eq ( rules:decimal-value($EquityAttributableToParent) + rules:decimal-value($EquityAttributableToNoncontrollingInterest)) let $audit-trail-message := rules:fact-trail($Equity) || (if($test) then " = " else " != ") || "( " || rules:fact-trail($EquityAttributableToParent,"EquityAttributableToParent") || " + " || rules:fact-trail($EquityAttributableToNoncontrollingInterest,"EquityAttributableToNoncontrollingInterest") || ")" let $source-facts := ( $EquityAttributableToParent, $EquityAttributableToNoncontrollingInterest) return rules:create-computed-fact( $Equity, "fac:EquityValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $Equity, $test)

Liabilities = CurrentLiabilities + NoncurrentLiabilities

for $facts in facts:facts-for-internal(( "fac:Liabilities", "fac:CurrentAssets", "fac:NoncurrentAssets", "fac:CurrentLiabilities", "fac:NoncurrentLiabilities"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $Liabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Liabilities"] let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"] let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"] let $CurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentLiabilities"] let $NoncurrentLiabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentLiabilities"] where exists($Liabilities) and not(rules:decimal-value($CurrentAssets) eq 0 and rules:decimal-value($NoncurrentAssets) eq 0 and rules:decimal-value($CurrentLiabilities) eq 0 and rules:decimal-value($NoncurrentLiabilities) eq 0) return let $test := rules:decimal-value($Liabilities) eq (rules:decimal-value($CurrentLiabilities) + rules:decimal-value($NoncurrentLiabilities)) let $audit-trail-message := rules:fact-trail($Liabilities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($CurrentLiabilities,"CurrentLiabilities") || " + " || rules:fact-trail($NoncurrentLiabilities,"NoncurrentLiabilities") || ")" let $source-facts := ( $CurrentAssets, $NoncurrentAssets, $CurrentLiabilities, $NoncurrentLiabilities) return rules:create-computed-fact( $Liabilities, "fac:LiabilitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $Liabilities, $test)

LiabilitiesAndEquity = Liabilities + CommitmentsAndContingencies + TemporaryEquity + Equity

for $facts in facts:facts-for-internal(( "fac:LiabilitiesAndEquity", "fac:Liabilities", "fac:CommitmentsAndContingencies", "fac:TemporaryEquity", "fac:Equity"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"] let $Liabilities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Liabilities"] let $CommitmentsAndContingencies as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CommitmentsAndContingencies"] let $TemporaryEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:TemporaryEquity"] let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"] where exists($LiabilitiesAndEquity) return let $test := rules:decimal-value($LiabilitiesAndEquity) eq (rules:decimal-value($Liabilities) + rules:decimal-value($CommitmentsAndContingencies) + rules:decimal-value($TemporaryEquity) + rules:decimal-value($Equity)) let $audit-trail-message := rules:fact-trail($LiabilitiesAndEquity) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($Liabilities,"Liabilities") || " + " || rules:fact-trail($CommitmentsAndContingencies,"CommitmentsAndContingencies") || " + " || rules:fact-trail($TemporaryEquity,"TemporaryEquity") || " + " || rules:fact-trail($Equity,"Equity") || ")" let $source-facts := ( $Liabilities, $CommitmentsAndContingencies, $TemporaryEquity, $Equity) return rules:create-computed-fact( $LiabilitiesAndEquity, "fac:LiabilitiesAndEquityValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $LiabilitiesAndEquity, $test)

NetCashFlows = NetCashFlowsFromOperatingActivities + NetCashFlowsFromInvestingActivities + NetCashFlowsFromFinancingActivities [+ ExchangeGainsLosses]

NetCashFlowsContinuing = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesContinuing

NetCashFlowsDiscontinued = NetCashFlowsFromOperatingActivitiesDiscontinued + NetCashFlowsFromInvestingActivitiesDiscontinued + NetCashFlowsFromFinancingActivitiesDiscontinued

NetCashFlowsFromOperatingActivities = NetCashFlowsFromOperatingActivitiesContinuing + NetCashFlowsFromOperatingActivitiesDiscontinued

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsFromOperatingActivities", "fac:NetCashFlowsFromOperatingActivitiesContinuing", "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"] let $NetCashFlowsFromOperatingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesContinuing"] let $NetCashFlowsFromOperatingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"] where exists($NetCashFlowsFromOperatingActivities) return let $test := rules:decimal-value($NetCashFlowsFromOperatingActivities) eq (rules:decimal-value($NetCashFlowsFromOperatingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromOperatingActivitiesDiscontinued)) let $audit-trail-message := rules:fact-trail($NetCashFlowsFromOperatingActivities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromOperatingActivitiesContinuing,"NetCashFlowsFromOperatingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromOperatingActivitiesDiscontinued,"NetCashFlowsFromOperatingActivitiesDiscontinued") || ")" let $source-facts := ( $NetCashFlowsFromOperatingActivitiesContinuing, $NetCashFlowsFromOperatingActivitiesDiscontinued) return rules:create-computed-fact( $NetCashFlowsFromOperatingActivities, "fac:NetCashFlowsFromOperatingActivitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsFromOperatingActivities, $test)

NetCashFlowsFromInvestingActivities = NetCashFlowsFromInvestingActivitiesContinuing + NetCashFlowsFromInvestingActivitiesDiscontinued

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsFromInvestingActivities", "fac:NetCashFlowsFromInvestingActivitiesContinuing", "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"] let $NetCashFlowsFromInvestingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesContinuing"] let $NetCashFlowsFromInvestingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"] where exists($NetCashFlowsFromInvestingActivities) return let $test := rules:decimal-value($NetCashFlowsFromInvestingActivities) eq (rules:decimal-value($NetCashFlowsFromInvestingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromInvestingActivitiesDiscontinued)) let $audit-trail-message := rules:fact-trail($NetCashFlowsFromInvestingActivities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromInvestingActivitiesContinuing,"NetCashFlowsFromInvestingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromInvestingActivitiesDiscontinued,"NetCashFlowsFromInvestingActivitiesDiscontinued") || ")" let $source-facts := ( $NetCashFlowsFromInvestingActivitiesContinuing, $NetCashFlowsFromInvestingActivitiesDiscontinued) return rules:create-computed-fact( $NetCashFlowsFromInvestingActivities, "fac:NetCashFlowsFromInvestingActivitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsFromInvestingActivities, $test)

NetCashFlowsFromFinancingActivities = NetCashFlowsFromFinancingActivitiesContinuing + NetCashFlowsFromFinancingActivitiesDiscontinued

for $facts in facts:facts-for-internal(( "fac:NetCashFlowsFromFinancingActivities", "fac:NetCashFlowsFromFinancingActivitiesContinuing", "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"] let $NetCashFlowsFromFinancingActivitiesContinuing as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesContinuing"] let $NetCashFlowsFromFinancingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"] where exists($NetCashFlowsFromFinancingActivities) return let $test := rules:decimal-value($NetCashFlowsFromFinancingActivities) eq (rules:decimal-value($NetCashFlowsFromFinancingActivitiesContinuing) + rules:decimal-value($NetCashFlowsFromFinancingActivitiesDiscontinued)) let $audit-trail-message := rules:fact-trail($NetCashFlowsFromFinancingActivities) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($NetCashFlowsFromFinancingActivitiesContinuing,"NetCashFlowsFromFinancingActivitiesContinuing") || " + " || rules:fact-trail($NetCashFlowsFromFinancingActivitiesDiscontinued,"NetCashFlowsFromFinancingActivitiesDiscontinued") || ")" let $source-facts := ( $NetCashFlowsFromFinancingActivitiesContinuing, $NetCashFlowsFromFinancingActivitiesDiscontinued) return rules:create-computed-fact( $NetCashFlowsFromFinancingActivities, "fac:NetCashFlowsFromFinancingActivitiesValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetCashFlowsFromFinancingActivities, $test)

for $facts in facts:facts-for-internal(( "fac:GrossProfit", "fac:Revenues", "fac:CostOfRevenue"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"] where exists($GrossProfit) return let $test := rules:decimal-value($GrossProfit) eq (rules:decimal-value($Revenues) - rules:decimal-value($CostOfRevenue)) let $audit-trail-message := rules:fact-trail($GrossProfit) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($Revenues,"Revenues") || " - " || rules:fact-trail($CostOfRevenue,"CostOfRevenue") || ")" let $source-facts := ( $Revenues, $CostOfRevenue) return rules:create-computed-fact( $GrossProfit, "fac:GrossProfitValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $GrossProfit, $test)

OperatingIncomeLoss = GrossProfit - OperatingExpenses + OtherOperatingIncomeExpenses

for $facts in facts:facts-for-internal(( "fac:OperatingIncomeLoss", "fac:GrossProfit", "fac:OperatingExpenses", "fac:OtherOperatingIncomeExpenses"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"] let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"] let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"] where exists($OperatingIncomeLoss) return let $test := rules:decimal-value($OperatingIncomeLoss) eq (rules:decimal-value($GrossProfit) - rules:decimal-value($OperatingExpenses) + rules:decimal-value($OtherOperatingIncomeExpenses)) let $audit-trail-message := rules:fact-trail($OperatingIncomeLoss) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($GrossProfit,"GrossProfit") || " - " || rules:fact-trail($OperatingExpenses,"OperatingExpenses") || " + " || rules:fact-trail($OtherOperatingIncomeExpenses,"OtherOperatingIncomeExpenses") || ")" let $source-facts := ( $GrossProfit, $OperatingExpenses, $OtherOperatingIncomeExpenses) return rules:create-computed-fact( $OperatingIncomeLoss, "fac:OperatingIncomeLossValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $OperatingIncomeLoss, $test)

OperatingIncomeLoss = Revenues - CostsAndExpenses + OtherOperatingIncomeExpenses

for $facts in facts:facts-for-internal(( "fac:OperatingIncomeLoss", "fac:Revenues", "fac:CostsAndExpenses", "fac:OtherOperatingIncomeExpenses"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"] let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"] let $OtherOperatingIncomeExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherOperatingIncomeExpenses"] where exists($OperatingIncomeLoss) return let $test := rules:decimal-value($OperatingIncomeLoss) eq (rules:decimal-value($Revenues) - rules:decimal-value($CostsAndExpenses) + rules:decimal-value($OtherOperatingIncomeExpenses)) let $audit-trail-message := rules:fact-trail($OperatingIncomeLoss) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($Revenues,"Revenues") || " - " || rules:fact-trail($CostsAndExpenses,"CostsAndExpenses") || " + " || rules:fact-trail($OtherOperatingIncomeExpenses,"OtherOperatingIncomeExpenses") || ")" let $source-facts := ( $Revenues, $CostsAndExpenses, $OtherOperatingIncomeExpenses) return rules:create-computed-fact( $OperatingIncomeLoss, "fac:OperatingIncomeLoss2Validation", $test, $rule, $audit-trail-message, $source-facts, $options, $OperatingIncomeLoss, $test)

IncomeBeforeEquityMethodInvestments = OperatingIncomeLoss + NonoperatingIncomeLossPlusInterestAndDebtExpense

for $facts in facts:facts-for-internal(( "fac:IncomeBeforeEquityMethodInvestments", "fac:OperatingIncomeLoss", "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"] let $OperatingIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingIncomeLoss"] let $NonoperatingIncomeLossPlusInterestAndDebtExpense as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NonoperatingIncomeLossPlusInterestAndDebtExpense"] where exists($IncomeBeforeEquityMethodInvestments) return let $test := rules:decimal-value($IncomeBeforeEquityMethodInvestments) eq rules:decimal-value($OperatingIncomeLoss) + rules:decimal-value($NonoperatingIncomeLossPlusInterestAndDebtExpense) let $audit-trail-message := rules:fact-trail($IncomeBeforeEquityMethodInvestments) || (if($test) then " = " else " != ") || "" || rules:fact-trail($OperatingIncomeLoss,"OperatingIncomeLoss") || " + " || rules:fact-trail($NonoperatingIncomeLossPlusInterestAndDebtExpense,"NonoperatingIncomeLossPlusInterestAndDebtExpense") || "" let $source-facts := ( $OperatingIncomeLoss, $NonoperatingIncomeLossPlusInterestAndDebtExpense) return rules:create-computed-fact( $IncomeBeforeEquityMethodInvestments, "fac:IncomeBeforeEquityMethodInvestmentsValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $IncomeBeforeEquityMethodInvestments, $test)

IncomeLossFromContinuingOperationsBeforeTax = IncomeBeforeEquityMethodInvestments + IncomeLossFromEquityMethodInvestments

for $facts in facts:facts-for-internal(( "fac:IncomeLossFromContinuingOperationsBeforeTax", "fac:IncomeBeforeEquityMethodInvestments", "fac:IncomeLossFromEquityMethodInvestments"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeLossFromContinuingOperationsBeforeTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsBeforeTax"] let $IncomeBeforeEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeBeforeEquityMethodInvestments"] let $IncomeLossFromEquityMethodInvestments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromEquityMethodInvestments"] where exists($IncomeLossFromContinuingOperationsBeforeTax) return let $test := rules:decimal-value($IncomeLossFromContinuingOperationsBeforeTax) eq rules:decimal-value($IncomeBeforeEquityMethodInvestments) + rules:decimal-value($IncomeLossFromEquityMethodInvestments) let $audit-trail-message := rules:fact-trail($IncomeLossFromContinuingOperationsBeforeTax) || (if($test) then " = " else " != ") || "" || rules:fact-trail($IncomeBeforeEquityMethodInvestments,"IncomeBeforeEquityMethodInvestments") || " + " || rules:fact-trail($IncomeLossFromEquityMethodInvestments,"IncomeLossFromEquityMethodInvestments") || "" let $source-facts := ( $IncomeBeforeEquityMethodInvestments, $IncomeLossFromEquityMethodInvestments) return rules:create-computed-fact( $IncomeLossFromContinuingOperationsBeforeTax, "fac:IncomeLossFromContinuingOperationsBeforeTaxValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $IncomeLossFromContinuingOperationsBeforeTax, $test)

IncomeLossFromContinuingOperationsAfterTax = IncomeLossFromContinuingOperationsBeforeTax - IncomeTaxExpenseBenefit

for $facts in facts:facts-for-internal(( "fac:IncomeLossFromContinuingOperationsAfterTax", "fac:IncomeLossFromContinuingOperationsBeforeTax", "fac:IncomeTaxExpenseBenefit"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $IncomeLossFromContinuingOperationsAfterTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsAfterTax"] let $IncomeLossFromContinuingOperationsBeforeTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsBeforeTax"] let $IncomeTaxExpenseBenefit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeTaxExpenseBenefit"] where exists($IncomeLossFromContinuingOperationsAfterTax) return let $test := rules:decimal-value($IncomeLossFromContinuingOperationsAfterTax) eq (rules:decimal-value($IncomeLossFromContinuingOperationsBeforeTax) - rules:decimal-value($IncomeTaxExpenseBenefit)) let $audit-trail-message := rules:fact-trail($IncomeLossFromContinuingOperationsAfterTax) || (if($test) then " = " else " != ") || "(" || rules:fact-trail($IncomeLossFromContinuingOperationsBeforeTax,"IncomeLossFromContinuingOperationsBeforeTax") || " - " || rules:fact-trail($IncomeTaxExpenseBenefit,"IncomeTaxExpenseBenefit") || ")" let $source-facts := ( $IncomeLossFromContinuingOperationsBeforeTax, $IncomeTaxExpenseBenefit) return rules:create-computed-fact( $IncomeLossFromContinuingOperationsAfterTax, "fac:IncomeLossFromContinuingOperationsAfterTaxValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $IncomeLossFromContinuingOperationsAfterTax, $test)

NetIncomeLoss = IncomeLossFromContinuingOperationsAfterTax + IncomeLossFromDiscontinuedOperationsNetTax + ExtraordinaryItemsIncomeExpenseNetTax

for $facts in facts:facts-for-internal(( "fac:NetIncomeLoss", "fac:IncomeLossFromContinuingOperationsAfterTax", "fac:IncomeLossFromDiscontinuedOperationsNetTax", "fac:ExtraordinaryItemsIncomeExpenseNetTax"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"] let $IncomeLossFromContinuingOperationsAfterTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromContinuingOperationsAfterTax"] let $IncomeLossFromDiscontinuedOperationsNetTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:IncomeLossFromDiscontinuedOperationsNetTax"] let $ExtraordinaryItemsIncomeExpenseNetTax as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ExtraordinaryItemsIncomeExpenseNetTax"] where exists($NetIncomeLoss) return let $test := rules:decimal-value($NetIncomeLoss) eq rules:decimal-value($IncomeLossFromContinuingOperationsAfterTax) + rules:decimal-value($IncomeLossFromDiscontinuedOperationsNetTax) + rules:decimal-value($ExtraordinaryItemsIncomeExpenseNetTax) let $audit-trail-message := rules:fact-trail($NetIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($IncomeLossFromContinuingOperationsAfterTax,"IncomeLossFromContinuingOperationsAfterTax") || " + " || rules:fact-trail($IncomeLossFromDiscontinuedOperationsNetTax,"IncomeLossFromDiscontinuedOperationsNetTax") || " + " || rules:fact-trail($ExtraordinaryItemsIncomeExpenseNetTax,"ExtraordinaryItemsIncomeExpenseNetTax") || "" let $source-facts := ( $IncomeLossFromContinuingOperationsAfterTax, $IncomeLossFromDiscontinuedOperationsNetTax, $ExtraordinaryItemsIncomeExpenseNetTax) return rules:create-computed-fact( $NetIncomeLoss, "fac:NetIncomeLossValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetIncomeLoss, $test)

NetIncomeLoss = NetIncomeAttributableToParent + NetIncomeAttributableToNoncontrollingInterest

for $facts in facts:facts-for-internal(( "fac:NetIncomeLoss", "fac:NetIncomeAttributableToParent", "fac:NetIncomeAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"] let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"] let $NetIncomeAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToNoncontrollingInterest"] where exists($NetIncomeLoss) return let $test := rules:decimal-value($NetIncomeLoss) eq rules:decimal-value($NetIncomeAttributableToParent) + rules:decimal-value($NetIncomeAttributableToNoncontrollingInterest) let $audit-trail-message := rules:fact-trail($NetIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($NetIncomeAttributableToParent,"NetIncomeAttributableToParent") || " + " || rules:fact-trail($NetIncomeAttributableToNoncontrollingInterest,"NetIncomeAttributableToNoncontrollingInterest") || "" let $source-facts := ( $NetIncomeAttributableToParent, $NetIncomeAttributableToNoncontrollingInterest) return rules:create-computed-fact( $NetIncomeLoss, "fac:NetIncomeLoss2Validation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetIncomeLoss, $test)

NetIncomeLossAvailableToCommonStockholdersBasic = NetIncomeAttributableToParent - PreferredStockDividendsAndOtherAdjustments

for $facts in facts:facts-for-internal(( "fac:NetIncomeLossAvailableToCommonStockholdersBasic", "fac:NetIncomeAttributableToParent", "fac:PreferredStockDividendsAndOtherAdjustments"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $NetIncomeLossAvailableToCommonStockholdersBasic as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLossAvailableToCommonStockholdersBasic"] let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"] let $PreferredStockDividendsAndOtherAdjustments as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:PreferredStockDividendsAndOtherAdjustments"] where exists($NetIncomeLossAvailableToCommonStockholdersBasic) return let $test := rules:decimal-value($NetIncomeLossAvailableToCommonStockholdersBasic) eq rules:decimal-value($NetIncomeAttributableToParent) - rules:decimal-value($PreferredStockDividendsAndOtherAdjustments) let $audit-trail-message := rules:fact-trail($NetIncomeLossAvailableToCommonStockholdersBasic) || (if($test) then " = " else " != ") || "" || rules:fact-trail($NetIncomeAttributableToParent,"NetIncomeAttributableToParent") || " - " || rules:fact-trail($PreferredStockDividendsAndOtherAdjustments,"PreferredStockDividendsAndOtherAdjustments") || "" let $source-facts := ( $NetIncomeAttributableToParent, $PreferredStockDividendsAndOtherAdjustments) return rules:create-computed-fact( $NetIncomeLossAvailableToCommonStockholdersBasic, "fac:NetIncomeLossAvailableToCommonStockholdersBasicValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $NetIncomeLossAvailableToCommonStockholdersBasic, $test)

ComprehensiveIncomeLoss = ComprehensiveIncomeLossAttributableToParent + ComprehensiveIncomeLossAttributableToNoncontrollingInterest

for $facts in facts:facts-for-internal(( "fac:ComprehensiveIncomeLoss", "fac:ComprehensiveIncomeLossAttributableToParent", "fac:ComprehensiveIncomeLossAttributableToNoncontrollingInterest"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"] let $ComprehensiveIncomeLossAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLossAttributableToParent"] let $ComprehensiveIncomeLossAttributableToNoncontrollingInterest as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLossAttributableToNoncontrollingInterest"] where exists($ComprehensiveIncomeLoss) return let $test := rules:decimal-value($ComprehensiveIncomeLoss) eq rules:decimal-value($ComprehensiveIncomeLossAttributableToParent) + rules:decimal-value($ComprehensiveIncomeLossAttributableToNoncontrollingInterest) let $audit-trail-message := rules:fact-trail($ComprehensiveIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($ComprehensiveIncomeLossAttributableToParent,"ComprehensiveIncomeLossAttributableToParent") || " + " || rules:fact-trail($ComprehensiveIncomeLossAttributableToNoncontrollingInterest,"ComprehensiveIncomeLossAttributableToNoncontrollingInterest") || "" let $source-facts := ( $ComprehensiveIncomeLossAttributableToParent, $ComprehensiveIncomeLossAttributableToNoncontrollingInterest) return rules:create-computed-fact( $ComprehensiveIncomeLoss, "fac:ComprehensiveIncomeLossValidation", $test, $rule, $audit-trail-message, $source-facts, $options, $ComprehensiveIncomeLoss, $test)

ComprehensiveIncomeLoss = NetIncomeLoss + OtherComprehensiveIncomeLoss

for $facts in facts:facts-for-internal(( "fac:ComprehensiveIncomeLoss", "fac:NetIncomeLoss", "fac:OtherComprehensiveIncomeLoss"), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options) group by $canonical-filter-string := facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance")) let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"] let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"] let $OtherComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OtherComprehensiveIncomeLoss"] where exists($ComprehensiveIncomeLoss) return let $test := rules:decimal-value($ComprehensiveIncomeLoss) eq rules:decimal-value($NetIncomeLoss) + rules:decimal-value($OtherComprehensiveIncomeLoss) let $audit-trail-message := rules:fact-trail($ComprehensiveIncomeLoss) || (if($test) then " = " else " != ") || "" || rules:fact-trail($NetIncomeLoss,"NetIncomeLoss") || " + " || rules:fact-trail($OtherComprehensiveIncomeLoss,"OtherComprehensiveIncomeLoss") || "" let $source-facts := ( $NetIncomeLoss, $OtherComprehensiveIncomeLoss) return rules:create-computed-fact( $ComprehensiveIncomeLoss, "fac:ComprehensiveIncomeLoss2Validation", $test, $rule, $audit-trail-message, $source-facts, $options, $ComprehensiveIncomeLoss, $test)

Rule to validate Assets (fac:Assets). It also creates a new fact (fac:AssetsValidation) that contains the validation result.

for $facts in facts:facts-for-internal((
      "fac:AssetsValidation", "fac:Assets", "fac:LiabilitiesAndEquity"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance"))
  , $aligned-period
let $AssetsValidation as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:AssetsValidation"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($AssetsValidation) return $AssetsValidation
  case (exists($Assets) and true)
  return
    let $computed-value := rules:decimal-value($Assets) eq rules:decimal-value($LiabilitiesAndEquity)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:AssetsValidation" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($Assets, "Assets") || " eq " || rules:fact-trail($LiabilitiesAndEquity, "LiabilitiesAndEquity")
	 let $source-facts := ($AssetsValidation, $Assets, $LiabilitiesAndEquity)
    return
      rules:create-computed-fact(
          $Assets,
          "fac:AssetsValidation",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Assets = CurrentAssets + NoncurrentAssets

Rule to validate Assets (fac:Assets). It also creates a new fact (fac:AssetsValidation2) that contains the validation result.

for $facts in facts:facts-for-internal((
      "fac:AssetsValidation2", "fac:Assets", "fac:CurrentAssets", "fac:NoncurrentAssets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance"))
  , $aligned-period
let $AssetsValidation2 as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:AssetsValidation2"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($AssetsValidation2) return $AssetsValidation2
  case (exists($Assets) and true)
  return
    let $computed-value := rules:decimal-value($Assets) eq rules:decimal-value($CurrentAssets) + rules:decimal-value($NoncurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:AssetsValidation2" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($Assets, "Assets") || " eq " || rules:fact-trail($CurrentAssets, "CurrentAssets") || " + " || rules:fact-trail($NoncurrentAssets, "NoncurrentAssets")
	 let $source-facts := ($AssetsValidation2, $Assets, $CurrentAssets, $NoncurrentAssets)
    return
      rules:create-computed-fact(
          $Assets,
          "fac:AssetsValidation2",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Assets (fac:Assets).

for $facts in facts:facts-for-internal((
      "fac:Assets", "fac:CurrentAssets", "fac:LiabilitiesAndEquity", "fac:NoncurrentAssets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance"))
  , $aligned-period
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $LiabilitiesAndEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:LiabilitiesAndEquity"]
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($Assets) return $Assets
  case (exists($LiabilitiesAndEquity) and rules:decimal-value($CurrentAssets) eq rules:decimal-value($LiabilitiesAndEquity))
  return
    let $computed-value := rules:decimal-value($CurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:Assets" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($CurrentAssets, "CurrentAssets")
	 let $source-facts := ($Assets, $CurrentAssets, $LiabilitiesAndEquity, $NoncurrentAssets)
    return
      rules:create-computed-fact(
          $LiabilitiesAndEquity,
          "fac:Assets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  case (exists($NoncurrentAssets) and ())
  return
    let $computed-value := rules:decimal-value($CurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:Assets" }, Value: $computed-value }) || " = "
	        || rules:fact-trail($CurrentAssets, "CurrentAssets")
	 let $source-facts := ($Assets, $CurrentAssets, $LiabilitiesAndEquity, $NoncurrentAssets)
    return
      rules:create-computed-fact(
          $NoncurrentAssets,
          "fac:Assets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Current Assets (fac:CurrentAssets).

for $facts in facts:facts-for-internal((
      "fac:CurrentAssets", "fac:NoncurrentAssets", "fac:Assets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($CurrentAssets) return $CurrentAssets
  case (exists($Assets) and not((not(exists($NoncurrentAssets)))))
  return
    let $computed-value := rules:decimal-value($Assets) - rules:decimal-value($NoncurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:CurrentAssets" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Assets, "Assets") || " - " || rules:fact-trail($NoncurrentAssets, "NoncurrentAssets")
	 let $source-facts := ($CurrentAssets, $NoncurrentAssets, $Assets)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Assets,
            "fac:CurrentAssets",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Assets,
          "fac:CurrentAssets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Noncurrent Assets (fac:NoncurrentAssets).

for $facts in facts:facts-for-internal((
      "fac:NoncurrentAssets", "fac:CurrentAssets", "fac:Assets"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NoncurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NoncurrentAssets"]
let $CurrentAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CurrentAssets"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NoncurrentAssets) return $NoncurrentAssets
  case (exists($Assets) and not((not(exists($CurrentAssets)))))
  return
    let $computed-value := rules:decimal-value($Assets) - rules:decimal-value($CurrentAssets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NoncurrentAssets" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Assets, "Assets") || " - " || rules:fact-trail($CurrentAssets, "CurrentAssets")
	 let $source-facts := ($NoncurrentAssets, $CurrentAssets, $Assets)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Assets,
            "fac:NoncurrentAssets",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Assets,
          "fac:NoncurrentAssets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Cost of Revenues (fac:CostOfRevenue).

Rule to compute Operating Expenses (fac:OperatingExpenses).

for $facts in facts:facts-for-internal((
      "fac:OperatingExpenses", "fac:CostOfRevenue", "fac:CostsAndExpenses"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $OperatingExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:OperatingExpenses"]
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $CostsAndExpenses as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostsAndExpenses"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($OperatingExpenses) return $OperatingExpenses
  case (exists($CostsAndExpenses) and not((not(exists($CostOfRevenue)))))
  return
    let $computed-value := rules:decimal-value($CostsAndExpenses) - rules:decimal-value($CostOfRevenue)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:OperatingExpenses" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($CostsAndExpenses, "CostsAndExpenses") || " - " || rules:fact-trail($CostOfRevenue, "CostOfRevenue")
	 let $source-facts := ($OperatingExpenses, $CostOfRevenue, $CostsAndExpenses)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $CostsAndExpenses,
            "fac:OperatingExpenses",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $CostsAndExpenses,
          "fac:OperatingExpenses",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Costs and Expenses (fac:CostsAndExpenses).

Rule to compute Return on Assets (ROA) (fac:ReturnOnAssets).

for $facts in facts:facts-for-internal((
      "fac:ReturnOnAssets", "fac:Assets", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ReturnOnAssets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ReturnOnAssets"]
let $Assets as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Assets"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ReturnOnAssets) return $ReturnOnAssets
  case (exists($Assets) and rules:decimal-value($Assets) ne 0)
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Assets)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ReturnOnAssets" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Assets, "Assets")
	 let $source-facts := ($ReturnOnAssets, $Assets, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Assets,
            "fac:ReturnOnAssets",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Assets,
          "fac:ReturnOnAssets",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Return on Equity (ROE) (fac:ReturnOnEquity).

for $facts in facts:facts-for-internal((
      "fac:ReturnOnEquity", "fac:Equity", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ReturnOnEquity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ReturnOnEquity"]
let $Equity as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Equity"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ReturnOnEquity) return $ReturnOnEquity
  case (exists($Equity) and rules:decimal-value($Equity) ne 0)
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Equity)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ReturnOnEquity" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Equity, "Equity")
	 let $source-facts := ($ReturnOnEquity, $Equity, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Equity,
            "fac:ReturnOnEquity",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Equity,
          "fac:ReturnOnEquity",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Return on Sales (ROS) (fac:ReturnOnSalesROS).

for $facts in facts:facts-for-internal((
      "fac:ReturnOnSalesROS", "fac:Revenues", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ReturnOnSalesROS as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ReturnOnSalesROS"]
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ReturnOnSalesROS) return $ReturnOnSalesROS
  case (exists($Revenues) and rules:decimal-value($Revenues) ne 0)
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss) div rules:decimal-value($Revenues)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ReturnOnSalesROS" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss") || " div " || rules:fact-trail($Revenues, "Revenues")
	 let $source-facts := ($ReturnOnSalesROS, $Revenues, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Revenues,
            "fac:ReturnOnSalesROS",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Revenues,
          "fac:ReturnOnSalesROS",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Other Operating Income (Expenses) (fac:OtherOperatingIncomeExpenses).

Rule to compute Operating Income (Loss) (fac:OperatingIncomeLoss).

Rule to compute Revenues (fac:Revenues).

for $facts in facts:facts-for-internal((
      "fac:Revenues", "fac:CostOfRevenue", "fac:GrossProfit"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($Revenues) return $Revenues
  case (exists($GrossProfit) and not((not(exists($CostOfRevenue)))))
  return
    let $computed-value := rules:decimal-value($GrossProfit) + rules:decimal-value($CostOfRevenue)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:Revenues" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($GrossProfit, "GrossProfit") || " + " || rules:fact-trail($CostOfRevenue, "CostOfRevenue")
	 let $source-facts := ($Revenues, $CostOfRevenue, $GrossProfit)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $GrossProfit,
            "fac:Revenues",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $GrossProfit,
          "fac:Revenues",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Gross Profit (fac:GrossProfit).

for $facts in facts:facts-for-internal((
      "fac:GrossProfit", "fac:Revenues", "fac:CostOfRevenue"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $GrossProfit as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:GrossProfit"]
let $Revenues as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:Revenues"]
let $CostOfRevenue as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:CostOfRevenue"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($GrossProfit) return $GrossProfit
  case (exists($Revenues) and ())
  return
    let $computed-value := rules:decimal-value($Revenues) - rules:decimal-value($CostOfRevenue)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:GrossProfit" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($Revenues, "Revenues") || " - " || rules:fact-trail($CostOfRevenue, "CostOfRevenue")
	 let $source-facts := ($GrossProfit, $Revenues, $CostOfRevenue)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $Revenues,
            "fac:GrossProfit",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $Revenues,
          "fac:GrossProfit",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Rule to compute Interest and Debt Expense (fac:InterestAndDebtExpense).

Nonoperating Income (Loss) + Interest and Debt Expense

Rule to compute Nonoperating Income (Loss) + Interest and Debt Expense (fac:NonoperatingIncomeLossPlusInterestAndDebtExpense).

Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments

Rule to compute Nonoperating Income (Loss) + Interest and Debt Expense + Income (Loss) from Equity Method Investments (fac:NonoperatingIncomePlusInterestAndDebtExpensePlusIncomeFromEquityMethodInvestments).

Income (Loss) from Continuing Operations Before Tax

Rule to compute Income (Loss) from Continuing Operations Before Tax (fac:IncomeLossFromContinuingOperationsBeforeTax).

Income (Loss) from Continuing Operations After Tax

Rule to compute Income (Loss) from Continuing Operations After Tax (fac:IncomeLossFromContinuingOperationsAfterTax).

Rule to compute Net Income Attributable to Parent (fac:NetIncomeAttributableToParent).

for $facts in facts:facts-for-internal((
      "fac:NetIncomeAttributableToParent", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetIncomeAttributableToParent as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeAttributableToParent"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetIncomeAttributableToParent) return $NetIncomeAttributableToParent
  case (exists($NetIncomeLoss) and ())
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetIncomeAttributableToParent" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss")
	 let $source-facts := ($NetIncomeAttributableToParent, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetIncomeLoss,
            "fac:NetIncomeAttributableToParent",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetIncomeLoss,
          "fac:NetIncomeAttributableToParent",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Preferred Stock Dividends and Other Adjustments

Rule to compute Preferred Stock Dividends and Other Adjustments (fac:PreferredStockDividendsAndOtherAdjustments).

Net Income (Loss) Available to Common Stockholders, Basic

Rule to compute Net Income (Loss) Available to Common Stockholders, Basic (fac:NetIncomeLossAvailableToCommonStockholdersBasic).

Income (Loss) Before Equity Method Investments

Rule to compute Income (Loss) Before Equity Method Investments (fac:IncomeBeforeEquityMethodInvestments).

Rule to compute Other Comprehensive Income (Loss) (fac:OtherComprehensiveIncomeLoss).

Rule to compute Comprehensive Income (Loss) (fac:ComprehensiveIncomeLoss).

for $facts in facts:facts-for-internal((
      "fac:ComprehensiveIncomeLoss", "fac:NetIncomeLoss"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $ComprehensiveIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:ComprehensiveIncomeLoss"]
let $NetIncomeLoss as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetIncomeLoss"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($ComprehensiveIncomeLoss) return $ComprehensiveIncomeLoss
  case (exists($NetIncomeLoss) and ())
  return
    let $computed-value := rules:decimal-value($NetIncomeLoss)
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:ComprehensiveIncomeLoss" }, Value: $computed-value }) || " = " ||
	        rules:fact-trail($NetIncomeLoss, "NetIncomeLoss")
	 let $source-facts := ($ComprehensiveIncomeLoss, $NetIncomeLoss)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetIncomeLoss,
            "fac:ComprehensiveIncomeLoss",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetIncomeLoss,
          "fac:ComprehensiveIncomeLoss",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Comprehensive Income (Loss) Attributable to Parent

Rule to compute Comprehensive Income (Loss) Attributable to Parent (fac:ComprehensiveIncomeLossAttributableToParent).

Net Cash Flows from Operating Activities, Continuing

Rule to compute Net Cash Flows from Operating Activities, Continuing (fac:NetCashFlowsFromOperatingActivitiesContinuing).

Net Cash Flows from Operating Activities, Discontinued

Rule to compute Net Cash Flows from Operating Activities, Discontinued (fac:NetCashFlowsFromOperatingActivitiesDiscontinued).

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromOperatingActivitiesDiscontinued", "fac:NetCashFlowsFromOperatingActivities"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromOperatingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivitiesDiscontinued"]
let $NetCashFlowsFromOperatingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromOperatingActivities"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromOperatingActivitiesDiscontinued) return $NetCashFlowsFromOperatingActivitiesDiscontinued
  case (exists($NetCashFlowsFromOperatingActivities) and ())
  return
    let $computed-value := 0
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromOperatingActivitiesDiscontinued" }, Value: $computed-value }) || " = " ||
	        "0"
	 let $source-facts := ($NetCashFlowsFromOperatingActivitiesDiscontinued, $NetCashFlowsFromOperatingActivities)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromOperatingActivities,
            "fac:NetCashFlowsFromOperatingActivitiesDiscontinued",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromOperatingActivities,
          "fac:NetCashFlowsFromOperatingActivitiesDiscontinued",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Cash Flows from Investing Activities, Continuing

Rule to compute Net Cash Flows from Investing Activities, Continuing (fac:NetCashFlowsFromInvestingActivitiesContinuing).

Net Cash Flows from Investing Activities, Discontinued

If NetCashFlowsInvesting = NetCashFlowsInvestingContinuing then NetCashFlowsInvestingDiscontinued must be 0

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromInvestingActivitiesDiscontinued", "fac:NetCashFlowsFromInvestingActivities"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromInvestingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivitiesDiscontinued"]
let $NetCashFlowsFromInvestingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromInvestingActivities"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromInvestingActivitiesDiscontinued) return $NetCashFlowsFromInvestingActivitiesDiscontinued
  case (exists($NetCashFlowsFromInvestingActivities) and ())
  return
    let $computed-value := 0
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromInvestingActivitiesDiscontinued" }, Value: $computed-value }) || " = " ||
	        "0"
	 let $source-facts := ($NetCashFlowsFromInvestingActivitiesDiscontinued, $NetCashFlowsFromInvestingActivities)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromInvestingActivities,
            "fac:NetCashFlowsFromInvestingActivitiesDiscontinued",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromInvestingActivities,
          "fac:NetCashFlowsFromInvestingActivitiesDiscontinued",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Cash Flows from Investing Activities

Rule to compute Net Cash Flows from Investing Activities (fac:NetCashFlowsFromInvestingActivities).

Net Cash Flows from Financing Activities, Continuing

Rule to compute Net Cash Flows from Financing Activities, Continuing (fac:NetCashFlowsFromFinancingActivitiesContinuing).

Net Cash Flows from Financing Activities, Discontinued

RIf NetCashFlowsFinancing = NetCashFlowsFinancingContinuing then NetCashFlowsFinancingDiscontinued must be 0

for $facts in facts:facts-for-internal((
      "fac:NetCashFlowsFromFinancingActivitiesDiscontinued", "fac:NetCashFlowsFromFinancingActivities"
    ), $hypercube, $aligned-filter, $concept-maps, $rules, $cache, $options)
let $aligned-period := ( facts:duration-for-fact($facts).End, facts:instant-for-fact($facts), "forever")[1]
group by $canonical-filter-string :=
  facts:canonically-serialize-object($facts, ($facts:CONCEPT, "_id", "IsInDefaultHypercube", "Type", "Value", "Decimals", "AuditTrails", "xbrl28:Type", "Balance", $facts:PERIOD))
  , $aligned-period
let $NetCashFlowsFromFinancingActivitiesDiscontinued as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivitiesDiscontinued"]
let $NetCashFlowsFromFinancingActivities as object? := $facts[$$.$facts:ASPECTS.$facts:CONCEPT eq "fac:NetCashFlowsFromFinancingActivities"]
let $_unit := ($facts.$facts:ASPECTS.$facts:UNIT)[1]
return
  switch (true)
  case exists($NetCashFlowsFromFinancingActivitiesDiscontinued) return $NetCashFlowsFromFinancingActivitiesDiscontinued
  case (exists($NetCashFlowsFromFinancingActivities) and ())
  return
    let $computed-value := 0
    let $audit-trail-message :=
	     rules:fact-trail({"Aspects": { "xbrl:Unit" : $_unit, "xbrl:Concept" : "fac:NetCashFlowsFromFinancingActivitiesDiscontinued" }, Value: $computed-value }) || " = " ||
	        "0"
	 let $source-facts := ($NetCashFlowsFromFinancingActivitiesDiscontinued, $NetCashFlowsFromFinancingActivities)
    return
      if(string(number($computed-value)) != "NaN" and not($computed-value instance of xs:boolean) and $computed-value ne xs:integer($computed-value))
      then
        copy $newfact :=
          rules:create-computed-fact(
            $NetCashFlowsFromFinancingActivities,
            "fac:NetCashFlowsFromFinancingActivitiesDiscontinued",
            $computed-value,
            $rule,
            $audit-trail-message,
            $source-facts,
            $options)
        modify (
            replace value of json $newfact("Decimals") with 2
          )
        return $newfact
      else
        rules:create-computed-fact(
          $NetCashFlowsFromFinancingActivities,
          "fac:NetCashFlowsFromFinancingActivitiesDiscontinued",
          $computed-value,
          $rule,
          $audit-trail-message,
          $source-facts,
          $options)
  default return ()

Net Cash Flows from Operating Activities

Rule to compute Net Cash Flows from Operating Activities (fac:NetCashFlowsFromOperatingActivities).

Rule to compute Net Cash Flows, Continuing (fac:NetCashFlowsContinuing).

Rule to compute Net Cash Flows, Discontinued (fac:NetCashFlowsDiscontinued).

Rule to compute Net Cash Flows (fac:NetCashFlows).

Rule to compute Sustainable Growth Rate (SGR) (fac:SustainableGrowthRate).

Net Cash Flows from Financing Activities

Rule to compute Net Cash Flows from Financing Activities (fac:NetCashFlowsFromFinancingActivities).