diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 24a8868..d11ddba 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1262,17 +1262,15 @@ class DeclarationTVA } // Check if PDF file exists in the VAT declarations directory - $vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/'; - $year_dir = $vat_declarations_dir . date('Y') . '/'; - $month_dir = $year_dir . date('m') . '/'; + $vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/validated/'; // Look for PDF files with the declaration number - $pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; + $pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; $files = glob($pattern); // If no files found with the exact pattern, try a more flexible search if (empty($files)) { - $pattern = $month_dir . 'CA3_*' . $obj->declaration_number . '*.pdf'; + $pattern = $vat_declarations_dir . 'CA3_*' . $obj->declaration_number . '*.pdf'; $files = glob($pattern); } @@ -1304,17 +1302,15 @@ class DeclarationTVA } // Check if PDF file exists in the VAT declarations directory - $vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/'; - $year_dir = $vat_declarations_dir . date('Y') . '/'; - $month_dir = $year_dir . date('m') . '/'; + $vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/validated/'; // Look for PDF files with the declaration number - $pattern = $month_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; + $pattern = $vat_declarations_dir . 'CA3_' . $obj->declaration_number . '_*.pdf'; $files = glob($pattern); // If no files found with the exact pattern, try a more flexible search if (empty($files)) { - $pattern = $month_dir . 'CA3_*' . $obj->declaration_number . '*.pdf'; + $pattern = $vat_declarations_dir . 'CA3_*' . $obj->declaration_number . '*.pdf'; $files = glob($pattern); } diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index f2c4c5c..dccf87d 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -184,22 +184,14 @@ class DeclarationTVA_PDF $filename = 'CA3_' . $declaration->declaration_number . '_' . date('Y-m-d') . '.pdf'; // Create VAT declarations documents directory structure - $vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/'; - $year_dir = $vat_declarations_dir . date('Y') . '/'; - $month_dir = $year_dir . date('m') . '/'; + $vat_declarations_dir = DOL_DATA_ROOT . '/documents/declarationtva/validated/'; - // Create directories if they don't exist + // Create directory if it doesn't exist if (!is_dir($vat_declarations_dir)) { dol_mkdir($vat_declarations_dir); } - if (!is_dir($year_dir)) { - dol_mkdir($year_dir); - } - if (!is_dir($month_dir)) { - dol_mkdir($month_dir); - } - $filepath = $month_dir . $filename; + $filepath = $vat_declarations_dir . $filename; // Generate detailed PDF with breakdown pages $result = $this->generateDetailedPDF($filepath, $declaration, $ca3_data, $company);