diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 02169a4..9c5af20 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -1451,6 +1451,40 @@ class DeclarationTVA return $account_code; // Fallback to account code } + + /** + * Get bank account details + * + * @param int $bank_account_id Bank account ID + * @return array|false Bank account details or false if not found + */ + private function getBankAccountDetails($bank_account_id) + { + // Get bank account info and its linked accounting account + $sql = "SELECT ba.rowid, ba.label, ba.number, ba.bank, ba.account_number + FROM " . MAIN_DB_PREFIX . "bank_account ba + WHERE ba.rowid = " . (int)$bank_account_id . " + AND ba.entity = " . $this->entity; + + $result = $this->db->query($sql); + if ($result && $this->db->num_rows($result) > 0) { + $obj = $this->db->fetch_object($result); + + // Get the accounting account label for the account code + $account_label = $this->getAccountLabel($obj->account_number); + + return array( + 'rowid' => $obj->rowid, + 'label' => $obj->label, + 'number' => $obj->number, + 'bank' => $obj->bank, + 'account_code' => $obj->account_number, // Use the linked accounting account code + 'account_label' => $account_label + ); + } + + return false; + } /** * Submit declaration (create accounting entries and update status)