From 908e4d794ce90e88041f55e443b0a0289d5b00af Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Tue, 7 Oct 2025 15:34:08 +0200 Subject: [PATCH] Fix to create correct 2 entries as requested - Main amount (rounded) on 4455100: 69.00 - Rounding difference on 758000: 0.90 - For difference 69.90: 4455100 credit 70.00 + 758000 credit 0.90 - Should now show correct split between main and rounding accounts --- core/class/declarationtva_pdf.class.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index b798c98..103d669 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -2087,18 +2087,32 @@ class DeclarationTVA_PDF error_log("DeclarationTVA: Total difference: " . $difference); error_log("DeclarationTVA: Difference > 0: " . ($difference > 0 ? 'true' : 'false')); - // Only real difference on 758000, no main balancing entry + // Split into main amount (rounded) and rounding difference if (abs($difference) >= 0.01) { - error_log("DeclarationTVA: *** SINGLE ENTRY *** Creating 4455100 entry with real difference: " . $difference); + $rounded_amount = round($difference); + $rounding_diff = $difference - $rounded_amount; - // Only real difference on 4455100 + error_log("DeclarationTVA: Difference: " . $difference . ", Rounded: " . $rounded_amount . ", Rounding diff: " . $rounding_diff); + + // Main amount (rounded) on 4455100 $balancing_entries[] = array( 'account_code' => '4455100', 'account_label' => $this->getAccountLabel('4455100'), 'entry_label' => $declaration->declaration_name, 'debit' => '', - 'credit' => $this->formatAmountReal(abs($difference)) + 'credit' => $this->formatAmount(abs($rounded_amount)) ); + + // Rounding difference on 758000 + if (abs($rounding_diff) >= 0.01) { + $balancing_entries[] = array( + 'account_code' => '758000', + 'account_label' => $this->getAccountLabel('758000'), + 'entry_label' => $declaration->declaration_name, + 'debit' => '', + 'credit' => $this->formatAmountReal(abs($rounding_diff)) + ); + } } return $balancing_entries;