diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index e8ea68c..87aa330 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1265,6 +1265,9 @@ class DeclarationTVA $debit->fk_user_modification = $user->id; $debit->label_operation = $declaration->declaration_name; + // Set ref field again to ensure it's not overwritten + $debit->ref = $declaration->declaration_name; + // 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_result = $this->db->query($journal_label_sql); @@ -1278,6 +1281,7 @@ class DeclarationTVA // Final check of montant before create error_log("DEBUG: Final montant check before create: " . $debit->montant); + error_log("DEBUG: Final ref field check: " . $debit->ref); $result = $debit->create($user); error_log("DEBUG: Debit entry create result: " . $result . " (type: " . gettype($result) . ")"); @@ -1320,6 +1324,9 @@ class DeclarationTVA $credit->fk_user_modification = $user->id; $credit->label_operation = $declaration->declaration_name; + // Set ref field again to ensure it's not overwritten + $credit->ref = $declaration->declaration_name; + // 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_result = $this->db->query($journal_label_sql); @@ -1333,6 +1340,7 @@ class DeclarationTVA // Final check of montant before create error_log("DEBUG: Final montant check before create: " . $credit->montant); + error_log("DEBUG: Final ref field check: " . $credit->ref); $result = $credit->create($user); error_log("DEBUG: Credit entry create result: " . $result . " (type: " . gettype($result) . ")");