From 1cb9837ae7b27a4821a59af8615717da2f5ceb61 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 14:48:12 +0200 Subject: [PATCH] Add debugging to validation PDF generation --- core/class/declarationtva_pdf.class.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index 6174196..4ce97f6 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -344,16 +344,25 @@ class DeclarationTVA_PDF // First generate the PDF using the same method as export $temp_pdf = $this->generateCA3PDF($declaration_id, $outputlangs); - if ($temp_pdf && file_exists($temp_pdf)) { - // Copy the generated PDF to the validation location - if (copy($temp_pdf, $filepath)) { - // Clean up the temporary file - unlink($temp_pdf); - return $filepath; - } + if (!$temp_pdf) { + $this->error = 'Failed to generate temporary PDF: ' . $this->error; + return false; } - return false; + if (!file_exists($temp_pdf)) { + $this->error = 'Temporary PDF file does not exist: ' . $temp_pdf; + return false; + } + + // Copy the generated PDF to the validation location + if (copy($temp_pdf, $filepath)) { + // Clean up the temporary file + unlink($temp_pdf); + return $filepath; + } else { + $this->error = 'Failed to copy PDF to validation location: ' . $filepath; + return false; + } } /**