Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Rounds a float
<?php round(int|float $num, int $precision = 0, int $mode = PHP_ROUND_HALF_UP): float
<?php $icls = new IncomeClassification();
$icls->setClassificationType($type);
$icls->setClassificationCategory($category);
$icls->setAmount(round($amount, 2));
if (!empty($options['enableClassificationIds'])) {
$id = count($flattenedIncomeClassifications) + 1;
<?php $ecls = new ExpensesClassification();
$ecls->setClassificationType($type);
$ecls->setClassificationCategory($category);
$ecls->setAmount(round($amounts['amount'], 2));
$ecls->setVatAmount(round($amounts['vatAmount'], 2));
$ecls->setVatCategory($vat);
$ecls->setVatExemptionCategory($exemption);
<?php $ecls->setClassificationType($type);
$ecls->setClassificationCategory($category);
$ecls->setAmount(round($amounts['amount'], 2));
$ecls->setVatAmount(round($amounts['vatAmount'], 2));
$ecls->setVatCategory($vat);
$ecls->setVatExemptionCategory($exemption);
<?php private function roundRow(InvoiceDetails $row): void
{
if ($row->getNetValue() !== null) {
$row->setNetValue(round($row->getNetValue(), 2));
}
if ($row->getVatAmount() !== null) {
<?php }
if ($row->getVatAmount() !== null) {
$row->setVatAmount(round($row->getVatAmount(), 2));
}
if ($row->getWithheldAmount() !== null) {
<?php }
if ($row->getWithheldAmount() !== null) {
$row->setWithheldAmount(round($row->getWithheldAmount(), 2));
}
if ($row->getFeesAmount() !== null) {
<?php }
if ($row->getFeesAmount() !== null) {
$row->setFeesAmount(round($row->getFeesAmount(), 2));
}
if ($row->getOtherTaxesAmount() !== null) {
<?php }
if ($row->getOtherTaxesAmount() !== null) {
$row->setOtherTaxesAmount(round($row->getOtherTaxesAmount(), 2));
}
if ($row->getStampDutyAmount() !== null) {
<?php }
if ($row->getStampDutyAmount() !== null) {
$row->setStampDutyAmount(round($row->getStampDutyAmount(), 2));
}
if ($row->getDeductionsAmount() !== null) {
<?php }
if ($row->getDeductionsAmount() !== null) {
$row->setDeductionsAmount(round($row->getDeductionsAmount(), 2));
}
}
<?php if ($row->getIncomeClassification()) {
foreach ($row->getIncomeClassification() as $classification) {
if ($classification->getAmount() !== null) {
$classification->setAmount(round($classification->getAmount(), 2));
}
}
}
<?php if ($row->getExpensesClassification()) {
foreach ($row->getExpensesClassification() as $classification) {
if ($classification->getAmount() !== null) {
$classification->setAmount(round($classification->getAmount(), 2));
}
if ($classification->getVatAmount() !== null) {
<?php }
if ($classification->getVatAmount() !== null) {
$classification->setVatAmount(round($classification->getVatAmount(), 2));
}
}
}
<?php $classifications = array_merge($incomeClassification, $expensesClassification);
$classificationSum = array_sum(array_map(fn($item) => $item->getAmount(), $classifications));
$diff = round($row->getNetValue() - $classificationSum, 2);
if ($diff != 0) {
end($classifications);
<?php protected function round(float $num, int $precision = 2): float
{
return round($num, $precision);
}
abstract function saveTotals(InvoiceSummary $summary): void;