v2.5.27: Removed debug code for production readiness

- Cleaned up all debug statements and error_log calls from PDF generation
- Removed test data and debugging code for production readiness
- Eliminated unnecessary logging during PDF generation
- Code is now clean and optimized for production use
- Updated module version to 2.5.27
This commit is contained in:
Frank Cools 2025-10-08 13:37:44 +02:00
parent 8792b261f7
commit 51c6f4122d
3 changed files with 10 additions and 52 deletions

View File

@ -1,5 +1,13 @@
# CHANGELOG MODULE DECLARATIONTVA FOR [DOLIBARR ERP CRM](https://www.dolibarr.org)
## 2.5.27
### Bug Fixes
- **Removed Debug Code**: Cleaned up all debug statements and error_log calls from PDF generation
- **Cleaner Codebase**: Removed test data and debugging code for production readiness
- **Improved Performance**: Eliminated unnecessary logging during PDF generation
- **Production Ready**: Code is now clean and optimized for production use
## 2.5.26
### Bug Fixes

View File

@ -290,25 +290,18 @@ class DeclarationTVA_PDF
*/
private function getTemplatePath()
{
error_log("DeclarationTVA: Template path: " . $this->template_path);
// Check for custom template first
$custom_template = $this->template_path . 'ca3_custom_template.pdf';
error_log("DeclarationTVA: Looking for custom template: " . $custom_template);
if (file_exists($custom_template)) {
error_log("DeclarationTVA: Custom template found");
return $custom_template;
}
// Fall back to default template
$default_template = $this->template_path . 'ca3_official_template.pdf';
error_log("DeclarationTVA: Looking for default template: " . $default_template);
if (file_exists($default_template)) {
error_log("DeclarationTVA: Default template found");
return $default_template;
}
error_log("DeclarationTVA: No template found");
return false;
}
@ -462,19 +455,6 @@ class DeclarationTVA_PDF
$field_data['F7_amount'] = $this->getCA3LineAmount($ca3_data, 'F7');
$field_data['F8_amount'] = $this->getCA3LineAmount($ca3_data, 'F8');
// Debug: Log the CA-3 data structure for troubleshooting
if (empty($ca3_data)) {
// Use test data for debugging
$ca3_data = array(
'A1' => array('vat_amount' => 1000.00),
'A2' => array('vat_amount' => 2000.00),
'08' => array('base_amount' => 5000.00, 'vat_amount' => 1000.00),
'09' => array('base_amount' => 10000.00, 'vat_amount' => 2000.00),
'20' => array('vat_amount' => 500.00),
'F1' => array('vat_amount' => 300.00),
'F2' => array('vat_amount' => 400.00)
);
}
// Section B: TVA due (Base + VAT columns)
@ -2120,25 +2100,17 @@ class DeclarationTVA_PDF
$bank_config = $this->getBankAccountConfiguration();
$bank_account_id = $bank_config['bank_account'];
// Debug: Log bank configuration
error_log("DeclarationTVA: Bank config: " . print_r($bank_config, true));
error_log("DeclarationTVA: Bank account ID: " . $bank_account_id);
if (empty($bank_account_id) || $bank_account_id == 0) {
// No bank account configured
error_log("DeclarationTVA: No bank account configured");
return $entries;
}
// Get bank account details
$bank_account = $this->getBankAccountDetails($bank_account_id);
if (!$bank_account) {
error_log("DeclarationTVA: Bank account details not found for ID: " . $bank_account_id);
return $entries;
}
error_log("DeclarationTVA: Bank account found: " . print_r($bank_account, true));
// Calculate VAT amounts the same way as in getBalancingEntries
$line_16_amount = $this->getLineAmount($declaration, '16');
$line_23_amount = $this->getLineAmount($declaration, '23');
@ -2154,19 +2126,9 @@ class DeclarationTVA_PDF
$vat_credit = abs($td_amount);
}
// Debug: Log calculated VAT amounts
error_log("DeclarationTVA: Line 16 amount: " . $line_16_amount);
error_log("DeclarationTVA: Line 23 amount: " . $line_23_amount);
error_log("DeclarationTVA: TD amount: " . $td_amount);
error_log("DeclarationTVA: Net VAT due: " . $net_vat_due);
error_log("DeclarationTVA: VAT credit: " . $vat_credit);
// Get journal configuration for VAT accounts
$journal_config = $this->getJournalConfiguration();
error_log("DeclarationTVA: Journal config: " . print_r($journal_config, true));
error_log("DeclarationTVA: About to check VAT amounts - net_vat_due: " . $net_vat_due . ", vat_credit: " . $vat_credit);
if ($net_vat_due > 0) {
// VAT payment case - money going out
// 1. Bank account (credit - money leaving)
@ -2221,11 +2183,7 @@ class DeclarationTVA_PDF
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
$config = new DeclarationTVA_Config($this->db, $this->entity);
// Debug: Log entity being used
error_log("DeclarationTVA: PDF using entity: " . $this->entity);
$bank_config = $config->getBankAccountConfiguration();
error_log("DeclarationTVA: PDF bank config: " . print_r($bank_config, true));
return $bank_config;
}
@ -2396,12 +2354,9 @@ class DeclarationTVA_PDF
$line_23_amount = $this->getLineAmount($declaration, '23');
$td_amount = $line_16_amount - $line_23_amount;
error_log("DeclarationTVA: TD amount: " . $td_amount);
// If TD = 0, use line 27 value and account 4456700
if (abs($td_amount) < 0.01) {
$line27_amount = $this->getLineAmount($declaration, '27');
error_log("DeclarationTVA: TD is 0, using line 27 amount: " . $line27_amount);
if (abs($line27_amount) < 0.01) {
return null;
@ -2657,16 +2612,11 @@ class DeclarationTVA_PDF
AND ca3_line = 'TD'
AND entity = " . $this->entity;
error_log("DeclarationTVA: TD line query: " . $sql);
$result = $this->db->query($sql);
if ($result && $this->db->num_rows($result) > 0) {
$obj = $this->db->fetch_object($result);
error_log("DeclarationTVA: TD line found with vat_amount: " . $obj->vat_amount);
return (float)$obj->vat_amount;
}
error_log("DeclarationTVA: TD line not found or has no rows");
return 0;
}

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'
// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated', 'experimental_deprecated' or a version string like 'x.y.z'
$this->version = '2.5.26';
$this->version = '2.5.27';
// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';