Add comprehensive debugging for accounting entry creation

- Add debug logging to track if createAccountingEntries is called multiple times
- Add debug logging for bank journal entries creation process
- Help identify why bank entries are not being created
- Track the flow of both OD and bank journal entry creation
This commit is contained in:
Frank Cools 2025-10-09 00:51:58 +02:00
parent c06c427478
commit 1fc83fe5d0

View File

@ -895,6 +895,8 @@ class DeclarationTVA
*/ */
public function createAccountingEntries($declaration_id, $user) public function createAccountingEntries($declaration_id, $user)
{ {
error_log("DEBUG: createAccountingEntries called for declaration ID: " . $declaration_id);
// Get declaration data // Get declaration data
$fetch_result = $this->fetch($declaration_id); $fetch_result = $this->fetch($declaration_id);
if (!$fetch_result) { if (!$fetch_result) {
@ -962,10 +964,13 @@ class DeclarationTVA
} }
// Create bank journal entries // Create bank journal entries
error_log("DEBUG: About to create bank journal entries");
$bank_entries = $this->createBankJournalEntries($declaration, $ca3_lookup, $journal_config, $user); $bank_entries = $this->createBankJournalEntries($declaration, $ca3_lookup, $journal_config, $user);
if (!$bank_entries) { if (!$bank_entries) {
error_log("DEBUG: Bank journal entries creation failed: " . $this->error);
return false; return false;
} }
error_log("DEBUG: Bank journal entries creation result: " . ($bank_entries === true ? 'SUCCESS' : 'FAILED'));
return true; return true;
} }
@ -1017,6 +1022,8 @@ class DeclarationTVA
*/ */
private function createBankJournalEntries($declaration, $ca3_lookup, $journal_config, $user) private function createBankJournalEntries($declaration, $ca3_lookup, $journal_config, $user)
{ {
error_log("DEBUG: createBankJournalEntries called");
// Get bank account configuration // Get bank account configuration
require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php'; require_once DOL_DOCUMENT_ROOT . '/custom/declarationtva/core/class/declarationtva_config.class.php';
$config = new DeclarationTVA_Config($this->db, $this->entity); $config = new DeclarationTVA_Config($this->db, $this->entity);