Add comprehensive OD journal debugging

- Add debugging to check total OD journal entries in system
- Add debugging to show recent OD journal entries with amounts
- Verify entries are being created in the correct journal
- Help identify if entries exist but are not visible in UI
This commit is contained in:
Frank Cools 2025-10-08 23:08:30 +02:00
parent d48b093ddd
commit ec6642c379

View File

@ -1408,6 +1408,27 @@ class DeclarationTVA
}
}
// Check if entries exist in OD journal specifically
$od_check_sql = "SELECT COUNT(*) as od_count FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping
WHERE code_journal = 'OD' AND entity = " . $this->entity;
$od_check_result = $this->db->query($od_check_sql);
if ($od_check_result && $this->db->num_rows($od_check_result) > 0) {
$od_obj = $this->db->fetch_object($od_check_result);
error_log("DEBUG: Total OD journal entries in system: " . $od_obj->od_count);
}
// Check recent OD entries
$recent_od_sql = "SELECT rowid, doc_ref, numero_compte, montant, sens, code_journal FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping
WHERE code_journal = 'OD' AND entity = " . $this->entity . "
ORDER BY rowid DESC LIMIT 10";
$recent_od_result = $this->db->query($recent_od_sql);
if ($recent_od_result && $this->db->num_rows($recent_od_result) > 0) {
error_log("DEBUG: Recent OD journal entries:");
while ($od_obj = $this->db->fetch_object($recent_od_result)) {
error_log("DEBUG: OD Entry - ID: " . $od_obj->rowid . ", Ref: " . $od_obj->doc_ref . ", Account: " . $od_obj->numero_compte . ", Amount: " . $od_obj->montant . ", Sens: " . $od_obj->sens);
}
}
// 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);