From 855b0c6d9bede53ce95a83bbcedf0195ce35b363 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Wed, 8 Oct 2025 22:18:58 +0200 Subject: [PATCH] Add missing required fields to Bookkeeping entries - Add date_creation and tms timestamps - Add fk_user_creation and fk_user_modification fields - These fields might be required by Dolibarr's Bookkeeping validation - Ensure all required fields are set before create() call --- core/class/declarationtva.class.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index de75e28..a8f1ef3 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1251,6 +1251,12 @@ class DeclarationTVA $debit->import_key = ''; $debit->entity = $this->entity; + // Add additional required fields that might be missing + $debit->date_creation = dol_now(); + $debit->tms = dol_now(); + $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 - 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); @@ -1294,6 +1300,12 @@ class DeclarationTVA $credit->import_key = ''; $credit->entity = $this->entity; + // Add additional required fields that might be missing + $credit->date_creation = dol_now(); + $credit->tms = dol_now(); + $credit->fk_user_creation = $user->id; + $credit->fk_user_modification = $user->id; + $result = $credit->create($user); error_log("DEBUG: Credit entry create result: " . $result . " (type: " . gettype($result) . ")");