Fix PDF search to use declaration ID instead of declaration number
This commit is contained in:
parent
3da20373ce
commit
9aeb09cc5c
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user