diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 4d5aea5..c4ed6f5 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1263,8 +1263,8 @@ class DeclarationTVA // 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'; + // Look for PDF files with the declaration ID (not declaration number) + $pattern = $vat_declarations_dir . 'CA3_' . $declaration_id . '_*.pdf'; $files = glob($pattern); // Debug: Log the pattern and results @@ -1273,7 +1273,7 @@ class DeclarationTVA // 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'; + $pattern = $vat_declarations_dir . 'CA3_*' . $declaration_id . '*.pdf'; $files = glob($pattern); error_log("hasValidatedDocument: Flexible pattern: " . $pattern); error_log("hasValidatedDocument: Flexible files found: " . print_r($files, true)); @@ -1311,13 +1311,13 @@ class DeclarationTVA // Check if PDF file exists in the VAT declarations validated directory $vat_declarations_dir = DOL_DATA_ROOT . '/declarationtva/validated/'; - // Look for PDF files with the declaration number - $pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; + // Look for PDF files with the declaration ID (not declaration number) + $pattern = $vat_declarations_dir . 'CA3_' . $declaration_id . '_*.pdf'; $files = glob($pattern); // 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'; + $pattern = $vat_declarations_dir . 'CA3_*' . $declaration_id . '*.pdf'; $files = glob($pattern); }