Fix PDF amount fields: A1-A5 are reference only

- A1-A5 fields are reference only and don't have actual amounts
- Real amounts come from B section calculation fields (B08, B09, 9B, etc.)
- Updated field mapping to correctly show 0,00 for reference fields
- Enhanced debug logging to reflect correct data structure
- Updated manual data file generation with proper field descriptions
This commit is contained in:
Frank Cools 2025-10-03 13:29:09 +02:00
parent 489678ed81
commit ae764b76ce

View File

@ -307,12 +307,13 @@ class DeclarationTVA_PDF
$field_data['declaration_period_end'] = dol_print_date($declaration->end_date, 'day'); $field_data['declaration_period_end'] = dol_print_date($declaration->end_date, 'day');
$field_data['declaration_number'] = $declaration->declaration_number; $field_data['declaration_number'] = $declaration->declaration_number;
// Section A: Opérations imposables // Section A: Opérations imposables (reference only - no amounts to display)
$field_data['A1_amount'] = isset($ca3_data['A1']) ? $this->formatAmount($ca3_data['A1']['vat_amount']) : '0,00'; // These fields are for user reference only and don't have actual amounts
$field_data['A2_amount'] = isset($ca3_data['A2']) ? $this->formatAmount($ca3_data['A2']['vat_amount']) : '0,00'; $field_data['A1_amount'] = '0,00'; // Reference only
$field_data['A3_amount'] = isset($ca3_data['A3']) ? $this->formatAmount($ca3_data['A3']['vat_amount']) : '0,00'; $field_data['A2_amount'] = '0,00'; // Reference only
$field_data['A4_amount'] = isset($ca3_data['A4']) ? $this->formatAmount($ca3_data['A4']['vat_amount']) : '0,00'; $field_data['A3_amount'] = '0,00'; // Reference only
$field_data['A5_amount'] = isset($ca3_data['A5']) ? $this->formatAmount($ca3_data['A5']['vat_amount']) : '0,00'; $field_data['A4_amount'] = '0,00'; // Reference only
$field_data['A5_amount'] = '0,00'; // Reference only
// Debug: Log the CA-3 data structure for troubleshooting // Debug: Log the CA-3 data structure for troubleshooting
if (empty($ca3_data)) { if (empty($ca3_data)) {
@ -333,8 +334,9 @@ class DeclarationTVA_PDF
} }
// Debug: Log specific amount field values // Debug: Log specific amount field values
error_log("DeclarationTVA: A1_amount will be: " . (isset($ca3_data['A1']) ? $this->formatAmount($ca3_data['A1']['vat_amount']) : '0,00')); error_log("DeclarationTVA: A1_amount (reference only): 0,00");
error_log("DeclarationTVA: B08_vat_amount will be: " . (isset($ca3_data['08']) ? $this->formatAmount($ca3_data['08']['vat_amount']) : '0,00')); error_log("DeclarationTVA: B08_vat_amount will be: " . (isset($ca3_data['08']) ? $this->formatAmount($ca3_data['08']['vat_amount']) : '0,00'));
error_log("DeclarationTVA: B09_vat_amount will be: " . (isset($ca3_data['09']) ? $this->formatAmount($ca3_data['09']['vat_amount']) : '0,00'));
error_log("DeclarationTVA: total_vat_collected will be: " . $this->formatAmount($declaration->total_vat_collected)); error_log("DeclarationTVA: total_vat_collected will be: " . $this->formatAmount($declaration->total_vat_collected));
// Section B: TVA due (Base + VAT columns) // Section B: TVA due (Base + VAT columns)
@ -635,13 +637,13 @@ class DeclarationTVA_PDF
$data_content .= "declaration_period_end: " . $field_data['declaration_period_end'] . "\n"; $data_content .= "declaration_period_end: " . $field_data['declaration_period_end'] . "\n";
$data_content .= "declaration_number: " . $field_data['declaration_number'] . "\n\n"; $data_content .= "declaration_number: " . $field_data['declaration_number'] . "\n\n";
$data_content .= "Section A - Opérations imposables:\n"; $data_content .= "Section A - Opérations imposables (Reference Only):\n";
$data_content .= "----------------------------------\n"; $data_content .= "----------------------------------------------------\n";
$data_content .= "A1_amount: " . $field_data['A1_amount'] . "\n"; $data_content .= "A1_amount: " . $field_data['A1_amount'] . " (Reference only)\n";
$data_content .= "A2_amount: " . $field_data['A2_amount'] . "\n"; $data_content .= "A2_amount: " . $field_data['A2_amount'] . " (Reference only)\n";
$data_content .= "A3_amount: " . $field_data['A3_amount'] . "\n"; $data_content .= "A3_amount: " . $field_data['A3_amount'] . " (Reference only)\n";
$data_content .= "A4_amount: " . $field_data['A4_amount'] . "\n"; $data_content .= "A4_amount: " . $field_data['A4_amount'] . " (Reference only)\n";
$data_content .= "A5_amount: " . $field_data['A5_amount'] . "\n\n"; $data_content .= "A5_amount: " . $field_data['A5_amount'] . " (Reference only)\n\n";
$data_content .= "Section B - TVA due:\n"; $data_content .= "Section B - TVA due:\n";
$data_content .= "--------------------\n"; $data_content .= "--------------------\n";