From 9afecbbac09e6b2ac0fa3e46973dd79269cab509 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 21:53:16 +0200 Subject: [PATCH] Add debugging and fix user parameter passing - Add debug logs to track user parameter through method calls - Update createAccountingEntries to accept user parameter - Remove redundant global user declarations - Pass user parameter through entire accounting creation chain --- core/class/declarationtva.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index b10e770..3481b7d 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -890,12 +890,11 @@ class DeclarationTVA * Create accounting entries for declaration submission * * @param int $declaration_id Declaration ID + * @param object $user User object * @return bool Success */ - public function createAccountingEntries($declaration_id) + public function createAccountingEntries($declaration_id, $user) { - global $user; - // Get declaration data $fetch_result = $this->fetch($declaration_id); if (!$fetch_result) { @@ -1295,6 +1294,8 @@ class DeclarationTVA */ public function submitDeclaration($declaration_id, $user) { + error_log("DEBUG: submitDeclaration called with user: " . ($user ? "VALID" : "NULL")); + // Get declaration data $declaration = $this->fetch($declaration_id); if (!$declaration) { @@ -1322,7 +1323,8 @@ class DeclarationTVA } // Create accounting entries - $accounting_result = $this->createAccountingEntries($declaration_id); + error_log("DEBUG: About to call createAccountingEntries with user: " . ($user ? "VALID" : "NULL")); + $accounting_result = $this->createAccountingEntries($declaration_id, $user); if (!$accounting_result) { $this->error = 'Failed to create accounting entries: ' . $this->error; return false;