diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index b86dab6..786b461 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -2082,22 +2082,22 @@ class DeclarationTVA_PDF if ($rounded_difference != 0) { // Main balancing entry with rounded amount if ($difference > 0) { + // More credits than debits - need debit entry (4456700) + $balancing_entries[] = array( + 'account_code' => '4456700', + 'account_label' => $this->getAccountLabel('4456700'), + 'entry_label' => $declaration->declaration_name, + 'debit' => $this->formatAmount($rounded_difference), + 'credit' => '' + ); + } else { // More debits than credits - need credit entry (4455100) $balancing_entries[] = array( 'account_code' => '4455100', 'account_label' => $this->getAccountLabel('4455100'), 'entry_label' => $declaration->declaration_name, 'debit' => '', - 'credit' => $this->formatAmount($rounded_difference) - ); - } else { - // More credits than debits - need debit entry (4456700) - $balancing_entries[] = array( - 'account_code' => '4456700', - 'account_label' => $this->getAccountLabel('4456700'), - 'entry_label' => $declaration->declaration_name, - 'debit' => $this->formatAmount(abs($rounded_difference)), - 'credit' => '' + 'credit' => $this->formatAmount(abs($rounded_difference)) ); } @@ -2106,7 +2106,7 @@ class DeclarationTVA_PDF error_log("DeclarationTVA: Rounding difference: " . $rounding_diff); if (abs($rounding_diff) >= 0.01) { - if ($difference < 0) { + if ($difference > 0) { // Credit difference - rounding goes to 658000 debit $balancing_entries[] = array( 'account_code' => '658000',