Busca correta da unidade cosumidora na fatura
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -29,14 +29,19 @@ def extrair_dados(texto_final):
|
||||
|
||||
nota_fiscal = extrair_seguro(r'NOTA FISCAL Nº\s*(\d+)', texto_final)
|
||||
|
||||
# --- Unidade Consumidora (UC): 8–12 dígitos, SEM hífen ---
|
||||
uc = extrair_seguro([
|
||||
r'(\d{7,10}-\d)',
|
||||
r'UNIDADE\s+CONSUMIDORA\s*[:\-]?\s*(\d{6,})',
|
||||
r'(\d{6,})\s+FAZENDA',
|
||||
r'(\d{6,})\s+AVENIDA',
|
||||
r'(\d{6,})\s+RUA'
|
||||
r'UNIDADE\s*CONSUMIDORA\D*?(\d{8,12})',
|
||||
r'\bUC\D*?(\d{8,12})',
|
||||
r'INSTALA[ÇC][ÃA]O\D*?(\d{8,12})',
|
||||
], texto_final)
|
||||
|
||||
# fallback: maior sequência "solta" de 8–10 dígitos sem hífen
|
||||
if not uc:
|
||||
seqs = re.findall(r'(?<!\d)(\d{8,10})(?![\d-])', texto_final)
|
||||
if seqs:
|
||||
uc = max(seqs, key=len)
|
||||
|
||||
logging.debug("TEXTO PDF:\n" + texto_final)
|
||||
|
||||
referencia = extrair_seguro([
|
||||
|
||||
Reference in New Issue
Block a user