#!/usr/bin/env python3
"""
Check detailed vehicle data for MNO-345 and PQR-678.
"""
import asyncio
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from app.db.session import AsyncSessionLocal
from app.models.vehicle.asset import Asset

async def check_details():
    async with AsyncSessionLocal() as db:
        # Get specific vehicles
        asset_stmt = select(Asset).where(
            Asset.license_plate.in_(["MNO-345", "PQR-678"])
        )
        asset_result = await db.execute(asset_stmt)
        assets = asset_result.scalars().all()
        
        print(f"✅ Found {len(assets)} vehicles:")
        for asset in assets:
            print(f"\n   Vehicle: {asset.license_plate}")
            print(f"   - Asset ID: {asset.id}")
            print(f"   - Owner Person ID: {asset.owner_person_id}")
            print(f"   - Operator Person ID: {asset.operator_person_id}")
            print(f"   - Owner Org ID: {asset.owner_org_id}")
            print(f"   - Operator Org ID: {asset.operator_org_id}")
            print(f"   - Branch ID: {asset.branch_id}")
            print(f"   - Current Org ID: {asset.current_organization_id}")
            print(f"   - Status: {asset.status}")
            print(f"   - Data Status: {asset.data_status}")
            
            # Check personal mode conditions
            owner_org_none = asset.owner_org_id is None
            operator_org_none = asset.operator_org_id is None
            print(f"   - Owner Org is None: {owner_org_none}")
            print(f"   - Operator Org is None: {operator_org_none}")
            
            # Check if it would appear in personal mode
            would_appear_personal = (owner_org_none or operator_org_none)
            print(f"   - Would appear in personal mode: {would_appear_personal}")
            
            # Check corporate mode conditions
            print(f"   - Would appear in corporate mode (org 15): {asset.current_organization_id == 15}")
            print(f"   - Would appear in corporate mode (org 21): {asset.current_organization_id == 21}")

if __name__ == "__main__":
    asyncio.run(check_details())