Spaces:
Sleeping
Sleeping
Commit History
-
feat: read per-product and per-region results from the filing's XBRL instance
companyfacts returns only undimensioned facts, which is why the brief has never had a segment breakdown. The detail is in the inline-XBRL instance document that ships inside the filing itself, where facts carry explicit dimension members (srt:ProductOrServiceAxis, us-gaap:StatementBusinessSegmentsAxis). One fetch per filing yields the quarter and its prior-year comparable, so year-on-year costs no extra request. Two traps that would produce plausible wrong numbers, both covered by tests: - A filing tags subtotals beside detail members (Apple's "Products" equals iPhone + Mac + iPad + Wearables). Plotting both inflates the mix by 72%. The subtotal is found by anchoring on consolidated revenue and taking the subset equal to the excess, so no per-issuer member list is needed. - The structural fallback enumerates subsets, and an early break on an oversized sum is wrong: itertools.combinations is not ordered by sum. analytics/impact.py adds the arithmetic that turns the breakdown …232b6f9