diff --git a/src/QUI/ERP/Accounting/Calc.php b/src/QUI/ERP/Accounting/Calc.php index 7926dc7f683e32bf39e48b3a2ad649936a4b5f3f..d89701e660ab662bcc7919f3abc928a408415239 100644 --- a/src/QUI/ERP/Accounting/Calc.php +++ b/src/QUI/ERP/Accounting/Calc.php @@ -1096,11 +1096,21 @@ public static function calculateTotal(array $invoiceList, QUI\ERP\Currency\Curre $invNettoTotal = floatval($invoice['calculated_nettosum']); $invVatSumPC = QUI\Utils\Math::percent($invVatSum, $invBruttoSum); + $invBruttoSum = round($invBruttoSum, $Currency->getPrecision()); + $invVatSum = round($invVatSum, $Currency->getPrecision()); + $invPaid = round($invPaid, $Currency->getPrecision()); + $invToPay = round($invToPay, $Currency->getPrecision()); + $invNettoTotal = round($invNettoTotal, $Currency->getPrecision()); + + if ($invoice['paid_status'] === QUI\ERP\Constants::PAYMENT_STATUS_PAID) { + $invPaid = $invBruttoSum; + } + if ($invVatSumPC) { if ($invToPay === 0.0) { $invVatPaid = $invVatSum; } else { - $invVatPaid = $invPaid * $invVatSumPC / 100; + $invVatPaid = round($invPaid * $invVatSumPC / 100, $Currency->getPrecision()); } } else { $invVatPaid = 0;