diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 41d96dc..e33f887 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -287,10 +287,12 @@ class DeclarationTVA $result = $this->db->query($sql); if ($result && $this->db->num_rows($result) > 0) { $obj = $this->db->fetch_object($result); - $total_amount = $obj->total_debit - $obj->total_credit; + + // For VAT accounts, we need the absolute value since credit side contains VAT amounts + $total_amount = abs($obj->total_debit - $obj->total_credit); // Log successful query for debugging - error_log("DeclarationTVA: Found data with query: " . substr($sql, 0, 100) . "... Amount: $total_amount"); + error_log("DeclarationTVA: Found data with query: " . substr($sql, 0, 100) . "... Debit: " . $obj->total_debit . ", Credit: " . $obj->total_credit . ", Amount: $total_amount"); return array( 'base_amount' => $total_amount,