Translate journal label using dol_gettext()

- Use dol_gettext() to translate the journal label key to actual text
- Convert 'ACCOUNTING_MISCELLANEOUS_JOURNAL' to proper translated label
- Add debug logging to show both original key and translated text
- Fix journal label to match working OD journal entries
This commit is contained in:
Frank Cools 2025-10-09 00:20:28 +02:00
parent 60d2abd8e9
commit 96288033a5

View File

@ -1264,13 +1264,14 @@ class DeclarationTVA
$debit->fk_user_modification = $user->id; $debit->fk_user_modification = $user->id;
$debit->label_operation = $declaration->declaration_name; $debit->label_operation = $declaration->declaration_name;
// Get journal label from database // Get journal label from database and translate it
$journal_label_sql = "SELECT label FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE code = 'OD' AND entity = " . $this->entity; $journal_label_sql = "SELECT label FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE code = 'OD' AND entity = " . $this->entity;
$journal_label_result = $this->db->query($journal_label_sql); $journal_label_result = $this->db->query($journal_label_sql);
if ($journal_label_result && $this->db->num_rows($journal_label_result) > 0) { if ($journal_label_result && $this->db->num_rows($journal_label_result) > 0) {
$journal_label_obj = $this->db->fetch_object($journal_label_result); $journal_label_obj = $this->db->fetch_object($journal_label_result);
$debit->journal_label = $journal_label_obj->label; $translated_label = dol_gettext($journal_label_obj->label);
error_log("DEBUG: Retrieved journal label: " . $journal_label_obj->label); $debit->journal_label = $translated_label;
error_log("DEBUG: Retrieved journal label: " . $journal_label_obj->label . " -> " . $translated_label);
} else { } else {
error_log("DEBUG: No journal label found for OD code"); error_log("DEBUG: No journal label found for OD code");
} }
@ -1318,13 +1319,14 @@ class DeclarationTVA
$credit->fk_user_modification = $user->id; $credit->fk_user_modification = $user->id;
$credit->label_operation = $declaration->declaration_name; $credit->label_operation = $declaration->declaration_name;
// Get journal label from database // Get journal label from database and translate it
$journal_label_sql = "SELECT label FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE code = 'OD' AND entity = " . $this->entity; $journal_label_sql = "SELECT label FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE code = 'OD' AND entity = " . $this->entity;
$journal_label_result = $this->db->query($journal_label_sql); $journal_label_result = $this->db->query($journal_label_sql);
if ($journal_label_result && $this->db->num_rows($journal_label_result) > 0) { if ($journal_label_result && $this->db->num_rows($journal_label_result) > 0) {
$journal_label_obj = $this->db->fetch_object($journal_label_result); $journal_label_obj = $this->db->fetch_object($journal_label_result);
$credit->journal_label = $journal_label_obj->label; $translated_label = dol_gettext($journal_label_obj->label);
error_log("DEBUG: Retrieved journal label: " . $journal_label_obj->label); $credit->journal_label = $translated_label;
error_log("DEBUG: Retrieved journal label: " . $journal_label_obj->label . " -> " . $translated_label);
} else { } else {
error_log("DEBUG: No journal label found for OD code"); error_log("DEBUG: No journal label found for OD code");
} }