Backend services: - targo-hub: extract deepGetValue to helpers.js, DRY disconnect reasons lookup map, compact CAPABILITIES, consolidate vision.js prompts/schemas, extract dispatch scoring weights, trim section dividers across 9 files - modem-bridge: extract getSession() helper (6 occurrences), resetIdleTimer(), consolidate DM query factory, fix duplicate username fill bug, trim headers (server.js -36%, tplink-session.js -47%, docker-compose.yml -57%) Frontend: - useWifiDiagnostic: extract THRESHOLDS const, split processDiagnostic into 6 focused helpers (processOnlineStatus, processWanIPs, processRadios, processMeshNodes, processClients, checkRadioIssues) - EquipmentDetail: merge duplicate ROLE_LABELS, remove verbose comments Documentation (17 → 13 files, -1,400 lines): - New consolidated README.md (architecture, services, dependencies, auth) - Merge ECOSYSTEM-OVERVIEW into ARCHITECTURE.md - Merge MIGRATION-PLAN + ARCHITECTURE-COMPARE + FIELD-GAP + CHANGELOG → MIGRATION.md - Merge COMPETITIVE-ANALYSIS into PLATFORM-STRATEGY.md - Update ROADMAP.md with current phase status - Delete CONTEXT.md (absorbed into README) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
"""Debug idx matching between legacy and ERPNext."""
|
|
import frappe, pymysql, os, sys
|
|
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
|
|
os.chdir("/home/frappe/frappe-bench/sites")
|
|
frappe.init(site="erp.gigafibre.ca", sites_path=".")
|
|
frappe.connect()
|
|
|
|
# Get an invoice that still has default income
|
|
r = frappe.db.sql("""
|
|
SELECT si.name, si.legacy_invoice_id
|
|
FROM "tabSales Invoice" si
|
|
JOIN "tabSales Invoice Item" sii ON sii.parent = si.name
|
|
WHERE sii.income_account = %s AND si.legacy_invoice_id > 0
|
|
LIMIT 1
|
|
""", ("Autres produits d'exploitation - T",))
|
|
|
|
if not r:
|
|
print("No invoices found with default account!")
|
|
frappe.destroy()
|
|
exit()
|
|
|
|
inv_name, legacy_id = r[0]
|
|
print(f"Invoice: {inv_name}, legacy_id: {legacy_id}")
|
|
|
|
# ERPNext items
|
|
items = frappe.db.sql("""
|
|
SELECT idx, item_name, income_account FROM "tabSales Invoice Item"
|
|
WHERE parent = %s ORDER BY idx
|
|
""", (inv_name,))
|
|
print(f"\nERPNext items (idx):")
|
|
for row in items:
|
|
print(f" idx={row[0]} {row[2]} {row[1][:60]}")
|
|
|
|
# Legacy items
|
|
legacy = pymysql.connect(
|
|
host="legacy-db", user="facturation", password="VD67owoj",
|
|
database="gestionclient", cursorclass=pymysql.cursors.DictCursor
|
|
)
|
|
with legacy.cursor() as cur:
|
|
cur.execute("""
|
|
SELECT id, sku, product_name,
|
|
ROW_NUMBER() OVER (PARTITION BY invoice_id ORDER BY id) as rn
|
|
FROM invoice_item WHERE invoice_id = %s ORDER BY id
|
|
""", (int(legacy_id),))
|
|
litems = cur.fetchall()
|
|
legacy.close()
|
|
|
|
print(f"\nLegacy items (ROW_NUMBER):")
|
|
for li in litems:
|
|
print(f" rn={li['rn']} sku={li['sku']} {li['product_name'][:60]}")
|
|
|
|
frappe.destroy()
|