Files
gomag-vending/api
Claude Agent e42b1f63b7 fix(address): ORA-06502 pe apart/scara/etaj token lung + strip city+region din adresa GoMag
Doua root cause-uri pentru ORA-12899 la importul comenzii #485841056:

1. Oracle ORA-06502: v_apart/v_scara/v_bloc/v_etaj in cauta_sau_creeaza_adresa
   declarate VARCHAR2(10/20/30) → Oracle mostenea constrangerea pe OUT parametrii
   din parseaza_adresa_semicolon → crash INAINTE de fix-ul overflow de la linia 521.
   Fix: marite la VARCHAR2(100).

2. Python format_address_for_oracle stripuia doar city exact, nu si 'city region'
   sau 'region city'. GoMag trimite adresa cu suffix 'Municipiul Bucuresti Bucuresti'
   (city+region) → token urias pentru apartament → declansa ORA-06502 de mai sus.
   Fix: incearca toate combinatiile city+region, region+city, city, region.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 10:31:05 +00:00
..

GoMag Import Manager - FastAPI Application

Admin interface si orchestrator pentru importul comenzilor GoMag in Oracle ROA.

Componente

Core

  • main.py - Entry point FastAPI, lifespan (Oracle pool + SQLite init), file logging
  • config.py - Settings via pydantic-settings (citeste .env)
  • database.py - Oracle connection pool + SQLite schema + helpers

Routers (HTTP Endpoints)

Router Prefix Descriere
health /health, /api/health Status Oracle + SQLite
dashboard / Dashboard HTML cu stat cards
mappings /mappings, /api/mappings CRUD ARTICOLE_TERTI + CSV
articles /api/articles Cautare NOM_ARTICOLE
validation /api/validate Scanare + validare SKU-uri
sync /sync, /api/sync Import orchestration + scheduler

Services (Business Logic)

Service Rol
mapping_service CRUD pe ARTICOLE_TERTI (Oracle)
article_service Cautare in NOM_ARTICOLE (Oracle)
import_service Port din VFP: partner/address/order creation
sync_service Orchestrare: read JSONs → validate → import → log
price_sync_service Sync preturi GoMag → Oracle politici de pret
invoice_service Verificare facturi ROA + cache SQLite
validation_service Batch-validare SKU-uri (chunks of 500)
order_reader Citire gomag_orders_page*.json din vfp/output/
sqlite_service CRUD pe SQLite (sync_runs, import_orders, missing_skus)
scheduler_service APScheduler - sync periodic configurabil din UI

Rulare

pip install -r requirements.txt
# INTOTDEAUNA via start.sh din project root (seteaza Oracle env vars)
cd .. && ./start.sh

Testare

# Din project root:
./test.sh ci       # Teste rapide (unit + e2e, ~30s, fara Oracle)
./test.sh full     # Teste complete (inclusiv Oracle, ~2-3 min)
./test.sh unit     # Doar unit tests
./test.sh e2e      # Doar browser tests (Playwright)
./test.sh oracle   # Doar Oracle integration

Dual Database

  • Oracle - date ERP (ARTICOLE_TERTI, NOM_ARTICOLE, COMENZI)
  • SQLite - tracking local (sync_runs, import_orders, missing_skus, scheduler_config)

Logging

Log files in ../logs/sync_comenzi_YYYYMMDD_HHMMSS.log Format: 2026-03-11 14:30:25 | INFO | app.services.sync_service | mesaj