diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 7807548..d848de6 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1225,11 +1225,12 @@ class DeclarationTVA // Use Dolibarr's bookkeeping class with correct field mapping require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeeping.class.php'; - $bookkeeping = new Bookkeeping($this->db); - foreach ($entries as $entry) { error_log("DEBUG: Creating accounting entry for account: " . $entry['account_code'] . ", debit: " . $entry['debit'] . ", credit: " . $entry['credit']); + // Create new instance for each entry + $bookkeeping = new Bookkeeping($this->db); + // Prepare amounts and determine debit/credit $debit_amount = !empty($entry['debit']) ? (float)$entry['debit'] : 0; $credit_amount = !empty($entry['credit']) ? (float)$entry['credit'] : 0;