diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 645bc29..e20f5a5 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1263,34 +1263,8 @@ class DeclarationTVA $debit->fk_user_creation = $user->id; $debit->fk_user_modification = $user->id; - // Debug: Log all field values before create - error_log("DEBUG: Debit entry fields before create:"); - error_log("DEBUG: - doc_date: " . $debit->doc_date); - error_log("DEBUG: - doc_ref: " . $debit->doc_ref); - error_log("DEBUG: - code_journal: " . $debit->code_journal); - error_log("DEBUG: - numero_compte: " . $debit->numero_compte); - error_log("DEBUG: - label_compte: " . $debit->label_compte); - error_log("DEBUG: - montant: " . $debit->montant); - error_log("DEBUG: - sens: " . $debit->sens); - error_log("DEBUG: - fk_doc: " . $debit->fk_doc); - error_log("DEBUG: - fk_user_author: " . $debit->fk_user_author); - - // Debug: Key Bookkeeping fields only - error_log("DEBUG: Key Debit Bookkeeping fields:"); - error_log("DEBUG: - doc_date: " . ($debit->doc_date ?? 'NULL')); - error_log("DEBUG: - doc_ref: " . ($debit->doc_ref ?? 'NULL')); - error_log("DEBUG: - code_journal: " . ($debit->code_journal ?? 'NULL')); - error_log("DEBUG: - numero_compte: " . ($debit->numero_compte ?? 'NULL')); - error_log("DEBUG: - label_compte: " . ($debit->label_compte ?? 'NULL')); - error_log("DEBUG: - montant: " . ($debit->montant ?? 'NULL')); - error_log("DEBUG: - sens: " . ($debit->sens ?? 'NULL')); - error_log("DEBUG: - fk_doc: " . ($debit->fk_doc ?? 'NULL')); - error_log("DEBUG: - fk_user_author: " . ($debit->fk_user_author ?? 'NULL')); - error_log("DEBUG: - entity: " . ($debit->entity ?? 'NULL')); - error_log("DEBUG: - date_creation: " . ($debit->date_creation ?? 'NULL')); - error_log("DEBUG: - tms: " . ($debit->tms ?? 'NULL')); - error_log("DEBUG: - fk_user_creation: " . ($debit->fk_user_creation ?? 'NULL')); - error_log("DEBUG: - fk_user_modification: " . ($debit->fk_user_modification ?? 'NULL')); + // Final check of montant before create + error_log("DEBUG: Final montant check before create: " . $debit->montant); $result = $debit->create($user); error_log("DEBUG: Debit entry create result: " . $result . " (type: " . gettype($result) . ")"); @@ -1331,34 +1305,8 @@ class DeclarationTVA $credit->fk_user_creation = $user->id; $credit->fk_user_modification = $user->id; - // Debug: Log all field values before create - error_log("DEBUG: Credit entry fields before create:"); - error_log("DEBUG: - doc_date: " . $credit->doc_date); - error_log("DEBUG: - doc_ref: " . $credit->doc_ref); - error_log("DEBUG: - code_journal: " . $credit->code_journal); - error_log("DEBUG: - numero_compte: " . $credit->numero_compte); - error_log("DEBUG: - label_compte: " . $credit->label_compte); - error_log("DEBUG: - montant: " . $credit->montant); - error_log("DEBUG: - sens: " . $credit->sens); - error_log("DEBUG: - fk_doc: " . $credit->fk_doc); - error_log("DEBUG: - fk_user_author: " . $credit->fk_user_author); - - // Debug: Key Bookkeeping fields only - error_log("DEBUG: Key Credit Bookkeeping fields:"); - error_log("DEBUG: - doc_date: " . ($credit->doc_date ?? 'NULL')); - error_log("DEBUG: - doc_ref: " . ($credit->doc_ref ?? 'NULL')); - error_log("DEBUG: - code_journal: " . ($credit->code_journal ?? 'NULL')); - error_log("DEBUG: - numero_compte: " . ($credit->numero_compte ?? 'NULL')); - error_log("DEBUG: - label_compte: " . ($credit->label_compte ?? 'NULL')); - error_log("DEBUG: - montant: " . ($credit->montant ?? 'NULL')); - error_log("DEBUG: - sens: " . ($credit->sens ?? 'NULL')); - error_log("DEBUG: - fk_doc: " . ($credit->fk_doc ?? 'NULL')); - error_log("DEBUG: - fk_user_author: " . ($credit->fk_user_author ?? 'NULL')); - error_log("DEBUG: - entity: " . ($credit->entity ?? 'NULL')); - error_log("DEBUG: - date_creation: " . ($credit->date_creation ?? 'NULL')); - error_log("DEBUG: - tms: " . ($credit->tms ?? 'NULL')); - error_log("DEBUG: - fk_user_creation: " . ($credit->fk_user_creation ?? 'NULL')); - error_log("DEBUG: - fk_user_modification: " . ($credit->fk_user_modification ?? 'NULL')); + // Final check of montant before create + error_log("DEBUG: Final montant check before create: " . $credit->montant); $result = $credit->create($user); error_log("DEBUG: Credit entry create result: " . $result . " (type: " . gettype($result) . ")"); @@ -1393,41 +1341,8 @@ class DeclarationTVA error_log("DEBUG: Final verification - Total entries in database for declaration " . $declaration->declaration_name . ": " . $final_check_obj->total_entries); } - // 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, entity, date_creation, tms FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping - WHERE doc_ref = '" . $this->db->escape($declaration->declaration_name) . "' - ORDER BY rowid DESC LIMIT 5"; - $detail_check_result = $this->db->query($detail_check_sql); - if ($detail_check_result && $this->db->num_rows($detail_check_result) > 0) { - error_log("DEBUG: Recent entries in database with dates:"); - 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 . ", Entity: " . $detail_obj->entity); - error_log("DEBUG: - doc_date: " . $detail_obj->doc_date . " (operation date)"); - error_log("DEBUG: - date_creation: " . $detail_obj->date_creation . " (creation date)"); - error_log("DEBUG: - tms: " . $detail_obj->tms . " (modification date)"); - } - } - - // 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); - } - } + // Simple verification + error_log("DEBUG: Accounting entries created successfully"); // Check what journal codes exist in the system $journal_check_sql = "SELECT code, label FROM " . MAIN_DB_PREFIX . "accounting_journal WHERE entity = " . $this->entity;