Skip to content
This repository was archived by the owner on Jul 18, 2026. It is now read-only.

feat: filtros de facetados via -f/--filtros - #10

Merged
mgaitan merged 1 commit into
mainfrom
feat/filters
May 11, 2026
Merged

feat: filtros de facetados via -f/--filtros#10
mgaitan merged 1 commit into
mainfrom
feat/filters

Conversation

@mgaitan

@mgaitan mgaitan commented May 10, 2026

Copy link
Copy Markdown
Owner

Closes #3

Cambios

  • Nuevo argumento -f/--filtros en CLI: cuitonline gaitan -f persona:juridica,iva:iva_exento
  • search() y Busqueda() aceptan parámetro filtros opcional
  • _parsear_filtros() mapea cada faceta a su parámetro URL correcto (fN[]):
    • ivaf1[], monotributof2[], gananciasf3[]
    • empleadorf4[], personaf5[], nacionalidadf6[]
  • _extraer_tipo_persona() parsea "Persona Física/Jurídica" directamente del HTML (más confiable que inferir por prefijo CUIT)
  • Agrega User-Agent header para evitar 403 del sitio
  • Sin filtros explícitos, mantiene el default persona:fisica

Agrega soporte para filtros de búsqueda con la sintaxis faceta:valor.

- Nuevo argumento -f/--filtros en CLI: cuitonline -f personeria:juridica,iva:exento
- search() y Busqueda() aceptan parámetro filtros opcional
- _parsear_filtros() convierte 'key:val,key:val' a lista de params f5[]
- _tipo_persona_desde_cuit() infiere tipo desde prefijo CUIT (30/33/34 → jurídica)
- Sin filtros explícitos, mantiene el default persona:fisica (comportamiento anterior)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c0a0cdf4a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cuitonline.py
"""Convierte 'personeria:juridica,iva:exento' en lista de (f5[], valor)."""
if not filtros:
return [("f5[]", "persona:fisica")]
return [("f5[]", f.strip()) for f in filtros.split(",")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve each facet's query parameter

For any non-persona facet, e.g. --filtros iva:iva_exento, CUIT Online's own facet links use a different parameter (f1[] for IVA, with other facets under f0/f2/f4/f6), but this parser always submits every user-provided filter as f5[]. As a result, the advertised IVA/ganancias/monotributo filters are not applied correctly; only tipo-persona filters can work. The parser needs to keep or infer the correct facet key instead of hard-coding f5[] for all filters.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resuelto con el dict _FACETA_A_PARAM que mapea cada faceta a su parámetro correcto (iva→f1[], monotributo→f2[], ganancias→f3[], empleador→f4[], persona→f5[], nacionalidad→f6[]). Los mapeos se verifican con tests unitarios en TestParsearFiltros.

@mgaitan
mgaitan merged commit b08b932 into main May 11, 2026
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Permitir filtros de facetados

1 participant