diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 86277ad..f0b052f 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -536,12 +536,17 @@ class DeclarationTVA */ public function recalculateCA3Amounts($declaration_id) { - // Get declaration info - $declaration = $this->getDeclarationInfo($declaration_id); - if (!$declaration) { + // Get declaration info directly from database + $sql = "SELECT start_date, end_date FROM " . MAIN_DB_PREFIX . "declarationtva_declarations + WHERE rowid = " . $declaration_id . " AND entity = " . $this->entity; + + $result = $this->db->query($sql); + if (!$result || $this->db->num_rows($result) == 0) { return false; } + $obj = $this->db->fetch_object($result); + // Clear existing CA-3 lines $sql = "DELETE FROM " . MAIN_DB_PREFIX . "declarationtva_ca3_lines WHERE declaration_id = " . $declaration_id; @@ -549,8 +554,8 @@ class DeclarationTVA // Recalculate using declaration dates $period = array( - 'start_date' => $declaration['start_date'], - 'end_date' => $declaration['end_date'] + 'start_date' => $obj->start_date, + 'end_date' => $obj->end_date ); return $this->calculateCA3Amounts($declaration_id, $period);