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
This commit is contained in:
Frank Cools 2025-10-08 13:07:20 +02:00
parent 3835d5f304
commit 3da77d0e3f
3 changed files with 62 additions and 4 deletions

View File

@ -1,5 +1,13 @@
# CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) # 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 ## 2.5.20
### Bug Fixes ### Bug Fixes

View File

@ -1080,10 +1080,26 @@ class DeclarationTVA_PDF
// Special handling for lines with both base and VAT accounts (08, 09, 9B) // Special handling for lines with both base and VAT accounts (08, 09, 9B)
if (in_array($line_code, array('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; $base_count = 0;
$vat_count = 0; $vat_count = 0;
foreach ($line_details['account_details'] as $account) { 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) { if (strpos($account['mapping_type'], '_BASE') !== false) {
$base_count++; $base_count++;
} elseif (strpos($account['mapping_type'], '_VAT') !== false) { } 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); $pdf->Cell(0, 6, 'Comptes de base: ' . $base_count . ' | Comptes de TVA: ' . $vat_count, 0, 1);
} else { } else {
// Standard count for other lines // Count non-zero accounts for other lines
$pdf->Cell(0, 6, 'Nombre de comptes: ' . $line_details['account_count'], 0, 1); $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'])) { if (!empty($line_details['calculated_line'])) {
@ -1130,6 +1163,23 @@ class DeclarationTVA_PDF
$other_accounts = array(); $other_accounts = array();
foreach ($account_details as $account) { 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) { if (strpos($account['mapping_type'], '_BASE') !== false) {
$base_accounts[] = $account; $base_accounts[] = $account;
} elseif (strpos($account['mapping_type'], '_VAT') !== false) { } elseif (strpos($account['mapping_type'], '_VAT') !== false) {

View File

@ -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' $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' // 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 // Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt'; //$this->url_last_version = 'http://www.example.com/versionmodule.txt';