diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 22d3644..de75e28 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1251,6 +1251,18 @@ class DeclarationTVA $debit->import_key = ''; $debit->entity = $this->entity; + // Debug: Log all field values before create + error_log("DEBUG: Debit entry fields - doc_date: " . $debit->doc_date . ", doc_ref: " . $debit->doc_ref . ", code_journal: " . $debit->code_journal . ", numero_compte: " . $debit->numero_compte . ", montant: " . $debit->montant . ", sens: " . $debit->sens . ", fk_doc: " . $debit->fk_doc . ", entity: " . $debit->entity); + + // Check if journal code exists + $journal_check_sql = "SELECT code FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE code = 'OD' AND entity = " . $this->entity; + $journal_check_result = $this->db->query($journal_check_sql); + if ($journal_check_result && $this->db->num_rows($journal_check_result) > 0) { + error_log("DEBUG: Journal code 'OD' exists in system"); + } else { + error_log("DEBUG: Journal code 'OD' NOT FOUND in system - this might be the issue"); + } + $result = $debit->create($user); error_log("DEBUG: Debit entry create result: " . $result . " (type: " . gettype($result) . ")");