Skip to content

v5.6.4: Critical XBRL Precision Fix

Choose a tag to compare

@dgunning dgunning released this 29 Dec 10:49
· 1557 commits to main since this release

Critical Bug Fix

Issue #564: XBRL Assets values were incorrectly rounded, breaking the balance sheet equation.

Problem

When multiple XBRL facts existed for the same concept/context with different precision (decimals attribute), the code selected the first fact encountered rather than the most precise one.

This caused incorrect values:

  • PFE 2017 Assets: $172,000M (wrong) vs $171,797M (correct) — $203M error
  • PFE 2018 Assets: $159,000M (wrong) vs $159,422M (correct)
  • ZTS 2018 Assets: $10,800M (wrong) vs $10,777M (correct)

Fix

  • Added _get_fact_precision() and _select_most_precise_fact() helpers
  • Modified fact selection to always prefer higher precision (higher decimals value)
  • Added regression tests to prevent future regressions

Impact

Balance sheet equation now balances correctly: Assets = Liabilities + Equity ✓


Thanks to @mpreiss9 for reporting this issue.