From 3da77d0e3f58346bafe4e06fb33c5008ecb88838 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 13:07:20 +0200 Subject: [PATCH] v2.5.21: Filtered zero-value accounts from PDF detailed pages - Only accounts with non-zero amounts are now displayed in PDF detailed pages - Eliminated display of accounts with 0.00 amounts to save paper and improve readability - Resume now shows count of only non-zero accounts - Detailed pages now contain only relevant accounts with actual values - Improved PDF efficiency and cleaner output - Updated module version to 2.5.21 --- ChangeLog.md | 8 ++++ core/class/declarationtva_pdf.class.php | 56 ++++++++++++++++++++++-- core/modules/modDeclarationTVA.class.php | 2 +- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index aaa4c46..046bd11 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,13 @@ # CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) +## 2.5.21 + +### Bug Fixes +- **Filtered Zero-Value Accounts**: Only accounts with non-zero amounts are now displayed in PDF detailed pages +- **Paper Saving**: Eliminated display of accounts with 0.00 amounts to save paper and improve readability +- **Improved Account Counts**: Resume now shows count of only non-zero accounts +- **Cleaner PDF Output**: Detailed pages now contain only relevant accounts with actual values + ## 2.5.20 ### Bug Fixes diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index f5e86c6..bef67ba 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -1080,10 +1080,26 @@ class DeclarationTVA_PDF // Special handling for lines with both base and VAT accounts (08, 09, 9B) if (in_array($line_code, array('08', '09', '9B'))) { - // Count base and VAT accounts separately + // Count base and VAT accounts separately (only non-zero amounts) $base_count = 0; $vat_count = 0; foreach ($line_details['account_details'] as $account) { + // Only count accounts with non-zero amounts + $has_amount = false; + if (isset($account['base_amount']) && $account['base_amount'] > 0) { + $has_amount = true; + } + if (isset($account['vat_amount']) && $account['vat_amount'] > 0) { + $has_amount = true; + } + if (isset($account['total_amount']) && $account['total_amount'] > 0) { + $has_amount = true; + } + + if (!$has_amount) { + continue; + } + if (strpos($account['mapping_type'], '_BASE') !== false) { $base_count++; } elseif (strpos($account['mapping_type'], '_VAT') !== false) { @@ -1092,8 +1108,25 @@ class DeclarationTVA_PDF } $pdf->Cell(0, 6, 'Comptes de base: ' . $base_count . ' | Comptes de TVA: ' . $vat_count, 0, 1); } else { - // Standard count for other lines - $pdf->Cell(0, 6, 'Nombre de comptes: ' . $line_details['account_count'], 0, 1); + // Count non-zero accounts for other lines + $non_zero_count = 0; + foreach ($line_details['account_details'] as $account) { + $has_amount = false; + if (isset($account['base_amount']) && $account['base_amount'] > 0) { + $has_amount = true; + } + if (isset($account['vat_amount']) && $account['vat_amount'] > 0) { + $has_amount = true; + } + if (isset($account['total_amount']) && $account['total_amount'] > 0) { + $has_amount = true; + } + + if ($has_amount) { + $non_zero_count++; + } + } + $pdf->Cell(0, 6, 'Nombre de comptes: ' . $non_zero_count, 0, 1); } if (!empty($line_details['calculated_line'])) { @@ -1130,6 +1163,23 @@ class DeclarationTVA_PDF $other_accounts = array(); foreach ($account_details as $account) { + // Only include accounts with non-zero amounts to save paper + $has_amount = false; + if (isset($account['base_amount']) && $account['base_amount'] > 0) { + $has_amount = true; + } + if (isset($account['vat_amount']) && $account['vat_amount'] > 0) { + $has_amount = true; + } + if (isset($account['total_amount']) && $account['total_amount'] > 0) { + $has_amount = true; + } + + // Skip accounts with zero amounts + if (!$has_amount) { + continue; + } + if (strpos($account['mapping_type'], '_BASE') !== false) { $base_accounts[] = $account; } elseif (strpos($account['mapping_type'], '_VAT') !== false) { diff --git a/core/modules/modDeclarationTVA.class.php b/core/modules/modDeclarationTVA.class.php index 9e0db5c..7192a20 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.20'; + $this->version = '2.5.21'; // Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt';