From 0b25641c35398e76e5301f15522f604900363cb5 Mon Sep 17 00:00:00 2001 From: Thomas Peterson Date: Tue, 17 Apr 2018 10:29:29 +0200 Subject: [PATCH] Fixes --- src/Engine.php | 30 ++++++++++++++++++++++++++++++ tests/Calc/PriceMinTest.php | 2 ++ 2 files changed, 32 insertions(+) diff --git a/src/Engine.php b/src/Engine.php index 5370526..132e3c7 100644 --- a/src/Engine.php +++ b/src/Engine.php @@ -37,6 +37,9 @@ class Engine /** @var float */ protected $price = 0; + /** @var float */ + protected $tax = 0; + /** @var bool */ protected $dirty = true; @@ -224,6 +227,17 @@ class Engine return round($this->price,2); } + /** + * @return mixed + */ + public function getTaxPrice() + { + if($this->dirty) { + $this->calc(); + } + return round($this->price+($this->price/100*$this->tax),2); + } + /** * @param mixed $price */ @@ -253,4 +267,20 @@ class Engine $this->variables[$var] = $value; } + /** + * @return float + */ + public function getTax() + { + return $this->tax; + } + + /** + * @param float $tax + */ + public function setTax($tax) + { + $this->tax = $tax; + } + } \ No newline at end of file diff --git a/tests/Calc/PriceMinTest.php b/tests/Calc/PriceMinTest.php index 0057c92..6996cce 100644 --- a/tests/Calc/PriceMinTest.php +++ b/tests/Calc/PriceMinTest.php @@ -33,6 +33,8 @@ class PriceMinTest extends \PHPUnit_Framework_TestCase $this->engine->calc(); $this->assertEquals(2500, $this->engine->getPrice()); + $this->engine->setTax(19); + $this->assertEquals(2975, $this->engine->getTaxPrice()); } public function testIfCalcReturnsGrenzeWithFormular()