Files
gomag-vending/api
Claude Agent 227dabd6d4 feat(settings): add GoMag API config, Oracle dropdowns, compact 2x2 layout
- Remove ID_GESTIUNE from config (unused)
- Add GoMag API settings (key, shop, days_back, limit) to SQLite — editable without restart
- sync_service reads GoMag settings from SQLite before download
- gomag_client.download_orders accepts api_key/api_shop/limit overrides
- New GET /api/settings/sectii and /api/settings/politici endpoints for Oracle dropdowns
  (nom_sectii.sectie, crm_politici_preturi.nume_lista_preturi)
- id_pol, id_sectie, transport_id_pol, discount_id_pol now use select dropdowns
- order_reader extracts discount_vat from GoMag JSON discounts[].vat
- import_service uses GoMag discount_vat as primary, settings as fallback
- settings.html redesigned to compact 2x2 grid (GoMag API | Import ROA / Transport | Discount)
- settings.js v2: loadDropdowns() sequential before loadSettings()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 16:39:59 +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
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
uvicorn app.main:app --host 0.0.0.0 --port 5003 --reload

Testare

# Test A - fara Oracle (verifica importuri + rute)
python test_app_basic.py

# Test C - cu Oracle (integrare completa)
python test_integration.py

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