From 3da20373ce914d5f6f4ec67877a7cc8a1f9345bd Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 14:54:45 +0200 Subject: [PATCH] Add debugging to hasValidatedDocument method --- core/class/declarationtva.class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 1dd14f1..4d5aea5 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1260,17 +1260,28 @@ class DeclarationTVA // Check if PDF file exists in the VAT declarations validated directory $vat_declarations_dir = DOL_DATA_ROOT . '/declarationtva/validated/'; + // Debug: Log the search + error_log("hasValidatedDocument: Searching in " . $vat_declarations_dir . " for declaration " . $obj->declaration_number); + // Look for PDF files with the declaration number $pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; $files = glob($pattern); + // Debug: Log the pattern and results + error_log("hasValidatedDocument: Pattern: " . $pattern); + error_log("hasValidatedDocument: Files found: " . print_r($files, true)); + // If no files found with the exact pattern, try a more flexible search if (empty($files)) { $pattern = $vat_declarations_dir . 'CA3_*' . $obj->declaration_number . '*.pdf'; $files = glob($pattern); + error_log("hasValidatedDocument: Flexible pattern: " . $pattern); + error_log("hasValidatedDocument: Flexible files found: " . print_r($files, true)); } - return !empty($files) && file_exists($files[0]); + $result = !empty($files) && file_exists($files[0]); + error_log("hasValidatedDocument: Final result: " . ($result ? 'true' : 'false')); + return $result; } /**