Add getBankAccountDetails method for bank journal entries
- Add getBankAccountDetails method copied from PDF class - This method gets bank account details and returns the linked accounting account code - Fixes the issue where bank account code is not found for bank journal entries - Uses the same logic that works in PDF generation
This commit is contained in:
parent
8d1e1265dd
commit
175a4bdc90
@ -1451,6 +1451,40 @@ class DeclarationTVA
|
|||||||
|
|
||||||
return $account_code; // Fallback to account code
|
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)
|
* Submit declaration (create accounting entries and update status)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user