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;