
#!/usr/bin/env python3
"""
Debug Application Rates - Check if applications have proposed_rate values
"""

from app import create_app
from app.models import Application, Job, User

def debug_application_rates():
    """Check all applications and their proposed rates"""
    
    print("🔍 DEBUGGING APPLICATION RATES")
    print("=" * 50)
    
    app = create_app()
    
    with app.app_context():
        applications = Application.query.all()
        
        if not applications:
            print("❌ No applications found in database")
            return
        
        print(f"📊 Found {len(applications)} applications:")
        
        for app_obj in applications:
            job = app_obj.job
            worker = app_obj.worker
            
            print(f"\n📋 Application #{app_obj.id}")
            print(f"   Job: {job.title}")
            print(f"   Worker: {worker.first_name} {worker.last_name}")
            print(f"   Status: {app_obj.status}")
            print(f"   💰 Proposed Rate: {app_obj.proposed_rate}")
            print(f"   Job Budget Range: ${job.budget_min} - ${job.budget_max}")
            print(f"   Job Hourly Rate: ${job.hourly_rate}")
            
            if app_obj.proposed_rate is None:
                print("   ⚠️  WARNING: No proposed rate set!")
            else:
                print(f"   ✅ Proposed rate: ${app_obj.proposed_rate}")

if __name__ == "__main__":
    debug_application_rates()
