Skip to content

Corregir manejo de booleanos en PostgreSQL en ReportTaxes#80

Merged
NeoRazorX merged 1 commit intoFacturaScripts:mainfrom
DanielRamosAcosta:fix/postgresql-suplido-boolean
Apr 7, 2026
Merged

Corregir manejo de booleanos en PostgreSQL en ReportTaxes#80
NeoRazorX merged 1 commit intoFacturaScripts:mainfrom
DanielRamosAcosta:fix/postgresql-suplido-boolean

Conversation

@DanielRamosAcosta
Copy link
Copy Markdown
Contributor

@DanielRamosAcosta DanielRamosAcosta commented Apr 7, 2026

Resumen

  • PostgreSQL devuelve los valores booleanos como los strings "t"/"f" en vez de 1/0 (como hace MySQL)
  • En PHP, el string "f" es truthy, por lo que $row['suplido'] ? 0 : $pvpTotal evalúa incorrectamente a 0 para todas las líneas que no son suplidos
  • Esto provoca que el informe de impuestos muestre "Diferencia encontrada al calcular el neto. 0 VS ..." y no se genere el PDF
  • Solución: usar filter_var($row['suplido'], FILTER_VALIDATE_BOOLEAN) para convertir correctamente el valor independientemente del motor de base de datos

Plan de pruebas

  • Ejecutar ReportTaxes con PostgreSQL y verificar que el informe se genera sin el error "Diferencia encontrada"
  • Verificar que el fix no afecta a instalaciones con MySQL (donde los booleanos ya son 0/1)

PostgreSQL returns boolean values as the strings "t"/"f" instead of
1/0 (as MySQL does). In PHP, the string "f" is truthy, so the
condition `$row['suplido'] ? 0 : $pvpTotal` incorrectly evaluates
to 0 for all non-suplido lines, causing the tax report to calculate
a net total of 0.

Use filter_var with FILTER_VALIDATE_BOOLEAN to properly convert the
database value to a PHP boolean regardless of the database backend.
@DanielRamosAcosta DanielRamosAcosta changed the title Fix boolean handling for PostgreSQL in ReportTaxes Corregir manejo de booleanos en PostgreSQL en ReportTaxes Apr 7, 2026
@NeoRazorX NeoRazorX merged commit 7f54d6f into FacturaScripts:main Apr 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants