EntityFacts can mix fiscal years when calculating gross profit or revenue
Issue Type
- [x] Data Quality Issue (incorrect financial values, missing data)
- [ ] XBRL Parsing Issue (statement rendering, concept mapping)
- [ ] Filing Access Issue (download failures, attachment problems)
- [ ] Performance Issue (slow operations, memory problems)
- [ ] Compatibility Issue (platform/dependency conflicts)
- [ ] Documentation Issue (unclear instructions, missing examples)
Environment
EdgarTools Version: 6.2.0 Python Version: [3.15.2] Operating System: macOS
Bug Description
What you expected to happen:
EntityFacts.get_gross_profit() should return None when gross profit is missing and the available revenue and cost facts cover different reporting periods.
What actually happened:
With $120 in FY2025 revenue and $70 in FY2024 cost of revenue, get_gross_profit() subtracts the two values and returns 50.0. The fallback selects the component facts independently without checking that their start and end dates match.
Error message (if any):
None. The method returns 50.0.
Reproduction
Company/Ticker: N/A (synthetic data) Time Period: FY2024 and FY2025 Relevant Forms: Synthetic 10-K facts. No SEC requests are needed.
Minimal code to reproduce:
from edgar.entity.parser import EntityFactsParser
def annual_fact(year, value):
return {
"start": f"{year}-01-01",
"end": f"{year}-12-31",
"filed": f"{year + 1}-02-15",
"accn": f"0000000001-{(year + 1) % 100:02d}-000001",
"fy": year,
"fp": "FY",
"form": "10-K",
"val": value,
}
facts = EntityFactsParser.parse_company_facts({
"cik": 1,
"entityName": "Synthetic Example",
"facts": {
"us-gaap": {
"Revenues": {"units": {"USD": [annual_fact(2025, 120)]}},
"CostOfRevenue": {"units": {"USD": [annual_fact(2024, 70)]}},
}
},
})
print(facts.get_gross_profit()) # Actual: 50.0. Expected: None.
Additional Context
I reproduced the same behavior in get_revenue() with a synthetic FY2025 gross profit of $50 and FY2024 cost of revenue of $70. It returned 120.0.
I’d like to work on a fix that checks whether the component facts cover the same reporting dates before doing the calculation.
This issue will be handled using EdgarTools' systematic issue resolution workflow. A reproduction test will be created to verify the fix.