Fix getBankAccountDetails to match PDF version exactly
- Use ba.account_number directly instead of LEFT JOIN - Get account label separately using getAccountLabel method - Match the exact logic from PDF generation that works - Add debug logging to see account_number and account_label values
This commit is contained in:
parent
f4bfa27433
commit
b5da8910ee
@ -1414,17 +1414,30 @@ class DeclarationTVA
|
||||
*/
|
||||
private function getBankAccountDetails($bank_account_id)
|
||||
{
|
||||
$sql = "SELECT ba.rowid, ba.label, ba.number, a.account_number as account_code, a.label as account_label
|
||||
// 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
|
||||
LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account a ON a.rowid = ba.account_number
|
||||
WHERE ba.rowid = " . (int)$bank_account_id . " AND ba.entity = " . $this->entity;
|
||||
WHERE ba.rowid = " . (int)$bank_account_id . "
|
||||
AND ba.entity = " . $this->entity;
|
||||
|
||||
error_log("DEBUG: Bank account query: " . $sql);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result && $this->db->num_rows($result) > 0) {
|
||||
$bank_data = $this->db->fetch_array($result);
|
||||
error_log("DEBUG: Bank account data: " . print_r($bank_data, true));
|
||||
return $bank_data;
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
// Get the accounting account label for the account code
|
||||
$account_label = $this->getAccountLabel($obj->account_number);
|
||||
|
||||
error_log("DEBUG: Bank account data - account_number: " . $obj->account_number . ", account_label: " . $account_label);
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
|
||||
error_log("DEBUG: No bank account found for ID: " . $bank_account_id);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user