diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index 59faa7f..20de41b 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -457,6 +457,17 @@ class DeclarationTVA_PDF return number_format($amount, 0, ',', ' '); } + /** + * Format amount for display with real values (with decimals) + * + * @param float $amount Amount to format + * @return string Formatted amount with decimals + */ + private function formatAmountReal($amount) + { + return number_format($amount, 2, ',', ' '); + } + /** * Fill a PDF form field by modifying PDF content * @@ -1877,12 +1888,13 @@ class DeclarationTVA_PDF } foreach ($line8_details['account_details'] as $account) { - if ($account['vat_amount'] > 0) { + // Only include 445 accounts (VAT accounts) with non-zero amounts + if (strpos($account['account_code'], '445') === 0 && $account['vat_amount'] > 0) { $entries[] = array( 'account_code' => $account['account_code'], 'account_label' => $account['account_label'], 'entry_label' => 'TVA due - Ligne 08', - 'debit' => $this->formatAmount($account['vat_amount']), + 'debit' => $this->formatAmountReal($account['vat_amount']), 'credit' => '' ); } @@ -1914,13 +1926,14 @@ class DeclarationTVA_PDF } foreach ($line20_details['account_details'] as $account) { - if ($account['vat_amount'] > 0) { + // Only include 445 accounts (VAT accounts) with non-zero amounts + if (strpos($account['account_code'], '445') === 0 && $account['vat_amount'] > 0) { $entries[] = array( 'account_code' => $account['account_code'], 'account_label' => $account['account_label'], 'entry_label' => 'TVA déductible - Ligne 20', 'debit' => '', - 'credit' => $this->formatAmount($account['vat_amount']) + 'credit' => $this->formatAmountReal($account['vat_amount']) ); } } @@ -1954,9 +1967,9 @@ class DeclarationTVA_PDF ); if ($vat_result < 0) { - $entry['debit'] = $this->formatAmount(abs($vat_result)); + $entry['debit'] = $this->formatAmountReal(abs($vat_result)); } else { - $entry['credit'] = $this->formatAmount($vat_result); + $entry['credit'] = $this->formatAmountReal($vat_result); } return $entry; @@ -2007,11 +2020,11 @@ class DeclarationTVA_PDF if ($rounding_diff < 0) { $entry['account_code'] = '658000'; $entry['account_label'] = 'Charges exceptionnelles'; - $entry['debit'] = $this->formatAmount(abs($rounding_diff)); + $entry['debit'] = $this->formatAmountReal(abs($rounding_diff)); } else { $entry['account_code'] = '758000'; $entry['account_label'] = 'Produits exceptionnels'; - $entry['credit'] = $this->formatAmount($rounding_diff); + $entry['credit'] = $this->formatAmountReal($rounding_diff); } return $entry;