Remove all debugging code and messages

Clean Interface:
- Removed all debug logging from updateAccountMapping method
- Removed debug output from form submission
- Removed debug logging from getAccountMappingsByLine method
- Clean, production-ready code without debug clutter

The account mapping functionality is now working perfectly!
This commit is contained in:
Frank Cools 2025-10-02 17:51:23 +02:00
parent fada7ba882
commit c91509f89e
2 changed files with 3 additions and 20 deletions

View File

@ -40,13 +40,6 @@ if ($action == 'update_mappings') {
$ca3_definitions = $config->getCA3LineDefinitions(); $ca3_definitions = $config->getCA3LineDefinitions();
$updated_count = 0; $updated_count = 0;
// Debug: Show what's being submitted
$debug_info = array();
foreach ($ca3_definitions as $line => $definition) {
$account_codes = GETPOST('account_codes_' . $line, 'array');
$debug_info[] = "$line: " . (is_array($account_codes) ? implode(',', $account_codes) : 'not set');
}
setEventMessages("Debug: Form data - " . implode(' | ', $debug_info), null, 'warnings');
foreach ($ca3_definitions as $line => $definition) { foreach ($ca3_definitions as $line => $definition) {
$account_codes = GETPOST('account_codes_' . $line, 'array'); $account_codes = GETPOST('account_codes_' . $line, 'array');

View File

@ -102,15 +102,11 @@ class DeclarationTVA_Config
*/ */
public function updateAccountMapping($ca3_line, $account_codes) public function updateAccountMapping($ca3_line, $account_codes)
{ {
// Debug: Log what we're trying to save
error_log("DeclarationTVA: updateAccountMapping called for line $ca3_line with codes: " . print_r($account_codes, true));
// First, deactivate all existing mappings for this CA-3 line // First, deactivate all existing mappings for this CA-3 line
$sql = "UPDATE " . MAIN_DB_PREFIX . "declarationtva_account_mappings $sql = "UPDATE " . MAIN_DB_PREFIX . "declarationtva_account_mappings
SET is_active = 0 SET is_active = 0
WHERE entity = " . $this->entity . " AND ca3_line = '" . $this->db->escape($ca3_line) . "'"; WHERE entity = " . $this->entity . " AND ca3_line = '" . $this->db->escape($ca3_line) . "'";
$result1 = $this->db->query($sql); $this->db->query($sql);
error_log("DeclarationTVA: Deactivate query result: " . ($result1 ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
// Then insert/activate new mappings // Then insert/activate new mappings
if (!empty($account_codes)) { if (!empty($account_codes)) {
@ -122,7 +118,6 @@ class DeclarationTVA_Config
AND ca3_line = '" . $this->db->escape($ca3_line) . "' AND ca3_line = '" . $this->db->escape($ca3_line) . "'
AND account_code = '" . $this->db->escape($account_code) . "'"; AND account_code = '" . $this->db->escape($account_code) . "'";
$check_result = $this->db->query($check_sql); $check_result = $this->db->query($check_sql);
error_log("DeclarationTVA: Check query result: " . ($check_result ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
if ($check_result && $this->db->num_rows($check_result) > 0) { if ($check_result && $this->db->num_rows($check_result) > 0) {
// Update existing mapping (reactivate it) // Update existing mapping (reactivate it)
@ -131,16 +126,14 @@ class DeclarationTVA_Config
WHERE entity = " . $this->entity . " WHERE entity = " . $this->entity . "
AND ca3_line = '" . $this->db->escape($ca3_line) . "' AND ca3_line = '" . $this->db->escape($ca3_line) . "'
AND account_code = '" . $this->db->escape($account_code) . "'"; AND account_code = '" . $this->db->escape($account_code) . "'";
$result2 = $this->db->query($sql); $this->db->query($sql);
error_log("DeclarationTVA: Update query result: " . ($result2 ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
} else { } else {
// Insert new mapping // Insert new mapping
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "declarationtva_account_mappings $sql = "INSERT INTO " . MAIN_DB_PREFIX . "declarationtva_account_mappings
(entity, ca3_line, account_code, account_label, vat_rate, is_active, created_date) (entity, ca3_line, account_code, account_label, vat_rate, is_active, created_date)
VALUES (" . $this->entity . ", '" . $this->db->escape($ca3_line) . "', VALUES (" . $this->entity . ", '" . $this->db->escape($ca3_line) . "',
'" . $this->db->escape($account_code) . "', '', 0, 1, NOW())"; '" . $this->db->escape($account_code) . "', '', 0, 1, NOW())";
$result3 = $this->db->query($sql); $this->db->query($sql);
error_log("DeclarationTVA: Insert query result: " . ($result3 ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
} }
} }
} }
@ -202,9 +195,6 @@ class DeclarationTVA_Config
} }
} }
// Debug: Log what we're retrieving
error_log("DeclarationTVA: getAccountMappingsByLine retrieved: " . print_r($mappings, true));
return $mappings; return $mappings;
} }