Skip to content

Commit 11a5bc4

Browse files
Fix boolean handling for PostgreSQL in ReportTaxes
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.
1 parent b22e629 commit 11a5bc4

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

Controller/ReportTaxes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ protected function getReportData(): array
284284
$data = [];
285285
foreach ($this->dataBase->select($sql) as $row) {
286286
$pvpTotal = floatval($row['pvptotal']) * (100 - floatval($row['dtopor1'])) * (100 - floatval($row['dtopor2'])) / 10000;
287+
$row['suplido'] = filter_var($row['suplido'], FILTER_VALIDATE_BOOLEAN);
287288
$code = $row['codigo'] . '-' . $row['iva'] . '-' . $row['recargo'] . '-' . $row['irpf'] . '-' . $row['suplido'];
288289
if (isset($data[$code])) {
289290
$data[$code]['neto'] += $row['suplido'] ? 0 : $pvpTotal;

0 commit comments

Comments
 (0)