diff --git a/backend/debug_mapper.py b/backend/debug_mapper.py deleted file mode 100644 index cc19459b..00000000 --- a/backend/debug_mapper.py +++ /dev/null @@ -1,15 +0,0 @@ -from api.v1.modules.a76.general_catalogs.company.models import Company -from api.v1.modules.a76.general_catalogs.company.service import CompanyService -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker - -print("Checking Company Mapper keys...") -try: - keys = Company.__mapper__.c.keys() - print(f"Keys found: {keys}") - if 'logo' in keys: - print("SUCCESS: 'logo' is in keys") - else: - print("FAILURE: 'logo' is NOT in keys") -except Exception as e: - print(f"Error: {e}") diff --git a/backend/inspect_schema.py b/backend/inspect_schema.py deleted file mode 100644 index 63a44ca6..00000000 --- a/backend/inspect_schema.py +++ /dev/null @@ -1,20 +0,0 @@ -from sqlalchemy import create_engine, text - -# Connect to DB (adjust for localhost) -DB_URL = "postgresql://postgres:postgres@localhost:5432/anexo76_core" -engine = create_engine(DB_URL) - -sql = """ -SELECT column_name, data_type, character_maximum_length -FROM information_schema.columns -WHERE table_name = 'company' AND table_schema = 'a76' -AND column_name IN ('has_express_line', 'is_service_company'); -""" - -try: - with engine.connect() as conn: - result = conn.execute(text(sql)) - for row in result: - print(f"Column: {row[0]}, Type: {row[1]}, Length: {row[2]}") -except Exception as e: - print(f"Error: {e}") diff --git a/backend/verify_logo_presence.py b/backend/verify_logo_presence.py deleted file mode 100644 index 9ccabeb1..00000000 --- a/backend/verify_logo_presence.py +++ /dev/null @@ -1,32 +0,0 @@ -from api.v1.modules.a76.general_catalogs.company.models import Company -from api.v1.modules.a76.general_catalogs.company.service import CompanyService -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker, Session -import os - -# Connect to DB (adjust for localhost) -DB_URL = "postgresql://postgres:postgres@localhost:5432/anexo76_core" -engine = create_engine(DB_URL) -SessionLocal = sessionmaker(bind=engine) -session = SessionLocal() - -try: - print("Querying first company...") - company = session.query(Company).first() - if company: - print(f"Company ID: {company.id}") - print(f"Direct Logo Access: '{company.logo}'") - - service = CompanyService(session) - flattened = service.flatten_company_dto(company) - - print(f"Flattened Logo: '{flattened.get('logo')}'") - - has_logo = 'logo' in flattened - print(f"Is 'logo' key in dict?: {has_logo}") - else: - print("No companies found in DB.") -except Exception as e: - print(f"Error: {e}") -finally: - session.close() diff --git a/debug_values.py b/debug_values.py deleted file mode 100644 index 337140ee..00000000 --- a/debug_values.py +++ /dev/null @@ -1,76 +0,0 @@ -from sqlalchemy import create_engine, text -from sqlalchemy.orm import sessionmaker -from api.v1.modules.a76.items.line_items.models import LineItem -from api.v1.modules.a76.items.line_quantities.models import LineQuantity -from api.v1.modules.a76.items.line_financials.models import LineFinancial -from api.v1.modules.a76.parts.models import Part -from api.v1.modules.a76.invoices.models import InvoiceHeader -from api.v1.modules.a76.pedmientos.models import Pedimentos - -# Setup DB (Adjust connection string if needed, checking environment assumption) -# Assuming local connection string or deriving from environment/config -# For this environment, I'll attempt a standard connection or reuse existing if possible. -# Since I cannot easily import 'db' from main app without setup, I will rely on standard raw SQL or simple ORM setup if I can import 'Session'. -# Using the imports available in the user's file. - -import sys -sys.path.append('/home/josmar/dev/anexo76/backend') - -from core.database import CoreSessionLocal - -# Manual Session creation -db = CoreSessionLocal() - -try: - # 1. Find the lines matching the description (Qty 1500 + HTS) - # The user said HTS: 2710190650 - # Qty: 1500 - - print("--- SEARCHING FOR LINES ---") - - # We look for lines with quantity 1500 first - candidates = db.query(LineItem).join(LineQuantity).filter( - LineQuantity.quantity == 1500 - ).all() - - found = False - for line in candidates: - part = db.query(Part).filter(Part.id == line.part_number).first() - fin = db.query(LineFinancial).filter(LineFinancial.item_line_id == line.id).first() - inv = db.query(InvoiceHeader).filter(InvoiceHeader.id == line.item.invoice_id).first() if line.item else None - - us_frac = part.us_fraction if part else "N/A" - - # Check fraction match (loose match) - if "2710190650" in us_frac.replace(".","").replace(" ",""): - found = True - print(f"\nMATCH FOUND: Line ID {line.id} - Invoice {inv.invoice_number if inv else 'N/A'}") - print(f"HTS: {us_frac}") - print(f"Qty: {1500}") - print(f"Inv Currency: {inv.financials.currency} / {inv.financials.currency_type} Rate: {inv.financials.exchange_rate}") - - print("\nFINANCIALS:") - if fin: - print(f" value_usd: {fin.value_usd}") - print(f" value_mxn: {fin.value_mxn}") - print(f" value_commercial_usd: {fin.value_commercial_usd}") - print(f" value_commercial_mxn: {fin.value_commercial_mxn}") - print(f" unit_cost_usd: {fin.unit_cost_usd}") - print(f" unit_cost_commercial_usd: {fin.unit_cost_commercial_usd}") - print(f" unit_cost_mxn: {fin.unit_cost_mxn}") - - # Check calculation hypothesis - val_usd = float(fin.value_usd or 0) - val_mxn = float(fin.value_mxn or 0) - rate = float(inv.financials.exchange_rate or 1) - - print(f"\n If using ValueMXN/Rate: {val_mxn} / {rate} = {val_mxn/rate}") - print(f" If using Max(MXN, USD): {max(val_mxn, val_usd)}") - else: - print(" No Financials found.") - - if not found: - print("No matching line (1500 qty, HTS 2710190650) found.") - -finally: - db.close()