Originally created by: grynn-in
Found reviewing [#160] (#153). scripts/build_consolidation_report.py, in fetch_entity_pnl and fetch_entity_bs (around lines 250–295), reads each entity's whole year from gold_trial_balance / gold_balance_sheet. The consolidated model, gold_consolidated_trial_balance, includes only the periods inside the entity's ownership window (gold_consolidated_trial_balance.sql:280-284, 334-335, via gold_entity_ownership.outside_ownership_window / has_complete_chain).
The entity columns and the consolidated column filter periods differently. For an entity acquired or disposed of mid-year, the entity columns carry pre-acquisition or post-disposal amounts that the consolidated column excludes. The report's waterfall then shows a difference with no elimination behind it. Today's data doesn't show this, because ownership never changes within 2024.
Filter the entity fetches to the periods where gold_entity_ownership has outside_ownership_window = 0 AND has_complete_chain = 1 for the group. Or read the entity columns from gold_consolidated_trial_balance.local_amount, which is already windowed. Add a synthetic mid-year case to prove it once the the customer data (with dated acquisitions) is loaded.
🤖 Generated with Claude Code
Tickets: #160
Tickets: #167
Tickets: #169
Tickets: #170
Tickets: #171
Tickets: #172
Ticket changed by: grynn-in