Fix CA-3 line details mapping logic and add debugging
Fixed: - Updated getCA3LineDetails() to handle special cases for lines 08, 09, 9B - These lines have _BASE and _VAT suffixes in the database - Added proper matching logic for both normal lines and special cases - Added debugging to AJAX endpoint and backend method - Added error logging to trace mapping issues This should fix the issue where only A1 works but other lines show no accounts.
This commit is contained in:
parent
f39a7f140a
commit
24890aae71
@ -882,13 +882,29 @@ class DeclarationTVA
|
|||||||
$mappings = $this->getAccountMappings();
|
$mappings = $this->getAccountMappings();
|
||||||
$line_mappings = array();
|
$line_mappings = array();
|
||||||
|
|
||||||
|
// Debug: Log all mappings for this line
|
||||||
|
error_log("DeclarationTVA: Looking for mappings for CA-3 line: " . $ca3_line);
|
||||||
|
error_log("DeclarationTVA: Total mappings found: " . count($mappings));
|
||||||
|
|
||||||
// Find mappings for this specific line
|
// Find mappings for this specific line
|
||||||
foreach ($mappings as $mapping) {
|
foreach ($mappings as $mapping) {
|
||||||
if ($mapping['ca3_line'] == $ca3_line) {
|
// Handle special cases for lines 08, 09, 9B which have _BASE and _VAT suffixes
|
||||||
$line_mappings[] = $mapping;
|
if (in_array($ca3_line, array('08', '09', '9B'))) {
|
||||||
|
if ($mapping['ca3_line'] == $ca3_line . '_BASE' || $mapping['ca3_line'] == $ca3_line . '_VAT') {
|
||||||
|
$line_mappings[] = $mapping;
|
||||||
|
error_log("DeclarationTVA: Found mapping for " . $ca3_line . ": " . $mapping['ca3_line'] . " -> " . $mapping['account_code']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Normal matching for other lines
|
||||||
|
if ($mapping['ca3_line'] == $ca3_line) {
|
||||||
|
$line_mappings[] = $mapping;
|
||||||
|
error_log("DeclarationTVA: Found mapping for " . $ca3_line . ": " . $mapping['ca3_line'] . " -> " . $mapping['account_code']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_log("DeclarationTVA: Line mappings found for " . $ca3_line . ": " . count($line_mappings));
|
||||||
|
|
||||||
$details = array();
|
$details = array();
|
||||||
$total_base = 0;
|
$total_base = 0;
|
||||||
$total_vat = 0;
|
$total_vat = 0;
|
||||||
|
|||||||
@ -49,8 +49,17 @@ if (!$declarationtva->fetch($declaration_id)) {
|
|||||||
// Get detailed breakdown
|
// Get detailed breakdown
|
||||||
$line_details = $declarationtva->getCA3LineDetails($declaration_id, $ca3_line);
|
$line_details = $declarationtva->getCA3LineDetails($declaration_id, $ca3_line);
|
||||||
|
|
||||||
|
// Debug information
|
||||||
if (empty($line_details)) {
|
if (empty($line_details)) {
|
||||||
|
echo '<div class="error">' . $langs->trans("NoDataFoundForLine") . '</div>';
|
||||||
|
echo '<div class="info">Debug: CA-3 line: ' . $ca3_line . ', Declaration ID: ' . $declaration_id . '</div>';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug: Show account count
|
||||||
|
if (empty($line_details['account_details'])) {
|
||||||
echo '<div class="info">' . $langs->trans("NoDataFoundForLine") . '</div>';
|
echo '<div class="info">' . $langs->trans("NoDataFoundForLine") . '</div>';
|
||||||
|
echo '<div class="info">Debug: No account details found for line ' . $ca3_line . '</div>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user