Fix database column name and duplicate entry issues
Database Fixes: - Fixed 'Unknown column id' error by using 'rowid' instead of 'id' - Fixed duplicate entry constraint by properly handling existing records - Now checks for both active and inactive existing records - Reactivates existing inactive records instead of trying to insert duplicates This should resolve the account mapping save issues!
This commit is contained in:
parent
68fa619895
commit
fada7ba882
@ -116,8 +116,8 @@ class DeclarationTVA_Config
|
||||
if (!empty($account_codes)) {
|
||||
foreach ($account_codes as $account_code) {
|
||||
if (!empty($account_code)) {
|
||||
// Check if mapping already exists
|
||||
$check_sql = "SELECT id FROM " . MAIN_DB_PREFIX . "declarationtva_account_mappings
|
||||
// Check if mapping already exists (active or inactive)
|
||||
$check_sql = "SELECT rowid, is_active FROM " . MAIN_DB_PREFIX . "declarationtva_account_mappings
|
||||
WHERE entity = " . $this->entity . "
|
||||
AND ca3_line = '" . $this->db->escape($ca3_line) . "'
|
||||
AND account_code = '" . $this->db->escape($account_code) . "'";
|
||||
@ -125,7 +125,7 @@ class DeclarationTVA_Config
|
||||
error_log("DeclarationTVA: Check query result: " . ($check_result ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
|
||||
|
||||
if ($check_result && $this->db->num_rows($check_result) > 0) {
|
||||
// Update existing mapping
|
||||
// Update existing mapping (reactivate it)
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "declarationtva_account_mappings
|
||||
SET is_active = 1
|
||||
WHERE entity = " . $this->entity . "
|
||||
|
||||
Loading…
Reference in New Issue
Block a user