#!/usr/bin/env -S uv run python """Rebuild Cedar Trail's statement of cash flows with plain Python. Run from any directory: uv run python cedar-trail-direct-indirect-reconstruction.py No third-party packages are required. Classification conclusions are supplied; this script checks their arithmetic and articulation. """ def money(amount: float) -> str: """Format a signed amount as financial-statement dollars.""" return f"(${abs(amount):,.0f})" if amount < 0 else f"${amount:,.0f}" def show(label: str, amount: float) -> None: print(f"{label:<46} {money(amount):>16}") # Step 1: build the direct operating subtotal from gross cash classes. operating_receipts = { "Customer collections": 900_000, "Other operating receipts": 90_000, } operating_payments = { "Suppliers": 550_000, "Employees": 160_000, "Interest": 30_000, "Income taxes": 30_000, } direct_operating_cash_flow = sum(operating_receipts.values()) - sum( operating_payments.values() ) print("CEDAR TRAIL — DIRECT OPERATING CASH FLOW") for name, amount in operating_receipts.items(): show(name, amount) for name, amount in operating_payments.items(): show(f"Less: {name}", -amount) show("Net cash provided by operating activities", direct_operating_cash_flow) # Step 2: independently reconcile net income to the same operating subtotal. net_income = 160_000 indirect_adjustments = { "Depreciation": 75_000, "Share-based compensation": 15_000, "Remove disposal gain": -20_000, "Receivables timing": -25_000, "Inventory timing": -10_000, "Payables timing": 25_000, } indirect_operating_cash_flow = net_income + sum(indirect_adjustments.values()) print("\nCEDAR TRAIL — INDIRECT OPERATING CROSS-CHECK") show("Net income", net_income) for name, amount in indirect_adjustments.items(): show(name, amount) show("Net cash provided by operating activities", indirect_operating_cash_flow) show( "Direct minus indirect control", direct_operating_cash_flow - indirect_operating_cash_flow, ) # Step 3: calculate deal cash from cash transferred or received—not headlines. cash_consideration = 320_000 cash_acquired = 45_000 net_acquisition_cash_used = cash_consideration - cash_acquired cash_proceeds = 210_000 cash_divested = 30_000 net_disposal_cash_provided = cash_proceeds - cash_divested other_investing_cash_flow = -250_000 - 10_000 investing_cash_flow = ( other_investing_cash_flow - net_acquisition_cash_used + net_disposal_cash_provided ) financing_cash_flow = 300_000 - 120_000 - 60_000 net_change_before_exchange_effect = ( direct_operating_cash_flow + investing_cash_flow + financing_cash_flow ) print("\nDEALS AND ACTIVITY SECTIONS") show("Net acquisition cash used", -net_acquisition_cash_used) show("Net disposal cash provided", net_disposal_cash_provided) show("Net cash used in investing activities", investing_cash_flow) show("Net cash provided by financing activities", financing_cash_flow) show("Net change before exchange-rate effect", net_change_before_exchange_effect) # Step 4: reconcile the combined cash population, including restricted cash. opening_population = 500_000 + 80_000 + 20_000 exchange_rate_effect = 5_000 expected_ending_population = ( opening_population + net_change_before_exchange_effect + exchange_rate_effect ) actual_ending_population = 430_000 + 80_000 + 80_000 # This transfer changes location, not the combined population. internal_transfer = -50_000 + 50_000 # These events did not move cash and never enter the three sections. noncash_activity = 90_000 + 60_000 print("\nCASH-POPULATION AND NONCASH CONTROLS") show("Beginning cash population", opening_population) show("Exchange-rate effect", exchange_rate_effect) show("Expected ending cash population", expected_ending_population) show("Ending population from locations", actual_ending_population) show("Population difference", expected_ending_population - actual_ending_population) show("Internal population-transfer control", internal_transfer) show("Noncash activity disclosed separately", noncash_activity) assert direct_operating_cash_flow == 220_000 assert indirect_operating_cash_flow == direct_operating_cash_flow assert investing_cash_flow == -355_000 assert financing_cash_flow == 120_000 assert expected_ending_population == actual_ending_population == 590_000 assert internal_transfer == 0 print("\nAll arithmetic controls pass. Professional judgments remain supplied inputs.")