"""Check Joshua's loan status"""
import pymysql

DB_CONFIG = {
    'host': 'localhost',
    'port': 3306,
    'db': 'xygbfpsg_loans',
    'user': 'xygbfpsg_graz',
    'password': 'j.ez-xy6##y.rllB',
    'charset': 'utf8mb4'
}

conn = pymysql.connect(**DB_CONFIG)

with conn.cursor() as cur:
    # Show all loans
    cur.execute("""
        SELECT loan_number, status, is_rolled_over, is_deleted, 
               principal_amount, interest_amount, total_amount
        FROM loans
        ORDER BY created_at DESC
    """)
    rows = cur.fetchall()
    
    print(f"All {len(rows)} loans in database:\n")
    for idx, row in enumerate(rows, 1):
        loan_num, status, is_rolled, is_deleted, principal, interest, total = row
        print(f"{idx}. {loan_num}")
        print(f"   Status: '{status}' | Rolled: {is_rolled} | Deleted: {is_deleted}")
        print(f"   Principal: {principal} | Interest: {interest} | Total: {total}")
        
        button_shows = status in ('active', 'rolled_over') and not is_deleted
        print(f"   Record Payment button shows: {button_shows}")
        print()

conn.close()
