diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php
index b1b6fde..bbda54a 100644
--- a/core/class/declarationtva.class.php
+++ b/core/class/declarationtva.class.php
@@ -882,29 +882,21 @@ class DeclarationTVA
$mappings = $this->getAccountMappings();
$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
foreach ($mappings as $mapping) {
// Handle special cases for lines 08, 09, 9B which have _BASE and _VAT suffixes
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();
$total_base = 0;
$total_vat = 0;
diff --git a/declarationtva_line_details_ajax.php b/declarationtva_line_details_ajax.php
index ed7f810..a4e7e80 100644
--- a/declarationtva_line_details_ajax.php
+++ b/declarationtva_line_details_ajax.php
@@ -49,17 +49,13 @@ if (!$declarationtva->fetch($declaration_id)) {
// Get detailed breakdown
$line_details = $declarationtva->getCA3LineDetails($declaration_id, $ca3_line);
-// Debug information
if (empty($line_details)) {
echo '
' . $langs->trans("NoDataFoundForLine") . '
';
- echo 'Debug: CA-3 line: ' . $ca3_line . ', Declaration ID: ' . $declaration_id . '
';
exit;
}
-// Debug: Show account count
if (empty($line_details['account_details'])) {
echo '' . $langs->trans("NoDataFoundForLine") . '
';
- echo 'Debug: No account details found for line ' . $ca3_line . '
';
exit;
}
@@ -67,6 +63,21 @@ if (empty($line_details['account_details'])) {
$ca3_definitions = $config->getCA3LineDefinitions();
$line_definition = isset($ca3_definitions[$ca3_line]) ? $ca3_definitions[$ca3_line] : null;
+// Group accounts by type for lines 08, 09, 9B
+$base_accounts = array();
+$vat_accounts = array();
+$other_accounts = array();
+
+foreach ($line_details['account_details'] as $account) {
+ if (strpos($account['mapping_type'], '_BASE') !== false) {
+ $base_accounts[] = $account;
+ } elseif (strpos($account['mapping_type'], '_VAT') !== false) {
+ $vat_accounts[] = $account;
+ } else {
+ $other_accounts[] = $account;
+ }
+}
+
// Display account details table
echo '';
echo '';
@@ -82,7 +93,52 @@ $total_base = 0;
$total_vat = 0;
$total_amount = 0;
-foreach ($line_details['account_details'] as $account) {
+// Display BASE accounts first (if any)
+if (!empty($base_accounts)) {
+ echo '
';
+ echo '| ' . $langs->trans("BaseAccounts") . ' | ';
+ echo '
';
+
+ foreach ($base_accounts as $account) {
+ $total_base += $account['base_amount'];
+ $total_vat += $account['vat_amount'];
+ $total_amount += $account['total_amount'];
+
+ echo '';
+ echo '| ' . $account['account_code'] . ' | ';
+ echo '' . $account['account_label'] . ' | ';
+ echo '' . price($account['base_amount']) . ' | ';
+ echo '' . price($account['vat_amount']) . ' | ';
+ echo '' . price($account['total_amount']) . ' | ';
+ echo '' . $account['mapping_type'] . ' | ';
+ echo '
';
+ }
+}
+
+// Display VAT accounts second (if any)
+if (!empty($vat_accounts)) {
+ echo '';
+ echo '| ' . $langs->trans("VATAccounts") . ' | ';
+ echo '
';
+
+ foreach ($vat_accounts as $account) {
+ $total_base += $account['base_amount'];
+ $total_vat += $account['vat_amount'];
+ $total_amount += $account['total_amount'];
+
+ echo '';
+ echo '| ' . $account['account_code'] . ' | ';
+ echo '' . $account['account_label'] . ' | ';
+ echo '' . price($account['base_amount']) . ' | ';
+ echo '' . price($account['vat_amount']) . ' | ';
+ echo '' . price($account['total_amount']) . ' | ';
+ echo '' . $account['mapping_type'] . ' | ';
+ echo '
';
+ }
+}
+
+// Display other accounts (normal lines)
+foreach ($other_accounts as $account) {
$total_base += $account['base_amount'];
$total_vat += $account['vat_amount'];
$total_amount += $account['total_amount'];
diff --git a/langs/en_US/declarationtva.lang b/langs/en_US/declarationtva.lang
index 80ed3dd..9942439 100644
--- a/langs/en_US/declarationtva.lang
+++ b/langs/en_US/declarationtva.lang
@@ -461,3 +461,5 @@ AccountBreakdown = Account Breakdown
Loading = Loading...
ErrorLoadingDetails = Error loading details
Summary = Summary
+BaseAccounts = Base Accounts (Sales)
+VATAccounts = VAT Accounts
diff --git a/langs/fr_FR/declarationtva.lang b/langs/fr_FR/declarationtva.lang
index 465aef3..4f369d6 100644
--- a/langs/fr_FR/declarationtva.lang
+++ b/langs/fr_FR/declarationtva.lang
@@ -450,3 +450,5 @@ AccountBreakdown = Détail des comptes
Loading = Chargement...
ErrorLoadingDetails = Erreur lors du chargement des détails
Summary = Résumé
+BaseAccounts = Comptes de base (ventes)
+VATAccounts = Comptes de TVA