diff --git a/app/Helpers/Invoice/InvoiceItemSum.php b/app/Helpers/Invoice/InvoiceItemSum.php index 3818285b20..1a6fa06484 100644 --- a/app/Helpers/Invoice/InvoiceItemSum.php +++ b/app/Helpers/Invoice/InvoiceItemSum.php @@ -242,11 +242,11 @@ class InvoiceItemSum private function setDiscount() { if ($this->invoice->is_amount_discount) { - $this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision)); + $this->setLineTotal(round($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision),2)); } else { $discount = ($this->item->line_total * ($this->item->discount / 100)); - $this->setLineTotal($this->formatValue(($this->getLineTotal() - $discount), $this->currency->precision)); + $this->setLineTotal(round($this->formatValue(($this->getLineTotal() - $discount), $this->currency->precision),2)); } $this->item->is_amount_discount = $this->invoice->is_amount_discount; diff --git a/app/Helpers/Invoice/InvoiceItemSumInclusive.php b/app/Helpers/Invoice/InvoiceItemSumInclusive.php index 3dab198af1..d9f9fe06f4 100644 --- a/app/Helpers/Invoice/InvoiceItemSumInclusive.php +++ b/app/Helpers/Invoice/InvoiceItemSumInclusive.php @@ -177,9 +177,9 @@ class InvoiceItemSumInclusive private function setDiscount() { if ($this->invoice->is_amount_discount) { - $this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision)); + $this->setLineTotal(round($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision),2)); } else { - $this->setLineTotal($this->getLineTotal() - $this->formatValue(($this->item->line_total * ($this->item->discount / 100)), $this->currency->precision)); + $this->setLineTotal(round($this->getLineTotal() - $this->formatValue(($this->item->line_total * ($this->item->discount / 100)), $this->currency->precision),2)); } $this->item->is_amount_discount = $this->invoice->is_amount_discount; diff --git a/tests/Unit/InvoiceTest.php b/tests/Unit/InvoiceTest.php index c8da2bf29b..18ffa74d4a 100644 --- a/tests/Unit/InvoiceTest.php +++ b/tests/Unit/InvoiceTest.php @@ -812,8 +812,7 @@ class InvoiceTest extends TestCase $invoice = $invoice->calc()->getInvoice(); - nlog($invoice->amount); - $this->assertEquals(100, $invoice->amount); + $this->assertEquals(99.99, $invoice->amount); }