#!/usr/bin/env python3 """Reproduce Linden Peak's research and software cost ledger. Run from the repository root with ``uv run python`` and this file's path. This script checks arithmetic after the accounting routes have been supplied. It does not determine R&D scope, software purpose, adoption, cloud contract rights, technological feasibility, or cost eligibility. """ def money(amount: float) -> str: """Format a number as accounting-style US dollars.""" return f"${amount:,.2f}" def show_section(title: str) -> None: print(f"\n{title}") print("-" * len(title)) # Each list contains plain-English labels and supplied dollar amounts. ordinary_research_and_development = [ ("Laboratory payroll", 240_000.00), ("Consumed prototype materials", 60_000.00), ("Pre-feasibility marketed-software work", 200_000.00), ] other_period_costs = [ ("Preliminary internal-software work", 45_000.00), ("Internal-software training", 30_000.00), ("Hosting training", 20_000.00), ("Annual hosting subscription", 90_000.00), ("Post-availability product maintenance", 30_000.00), ] capitalized_costs = [ ("Successful patent filing cost", "Finite-lived intangible", 18_000.00), ( "Application work before uncertainty resolves", "Internal-use software", 60_000.00, ), ( "Application work after uncertainty resolves", "Internal-use software", 120_000.00, ), ("Qualifying hosting configuration", "Hosting implementation", 80_000.00), ("Post-feasibility product work", "External-use software", 150_000.00), ] show_section("1. Ordinary R&D expense") for label, amount in ordinary_research_and_development: print(f"{label:<44} {money(amount):>16}") research_and_development_expense = sum(amount for _, amount in ordinary_research_and_development) print(f"{'R&D expense':<44} {money(research_and_development_expense):>16}") show_section("2. Other period costs") for label, amount in other_period_costs: print(f"{label:<44} {money(amount):>16}") other_period_expense = sum(amount for _, amount in other_period_costs) print(f"{'Other period expense':<44} {money(other_period_expense):>16}") show_section("3. Capitalized destinations") for label, destination, amount in capitalized_costs: print(f"{label:<48} {destination:<25} {money(amount):>16}") total_capitalized = sum(amount for _, _, amount in capitalized_costs) print(f"{'Total capitalized':<74} {money(total_capitalized):>16}") show_section("4. Current and pending software comparison") current_software_capitalized = 60_000.00 + 120_000.00 current_software_expensed = 45_000.00 + 30_000.00 pending_software_capitalized = 120_000.00 pending_software_expensed = 45_000.00 + 60_000.00 + 30_000.00 print(f"{'Current content: capitalized':<44} {money(current_software_capitalized):>16}") print(f"{'Current content: expensed':<44} {money(current_software_expensed):>16}") print(f"{'Pending comparison: capitalized':<44} {money(pending_software_capitalized):>16}") print(f"{'Pending comparison: expensed':<44} {money(pending_software_expensed):>16}") if abs(current_software_capitalized + current_software_expensed - 255_000.00) > 0.005: raise SystemExit("FAIL: current software comparison does not reconcile") if abs(pending_software_capitalized + pending_software_expensed - 255_000.00) > 0.005: raise SystemExit("FAIL: pending software comparison does not reconcile") show_section("5. Deferred hosting implementation amortization") deferred_hosting_cost = 80_000.00 hosting_term_months = 36 months_in_period = 12 monthly_hosting_amortization = deferred_hosting_cost / hosting_term_months period_hosting_amortization = monthly_hosting_amortization * months_in_period ending_deferred_hosting_cost = deferred_hosting_cost - period_hosting_amortization print(f"{'Deferred implementation cost':<44} {money(deferred_hosting_cost):>16}") print(f"{'Monthly amortization':<44} {money(monthly_hosting_amortization):>16}") print(f"{'Twelve-month expense':<44} {money(period_hosting_amortization):>16}") print(f"{'Ending deferred balance':<44} {money(ending_deferred_hosting_cost):>16}") if abs(period_hosting_amortization + ending_deferred_hosting_cost - deferred_hosting_cost) > 0.005: raise SystemExit("FAIL: hosting amortization does not reconcile") show_section("6. Reconciliation") total_expense = research_and_development_expense + other_period_expense total_cost_ledger = total_expense + total_capitalized print(f"{'Total expense':<44} {money(total_expense):>16}") print(f"{'Total capitalized':<44} {money(total_capitalized):>16}") print(f"{'Total cost ledger':<44} {money(total_cost_ledger):>16}") expected_cost_ledger = 1_143_000.00 if abs(total_cost_ledger - expected_cost_ledger) > 0.005: raise SystemExit("FAIL: cost destinations do not reconcile to the supplied ledger") print("\nPASS: expense plus capitalized destinations reconcile to $1,143,000.00.") print("Boundary: PASS verifies arithmetic only; the supplied scope decisions still need review.")