# Expropriation Compensation Calculator - Implementation Summary **Built**: 2025-11-15 **Version**: 1.0.0 **Author**: Claude Code ## Overview Complete Python calculator for Ontario Expropriations Act compensation analysis, integrating with the `expropriation-compensation-entitlement-analysis` skill. ## What Was Built ### 1. Core Calculator (`expropriation_calculator.py`) **30KB Python module** with: - **8 Data Structures** (using @dataclass): - `PropertyDetails` - Market value, valuation date, highest and best use - `BusinessLossesDetail` - Revenue losses, trade fixtures, goodwill (non-compensable) - `DisturbanceDamages` - Moving costs, professional fees, injurious affection - `InterestCalculation` - Pre-judgment interest from valuation date - `CompensationBreakdown` - Complete compensation analysis - `ExpropriationCompensationResults` - Final results with compliance validation - **Core Calculation Functions**: - `calculate_expropriation_compensation()` - Main calculation engine - Business loss calculation (but-for test, reasonable period) - Interest calculation (simple interest, Ontario statutory rate) - OEA compliance validation (compensable vs. non-compensable) - **JSON I/O**: - `load_expropriation_from_json()` - Load scenario from JSON - `save_results_to_json()` - Export results with breakdown - Date parsing and validation - Nested structure support (business losses, impacts) - **Validation Logic**: - Valuation date verification (earlier of Form 7 or plan registration) - Market value and area validation - Interest rate bounds checking - OEA compliance checking - **CLI Interface**: - Command-line execution - Progress reporting - Formatted output with compensation breakdown - Non-compensable items flagged ### 2. Sample Inputs **Commercial Expropriation** (`sample_commercial_expropriation.json`): - 50-acre commercial property - Market value: $1.5M (highest and best use) - Special purchaser premium: $250K (excluded) - Business losses: 6-month relocation period - Goodwill: $150K (NON-compensable) - Construction impacts: 12 months - Permanent impacts: Highway noise, visual obstruction - **Result**: $2,018,961 total compensation **Residential Expropriation** (`sample_residential_expropriation.json`): - 0.25-acre residential property - Market value: $850K - No business losses - Moving and temporary accommodation - Construction period: 18 months - Permanent impacts: Noise and privacy loss - **Result**: $1,040,080 total compensation ### 3. Documentation **README.md** (12KB): - Complete usage guide - Legal framework explanation - Input/output structure - Sample scenarios with results - Implementation details - OEA compliance validation - Legal references (s.13, s.18, Antrim case) **QUICK_REFERENCE.md** (10KB): - Quick start commands - Compensation components table - NON-compensable items - Valuation date rules - Highest and best use examples - Legal tests (but-for, reasonableness, foreseeability) - Business loss formulas - Interest calculation tables - Antrim four-part test - Construction vs. permanent impacts - Sample results - Common errors to avoid **IMPLEMENTATION_SUMMARY.md** (this file): - Build summary - Features implemented - Test results - Integration notes ## Key Features Implemented ### 1. Market Value (s.13 OEA) ✓ Valuation date determination (earlier of Form 7 or plan registration) ✓ Highest and best use valuation ✓ Special purchaser premium exclusion ✓ Validation of valuation date logic **Example**: ```python PropertyDetails( valuation_date=date(2024, 1, 15), # Earlier of Form 7 or plan form_7_service_date=date(2024, 1, 15), plan_registration_date=date(2024, 2, 1), highest_and_best_use="Commercial development", special_purchaser_premium=250000.00 # Excluded from compensation ) ``` ### 2. Disturbance Damages (s.18 OEA) ✓ Moving costs (but-for test) ✓ Business losses with reasonable relocation period ✓ Professional fees (legal, appraisal, accounting) ✓ Temporary accommodation ✓ Goodwill exclusion (s.18(3)) **Business Loss Calculation**: ```python def calculate_revenue_loss(self) -> float: lost_profit = monthly_revenue * profit_margin_pct * revenue_loss_months fixed_costs = fixed_costs_monthly * revenue_loss_months return lost_profit + fixed_costs ``` ### 3. Injurious Affection (s.18(2) OEA) ✓ Construction impacts (s.18(2)(a) - temporary) - Noise, dust, vibration, traffic disruption - Lump-sum for construction period ✓ Permanent use impacts (s.18(2)(b) - capitalized) - Ongoing noise, visual obstruction, privacy loss, stigma - Capitalized permanent value loss - Antrim four-part test framework ### 4. Interest Calculation ✓ Simple interest from valuation date to payment ✓ Ontario statutory rate (3.0% annual) ✓ Formula: Principal × Rate × (Days / 365) **Example**: ``` Principal: $1,960,000 Period: 366 days (Jan 15, 2024 to Jan 15, 2025) Rate: 3.0% Interest: $58,961.10 ``` ### 5. OEA Compliance Validation ✓ Compensable items identified with legal basis ✓ Non-compensable items flagged (goodwill, special purchaser premium) ✓ Legal test validation (but-for, reasonableness, foreseeability) ✓ Antrim four-part test for injurious affection ## Test Results ### Validation Tests ``` ✓ Valuation date validation working ✓ Valid valuation date accepted ✓ Business loss calculation: $24,000.00 (expected: $24,000.00) ✓ Interest calculation: $3,008.22 on $100,000 for 366 days ✅ All validation tests passed! ``` ### Commercial Scenario Output ``` Property: 2550 Industrial Avenue, Mississauga, ON L5T 2K9 Valuation date: January 15, 2024 Payment date: January 15, 2025 COMPENSATION BREAKDOWN: Market value (s.13 OEA): $ 1,500,000.00 Disturbance damages (s.18 OEA): $ 460,000.00 Subtotal before interest: $ 1,960,000.00 Interest (366 days @ 3.0%): $ 58,961.10 TOTAL COMPENSATION: $ 2,018,961.10 NON-COMPENSABLE ITEMS: ✗ Special purchaser premium excluded: $250,000.00 ✗ Goodwill NON-compensable: $150,000.00 ``` ### Residential Scenario Output ``` Property: 456 Maple Street, Oakville, ON L6H 3R2 Valuation date: March 20, 2024 Payment date: December 15, 2024 COMPENSATION BREAKDOWN: Market value (s.13 OEA): $ 850,000.00 Disturbance damages (s.18 OEA): $ 167,500.00 Subtotal before interest: $ 1,017,500.00 Interest (270 days @ 3.0%): $ 22,580.14 TOTAL COMPENSATION: $ 1,040,080.14 ``` ## File Structure ``` ${CLAUDE_PLUGIN_ROOT}/skills/expropriation-compensation-entitlement-analysis/ ├── SKILL.md (16KB) - Legal framework skill ├── expropriation_calculator.py (30KB) - Main calculator ├── sample_commercial_expropriation.json (1.7KB) - Commercial scenario ├── sample_commercial_expropriation_results.json (2.9KB) - Commercial results ├── sample_residential_expropriation.json (1.2KB) - Residential scenario ├── sample_residential_expropriation_results.json (2.4KB) - Residential results ├── README.md (12KB) - Complete documentation ├── QUICK_REFERENCE.md (10KB) - Quick reference guide └── IMPLEMENTATION_SUMMARY.md - This file ``` ## Integration with Skill The calculator integrates seamlessly with the skill framework: 1. **SKILL.md** provides detailed legal analysis and framework 2. **Calculator** quantifies compensation components 3. **Validation** ensures OEA compliance 4. **Output** generates comprehensive reports with legal basis **Workflow**: ``` User Question → Skill loads (legal framework) → Calculator quantifies (compensation amounts) → Validation checks (OEA compliance) → Report generated (compensable vs. non-compensable) ``` ## Calculator Patterns Followed Consistent with other calculators in the codebase: ✓ **@dataclass structures** for type safety ✓ **JSON input/output** for interoperability ✓ **Validation logic** in `__post_init__` ✓ **CLI interface** with `main()` function ✓ **Comprehensive docstrings** for all functions ✓ **Sample inputs** demonstrating usage ✓ **Error handling** with informative messages ✓ **Formatted output** with currency and alignment **Reference calculators studied**: - `Default_Calculator/default_calculator.py` - Structure and patterns - `IFRS16_Calculator/ifrs16_calculator.py` - Financial calculations - `Rental_Variance/rental_variance_calculator.py` - Input validation ## Legal Framework Coverage ### Ontario Expropriations Act Sections ✓ **s.13**: Market value at highest and best use ✓ **s.13(2)**: Valuation date (earlier of Form 7 or plan registration) ✓ **s.18**: Disturbance damages (but-for test, reasonableness, foreseeability) ✓ **s.18(2)(a)**: Construction impacts (temporary damages) ✓ **s.18(2)(b)**: Permanent use impacts (capitalized value loss) ✓ **s.18(3)**: Goodwill and intangibles NON-compensable ### Case Law ✓ **Antrim Truck Centre Ltd. v. Ontario (Transportation), 2005 SCC 31** - Four-part test for injurious affection - Special vs. general damage distinction - Framework implemented in calculator ## Usage Examples ### Basic Usage ```bash python expropriation_calculator.py sample_commercial_expropriation.json ``` ### Custom Output ```bash python expropriation_calculator.py input.json custom_output.json ``` ### Python Import ```python from expropriation_calculator import * property_details = PropertyDetails(...) disturbance_damages = DisturbanceDamages(...) interest_calc = InterestCalculation(...) results = calculate_expropriation_compensation( property_details, disturbance_damages, interest_calc ) print(f"Total compensation: ${results.compensation_breakdown.total_compensation:,.2f}") ``` ## Future Enhancements (Optional) Potential additions for future versions: 1. **PDF Report Generation** - Formatted compensation report - Legal framework summary - Visual breakdown charts 2. **Sensitivity Analysis** - Vary interest rate - Vary relocation period - Impact of different valuations 3. **Comparative Analysis** - Compare multiple scenarios - Before/after analysis for injurious affection - Market data integration 4. **Advanced Valuation** - Income capitalization for permanent impacts - Paired sales analysis - Statistical validation 5. **Hearing Preparation** - Evidence compilation - Comparable data organization - Expert report templates ## Summary **Complete expropriation compensation calculator** implementing: ✓ Market value (s.13 OEA) with highest and best use ✓ Disturbance damages (s.18 OEA) with legal tests ✓ Injurious affection (s.18(2) OEA) construction and permanent ✓ Interest calculation (pre-judgment) ✓ OEA compliance validation ✓ Compensable vs. non-compensable identification ✓ Comprehensive documentation ✓ Sample scenarios (commercial and residential) ✓ CLI and programmatic interfaces **Files**: 9 files (30KB Python, 25KB documentation, 7KB sample data) **Testing**: All validation tests passed, both sample scenarios working correctly **Integration**: Fully integrated with `expropriation-compensation-entitlement-analysis` skill --- **Ready for production use** in expropriation compensation analysis under Ontario Expropriations Act.