From a24bf86ecb4dac72101e383c6e4fd3797078959f Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 13:53:15 +0200 Subject: [PATCH] v2.5.29: Fixed export functionality and validation PDF layout - Restored export functionality to use fillable PDF template when available - Fixed validation PDF to use improved layout with all enhancements - Separated export and validation: export uses fillable template, validation uses improved layout - Validation PDF now includes OD and bank journal tables on first page - Validation PDF now has all improvements (footer, filtered accounts, etc.) - Updated module version to 2.5.29 --- ChangeLog.md | 9 ++++++ core/class/declarationtva_pdf.class.php | 36 ++++++++---------------- core/modules/modDeclarationTVA.class.php | 2 +- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index b1eb0cd..966982e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,14 @@ # CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) +## 2.5.29 + +### Bug Fixes +- **Restored Export Functionality**: Export now correctly uses fillable PDF template when available +- **Fixed Validation PDF Layout**: Validation now uses improved PDF generation with all enhancements +- **Separated Export and Validation**: Export uses fillable template, validation uses improved layout +- **Consistent Validation**: Validation PDF now includes OD and bank journal tables on first page +- **Complete PDF Features**: Validation PDF now has all improvements (footer, filtered accounts, etc.) + ## 2.5.28 ### Bug Fixes diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index a423ce5..ce2656b 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -254,31 +254,13 @@ class DeclarationTVA_PDF $filepath = $vat_declarations_dir . $filename; - // Generate complete PDF with CA-3 form and detailed breakdown pages - $result = $this->generateCA3PDF($declaration_id); - - if ($result && file_exists($result)) { - // Copy the generated PDF to our target location - if (copy($result, $filepath)) { - // Clean up the temporary file - unlink($result); - $result = true; - } else { - $this->error = "Failed to copy PDF to target location"; - $result = false; - } - } + // For validation, always use the improved PDF generation with all enhancements + // This ensures validation PDF has the same layout as export + $result = $this->generateBasicPDF($filepath, $declaration, $ca3_data, $mysoc); if ($result) { - // Verify file was actually created - if (file_exists($filepath)) { - return $filepath; - } else { - $this->error = "PDF file was not created at expected path: " . $filepath; - return false; - } + return $filepath; } else { - $this->error = "PDF generation failed: " . $this->error; return false; } } @@ -318,9 +300,13 @@ class DeclarationTVA_PDF private function fillPDFTemplate($template_path, $output_path, $declaration, $ca3_data, $mysoc) { try { - // Always use the improved PDF generation for consistency - // This ensures validation uses the same layout as export - return $this->generateBasicPDF($output_path, $declaration, $ca3_data, $mysoc); + // Check if we have a custom fillable PDF template + if (file_exists($template_path) && $this->isFillablePDF($template_path)) { + return $this->fillFillablePDF($template_path, $output_path, $declaration, $ca3_data, $mysoc); + } else { + // Fall back to basic PDF generation + return $this->generateBasicPDF($output_path, $declaration, $ca3_data, $mysoc); + } } catch (Exception $e) { $this->error = 'PDF generation failed: ' . $e->getMessage(); return false; diff --git a/core/modules/modDeclarationTVA.class.php b/core/modules/modDeclarationTVA.class.php index fd2cbf5..099951e 100644 --- a/core/modules/modDeclarationTVA.class.php +++ b/core/modules/modDeclarationTVA.class.php @@ -76,7 +76,7 @@ class modDeclarationTVA extends DolibarrModules $this->editor_squarred_logo = ''; // Must be image filename into the module/img directory followed with @modulename. Example: 'myimage.png@declarationtva' // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z' - $this->version = '2.5.28'; + $this->version = '2.5.29'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt';