gigafibre-fsm/scripts/migration/check_items.py
louispaulb 607ea54b5c refactor: reduce token count, DRY code, consolidate docs
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>
2026-04-13 08:39:58 -04:00

26 lines
1.1 KiB
Python

"""Check what item_code/item_name values look like in tabSales Invoice Item."""
import frappe, 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()
r = frappe.db.sql('SELECT item_code, COUNT(*) as cnt FROM "tabSales Invoice Item" GROUP BY item_code ORDER BY cnt DESC LIMIT 20')
print("item_code distribution:")
for row in r:
print(f" {row[1]:>10} {repr(row[0])}")
r2 = frappe.db.sql('SELECT item_name, COUNT(*) as cnt FROM "tabSales Invoice Item" GROUP BY item_name ORDER BY cnt DESC LIMIT 15')
print("\nitem_name distribution:")
for row in r2:
print(f" {row[1]:>10} {repr(row[0][:80] if row[0] else None)}")
# Check a sample invoice with items
r3 = frappe.db.sql("""SELECT sii.item_code, sii.item_name, sii.description, sii.income_account
FROM "tabSales Invoice Item" sii LIMIT 5""")
print("\nSample items:")
for row in r3:
print(f" code={repr(row[0][:40] if row[0] else None)} name={repr(row[1][:40] if row[1] else None)} acct={row[3]}")
frappe.destroy()