From ae27792eac9c5fa8b25c43b591c729c628d8baf5 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Tue, 17 Apr 2018 11:10:13 +0200 Subject: [PATCH] Fixes --- src/Engine.php | 11 +++++++++++ tests/Calc/PriceMinTest.php | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Engine.php b/src/Engine.php index 132e3c7..940dae7 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -231,6 +231,17 @@ class Engine * @return mixed */ public function getTaxPrice() + { + if($this->dirty) { + $this->calc(); + } + return round(($this->price/100*$this->tax),2); + } + + /** + * @return mixed + */ + public function getCompletePrice() { if($this->dirty) { $this->calc(); diff --git a/tests/Calc/PriceMinTest.php b/tests/Calc/PriceMinTest.php index 6996cce..8955db8 100644 --- a/tests/Calc/PriceMinTest.php +++ b/tests/Calc/PriceMinTest.php @@ -34,7 +34,8 @@ class PriceMinTest extends \PHPUnit_Framework_TestCase $this->assertEquals(2500, $this->engine->getPrice()); $this->engine->setTax(19); - $this->assertEquals(2975, $this->engine->getTaxPrice()); + $this->assertEquals(475, $this->engine->getTaxPrice()); + $this->assertEquals(2975, $this->engine->getCompletePrice()); } public function testIfCalcReturnsGrenzeWithFormular() @@ -50,6 +51,9 @@ class PriceMinTest extends \PHPUnit_Framework_TestCase $this->engine->calc(); $this->assertEquals(2721.40, $this->engine->getPrice()); + $this->engine->setTax(19); + $this->assertEquals(517.07, $this->engine->getTaxPrice()); + $this->assertEquals(3238.47, $this->engine->getCompletePrice()); } } \ No newline at end of file