Add comprehensive debugging to account mapping operations
Database Operation Debugging: - Added detailed logging to updateAccountMapping method - Logs each SQL operation (deactivate, check, update, insert) - Shows success/failure for each database query - Added debugging to getAccountMappingsByLine method This will help identify exactly where the account mapping process is failing!
This commit is contained in:
parent
1a7663344d
commit
68fa619895
@ -102,11 +102,15 @@ class DeclarationTVA_Config
|
||||
*/
|
||||
public function updateAccountMapping($ca3_line, $account_codes)
|
||||
{
|
||||
// Debug: Log what we're trying to save
|
||||
error_log("DeclarationTVA: updateAccountMapping called for line $ca3_line with codes: " . print_r($account_codes, true));
|
||||
|
||||
// First, deactivate all existing mappings for this CA-3 line
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "declarationtva_account_mappings
|
||||
SET is_active = 0
|
||||
WHERE entity = " . $this->entity . " AND ca3_line = '" . $this->db->escape($ca3_line) . "'";
|
||||
$this->db->query($sql);
|
||||
$result1 = $this->db->query($sql);
|
||||
error_log("DeclarationTVA: Deactivate query result: " . ($result1 ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
|
||||
|
||||
// Then insert/activate new mappings
|
||||
if (!empty($account_codes)) {
|
||||
@ -118,6 +122,7 @@ class DeclarationTVA_Config
|
||||
AND ca3_line = '" . $this->db->escape($ca3_line) . "'
|
||||
AND account_code = '" . $this->db->escape($account_code) . "'";
|
||||
$check_result = $this->db->query($check_sql);
|
||||
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
|
||||
@ -126,14 +131,16 @@ class DeclarationTVA_Config
|
||||
WHERE entity = " . $this->entity . "
|
||||
AND ca3_line = '" . $this->db->escape($ca3_line) . "'
|
||||
AND account_code = '" . $this->db->escape($account_code) . "'";
|
||||
$this->db->query($sql);
|
||||
$result2 = $this->db->query($sql);
|
||||
error_log("DeclarationTVA: Update query result: " . ($result2 ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
|
||||
} else {
|
||||
// Insert new mapping
|
||||
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "declarationtva_account_mappings
|
||||
(entity, ca3_line, account_code, account_label, vat_rate, is_active, created_date)
|
||||
VALUES (" . $this->entity . ", '" . $this->db->escape($ca3_line) . "',
|
||||
'" . $this->db->escape($account_code) . "', '', 0, 1, NOW())";
|
||||
$this->db->query($sql);
|
||||
$result3 = $this->db->query($sql);
|
||||
error_log("DeclarationTVA: Insert query result: " . ($result3 ? 'SUCCESS' : 'FAILED - ' . $this->db->lasterror()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -195,6 +202,9 @@ class DeclarationTVA_Config
|
||||
}
|
||||
}
|
||||
|
||||
// Debug: Log what we're retrieving
|
||||
error_log("DeclarationTVA: getAccountMappingsByLine retrieved: " . print_r($mappings, true));
|
||||
|
||||
return $mappings;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user