From b0705ecb4cdc771f2e5d4ce3103b024bfffd30ad Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Thu, 9 Oct 2025 00:12:14 +0200 Subject: [PATCH] Add journal_label field from database - Query accounting_journal table to get label for 'OD' journal - Set journal_label field for both debit and credit entries - Match the working OD journal entries that have proper journal labels - Complete the missing fields identified in comparison --- core/class/declarationtva.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index fb389f4..4464a28 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1264,6 +1264,14 @@ class DeclarationTVA $debit->fk_user_modification = $user->id; $debit->label_operation = $declaration->declaration_name; + // Get journal label from database + $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); + if ($journal_label_result && $this->db->num_rows($journal_label_result) > 0) { + $journal_label_obj = $this->db->fetch_object($journal_label_result); + $debit->journal_label = $journal_label_obj->label; + } + // Final check of montant before create error_log("DEBUG: Final montant check before create: " . $debit->montant); @@ -1307,6 +1315,14 @@ class DeclarationTVA $credit->fk_user_modification = $user->id; $credit->label_operation = $declaration->declaration_name; + // Get journal label from database + $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); + if ($journal_label_result && $this->db->num_rows($journal_label_result) > 0) { + $journal_label_obj = $this->db->fetch_object($journal_label_result); + $credit->journal_label = $journal_label_obj->label; + } + // Final check of montant before create error_log("DEBUG: Final montant check before create: " . $credit->montant);