mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 14:12:44 +01: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
|
||||
{
|
||||
$this->sub_total += $this->getLineTotal();
|
||||
$this->sub_total += round($this->getLineTotal(), $this->currency->precision);
|
||||
|
||||
$this->gross_sub_total += $this->getGrossLineTotal();
|
||||
|
||||
@ -333,6 +333,18 @@ class InvoiceItemSum
|
||||
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()
|
||||
{
|
||||
return $this->item->line_total;
|
||||
|
@ -107,7 +107,7 @@ class InvoiceTest extends TestCase
|
||||
|
||||
$invoice = $invoice->calc()->getInvoice();
|
||||
|
||||
$this->assertEquals(57.90, $invoice->amount);
|
||||
$this->assertEquals(57.92, $invoice->amount);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user