fix(anaf): handle notFound integers, skip 4xx retry, propagate errors to run log
ANAF notFound items are plain integers, not dicts — caused 'int has no attribute get'. 4xx errors (like 404) no longer retry uselessly. ANAF errors now appear in the UI sync log via log_fn callback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -683,7 +683,9 @@ async def run_sync(id_pol: int = None, id_sectie: int = None, run_id: str = None
|
||||
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)
|
||||
prepop_results = await anaf_service.check_vat_status_batch(
|
||||
prepop_cuis, log_fn=lambda msg: _log_line(run_id, msg)
|
||||
)
|
||||
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")
|
||||
@@ -716,7 +718,9 @@ async def run_sync(id_pol: int = None, id_sectie: int = None, run_id: str = None
|
||||
# Batch ANAF call for uncached CUIs only
|
||||
if uncached_cuis:
|
||||
_log_line(run_id, f"ANAF: verificare {len(uncached_cuis)} CUI-uri noi...")
|
||||
anaf_results = await anaf_service.check_vat_status_batch(uncached_cuis)
|
||||
anaf_results = await anaf_service.check_vat_status_batch(
|
||||
uncached_cuis, log_fn=lambda msg: _log_line(run_id, msg)
|
||||
)
|
||||
if anaf_results:
|
||||
await sqlite_service.bulk_populate_anaf_cache(anaf_results)
|
||||
cached_results.update(anaf_results)
|
||||
|
||||
Reference in New Issue
Block a user