Add journal code and entity debugging

- Show entity and date information for saved entries
- List all available journal codes in the system
- Help identify if journal code 'OD' exists and is correct
- Debug why entries don't appear in OD journal view
This commit is contained in:
Frank Cools 2025-10-08 22:39:36 +02:00
parent 39198df2c3
commit 7dbd4f3486

View File

@ -1350,14 +1350,24 @@ class DeclarationTVA
} }
// Check what's actually in the database // Check what's actually in the database
$detail_check_sql = "SELECT rowid, doc_date, doc_ref, code_journal, numero_compte, label_compte, montant, sens, fk_doc FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping $detail_check_sql = "SELECT rowid, doc_date, doc_ref, code_journal, numero_compte, label_compte, montant, sens, fk_doc, entity FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping
WHERE doc_ref = '" . $this->db->escape($declaration->declaration_name) . "' WHERE doc_ref = '" . $this->db->escape($declaration->declaration_name) . "'
ORDER BY rowid DESC LIMIT 5"; ORDER BY rowid DESC LIMIT 5";
$detail_check_result = $this->db->query($detail_check_sql); $detail_check_result = $this->db->query($detail_check_sql);
if ($detail_check_result && $this->db->num_rows($detail_check_result) > 0) { if ($detail_check_result && $this->db->num_rows($detail_check_result) > 0) {
error_log("DEBUG: Recent entries in database:"); error_log("DEBUG: Recent entries in database:");
while ($detail_obj = $this->db->fetch_object($detail_check_result)) { while ($detail_obj = $this->db->fetch_object($detail_check_result)) {
error_log("DEBUG: Entry ID: " . $detail_obj->rowid . ", Account: " . $detail_obj->numero_compte . ", Amount: " . $detail_obj->montant . ", Sens: " . $detail_obj->sens . ", Journal: " . $detail_obj->code_journal); error_log("DEBUG: Entry ID: " . $detail_obj->rowid . ", Account: " . $detail_obj->numero_compte . ", Amount: " . $detail_obj->montant . ", Sens: " . $detail_obj->sens . ", Journal: " . $detail_obj->code_journal . ", Entity: " . $detail_obj->entity . ", Date: " . $detail_obj->doc_date);
}
}
// Check what journal codes exist in the system
$journal_check_sql = "SELECT code, label FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE 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: Available journal codes in system:");
while ($journal_obj = $this->db->fetch_object($journal_check_result)) {
error_log("DEBUG: Journal: " . $journal_obj->code . " - " . $journal_obj->label);
} }
} }