Add getAccountMappings() method to retrieve account labels
Fixed: - Added missing getAccountMappings() method to DeclarationTVA class - Joins with Dolibarr's accounting_account table to get labels - Retrieves account labels from chart of accounts (llx_accounting_account) - Falls back to stored label if chart of accounts label not available - Returns array with rowid, ca3_line, account_code, account_label, vat_rate, is_active This fixes the issue where account labels were not showing in dropdown panels.
This commit is contained in:
parent
e78e6061a8
commit
5cbffd799a
@ -856,6 +856,42 @@ class DeclarationTVA
|
|||||||
return $this->calculateCA3Amounts($declaration_id, $period);
|
return $this->calculateCA3Amounts($declaration_id, $period);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get account mappings with labels from chart of accounts
|
||||||
|
*
|
||||||
|
* @return array Array of account mappings with labels
|
||||||
|
*/
|
||||||
|
public function getAccountMappings()
|
||||||
|
{
|
||||||
|
$sql = "SELECT m.rowid, m.ca3_line, m.account_code, m.account_label, m.vat_rate, m.is_active,
|
||||||
|
a.label as account_label_pcg
|
||||||
|
FROM " . MAIN_DB_PREFIX . "declarationtva_account_mappings m
|
||||||
|
LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account a ON a.account_number = m.account_code AND a.entity = m.entity
|
||||||
|
WHERE m.entity = " . $this->entity . " AND m.is_active = 1
|
||||||
|
ORDER BY m.ca3_line, m.account_code";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
$mappings = array();
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
while ($obj = $this->db->fetch_object($result)) {
|
||||||
|
// Use the label from chart of accounts if available, otherwise use the stored label
|
||||||
|
$account_label = !empty($obj->account_label_pcg) ? $obj->account_label_pcg : $obj->account_label;
|
||||||
|
|
||||||
|
$mappings[] = array(
|
||||||
|
'rowid' => $obj->rowid,
|
||||||
|
'ca3_line' => $obj->ca3_line,
|
||||||
|
'account_code' => $obj->account_code,
|
||||||
|
'account_label' => $account_label,
|
||||||
|
'vat_rate' => $obj->vat_rate,
|
||||||
|
'is_active' => $obj->is_active
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $mappings;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get detailed account breakdown for a specific CA-3 line
|
* Get detailed account breakdown for a specific CA-3 line
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user