Add debugging to getAccountLabel method to diagnose account name issue

- Added error_log statements to track account lookup process
- Removed entity filtering temporarily to test if that's the issue
- Will help identify why account names are not showing from chart of accounts
- Check error logs after generating PDF to see what's happening
This commit is contained in:
Frank Cools 2025-10-07 11:59:00 +02:00
parent 8336fff139
commit 61bc28597b

View File

@ -2119,16 +2119,21 @@ class DeclarationTVA_PDF
{ {
$sql = "SELECT label FROM " . MAIN_DB_PREFIX . "accounting_account $sql = "SELECT label FROM " . MAIN_DB_PREFIX . "accounting_account
WHERE account_number = '" . $this->db->escape($account_code) . "' WHERE account_number = '" . $this->db->escape($account_code) . "'
AND entity = " . $this->entity . "
AND active = 1 AND active = 1
LIMIT 1"; LIMIT 1";
// Debug logging
error_log("DeclarationTVA: Looking for account " . $account_code . " with entity " . $this->entity);
error_log("DeclarationTVA: SQL query: " . $sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result && $this->db->num_rows($result) > 0) { if ($result && $this->db->num_rows($result) > 0) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
error_log("DeclarationTVA: Found account label: " . $obj->label);
return $obj->label; return $obj->label;
} }
error_log("DeclarationTVA: Account " . $account_code . " not found, using generic label");
// If account not found in chart of accounts, return generic label // If account not found in chart of accounts, return generic label
return 'Compte ' . $account_code; return 'Compte ' . $account_code;
} }