Fix Bookkeeping instantiation - create new instance for each entry
- Move Bookkeeping instantiation inside the loop - Create fresh instance for each accounting entry - Prevents field contamination between entries - Ensures each entry is processed independently
This commit is contained in:
parent
a1cb48c8cf
commit
f2b8cbfef0
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user