From a363c301fffe57df6525f3c972e98dbf9137a679 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Thu, 2 Oct 2025 20:56:21 +0200 Subject: [PATCH] Fix recalculateCA3Amounts() method Fixed: - Replaced non-existent getDeclarationInfo() with direct database query - Fetches start_date and end_date from declarationtva_declarations table - Proper error handling for missing declarations - recalculateCA3Amounts() now works without undefined method errors --- core/class/declarationtva.class.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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);