fix(anaf-dedup): fix ANAF parsing, facturare addr, compact modal layout
- Fix ANAF API: extract CUI from date_generale (not top-level), fix notFound casing (capital F) - Fix missing facturare address when same ID as livrare (copy instead of skip) - Replace ANAF cache pre-population stub with real logic (3-month CUIs) - Restructure order detail modal: inline 2-col GOMAG|ROA layout with compact address lines replacing collapsed sections - Fix addrMatch() to use field-level comparison with Romanian abbreviation stripping (STR, NR, BL, SC, AP, ET, ETAJ, APART) - Add dashboard "Diferente" filter pill for ANAF-adjusted orders - Update e2e test for new modal structure Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -638,20 +638,20 @@ async def run_sync(id_pol: int = None, id_sectie: int = None, run_id: str = None
|
||||
0, len(truly_importable),
|
||||
{"imported": 0, "skipped": skipped_count, "errors": 0, "already_imported": already_imported_count})
|
||||
|
||||
# ANAF cache pre-population check
|
||||
# ANAF cache pre-population: CUIs from last 3 months with expired/missing cache
|
||||
try:
|
||||
db_check = await sqlite_service.get_sqlite()
|
||||
try:
|
||||
cursor = await db_check.execute("SELECT COUNT(*) FROM anaf_cache WHERE checked_at > datetime('now', '-7 days')")
|
||||
row = await cursor.fetchone()
|
||||
cache_count = row[0] if row else 0
|
||||
finally:
|
||||
await db_check.close()
|
||||
|
||||
if cache_count < 10:
|
||||
_log_line(run_id, "ANAF pre-populare cache...")
|
||||
prepop_cuis = await sqlite_service.get_expired_cuis_for_prepopulate()
|
||||
if prepop_cuis:
|
||||
_log_line(run_id, f"ANAF pre-populare: {len(prepop_cuis)} CUI-uri cu cache expirat")
|
||||
prepop_results = await anaf_service.check_vat_status_batch(prepop_cuis)
|
||||
if prepop_results:
|
||||
await sqlite_service.bulk_populate_anaf_cache(prepop_results)
|
||||
_log_line(run_id, f"ANAF pre-populare: {len(prepop_results)} rezultate stocate")
|
||||
else:
|
||||
_log_line(run_id, "ANAF pre-populare: cache complet")
|
||||
except Exception as e:
|
||||
logger.warning(f"ANAF cache pre-population check failed: {e}")
|
||||
_log_line(run_id, f"ANAF pre-populare eroare: {e}")
|
||||
logger.warning(f"ANAF cache pre-population failed: {e}")
|
||||
|
||||
# Step 4: ANAF batch verification for company CUIs
|
||||
company_cuis = set()
|
||||
|
||||
Reference in New Issue
Block a user