mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Adjustments for invoice calculations to support higher precision
This commit is contained in:
parent
c0542483c3
commit
08f3ba06a4
@ -198,7 +198,7 @@ class InvoiceItemSum
|
|||||||
|
|
||||||
private function push(): self
|
private function push(): self
|
||||||
{
|
{
|
||||||
$this->sub_total += $this->getLineTotal();
|
$this->sub_total += round($this->getLineTotal(), $this->currency->precision);
|
||||||
|
|
||||||
$this->gross_sub_total += $this->getGrossLineTotal();
|
$this->gross_sub_total += $this->getGrossLineTotal();
|
||||||
|
|
||||||
@ -333,6 +333,18 @@ class InvoiceItemSum
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRoundedLineTotal(): float
|
||||||
|
{
|
||||||
|
$total = 0;
|
||||||
|
|
||||||
|
foreach($this->line_items as $item)
|
||||||
|
{
|
||||||
|
$total += round($item->line_total, $this->currency->precision);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $total;
|
||||||
|
}
|
||||||
|
|
||||||
public function getLineTotal()
|
public function getLineTotal()
|
||||||
{
|
{
|
||||||
return $this->item->line_total;
|
return $this->item->line_total;
|
||||||
|
@ -107,7 +107,7 @@ class InvoiceTest extends TestCase
|
|||||||
|
|
||||||
$invoice = $invoice->calc()->getInvoice();
|
$invoice = $invoice->calc()->getInvoice();
|
||||||
|
|
||||||
$this->assertEquals(57.90, $invoice->amount);
|
$this->assertEquals(57.92, $invoice->amount);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user