"""Quick module status check - prints only the summary table."""
import requests

BASE = "http://localhost:8010/api/v1"
resp = requests.post(f"{BASE}/auth/login-json", json={"username": "superadmin", "password": "Super@dmin123"})
tok = resp.json().get("access_token", "")
H = {"Authorization": f"Bearer {tok}"}

checks = [
    ("Sales / Customers",       f"{BASE}/sales/customers/count"),
    ("Sales / Invoices",        f"{BASE}/sales/invoices?limit=1"),
    ("Sales / Sales",           f"{BASE}/sales/?limit=1"),
    ("Inventory / Products",    f"{BASE}/inventory/products?limit=1"),
    ("Purchases / Suppliers",   f"{BASE}/purchases/suppliers?limit=1"),
    ("Purchases / POs",         f"{BASE}/purchases/orders?limit=1"),
    ("Accounting / Accounts",   f"{BASE}/accounting/codes?limit=1"),
    ("Banking / Accounts",      f"{BASE}/banking/accounts?limit=1"),
    ("Users",                   f"{BASE}/users?limit=1"),
    ("Branches",                f"{BASE}/branches"),
    ("VAT Transactions",        f"{BASE}/vat/transactions?limit=1"),
    ("Asset Management",        f"{BASE}/asset-management/assets?limit=1"),
    ("Budgeting",               f"{BASE}/budgeting/budgets?limit=1"),
    ("Manufacturing Products",  f"{BASE}/manufacturing/products?limit=1"),
    ("POS Sessions",            f"{BASE}/pos/sessions?limit=1"),
    ("General Ledger Entries",  f"{BASE}/general-ledger/general-ledger?limit=1"),
    ("Settings",                f"{BASE}/settings/"),
    ("Quotations",              f"{BASE}/quotations?limit=1"),
    ("Job Cards",               f"{BASE}/job-cards?limit=1"),
    ("Serial Numbers",          f"{BASE}/serial-numbers?limit=1"),
    ("Unit of Measure",         f"{BASE}/unit-of-measure?limit=1"),
    ("Credit Notes",            f"{BASE}/credit-notes?limit=1"),
    ("Invoices",                f"{BASE}/invoices?limit=1"),
    ("Roles",                   f"{BASE}/roles"),
    ("Notifications",           f"{BASE}/notifications?limit=1"),
]

print(f"{'Module':<32} {'Status'}")
print("-" * 45)
all_ok = True
for name, url in checks:
    try:
        r = requests.get(url, headers=H, timeout=5)
        if r.status_code == 200:
            print(f"{name:<32} OK")
        else:
            print(f"{name:<32} FAIL ({r.status_code})")
            all_ok = False
    except Exception as e:
        print(f"{name:<32} ERROR {e}")
        all_ok = False

print()
print(f"All modules OK: {all_ok}")
